/*
============================================
Net Ninja Tutorial — PKA-STYLE rewrite (v2, dual-theme, default dark)
============================================
- Cinematic "study-at-night" aesthetic: neutral charcoal base lit by a restrained GOLD glow.
- Same layout as before: fixed header, 260px sticky sidebar, 820px content column.
- Two theming axes on <html>:
    data-theme = dark | light
    data-atmo  = full | calm   (dark-only atmosphere; light is always clean)
- Tokens drive everything. Legacy token names (--text-color, --accent-color, …) are kept
  and remapped to pka, so every existing selector re-skins for free.
*/

/* ============================================
   TIER 1 — theme-independent (fonts, layout, hover-glow) + DARK token defaults
   ============================================ */
:root {
    /* fonts */
    --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
    --mono:  "Geist Mono", ui-monospace, "SF Mono", Monaco, Consolas, monospace;
    --sans:  "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* layout (unchanged) */
    --max-width: 1600px;
    --content-width: 820px;
    --nav-width: 260px;
    --header-height: 60px;

    /* the ONE retained orange — subtle warm card hover glow (both themes) */
    --hover-glow: 0 10px 30px -10px rgba(249,140,30,.40), 0 0 0 1px rgba(249,140,30,.18);

    /* ---- DARK token roster (default) ---- */
    --gold:#d4a017;
    --gold-rgb:212,160,23;
    --gold-soft:#e0b34a;
    --gold-deep:#9a7322;
    --gold-label:#cfa330;     /* small mono labels — AA on panels */
    --gold-text:#d4a017;      /* gold as small text */
    --gold-fill:#d4a017;      /* solid CTA fill */
    --on-gold:#1a1206;        /* text on a gold fill */

    --heading:#fbf3e4;
    --background-color:#0c0c0d;
    --text-color:#f4ead7;            /* cream — primary text */
    --secondary-text-color:#b2a589;  /* muted */
    --dim:#9a8d73;

    --border-color:rgba(212,160,23,.18);
    --edge:rgba(212,160,23,.22);
    --edge-soft:rgba(212,160,23,.13);
    --edge-strong:rgba(212,160,23,.40);
    --line:rgba(212,160,23,.06);

    --code-bg:rgba(18,13,8,.85);     /* deep charcoal for pre */
    --panel:rgba(28,28,32,.55);      /* glassy translucent panel */
    --panel-solid:rgba(22,22,26,.92);/* near-solid reading panel (text never fights texture) */
    --panel-edge:rgba(212,160,23,.16);
    --inset-hi:rgba(255,255,255,.03);
    --card-shadow:none;

    --header-bg:rgba(12,12,14,.72);
    --toptop-bg:rgba(28,28,32,.88);

    --accent-color:#d4a017;          /* links */
    --focus:#d4a017;                 /* GOLD focus ring */
    --lamp:#2f9c6a;                  /* status green only */
    --crimson:#fb5a3c;               /* status red only */
}

/* ---- LIGHT token roster ---- */
:root[data-theme="light"] {
    --gold:#b8860b;
    --gold-rgb:184,134,11;
    --gold-soft:#8c6200;
    --gold-deep:#9a6d00;
    --gold-label:#8a6000;
    --gold-text:#8a6000;      /* 5.0:1 on white — AA small text */
    --gold-fill:#9a6d00;      /* active fill — white text 4.6:1 */
    --on-gold:#ffffff;

    --heading:#1d1d1f;
    --background-color:#fbfbfd;
    --text-color:#1d1d1f;
    --secondary-text-color:#636366;
    --dim:#636366;

    --border-color:rgba(0,0,0,.10);
    --edge:rgba(0,0,0,.10);
    --edge-soft:rgba(0,0,0,.10);
    --edge-strong:rgba(0,0,0,.22);
    --line:rgba(0,0,0,.06);

    --code-bg:#f5f5f7;
    --panel:#ffffff;
    --panel-solid:#ffffff;
    --panel-edge:rgba(0,0,0,.10);
    --inset-hi:transparent;
    --card-shadow:0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);

    --header-bg:rgba(255,255,255,.82);
    --toptop-bg:#ffffff;

    --accent-color:#8a6000;   /* link gold — AA small text on white */
    --focus:#9a6d00;          /* deeper gold — clears 3:1 on #f5f5f7 */
    --lamp:#1a7a3c;
    --crimson:#c9261b;
}

