/* === Common styles for all subpages (nav, footer, legacy compat) === */

/* Legacy variable aliases */
:root {
    --jeopardy-blue: var(--blue-text);  /* 508-compliant: use readable blue for text/links */
    --jeopardy-gold: var(--gold);
    --deep-navy: var(--text-primary);
    --rich-purple: var(--blue-muted);
    --off-white: var(--text-primary);
    --gold-accent: var(--gold-dim);
    --space-xs: var(--sp-2);
    --space-sm: var(--sp-3);
    --space-md: var(--sp-4);
    --space-lg: var(--sp-6);
    --space-xl: var(--sp-8);
    --space-2xl: var(--sp-12);
    --transition-fast: var(--duration-fast) var(--ease-out);
    --transition-normal: var(--duration-normal) var(--ease-out);
}

/* Page container - override old white-card pattern */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-4);
    background-color: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: var(--text-primary);
}
.container::before {
    display: none !important;
}

/* Override old text colors that assumed white background */
h1 { color: var(--text-primary) !important; }
.subtitle { color: var(--text-secondary) !important; }

/* Override old nav styles */
.top-nav {
    background: var(--ink) !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
    border-bottom: 1px solid var(--surface-border);
}

/* Override old nav colors */
.nav-logo { color: var(--text-primary) !important; }
.nav-group-label { color: var(--text-secondary) !important; }
.nav-group-label:hover { color: var(--text-primary) !important; background: rgba(255,255,255,0.04) !important; }
.nav-dropdown { background: var(--elevated) !important; border: 1px solid var(--surface-border) !important; }
.nav-dropdown a { color: var(--text-secondary) !important; }
.nav-dropdown a:hover { color: var(--text-primary) !important; background: rgba(255,255,255,0.04) !important; }
.hamburger-menu span { background: var(--text-primary) !important; }

/* Override old footer colors */
footer { color: var(--text-muted) !important; border-top-color: var(--surface-border) !important; }
footer a { color: var(--blue-bright) !important; }
footer p { color: var(--text-muted) !important; }

/* Navigation */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--ink);
    border-bottom: 1px solid var(--surface-border);
    height: 56px;
}
@media (min-width: 768px) { .top-nav { height: 60px; } }
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--sp-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.nav-logo {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: var(--text-lg);
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}
.nav-logo:hover { color: var(--gold); text-decoration: none; }

/* Desktop nav */
.nav-links {
    display: none;
    align-items: center;
    gap: var(--sp-1);
}
@media (min-width: 768px) {
    .nav-links { display: flex; }
    .mobile-nav-section { display: none; }
}
.nav-group { position: relative; }
.nav-group-label {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.nav-group-label:hover { color: var(--text-primary); text-decoration: none; }
.chevron { font-size: 0.65em; }
.nav-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--elevated);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: var(--sp-2) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration-fast) var(--ease-out);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}
.nav-group:hover .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.nav-dropdown a {
    display: block;
    padding: var(--sp-2) var(--sp-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}
.nav-dropdown a:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    text-decoration: none;
}

/* Hamburger */
.hamburger-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.hamburger-menu span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    transition: all var(--duration-fast);
    border-radius: 1px;
}
.hamburger-menu.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-menu.active span:nth-child(2) { opacity: 0; }
.hamburger-menu.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }
@media (min-width: 768px) { .hamburger-menu { display: none; } }

/* Mobile drawer */
.nav-links.active {
    display: block;
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: 280px;
    background: var(--ink);
    padding: var(--sp-6) var(--sp-4);
    overflow-y: auto;
    z-index: 9999;
    border-left: 1px solid var(--surface-border);
}
@media (max-width: 480px) {
    .nav-links.active {
        width: 100%;
        border-left: none;
    }
}
.nav-links.active .nav-group { display: none; }
.nav-links.active .mobile-nav-section { display: block; }
.mobile-nav-section { display: none; }
.mobile-nav-header {
    display: block;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--surface-border);
    margin-bottom: var(--sp-2);
    margin-top: var(--sp-4);
}
.mobile-nav-section:first-child .mobile-nav-header { margin-top: 0; }
.mobile-nav-section a {
    display: block;
    padding: var(--sp-3) 0;
    color: var(--text-secondary);
    font-size: var(--text-lg);
    font-weight: 500;
    text-decoration: none;
}
.mobile-nav-section a:hover { color: var(--gold); }
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}
.nav-backdrop.active { display: block; }

/* Desktop only / mobile only */
.desktop-only { display: none; }
@media (min-width: 768px) { .desktop-only { display: inline; } }
.mobile-only { display: initial; }
@media (min-width: 768px) { .mobile-only { display: none; } }

/* Loading / Error states */
.loading, .error-message {
    text-align: center;
    padding: var(--sp-12);
    color: var(--text-muted);
    font-size: var(--text-lg);
}
.error-message { color: var(--negative); }

/* Page header pattern */
.page-header-section {
    margin-bottom: var(--sp-6);
    padding-bottom: var(--sp-6);
    border-bottom: 1px solid var(--surface-border);
}
.page-header-section h1 {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: var(--sp-3);
}
.page-header-section .subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 700px;
}
.page-header-section .subtitle a {
    color: var(--blue-bright);
}

/* Share buttons pattern */
.share-section {
    display: flex;
    justify-content: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin: var(--sp-6) 0;
}

/* Override old element colors for dark theme */
.search-input {
    background: var(--elevated) !important;
    border-color: var(--surface-border) !important;
    color: var(--text-primary) !important;
}
.search-input:focus {
    border-color: var(--blue-bright) !important;
    box-shadow: 0 0 0 3px rgba(61,90,254,0.2) !important;
}
.search-input::placeholder { color: var(--text-muted) !important; }

/* Override old link/text colors that assumed white bg */
a { color: var(--blue-bright); }
p { color: var(--text-secondary); }

/* Mobile drawer override */
@media (max-width: 768px) {
    .nav-links {
        background: var(--ink) !important;
        border-left: 1px solid var(--surface-border) !important;
        box-shadow: none !important;
    }
    .mobile-nav-section a { color: var(--text-secondary) !important; }
    .mobile-nav-section a:hover { color: var(--gold) !important; }
    .mobile-nav-header { color: var(--text-muted) !important; border-bottom-color: var(--surface-border) !important; }
}

/* Note: removed old body > * { position: relative; z-index: 1 } rule.
   It created stacking contexts on every direct child of body, which
   trapped fixed-position elements (nav drawer, backdrop) inside their
   parent's stacking context and caused z-index conflicts with controls. */

/* Animation */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.container { animation: fadeInUp 0.5s ease-out; }
