/* ========================================
   GLOSSARY V2 - CLEANER, BOLDER DESIGN
   ======================================== */

:root {
    /* Primary colors */
    --primary: #2c5aa0;
    --primary-light: #4d7bc7;
    --accent: #1a73e8;

    /* Text colors */
    --text: #1a1a1a;
    --text-muted: #666;

    /* Background colors */
    --bg-warm: #fafafa;
    --bg-card: #ffffff;
    --bg-hover: #f7fafc;
    --bg-expanded: #f8fafc;

    /* Border */
    --border: #e0e0e0;
    --border-hover: #cbd5e0;

    /* Level colors - consistent palette */
    --level-basic: #2e7d32;
    --level-basic-bg: #c6f6d5;
    --level-basic-text: #276749;
    --level-intermediate: #e65100;
    --level-intermediate-bg: #feebc8;
    --level-intermediate-text: #c05621;
    --level-advanced: #553c9a;
    --level-advanced-bg: #e9d8fd;
    --level-advanced-text: #553c9a;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 4px 20px rgba(44, 82, 130, 0.1);
    --shadow-focus: 0 2px 12px rgba(44, 90, 160, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
}

/* ========================================
   HERO - Matching main site style
   ======================================== */
.glossary-hero {
    background-color: #f9f9f9;
    padding: 120px 0 50px;
    color: var(--text);
}

.glossary-hero h1 {
    font-size: 2.5em;
    margin-bottom: 0.3em;
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: normal;
}

.glossary-hero .subtitle {
    color: var(--text-muted);
    font-size: 1.1em;
    margin-bottom: 30px;
    font-style: italic;
}

/* Search in Hero */
.hero-search {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.hero-search input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    font-size: 1em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.hero-search input::placeholder {
    color: #999;
}

.hero-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.hero-search svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #999;
}

.search-hint {
    margin-top: 12px;
    font-size: 0.85em;
    color: var(--text-muted);
}

.search-hint kbd {
    background: #e0e0e0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.9em;
}

/* ========================================
   MAIN LAYOUT - Two columns
   ======================================== */
.glossary-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0;
    min-height: calc(100vh - 200px);
}

/* ========================================
   LEFT SIDEBAR - Navigation
   ======================================== */
.glossary-nav {
    background: var(--bg-warm);
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 30px;
}

.nav-section h3 {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 600;
}

/* Alphabet Grid */
.alphabet-section {
    padding-top: 0;
}

.alpha-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 3px;
}

.alpha-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.alpha-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

.alpha-btn.disabled {
    color: #cbd5e0;
    background: transparent;
    border-color: transparent;
    cursor: default;
}

.alpha-btn.disabled:hover {
    transform: none;
    background: transparent;
    color: #cbd5e0;
}

.alpha-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Category List */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 0.9em;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.category-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.category-item .count {
    font-size: 0.8em;
    opacity: 0.6;
}

/* Level Filters */
.level-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    font-size: 0.85em;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.level-item:hover {
    border-color: var(--primary-light);
}

