/* ============================================================
   ROOT VARIABLES
   ============================================================ */

:root {
    --bg: #f7f4ef;
    --bg-secondary: #ede8e0;
    --bg-card: #ffffff;
    --text: #1a1715;
    --text-secondary: #4a4540;
    --text-muted: #7a756e;
    --border: #d6d0c8;
    --accent: #8b3a2a;
    --accent-light: #b55a48;
    --gold: #b5975a;
    --gold-light: #d4be8a;
    --shadow: rgba(26, 23, 21, 0.06);
    --radius: 6px;
    --font-serif: "Instrument Serif", serif;
    --font-mono: "JetBrains Mono", monospace;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #141210;
    --bg-secondary: #1f1b18;
    --bg-card: #241f1b;
    --text: #ece6e0;
    --text-secondary: #b8b0a8;
    --text-muted: #7a726a;
    --border: #3a3430;
    --accent: #c06a50;
    --accent-light: #d48a72;
    --gold: #c4a86a;
    --gold-light: #d8c08a;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition:
        background var(--transition),
        color var(--transition);
    min-height: 100vh;
    padding-top: 70px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   HEADER
   ============================================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    transition:
        background var(--transition),
        border var(--transition);
}

.header-inner {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-serif);
    font-size: 1.25rem;
}

.logo-symbol {
    color: var(--accent);
    font-size: 1.1rem;
}

.logo-text {
    letter-spacing: -0.01em;
}

.header-nav {
    display: flex;
    gap: 6px;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition:
        background var(--transition),
        color var(--transition);
}

.nav-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.nav-btn.active {
    background: var(--bg-secondary);
    color: var(--text);
}

