/* Word Tree – Dark theme matching word_index.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: #000;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Header ── */
.wt-header {
    text-align: center;
    padding: 20px 20px 12px;
    border-bottom: 1px solid rgba(255,215,0,0.2);
}

.wt-header h1 {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 4px;
}

.wt-subtitle {
    font-size: 0.95rem;
    color: #aaa;
    margin-bottom: 10px;
}

/* ── Navigation ── */
.wt-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.wt-nav a {
    padding: 7px 16px;
    background: rgba(255,255,255,0.06);
    color: #ffd700;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid rgba(255,215,0,0.25);
    transition: all 0.25s;
    font-size: 0.88rem;
}

.wt-nav a:hover {
    background: rgba(255,215,0,0.15);
    border-color: #ffd700;
}

.wt-nav a.active {
    background: #ffd700;
    color: #000;
    font-weight: 600;
    border-color: #ffd700;
}

/* ── Toolbar (controls row) ── */
.wt-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,215,0,0.12);
    flex-wrap: wrap;
}

.wt-toolbar label {
    color: #ccc;
    font-size: 0.82rem;
    white-space: nowrap;
}

.wt-search {
    padding: 6px 12px;
    border: 1px solid rgba(255,215,0,0.35);
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-size: 0.88rem;
    width: 200px;
    transition: border-color 0.2s;
}

.wt-search:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 6px rgba(255,215,0,0.25);
}

.wt-depth-slider {
    width: 80px;
    accent-color: #ffd700;
    vertical-align: middle;
}

.wt-depth-val {
    color: #ffd700;
    font-weight: bold;
    min-width: 16px;
    text-align: center;
    font-size: 0.88rem;
}

.wt-btn {
    padding: 5px 14px;
    border: 1px solid rgba(255,215,0,0.35);
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    color: #ffd700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.wt-btn:hover {
    background: rgba(255,215,0,0.15);
    border-color: #ffd700;
}

.wt-btn:active {
    transform: scale(0.97);
}

.wt-toolbar-spacer {
    flex: 1;
}

/* ── Breadcrumb bar ── */
.wt-breadcrumb {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: rgba(255,215,0,0.06);
    border-bottom: 1px solid rgba(255,215,0,0.1);
    font-size: 0.88rem;
    color: #ccc;
}

.wt-breadcrumb.visible {
    display: flex;
}

.wt-breadcrumb .back-btn {
    padding: 4px 12px;
    border: 1px solid rgba(255,215,0,0.35);
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    color: #ffd700;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
}

.wt-breadcrumb .back-btn:hover {
    background: rgba(255,215,0,0.2);
}

.wt-breadcrumb .crumb-sep {
    color: #666;
}

.wt-breadcrumb .crumb-active {
    color: #ffd700;
    font-weight: 600;
}

/* ── Onboarding hint ── */
.wt-onboarding {
    text-align: center;
    padding: 10px;
    color: #888;
    font-size: 0.85rem;
    transition: opacity 0.4s;
}

.wt-onboarding.hidden {
    display: none;
}

.wt-onboarding span {
    color: #ffd700;
}

/* ── Main layout: tree + info side panel ── */
.wt-main {
    display: flex;
    position: relative;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 180px);
}

/* ── Tree container ── */
.wt-tree {
    flex: 1;
    min-width: 0;
    position: relative;
    background: #000;
    overflow: hidden;
}

.wt-tree svg {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.wt-tree svg:active {
    cursor: grabbing;
}

/* ── Zoom controls (overlay on tree) ── */
.wt-zoom-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.wt-zoom-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,215,0,0.35);
    border-radius: 6px;
    background: rgba(0,0,0,0.7);
    color: #ffd700;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(6px);
}

.wt-zoom-btn:hover {
    background: rgba(255,215,0,0.2);
    border-color: #ffd700;
}

/* ── Info panel (right side) ── */
.wt-info {
    width: 280px;
    background: rgba(255,255,255,0.03);
    border-left: 1px solid rgba(255,215,0,0.12);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    overflow: hidden;
}

.wt-info.collapsed {
    width: 0;
    border-left: none;
}

.wt-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,215,0,0.1);
}

.wt-info-header h3 {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: #ffd700;
}

.wt-info-toggle {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
}

.wt-info-toggle:hover {
    color: #ffd700;
}

.wt-info-body {
    padding: 12px 14px;
    overflow-y: auto;
    flex: 1;
    color: #ccc;
    font-size: 0.85rem;
    line-height: 1.6;
}