.level-item.active {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.level-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.level-dot.basic { background: var(--level-basic); }
.level-dot.intermediate { background: var(--level-intermediate); }
.level-dot.advanced { background: var(--level-advanced); }

.level-item span:last-child {
    margin-left: auto;
    opacity: 0.5;
    font-size: 0.85em;
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.lang-btn {
    flex: 1;
    padding: 8px;
    font-size: 0.85em;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-muted);
}

.lang-btn.active {
    background: var(--primary);
    color: white;
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
.glossary-content {
    padding: 40px 50px;
    background: white;
}

/* Introduction Text */
.glossary-intro {
    margin-bottom: 30px;
    padding: 20px 24px;
    background: var(--bg-hover);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.glossary-intro p {
    margin: 0 0 0.8em 0;
    font-size: 0.95em;
    line-height: 1.7;
    color: var(--text);
}

.glossary-intro p:last-child {
    margin-bottom: 0;
}

.glossary-intro em {
    color: var(--text-muted);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85em;
    color: var(--text-muted);
}

/* ========================================
   LETTER SECTIONS
   ======================================== */
.letter-section {
    margin-bottom: 50px;
    scroll-margin-top: 90px;
}

.letter-heading {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.letter-char {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: normal;
    color: white;
    background: var(--primary);
    border-radius: 50%;
    font-family: Georgia, serif;
}

.letter-meta {
    color: var(--text-muted);
    font-size: 0.9em;
}

/* ========================================
   GLOSSARY CARDS - Clean & Readable
   ======================================== */
.term-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    overflow: hidden;
    scroll-margin-top: 90px;
}

.term-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.term-card.expanded {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
}

/* Card Header */
.term-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 20px 24px;
    cursor: pointer;
}

.term-header:hover {
    background: var(--bg-warm);
}

.term-title-group {
    flex: 1;
}

.term-title {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.term-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.term-category {
    padding: 2px 8px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.75em;
    color: #888;
    cursor: pointer;
    transition: all 0.15s ease;
    font-style: normal;
}

.term-category:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-hover);
}

.term-level {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.term-level.basic {
    background: var(--level-basic-bg);
    color: var(--level-basic-text);
}

.term-level.intermediate {
    background: var(--level-intermediate-bg);
    color: var(--level-intermediate-text);
}

.term-level.advanced {
    background: var(--level-advanced-bg);
    color: var(--level-advanced-text);
}

/* Status Badges (contested, wip) */
.term-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.term-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.term-badge.contested {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.term-badge.contested i {
    color: #d97706;
}

.term-badge.wip {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #a5b4fc;
}

.term-badge.wip i {
    color: #6366f1;
}

.expand-toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.term-card.expanded .expand-toggle {
    transform: rotate(180deg);
}

/* Card Preview */
.term-preview {
    padding: 0 24px 20px;
    color: #444;
    font-size: 0.95em;
    cursor: pointer;
    line-height: 1.6;
}

/* Card Body (Expanded) */
.term-body {
    display: none;
    padding: 24px;
    background: var(--bg-expanded);
    border-top: 1px solid var(--border);
}

.term-card.expanded .term-body {
    display: block;
}

.term-card.expanded .term-preview {
    display: none;
}

.term-definition {
    font-size: 1em;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 20px;
}

.term-definition p {
    margin-bottom: 1em;
}

.term-definition p:last-child {
    margin-bottom: 0;
}

/* Links within definitions */
.term-link {
    color: var(--primary-light);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-light);
    transition: all 0.15s ease;
}

.term-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Sources - Compact inline style */
.term-sources {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.term-sources h4 {
    font-size: 0.75em;
    font-weight: 500;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.term-sources ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.term-sources li {
    font-size: 0.8em;
    color: var(--text-muted);
    line-height: 1.4;
}

.term-sources li::before {
    content: none;
}

.term-sources a {
    color: var(--primary-light);
    word-break: break-word;
}

.term-sources a:hover {
    text-decoration: underline;
}

/* Source Icons */
.term-sources .source-icon {
    margin-right: 6px;
    width: 14px;
    text-align: center;
    display: inline-block;
}

.term-sources .source-icon.youtube { color: #FF0000; }
.term-sources .source-icon.arxiv { color: #B31B1B; }
.term-sources .source-icon.github { color: #333; }
.term-sources .source-icon.book { color: #8B4513; }
.term-sources .source-icon.paper { color: #2c5aa0; }
.term-sources .source-icon.web { color: #666; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
    .glossary-layout {
        grid-template-columns: 1fr;
    }

    .glossary-nav {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 20px;
    }

    .nav-section {
        margin-bottom: 20px;
    }

    .alpha-grid {
        grid-template-columns: repeat(13, 1fr);
    }

    .alphabet-section {
        padding-top: 12px;
    }

    .category-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .category-item {
        flex: 0 0 auto;
    }

    .level-list {
        flex-direction: row;
    }

    .glossary-content {
        padding: 30px 20px;
    }
}

@media (max-width: 768px) {
    .glossary-hero {
        padding: 100px 0 40px;
    }

    .glossary-hero h1 {
        font-size: 2em;
    }

    .alpha-grid {
        grid-template-columns: repeat(9, 1fr);
    }

    .term-header {
        padding: 16px;
    }

    .term-title {
        font-size: 1.1em;
    }

    .letter-char {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .stats-bar {
        flex-wrap: wrap;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .alpha-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .term-level {
        font-size: 0.65em;
        padding: 4px 8px;
    }
}

/* ========================================
   LOADING STATE
   ======================================== */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading-state p {
    font-size: 1.1em;
}

/* ========================================
   PRINT
   ======================================== */
@media print {
    .glossary-nav,
    .glossary-hero,
    .expand-toggle,
    .stats-bar {
        display: none !important;
    }

    .glossary-layout {
        display: block;
    }

    .term-card {
        break-inside: avoid;
        border: 1px solid #ccc;
        margin-bottom: 20px;
    }

    .term-body {
        display: block !important;
    }

    .term-preview {
        display: none !important;
    }
}