/*
============================================
ICON STYLES (stroke = currentColor → inherits theme)
============================================
*/
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }

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

html {
    scroll-behavior: smooth;
    background: var(--background-color);
}

body {
    font-family: var(--sans);
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    overflow-x: hidden;
}

/*
============================================
ATMOSPHERE — dark only, gated by data-atmo
- body background carries the lit-room gradient (lamp glow + charcoal)
- ::before = blueprint grid   (full only)
- ::after  = vignette + grain (full only)
============================================
*/
:root[data-theme="dark"] body {
    /* base: top gold lamp glow over a neutral charcoal ramp (present in full + calm) */
    background:
        radial-gradient(1200px 720px at 50% -8%, rgba(var(--gold-rgb), .13), transparent 60%),
        linear-gradient(180deg, #101012 0%, #0d0d0f 45%, #0a0a0b 100%);
    background-attachment: fixed;
}

:root[data-theme="dark"][data-atmo="full"] body {
    background:
        radial-gradient(1200px 720px at 50% -8%, rgba(var(--gold-rgb), .14), transparent 60%),
        radial-gradient(900px 600px at 88% 18%, rgba(150,152,160,.05), transparent 55%),
        radial-gradient(1100px 900px at 10% 95%, rgba(47,156,106,.04), transparent 55%),
        linear-gradient(180deg, #101012 0%, #0d0d0f 45%, #0a0a0b 100%);
    background-attachment: fixed;
}

/* atmosphere texture layers — hidden by default, shown only in dark + full */
body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    display: none;
}

/* blueprint grid */
:root[data-theme="dark"][data-atmo="full"] body::before {
    display: block;
    background-image:
        linear-gradient(to right, rgba(var(--gold-rgb), .05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(var(--gold-rgb), .05) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(1200px 1000px at 50% 18%, #000 30%, transparent 80%);
            mask-image: radial-gradient(1200px 1000px at 50% 18%, #000 30%, transparent 80%);
}

/* vignette + film grain */
:root[data-theme="dark"][data-atmo="full"] body::after {
    display: block;
    box-shadow: inset 0 0 240px 90px rgba(0,0,0,.6);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/></svg>");
}

/*
============================================
LAYOUT & STRUCTURE
============================================
*/
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
}

.sidebar {
    width: var(--nav-width);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: calc(var(--header-height) + 40px) 20px 40px 0;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.content {
    flex-grow: 1;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: calc(var(--header-height) + 40px) 40px 100px 40px;
}

/*
============================================
HEADER — per-theme blurred bar
============================================
*/
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--header-bg);
    backdrop-filter: saturate(160%) blur(20px);
    -webkit-backdrop-filter: saturate(160%) blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header h1 {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 400;
    letter-spacing: .2px;
    margin: 0;
    color: var(--heading);
    display: flex;
    align-items: center;
    gap: 10px;
}
.site-header h1 .icon { color: var(--gold); }

.site-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* shared header control look */
.search-button,
.sidebar-toggle,
.theme-toggle,
.atmo-toggle {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    cursor: pointer;
    padding: 8px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    gap: 8px;
    transition: border-color .18s ease, color .18s ease, background-color .25s ease;
}
.search-button { padding: 8px 12px; }

.search-button:hover,
.sidebar-toggle:hover,
.theme-toggle:hover,
.atmo-toggle:hover {
    border-color: var(--gold-label);
    color: var(--gold-text);
}

/* theme toggle — show exactly one icon per theme */
.theme-toggle { width: 40px; color: var(--gold-text); }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* atmosphere toggle — temporary comparison control (label + icon) */
.atmo-toggle {
    padding: 8px 14px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold-label);
}
.atmo-toggle .icon { color: currentColor; }
/* atmosphere control is meaningless in light — dim it so testers know it's dark-only */
:root[data-theme="light"] .atmo-toggle { opacity: .45; }

.keyboard-hint {
    font-size: 12px;
    color: var(--secondary-text-color);
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--mono);
}

/*
============================================
SKIP LINKS
============================================
*/
.skip-links { position: absolute; top: 0; left: 0; z-index: 9999; }

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background-color: var(--gold-fill);
    color: var(--on-gold);
    padding: 8px 16px;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 4px 0;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: 0;
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/*
============================================
SCREEN READER ONLY
============================================
*/
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/*
============================================
SIDEBAR NAVIGATION — glassy, gold active-state
============================================
*/
.sidebar nav ul { list-style: none; }

.sidebar nav h2 {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    margin-bottom: 20px;
    color: var(--gold-label);
}

.sidebar nav li { margin-bottom: 4px; }

.sidebar nav li a {
    color: var(--secondary-text-color);
    text-decoration: none;
    display: block;
    padding: 8px 10px;
    font-size: 14px;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    border-left: 2px solid transparent;
    margin-left: -12px;
    border-radius: 0 6px 6px 0;
}
.sidebar nav li a .icon { color: var(--secondary-text-color); transition: color .2s ease; }

.sidebar nav li a:hover {
    color: var(--text-color);
    background-color: rgba(var(--gold-rgb), .05);
}
.sidebar nav li a:hover .icon { color: var(--gold); }

.sidebar nav li a.active {
    color: var(--gold-text);
    font-weight: 600;
    border-left-color: var(--gold);
    background-color: rgba(var(--gold-rgb), .07);
}
.sidebar nav li a.active .icon { color: var(--gold); }

.sidebar hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/*
============================================
TYPOGRAPHY & CONTENT
============================================
*/
h1, h2, h3, h4 {
    font-family: var(--serif);
    font-weight: 400;
    line-height: 1.2;
    color: var(--heading);
    letter-spacing: .2px;
}

h1 { font-size: 40px; margin-bottom: 8px; }

.text-lg {
    font-family: var(--serif);
    font-size: 22px;
    line-height: 1.4;
    color: var(--secondary-text-color);
    margin-bottom: 40px;
}

.chapter-title {
    font-family: var(--serif);
    font-size: 30px;
    color: var(--heading);
}

.chapter-content h3 {
    font-size: 25px;
    margin-top: 30px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(90deg, var(--gold-deep), rgba(var(--gold-rgb), .05) 70%, transparent) 1;
}

.chapter-content h4 {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold-label);
    margin-top: 25px;
    margin-bottom: 10px;
}

p, li {
    font-size: 16px;
    margin-bottom: 1em;
}

ul, ol { padding-left: 20px; margin-bottom: 1em; }
ul li, ol li { margin-bottom: 0.5em; }

strong, b { font-weight: 600; color: var(--heading); }

kbd {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--mono);
    font-size: 0.85em;
    color: var(--gold-soft);
}

