/* ===== CSS Variables — Rose Pine Moon × Phosphor Noir ===== */
/* Circadian values are overridden at runtime by circadian.js   */
:root {
    /* phase defaults (night) — js overwrites on load */
    --bg:           #191724;
    --surface:      #1f1d2e;
    --surface-light:#26233a;
    --accent:       #c4a7e7;
    --accent-dark:  #9c7dc7;
    --accent-rgb:   196,167,231;
    --accent-glow:  rgba(196,167,231,0.14);
    --text-muted:   #6e6a86;

    /* the mercury bead between the glyphs — phase-linked via circadian.js,
       fallback values below only apply before JS runs on first paint */
    --mercury-dot:     #e8e8f0;
    --mercury-dot-rgb: 232,232,240;

    /* static rose pine moon */
    --text:     #e0def4;
    --subtle:   #908caa;
    --success:  #9ccfd8;
    --warning:  #f6c177;
    --error:    #eb6f92;

    --radius:     12px;
    --shadow:     0 4px 6px -1px rgba(0,0,0,0.45), 0 2px 4px -2px rgba(0,0,0,0.35);
    --transition: 0.2s cubic-bezier(0.19, 1, 0.22, 1);
}

/* smooth phase transitions */
body,
.navbar,
.chapter-card,
.lesson-card,
.card,
.code-block,
pre,
.quiz-question,
.footer {
    transition:
        background-color 1.8s ease,
        border-color 1.2s ease;
}

/* phosphor glow on code */
pre, .code-block {
    box-shadow: 0 0 18px var(--accent-glow), var(--shadow);
}

/* phosphor accent glow on focus/interactive */
.btn-primary:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a:hover {
    text-decoration: underline;
}

/* ===== View Transitions ===== */
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
    animation-duration: 0.25s;
    animation-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
}

/* ===== Navbar ===== */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--surface-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.logo {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
    transition: color var(--transition);
}

.nav-links a:hover {
    color: var(--text);
    text-decoration: none;
}

.phase-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.65;
    transition: opacity var(--transition);
}
.phase-indicator:hover { opacity: 1; }

/* mercury glyph shifts color with the live circadian phase, same as .signature */
.mercury-glyph {
    display: inline-block;
    color: var(--accent);
    text-shadow: 0 0 6px rgba(var(--accent-rgb), 0.45);
    transition: color 1.8s ease, text-shadow 1.8s ease;
}
/* slower than the other sites on purpose — this is a learning site, the
   glyph/bead are ambient, not something meant to catch a learner's eye */
.mercury-glyph--out  { animation: flow 16s ease-in-out infinite; }
.mercury-glyph--back { animation: flow-delay 16s ease-in-out infinite; margin-right: 4px; }

@keyframes flow {
    0%   { opacity:0.2; transform:translateY(2px) scale(0.98); }
    50%  { opacity:1;   transform:translateY(-2px) scale(1.02); }
    100% { opacity:0.2; transform:translateY(2px) scale(0.98); }
}
@keyframes flow-delay {
    0%   { opacity:1;   transform:translateY(-2px) scale(1.02); }
    50%  { opacity:0.2; transform:translateY(2px) scale(0.98); }
    100% { opacity:1;   transform:translateY(-2px) scale(1.02); }
}

/* a bead of quicksilver crawling the navbar's bottom divider, to-and-fro */
.navbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 5px var(--accent);
    opacity: 0.8;
    animation: mercury-crawl 40s ease-in-out infinite alternate;
    pointer-events: none;
    transition: background 1.8s ease, box-shadow 1.8s ease;
}
@keyframes mercury-crawl {
    0%   { left: 0%; }
    100% { left: 90%; }
}


.logo-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
}

@keyframes phase-pulse {
    0%, 100% { box-shadow: 0 0 3px rgba(var(--mercury-dot-rgb), 0.5); opacity: 0.7; }
    50%       { box-shadow: 0 0 9px rgba(var(--mercury-dot-rgb), 1.0); opacity: 1.0; }
}

#phase-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mercury-dot);
    box-shadow: 0 0 7px rgba(var(--mercury-dot-rgb), 0.7);
    flex-shrink: 0;
    margin: 0 2px;
    transition: background-color 1.8s ease, box-shadow 1.8s ease;
    animation: phase-pulse 16s ease-in-out infinite;
}

#phase-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 1.8s ease;
}