.wt-info-body h4 {
    color: #ffd700;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.wt-info-body a {
    color: #4ecdc4;
    text-decoration: none;
    display: block;
    padding: 4px 0;
    border-bottom: 1px solid rgba(78,205,196,0.15);
    transition: color 0.2s;
}

.wt-info-body a:hover {
    color: #7fffd4;
}

.wt-info-body .tip-box {
    background: rgba(255,215,0,0.06);
    border-left: 3px solid #ffd700;
    padding: 8px 10px;
    border-radius: 0 4px 4px 0;
    margin-top: 10px;
    font-size: 0.82rem;
}

/* ── Legend (inline, below toolbar) ── */
.wt-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 20px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,215,0,0.08);
    flex-wrap: wrap;
    overflow: hidden;
    max-height: 40px;
    transition: max-height 0.3s;
}

.wt-legend.collapsed {
    max-height: 0;
    padding: 0 20px;
}

.wt-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #999;
    white-space: nowrap;
}

.wt-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── SVG node styles ── */

/* Opaque pill backgrounds behind all text labels.
   HF rationale: when layers overlap, text-shadow alone fails.
   Solid pills guarantee legibility at every zoom level. */
.label-bg {
    pointer-events: none;
}

/* Category node pulsing glow to show clickability */
@keyframes category-pulse {
    0%   { filter: drop-shadow(0 0 4px rgba(255,215,0,0.3)); }
    50%  { filter: drop-shadow(0 0 12px rgba(255,215,0,0.6)); }
    100% { filter: drop-shadow(0 0 4px rgba(255,215,0,0.3)); }
}

.node-category circle {
    transition: all 0.25s;
    animation: category-pulse 3s ease-in-out infinite;
}

.node-category:hover circle {
    filter: drop-shadow(0 0 16px rgba(255,215,0,0.8)) !important;
    animation: none;
}

.node-center circle {
    transition: all 0.25s;
}

.node-word circle {
    transition: all 0.25s;
}

.node-word:hover circle {
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.5));
    transform: scale(1.15);
}

/* Search highlight */
.node-search-match circle {
    stroke: #ff4444 !important;
    stroke-width: 4px !important;
}

@keyframes search-pulse {
    0%   { filter: drop-shadow(0 0 6px rgba(255,68,68,0.5)); }
    50%  { filter: drop-shadow(0 0 14px rgba(255,68,68,0.9)); }
    100% { filter: drop-shadow(0 0 6px rgba(255,68,68,0.5)); }
}

.node-search-match circle {
    animation: search-pulse 1.5s infinite;
}

.node-dimmed {
    opacity: 0.15 !important;
}

/* Expanded category glow */
.node-expanded circle {
    stroke: #ffd700 !important;
    stroke-width: 4px !important;
    filter: drop-shadow(0 0 14px rgba(255,215,0,0.6)) !important;
    animation: none !important;
}

/* ── Tooltip ── */
.wt-tooltip {
    position: absolute;
    background: rgba(0,0,0,0.92);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    pointer-events: none;
    z-index: 1001;
    border: 1px solid rgba(255,215,0,0.3);
    max-width: 220px;
    word-wrap: break-word;
    backdrop-filter: blur(6px);
}

/* ── Loading / Error ── */
.wt-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    color: #ffd700;
    font-size: 1rem;
    gap: 12px;
}

.wt-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ffd700;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.wt-error {
    text-align: center;
    color: #ff6b6b;
    padding: 60px 20px;
    font-size: 0.95rem;
}

/* ── Responsive: mobile ── */
@media (max-width: 768px) {
    .wt-header h1 {
        font-size: 1.5rem;
    }

    .wt-toolbar {
        padding: 8px 12px;
        gap: 8px;
    }

    .wt-search {
        width: 140px;
    }

    .wt-main {
        flex-direction: column;
        height: calc(100vh - 200px);
    }

    .wt-tree {
        flex: 1;
    }

    /* Info panel becomes bottom sheet on mobile */
    .wt-info {
        width: 100%;
        max-height: 200px;
        border-left: none;
        border-top: 1px solid rgba(255,215,0,0.15);
    }

    .wt-info.collapsed {
        width: 100%;
        max-height: 0;
        border-top: none;
    }

    .wt-zoom-controls {
        bottom: 10px;
        right: 10px;
    }

    .wt-zoom-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .wt-legend {
        gap: 10px;
        padding: 6px 12px;
    }

    .wt-breadcrumb {
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .wt-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .wt-search {
        width: 100%;
    }

    .wt-toolbar-spacer {
        display: none;
    }
}