a {
    color: var(--accent-color);
    text-decoration: none;
}
a:hover { text-decoration: underline; }
a:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-deep), transparent);
    margin: 40px 0;
}

/*
============================================
COLLAPSIBLE SECTIONS (<details>)
============================================
*/
.chapter { margin-bottom: 0; }

details { border-bottom: 1px solid var(--border-color); }

summary {
    list-style: none;
    cursor: pointer;
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

summary::after {
    content: '';
    display: inline-block;
    width: 24px; height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23d4a017' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease-in-out;
    flex-shrink: 0;
}
details[open] > summary::after { transform: rotate(90deg); }

.chapter-header {
    flex: 1;
    display: flex;
    align-items: center;
}
.chapter-header h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 400;
    color: var(--heading);
}

.chapter-content { padding-bottom: 30px; }

/*
============================================
CODE BLOCKS
============================================
*/
.code-wrapper { position: relative; margin-bottom: 1em; }

pre {
    background-color: var(--code-bg);
    border: 1px solid var(--panel-edge);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: inset 0 1px 0 var(--inset-hi);
}

code { font-family: var(--mono); color: var(--text-color); }

p > code, li > code {
    background-color: rgba(var(--gold-rgb), .08);
    color: var(--gold-soft);
    border: 1px solid rgba(var(--gold-rgb), .14);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.86em;
}