.theme-toggle {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.section {
    display: none;
    animation: fadeIn 0.25s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1,
h2,
h3,
h4 {
    font-family: var(--font-serif);
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 0.25em;
}

h2 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

h3 {
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 0.4rem;
}

h4 {
    font-size: 1.1rem;
    margin-top: 1.2rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ============================================================
   NOW PLAYING (HOME)
   ============================================================ */

.now-playing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.now-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: 0 4px 16px var(--shadow);
    transition:
        background var(--transition),
        border var(--transition);
}

.now-card.full-width {
    grid-column: 1 / -1;
}

.now-card .label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.now-card .title {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.now-card .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.now-card .progress-track {
    margin-top: 12px;
}

.progress-bar {
    height: 3px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar .fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.next-action {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.next-action .action-text {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--accent);
}

.next-action .action-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   ROADMAP / PHASES
   ============================================================ */

.phase-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.phase-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition:
        background var(--transition),
        border var(--transition),
        transform 0.15s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.phase-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-light);
}

.phase-card .phase-number {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.phase-card .phase-title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    margin: 4px 0 2px;
}

.phase-card .phase-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.phase-card .phase-status {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 12px;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.phase-card .phase-status.active {
    background: var(--accent);
    color: #fff;
}

.phase-card .phase-status.done {
    background: var(--gold);
    color: #fff;
}

/* ============================================================
   PHASE DETAIL VIEW
   ============================================================ */

.phase-detail .back-link {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 16px;
    padding: 4px 0;
}

.phase-detail .back-link:hover {
    color: var(--text);
}

.phase-detail .phase-header {
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 24px;
}

.phase-detail .phase-header .phase-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.phase-detail .phase-header h1 {
    font-size: 2.6rem;
    margin: 4px 0 0;
}

.phase-detail .phase-header .phase-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* ============================================================
   TASK LIST (TRACKS)
   ============================================================ */

.tracklist {
    list-style: none;
    padding: 0;
    margin: 16px 0 24px;
}

.tracklist li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.tracklist li:last-child {
    border-bottom: none;
}

.tracklist input[type="checkbox"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.tracklist .task-done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.tracklist .task-label {
    flex: 1;
}

.tracklist .task-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 10px;
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ============================================================
   SIDE NOTES (LINER NOTES)
   ============================================================ */

.liner-notes {
    background: var(--bg-secondary);
    border-left: 3px solid var(--gold);
    padding: 20px 24px;
    margin: 20px 0 28px;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.liner-notes h4 {
    font-family: var(--font-serif);
    font-size: 1rem;
    margin-top: 0;
    margin-bottom: 6px;
}

.liner-notes p,
.liner-notes li {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.liner-notes ul {
    padding-left: 20px;
    margin: 4px 0;
}

/* ============================================================
   RESOURCES
   ============================================================ */

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin: 12px 0 20px;
}

.resource-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.resource-item .res-role {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.resource-item .res-title {
    font-weight: 600;
    margin: 2px 0;
}

.resource-item .res-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================================
   EXIT CRITERIA
   ============================================================ */

.exit-criteria {
    margin: 16px 0 24px;
}

.exit-criteria li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 0;
    font-size: 0.92rem;
}

.exit-criteria input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ============================================================
   PROJECT LADDER
   ============================================================ */

.project-ladder {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    transition:
        background var(--transition),
        border var(--transition);
}

.project-item .proj-order {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 36px;
}

.project-item .proj-name {
    font-weight: 600;
    flex: 1;
}

.project-item .proj-demo {
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: 2;
}

.project-item .proj-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 14px;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.project-item .proj-status.public {
    background: var(--accent);
    color: #fff;
}

.project-item .proj-status.private {
    background: var(--gold);
    color: #fff;
}

/* ============================================================
   LIBRARY
   ============================================================ */

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.library-book {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.library-book .book-role {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.library-book .book-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    margin: 2px 0;
}

.library-book .book-author {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.library-book .book-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    margin-top: 8px;
    color: var(--text-muted);
}

/* ============================================================
   MATHEMATICS
   ============================================================ */

.math-chain {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.math-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.math-link .math-concept {
    font-weight: 600;
    min-width: 140px;
}

.math-link .math-arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.math-link .math-app {
    color: var(--text-secondary);
}

/* ============================================================
   CONTRACT (RULES)
   ============================================================ */

.contract-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contract-list li {
    display: flex;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    align-items: flex-start;
}

.contract-list .rule-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--gold);
    min-width: 28px;
    font-weight: 600;
}

.contract-list .rule-text {
    flex: 1;
}

/* ============================================================
   COMMAND PALETTE
   ============================================================ */

.command-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    backdrop-filter: blur(4px);
}

.command-overlay.hidden {
    display: none;
}

.command-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 540px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.command-modal input {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-sans);
    font-size: 1rem;
    background: transparent;
    color: var(--text);
    outline: none;
}

.command-modal input::placeholder {
    color: var(--text-muted);
}

.command-modal ul {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.command-modal ul li {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s ease;
}

.command-modal ul li:hover,
.command-modal ul li.selected {
    background: var(--bg-secondary);
}

.command-modal ul li .cmd-path {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.command-hint {
    padding: 8px 20px;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    text-align: center;
    font-family: var(--font-mono);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    body {
        padding-top: 56px;
    }

    .site-header {
        height: 56px;
        padding: 0 16px;
    }

    .header-nav {
        gap: 2px;
    }

    .nav-btn {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .logo-text {
        font-size: 1rem;
    }

    #app {
        padding: 24px 16px 60px;
    }

    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.6rem;
    }

    .now-playing {
        grid-template-columns: 1fr;
    }

    .phase-grid {
        grid-template-columns: 1fr;
    }

    .project-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .project-item .proj-demo {
        flex-basis: 100%;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }

    .command-modal {
        width: 95vw;
        margin-top: 10vh;
    }

    .math-link {
        flex-wrap: wrap;
        gap: 6px;
    }
    .math-link .math-arrow {
        display: none;
    }

    .resource-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header-nav {
        display: none;
    }

    .now-card {
        padding: 20px;
    }

    .phase-card {
        padding: 18px;
    }
}