.progress-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.progress-bar-mini {
    width: 80px;
    height: 6px;
    background: var(--surface-light);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-mini > div {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width var(--transition);
}

/* ===== Container ===== */
.container {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
}

.btn-secondary:hover {
    background: #475569;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--surface-light);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-run {
    background: var(--success);
    color: #064e3b;
}

.btn-reset {
    background: var(--surface-light);
    color: var(--text-muted);
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 3rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Chapter Cards ===== */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.chapter-card {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform var(--transition), border-color var(--transition);
}

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

.chapter-number {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.chapter-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.chapter-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.chapter-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    border-radius: 4px;
    transition: width var(--transition);
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-passed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-completed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-pending {
    background: rgba(234, 179, 8, 0.15);
    color: var(--warning);
}

/* ===== Chapter Page ===== */
.chapter-hero {
    text-align: center;
    padding: 2rem 0;
}

.chapter-number-large {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.chapter-hero h1 {
    font-size: 2rem;
    margin: 0.5rem 0;
}

.chapter-description {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.chapter-further-reading {
    max-width: 600px;
    margin: 1rem auto 0;
    padding-top: 0.875rem;
    border-top: 1px solid var(--surface-light);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1rem;
}

.chapter-further-reading-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    opacity: 0.7;
    width: 100%;
    text-align: center;
}

.chapter-further-reading a {
    font-size: 0.8125rem;
    color: var(--accent);
    text-decoration: none;
}
.chapter-further-reading a:hover {
    text-decoration: underline;
}

.lessons-list {
    margin: 2rem 0;
}

.lessons-list h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lesson-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: border-color var(--transition);
}

.lesson-row:hover {
    border-color: var(--accent-dark);
}

.lesson-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lesson-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-light);
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--accent);
}

.lesson-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.lesson-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chapter-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.resource-viewer {
    max-width: 900px;
    margin: 2rem auto 0;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--surface-light);
    background: var(--surface);
}

.resource-viewer iframe {
    display: block;
    width: 100%;
    height: 75vh;
    min-height: 500px;
    border: none;
    background: #fff;
}

@media (max-width: 640px) {
    .resource-viewer iframe {
        height: 60vh;
    }
}

/* ===== Lesson Page ===== */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.breadcrumbs a {
    color: var(--text-muted);
}

.breadcrumbs a:hover {
    color: var(--accent);
}

.lesson-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.lesson-header h1 {
    font-size: 1.75rem;
}

.objectives {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.objectives h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.objectives ul {
    list-style: none;
    padding-left: 0;
}

.objectives li {
    padding: 0.25rem 0;
    padding-left: 1.25rem;
    position: relative;
}

.objectives li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

.lesson-section {
    margin-bottom: 2rem;
}

.lesson-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.lesson-section p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.note {
    background: rgba(234, 179, 8, 0.1);
    border-left: 3px solid var(--warning);
    padding: 0.75rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.875rem;
    color: var(--warning);
    margin-bottom: 1rem;
}

.code-block {
    position: relative;
    background: #0b1220;
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.code-block pre {
    padding: 1rem;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875rem;
    color: #e2e8f0;
    line-height: 1.6;
}

.code-block .btn-run {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* ===== Code Editor ===== */
.exercise {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
}

.exercise h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.exercise > p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.editor-wrap {
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0b1220;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--surface-light);
}

.editor-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.code-editor {
    width: 100%;
    min-height: 180px;
    background: #0b1220;
    color: #e2e8f0;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 1rem;
    border: none;
    resize: vertical;
    outline: none;
}

.output-wrap {
    border-top: 1px solid var(--surface-light);
}

.output-header {
    background: #0b1220;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-output {
    background: #0b1220;
    color: #e2e8f0;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875rem;
    padding: 1rem;
    min-height: 60px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-output.error {
    color: var(--error);
}

.code-output.success {
    color: var(--success);
}

.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--surface-light);
}

/* ===== Quiz ===== */
.quiz {
    max-width: 720px;
    margin: 0 auto;
}

.quiz-header {
    text-align: center;
    margin-bottom: 2rem;
}

.quiz-header h1 {
    font-size: 1.75rem;
}

.quiz-header p {
    color: var(--text-muted);
}

.quiz-question {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--surface-light);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.option:hover {
    border-color: var(--accent-dark);
}

.option input {
    accent-color: var(--accent);
}

.option.correct {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.option.wrong {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.explanation {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(56, 189, 248, 0.1);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--accent);
    display: none;
}

.explanation.visible {
    display: block;
}

.quiz-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.quiz-result {
    text-align: center;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius);
    margin-top: 1.5rem;
}

.quiz-result.hidden {
    display: none;
}

.quiz-result.passed {
    border-color: var(--success);
}

.quiz-result.failed {
    border-color: var(--error);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--surface-light);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .navbar {
        padding: 1rem;
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }
    .nav-links {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.75rem;
    }
    .container {
        padding: 1rem;
    }
    .hero h1 {
        font-size: 1.75rem;
    }
    .stats {
        gap: 1.5rem;
    }
    .chapter-actions,
    .quiz-actions,
    .lesson-nav {
        flex-direction: column;
    }
    .lesson-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