pre code {
    white-space: pre-wrap;
    word-wrap: break-word;
    background: none;
    border: none;
    padding: 0;
    color: var(--text-color);
}

/* Copy button — gold pill */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background-color: var(--gold-fill);
    color: var(--on-gold);
    border: none;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s ease;
    z-index: 10;
}
.copy-btn:hover { opacity: 1; }
.copy-btn:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}
.copy-btn.copied { background-color: var(--lamp); color: #fff; }

.code-platform-label {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold-label);
    margin: 20px 0 10px 0;
}

/* Command Demo */
.command-demo { margin: 20px 0; }
.demo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.demo-header span {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--gold-label);
}
.demo-explanation {
    font-size: 14px;
    color: var(--secondary-text-color);
    margin-top: 8px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: 14px;
}
table th, table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
}
table th {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gold-label);
}
table td:first-child {
    font-family: var(--mono);
    color: var(--gold-soft);
}

/*
============================================
PANEL-LIKE CARDS — glassy gold-edged, near-solid for readability
============================================
*/
.reference-card,
.tip-card,
.analogy-card,
.quick-summary,
.learning-objectives,
.chapter-quiz-link {
    background-color: var(--panel-solid);
    border: 1px solid var(--panel-edge);
    border-radius: 16px;
    padding: 24px;
    margin: 24px 0;
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--card-shadow);
    transition: transform .18s ease, box-shadow .25s ease, border-color .18s ease;
}

.reference-card h4,
.tip-card h4,
.analogy-card h4,
.quick-summary h4,
.learning-objectives h4 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--gold-label);
}

/* light differentiation between card families via a gold left accent + tint */
.tip-card {
    border-left: 3px solid var(--gold);
    background-color: var(--panel-solid);
}
.analogy-card {
    border-left: 3px solid var(--gold-soft);
}
.learning-objectives {
    background-image: radial-gradient(420px 220px at 0% 0%, rgba(var(--gold-rgb), .07), transparent 70%);
}
.quick-summary {
    background-image: radial-gradient(420px 220px at 100% 0%, rgba(var(--gold-rgb), .06), transparent 70%);
}

/* warm hover glow — the ONE retained orange */
.reference-card:hover,
.tip-card:hover,
.analogy-card:hover {
    transform: translateY(-2px);
    border-color: var(--edge-strong);
    box-shadow: var(--hover-glow);
}

/*
============================================
CHAPTER QUIZ LINKS
============================================
*/
.chapter-quiz-link {
    margin-top: 32px;
    text-align: center;
}
.chapter-quiz-link h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-family: var(--serif);
    font-size: 22px;
    color: var(--heading);
    letter-spacing: 0;
    text-transform: none;
}
.chapter-quiz-link p {
    margin-bottom: 16px;
    color: var(--secondary-text-color);
    font-size: 1rem;
}

/*
============================================
BUTTONS — gold fill (primary) / gold outline (secondary)
============================================
*/
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--gold-fill);
    color: var(--on-gold);
    text-decoration: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.25s ease;
    border: 1px solid var(--gold-fill);
    cursor: pointer;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px -10px rgba(var(--gold-rgb), .7);
    text-decoration: none;
}
.btn:active { transform: translateY(0); }
.btn:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--gold-fill);
    color: var(--on-gold);
    border-color: var(--gold-fill);
}

.btn-secondary {
    background: transparent;
    color: var(--gold-text);
    border-color: var(--edge-strong);
}
.btn-secondary:hover {
    background: rgba(var(--gold-rgb), .08);
    color: var(--gold-text);
}

/*
============================================
CHAPTER NAVIGATION
============================================
*/
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid var(--border-color);
}

/*
============================================
BACK TO TOP — pka pill
============================================
*/
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 48px; height: 48px;
    background-color: var(--toptop-bg);
    color: var(--gold-text);
    border: 1px solid var(--panel-edge);
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s, border-color 0.2s;
    box-shadow: 0 12px 30px -12px rgba(0,0,0,.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}
.back-to-top.visible { opacity: 1; pointer-events: all; }
.back-to-top:hover { transform: translateY(-4px); border-color: var(--gold-label); }
.back-to-top:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* FOOTER */
.site-footer {
    text-align: center;
    padding: 40px 20px;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .08em;
    color: var(--secondary-text-color);
    border-top: 1px solid var(--border-color);
}
.site-footer p { font-size: 11.5px; }

/*
============================================
FOCUS MANAGEMENT — GOLD, opaque, both themes
============================================
*/
:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/*
============================================
REDUCED MOTION
============================================
*/
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    html { scroll-behavior: auto; }
}

/*
============================================
RESPONSIVE
============================================
*/
.sidebar-toggle { display: none; }

@media (max-width: 1024px) {
    .container { flex-direction: column; }

    .sidebar {
        position: fixed;
        left: -300px;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        background-color: var(--background-color);
        z-index: 99;
        transition: left 0.3s ease;
        box-shadow: 2px 0 18px rgba(0,0,0,0.4);
        padding-left: 20px;
    }
    :root[data-theme="dark"] .sidebar { background-color: #0c0c0d; }
    .sidebar.open { left: 0; }

    .sidebar-toggle { display: flex; }

    .content {
        width: 100%;
        padding: calc(var(--header-height) + 20px) 20px 50px 20px;
    }

    .site-header { padding: 0 20px; }

    .chapter-navigation { flex-direction: column; }
    .chapter-navigation .btn { width: 100%; justify-content: center; }
}

@media (max-width: 768px) {
    .chapter-quiz-link { padding: 20px; }
    .btn {
        display: flex;
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
    /* keep the atmosphere comparison control readable, hide its long label only if cramped */
    .atmo-toggle { padding: 8px 10px; }

    /* Header must stay a compact single row on phones — the broad .btn{width:100%}
       above is for in-content buttons, NOT the header's "Back to Tutorial". */
    .header-content { padding: 0 16px; }
    .site-header h1 { font-size: 18px; }
    .site-header-actions { gap: 8px; }
    .site-header-actions .btn { width: auto; display: inline-flex; padding: 8px 12px; }
    #atmo-toggle-label { display: none; }   /* atmosphere control -> icon-only when cramped */
}

/*
============================================
PRINT — force light ink, atmosphere off, sidebar hidden
============================================
*/
@media print {
    :root, :root[data-theme="dark"], :root[data-theme="light"] {
        --background-color: #ffffff;
        --text-color: #000000;
        --secondary-text-color: #333333;
        --heading: #000000;
        --accent-color: #000000;
        --panel: #ffffff;
        --panel-solid: #ffffff;
        --code-bg: #f4f4f4;
        --border-color: #cccccc;
        --panel-edge: #cccccc;
    }

    html, body { background: #ffffff !important; color: #000 !important; }
    body::before, body::after { display: none !important; }

    .site-header,
    .sidebar-toggle,
    .back-to-top,
    .search-button,
    .theme-toggle,
    .atmo-toggle,
    .skip-links,
    .chapter-quiz-link,
    .chapter-navigation {
        display: none !important;
    }

    .sidebar { display: none; }

    .content { margin-left: 0; max-width: 100%; padding: 0; }

    .reference-card, .tip-card, .analogy-card,
    .quick-summary, .learning-objectives {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    .chapter { page-break-inside: avoid; }

    a { color: #000; text-decoration: underline; }

    details { border: none; }
    summary { display: none; }
    .chapter-content { display: block !important; padding: 0; }
}

/*
============================================
UTILITY CLASSES
============================================
*/
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none; }
.visible { display: block; }
