/* ===== Theme tokens =====
   theme.js sets on <html>: data-daypart (dawn|day|dusk|night), data-tone (light|dark)
   and data-holiday. Daypart sets the base palette; a holiday only swaps the accent colors
   (plus a darker background for Halloween nights). Without JS, the OS light/dark setting applies. */

/* Day (default, light) */
:root {
  --bg: #f7f6f2; --surface: #ffffff; --surface-2: #efede6; --text: #1d1d1b; --muted: #5f5d57;
  --border: #dcd9cf; --accent: #2f5fd0; --on-accent: #ffffff;
  --good: #1f7a4a; --good-soft: #dff1e6; --warn: #9a5b00; --warn-soft: #fbedd5;
  --bad: #b3261e; --bad-soft: #f9e0de; --code-bg: #1e1f24; --code-text: #e8e6df;
}
/* Night (dark) */
:root[data-tone="dark"] {
  --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --text: #ecebe6; --muted: #a3a199;
  --border: #3a3935; --accent: #7fa2f5; --on-accent: #141413;
  --good: #6fcf97; --good-soft: #1c3527; --warn: #f2b45a; --warn-soft: #3b2c14;
  --bad: #f28b82; --bad-soft: #3d1f1d; --code-bg: #0e0e0d; --code-text: #e8e6df;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tone]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --text: #ecebe6; --muted: #a3a199;
    --border: #3a3935; --accent: #7fa2f5; --on-accent: #141413;
    --good: #6fcf97; --good-soft: #1c3527; --warn: #f2b45a; --warn-soft: #3b2c14;
    --bad: #f28b82; --bad-soft: #3d1f1d; --code-bg: #0e0e0d; --code-text: #e8e6df;
  }
}
/* Dawn: warm sunrise light */
:root[data-daypart="dawn"] {
  --bg: #fbf0e8; --surface: #fffaf6; --surface-2: #f4e2d6; --text: #2a1d17; --muted: #6b574d;
  --border: #ead2c3; --accent: #b8492a;
}
/* Dusk: indigo evening with amber light */
:root[data-daypart="dusk"] {
  --bg: #1c1726; --surface: #251f33; --surface-2: #302941; --text: #efe9f5; --muted: #b3a9c3;
  --border: #433a5c; --accent: #f2a65a;
}

/* Holiday accents: light-tone value first, then dark-tone */
:root[data-holiday="new-year"]                           { --accent: #8a6500; }
:root[data-holiday="new-year"][data-tone="dark"]         { --accent: #f0c74a; }
:root[data-holiday="valentines"]                         { --accent: #c2185b; }
:root[data-holiday="valentines"][data-tone="dark"]       { --accent: #f48fb1; }
:root[data-holiday="st-patricks"]                        { --accent: #1b7f3b; }
:root[data-holiday="st-patricks"][data-tone="dark"]      { --accent: #5fd68a; }
:root[data-holiday="easter"]                             { --accent: #7b4fc9; }
:root[data-holiday="easter"][data-tone="dark"]           { --accent: #c3a6f5; }
:root[data-holiday="canada-day"]                         { --accent: #c8102e; }
:root[data-holiday="canada-day"][data-tone="dark"]       { --accent: #ff7b8a; }
:root[data-holiday="independence-day"]                   { --accent: #1f4fa8; }
:root[data-holiday="independence-day"][data-tone="dark"] { --accent: #8fb2ff; }
:root[data-holiday="thanksgiving"]                       { --accent: #a14a0b; }
:root[data-holiday="thanksgiving"][data-tone="dark"]     { --accent: #f0a050; }
:root[data-holiday="halloween"]                          { --accent: #b34700; }
:root[data-holiday="halloween"][data-tone="dark"] {
  --accent: #ff8c2e; --bg: #120d16; --surface: #1b1520; --surface-2: #261d2c; --border: #3d2f45;
}
:root[data-holiday="christmas"]                          { --accent: #b3261e; }
:root[data-holiday="christmas"][data-tone="dark"]        { --accent: #ff7a6e; }
:root[data-holiday="mlk-day"]                            { --accent: #3949ab; }
:root[data-holiday="mlk-day"][data-tone="dark"]          { --accent: #9fa8ff; }
:root[data-holiday="black-history-month"]                { --accent: #217a3c; }
:root[data-holiday="black-history-month"][data-tone="dark"]{ --accent: #7be495; }
:root[data-holiday="juneteenth"]                         { --accent: #b02a2a; }
:root[data-holiday="juneteenth"][data-tone="dark"]       { --accent: #ff8a80; }
:root[data-holiday="kwanzaa"]                            { --accent: #2e7d32; }
:root[data-holiday="kwanzaa"][data-tone="dark"]          { --accent: #81d98a; }
:root[data-holiday="cinco-de-mayo"]                      { --accent: #00796b; }
:root[data-holiday="cinco-de-mayo"][data-tone="dark"]    { --accent: #4fd6c4; }
:root[data-holiday="mexican-independence"]               { --accent: #006847; }
:root[data-holiday="mexican-independence"][data-tone="dark"]{ --accent: #4ed79a; }
:root[data-holiday="heritage-month"]                     { --accent: #ad1457; }
:root[data-holiday="heritage-month"][data-tone="dark"]   { --accent: #f48fb1; }
:root[data-holiday="dia-de-muertos"]                     { --accent: #a84b00; }
:root[data-holiday="dia-de-muertos"][data-tone="dark"]   { --accent: #ffb347; }
:root[data-holiday="guadalupe"]                          { --accent: #1565c0; }
:root[data-holiday="guadalupe"][data-tone="dark"]        { --accent: #90caf9; }
:root[data-holiday="africa-day"]                         { --accent: #8a6500; }
:root[data-holiday="africa-day"][data-tone="dark"]       { --accent: #f2c14e; }
:root[data-holiday="national-day"]                       { --accent: #1f4fa8; }
:root[data-holiday="national-day"][data-tone="dark"]     { --accent: #8fb2ff; }

/* Huginn and Muninn: black ravens in the light themes, white ravens in the dark ones */
:root { --raven: #141413; }
:root[data-tone="dark"] { --raven: #f2f1ec; }
@media (prefers-color-scheme: dark) { :root:not([data-tone]) { --raven: #f2f1ec; } }

/* Derived from whichever accent is active */
:root { --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg)); }

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }

/* ---- site chrome ---- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .inner { max-width: 920px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; margin-right: auto; display: inline-flex; align-items: center; gap: 8px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.raven-mark { width: 52px; height: 26px; color: var(--raven); fill: currentColor; }
.hero { display: flex; gap: 20px; align-items: center; margin-bottom: 8px; }
.hero-ravens { flex: 0 0 auto; width: 150px; height: 73px; color: var(--raven); fill: currentColor; }
@media (max-width: 600px) { .hero { flex-direction: column; align-items: flex-start; } .hero-ravens { width: 110px; height: 54px; } }
.site-footer .runes { margin: 0 0 4px; font-size: 1.1rem; letter-spacing: .35em; color: var(--muted); }
.site-footer p { margin: 0; }
.nav { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.nav a { text-decoration: none; }
.nav form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
main { max-width: 920px; margin: 0 auto; padding: 32px 16px 80px; }
.site-footer { max-width: 920px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { background: var(--good-soft); color: var(--good); padding: 10px 14px; border-radius: 8px; }

/* ---- typography ---- */
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.15; margin: 0 0 8px; }
h2 { font-size: 1.45rem; margin: 48px 0 8px; }
h3 { font-size: 1.1rem; margin: 0 0 6px; }
/* A card's own heading, sized like an h3 but one level down from the page's h1 (no skipped levels). */
.card-heading { font-size: 1.1rem; margin: 0 0 6px; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 62ch; }
.why, .muted { color: var(--muted); font-size: .93rem; }
.eyebrow { font-size: .75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre {
  margin: 0; background: var(--code-bg); color: var(--code-text); border-radius: 8px;
  padding: 14px 16px; padding-right: 80px; overflow-x: auto; font: .88rem/1.5 ui-monospace, Consolas, monospace;
}
pre code { background: none; padding: 0; color: inherit; }

/* ---- shared components ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 14px 16px; margin: 16px 0; }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; margin: 2px 4px 2px 0; }
.tag.high { background: var(--good-soft); color: var(--good); }
.tag.mid { background: var(--warn-soft); color: var(--warn); }
.tag.low { background: var(--bad-soft); color: var(--bad); }
button, .button {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 99px; padding: 8px 16px; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: var(--accent); }
.button.primary, button.primary, button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
/* For actions that can't be undone, like deleting an account */
button.danger, .button.danger { background: var(--bad); color: var(--bg); border-color: var(--bad); }
.step-num {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: .95rem; margin-right: 8px; vertical-align: 2px;
}
.table-wrap { overflow-x: auto; margin-top: 16px; }
table { border-collapse: collapse; width: 100%; min-width: 560px; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .93rem; vertical-align: top; }
th { background: var(--surface-2); }
.code { position: relative; margin: 10px 0; }
/* A code box that is a whole file shows its path above it: <div class="code" data-file="tasks/views.py"> */
.code[data-file]::before { content: attr(data-file); display: block; margin-bottom: 4px; font: 600 .78rem ui-monospace, Consolas, monospace; color: var(--muted); }
.copy { position: absolute; top: 8px; right: 8px; font-size: .8rem; padding: 4px 10px; background: var(--surface-2); }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ---- home / track list ---- */
.track { margin-top: 36px; }
.track h2 { margin: 0 0 4px; }
.lesson-list { list-style: none; padding: 0; margin: 12px 0 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.lesson-list li { display: flex; gap: 12px; align-items: baseline; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.lesson-list li:last-child { border-bottom: 0; }
.lesson-list .num { font-family: ui-monospace, Consolas, monospace; color: var(--muted); min-width: 2ch; }
.lesson-list .title { flex: 1; }
.lesson-list .soon { color: var(--muted); }
.lesson-list .done { color: var(--good); font-weight: 700; }

/* ---- lesson page ---- */
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; flex-wrap: wrap; }
.nav-soon { color: var(--muted); }
.lesson-actions { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.locked { text-align: center; padding: 40px 20px; margin-top: 24px; }

/* ---- interactive lesson widgets (see site.js) ---- */
.chooser { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.chooser-result { min-height: 80px; }
.options .card.recommended { border: 2px solid var(--accent); }
.proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; font-size: .92rem; }
.proscons ul { margin: 4px 0 0; padding-left: 18px; }
.proscons li { margin-bottom: 4px; }
.pro-h { color: var(--good); font-weight: 700; }
.con-h { color: var(--bad); font-weight: 700; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 16px 0 0; }
.steps > li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 12px; }
.steps > li h3::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); margin-right: 8px; font-size: .9rem; }
.checklist { list-style: none; padding: 0; margin: 12px 0 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.checklist li { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.checklist li:last-child { border-bottom: 0; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress div { height: 100%; width: 0; background: var(--good); transition: width .3s; }

/* ---- box model diagram (lesson 02) ---- */
.boxmodel { margin: 16px 0; font-size: .85rem; }
.boxmodel > div, .boxmodel div div { border-radius: 8px; padding: 10px 14px 14px; }
.bm-label { display: block; font-weight: 600; margin-bottom: 6px; }
.bm-margin { background: var(--warn-soft); border: 1px dashed var(--warn); }
.bm-margin > .bm-label { color: var(--warn); }
.bm-border { background: var(--surface); border: 3px solid var(--text); }
.bm-padding { background: var(--good-soft); }
.bm-padding > .bm-label { color: var(--good); }
.bm-content { background: var(--accent-soft); border: 1px solid var(--accent); text-align: center; padding: 14px; color: var(--text); }

/* ---- interactive layout demos (lesson 03; see site.js [data-demo]) ---- */
/* "Try it" boxes: editors on the left, live preview on the right (stacked on narrow screens) */
.tryit { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin: 16px 0;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tryit-code { display: grid; gap: 8px; align-content: start; }
.tryit-label { font-size: .75rem; font-weight: 600; letter-spacing: .05em; color: var(--muted); }
.tryit textarea { width: 100%; min-height: 9rem; resize: vertical; box-sizing: border-box; tab-size: 2;
  background: var(--code-bg); color: var(--code-text); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: .88rem/1.5 ui-monospace, Consolas, monospace; white-space: pre; overflow: auto; }
.tryit textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tryit-side { display: flex; flex-direction: column; gap: 8px; }
.tryit-bar { display: flex; justify-content: space-between; align-items: center; }
.tryit-bar button { padding: 2px 10px; font-size: .8rem; }
/* A real page is white unless the learner's CSS says otherwise, in any site theme. */
.tryit-preview { flex: 1; min-height: 14rem; width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* The Raven's Forge: Sketch (CAD boxes, static/js/cad.js). The drawing follows the site's light/dark tone. */
.cadbox .tryit-bar { gap: 6px; }
.cadbox .tryit-bar .tryit-label { margin-right: auto; }
.cad-preview { min-height: 18rem; background: var(--surface); }
.cad-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.cad-checks .todo { color: var(--muted); }
.cad-checks .ok { color: var(--text); }
.cad-checks .done { font-weight: 600; }

.demo { margin: 16px 0; }
.demo-controls { display: grid; gap: 10px; margin-bottom: 12px; }
.demo-controls [data-prop] { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.demo-controls code { min-width: 9.5em; }
.demo-controls button { padding: 4px 12px; font-size: .85rem; }
.demo-stage {
  min-height: 170px; padding: 10px; border: 2px dashed var(--border); border-radius: 10px;
  background: var(--surface-2); transition: all .2s;
}
.demo-stage.flex { display: flex; gap: 8px; }
.demo-stage.grid { display: grid; gap: 8px; }
.demo-item {
  background: var(--accent); color: var(--on-accent); border-radius: 8px; padding: 12px 16px;
  font-weight: 700; text-align: center;
}
.demo-item.tall { padding-top: 34px; padding-bottom: 34px; }
.demo-css { margin-top: 10px; }

/* ---- resizable responsive demo (lesson 04) ----
   Uses a container query so the layout reacts to the box's width, which is
   the same idea as a media query reacting to the screen's width. */
.resize-demo {
  resize: horizontal; overflow: auto; width: 100%; min-width: 220px; max-width: 100%;
  border: 2px dashed var(--border); border-radius: 10px; padding: 10px; background: var(--surface-2);
  container-type: inline-size;
}
.rd-nav { display: flex; flex-direction: column; gap: 6px; background: var(--text); color: var(--bg); border-radius: 6px; padding: 8px 10px; font-weight: 700; }
.rd-nav span:not(:first-child) { font-weight: 400; font-size: .85rem; }
.rd-cards { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.rd-cards div { background: var(--accent); color: var(--on-accent); border-radius: 6px; padding: 16px; text-align: center; font-weight: 700; }
.rd-size::before { content: "Phone layout: 1 column"; }
.rd-size { display: block; margin-top: 8px; font-size: .85rem; color: var(--muted); }
@container (min-width: 520px) {
  .rd-nav { flex-direction: row; justify-content: space-between; align-items: center; }
  .rd-cards { grid-template-columns: 1fr 1fr; }
  .rd-size::before { content: "Tablet layout: 2 columns (520px and wider)"; }
}
@container (min-width: 760px) {
  .rd-cards { grid-template-columns: 1fr 1fr 1fr; }
  .rd-size::before { content: "Desktop layout: 3 columns (760px and wider)"; }
}

/* ---- forms ---- */
.form-card { max-width: 440px; }
.form-card label { display: block; font-weight: 600; margin-top: 12px; }
.form-card input[type=text], .form-card input[type=password], .form-card input[type=email],
.form-card input[type=number], .form-card select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; margin-top: 4px;
}
.form-card .helptext, .form-card .helptext ul { color: var(--muted); font-size: .85rem; }
.errorlist { color: var(--bad); padding-left: 18px; font-size: .9rem; }

/* ---- holiday banner ---- */
/* Text stays --text: accent-colored text on the accent tint falls below 4.5:1 in the
   light palettes (tests/js/contrast.test.js). The holiday color shows in the tint and border. */
.holiday-banner { background: var(--accent-soft); color: var(--text); text-align: center; font-size: .92rem; padding: 6px 16px; border-bottom: 2px solid var(--accent); }
.holiday-banner strong { color: var(--text); }
.banner-toggle { margin-left: 12px; font-size: .85rem; color: var(--text); text-decoration: underline; }

/* ---- Halloween glitch (effect from dos-web; scheduled in site.js) ---- */
/* Played once, over half a second: at most one brightness flash per glitch, far under the WCAG 2.3.1
   limit of three flashes in any second (tests/js/photosensitivity.test.js keeps it that way). */
body.glitching { animation: glitch-flash .5s steps(2, end) 1; }
@keyframes glitch-flash {
  0%   { transform: translate(0, 0); filter: none; text-shadow: none; }
  20%  { transform: translate(-2px, 1px); filter: hue-rotate(18deg) saturate(1.4); text-shadow: 2px 0 rgba(255, 0, 60, .55), -2px 0 rgba(0, 255, 200, .45); }
  40%  { transform: translate(2px, -1px); filter: contrast(1.6); }
  60%  { transform: translate(-1px, 0); filter: brightness(1.15); text-shadow: -2px 0 rgba(255, 0, 60, .5), 2px 0 rgba(0, 255, 200, .4); }
  80%  { transform: translate(1px, 1px); filter: hue-rotate(-10deg); }
  100% { transform: translate(0, 0); filter: none; text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { body.glitching { animation: none; } }

@media (max-width: 560px) { .proscons { grid-template-columns: 1fr; } }

/* Spacing that used to be inline style="" (kept out of HTML for a strict CSP) */
.form-actions { margin-top: 16px; }
.locked h2 { margin-top: 0; }
details > summary + * { margin-top: 8px; }

/* --- landing page --- */
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.landing-section { margin: 40px 0; }
.landing-section > h2 { font-size: 1.5rem; margin-bottom: 14px; }
.track-overview { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.track-overview h3 { margin: 4px 0 6px; }
.outcomes { display: grid; gap: 10px; padding-left: 20px; max-width: 70ch; }
.outcomes li { line-height: 1.5; }
.landing-cta { margin: 48px 0; padding: 28px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: center; }
.landing-cta .hero-cta { justify-content: center; }
.site-footer .copyright { margin-top: 6px; font-size: .8rem; }
.callout.branch { border-left: 4px solid var(--accent); }

/* --- staff dashboard stat tiles --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.stat-num { display: block; font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-label { display: block; font-size: .82rem; color: var(--muted); margin-top: 4px; }
.stat.stat-warn { border-color: var(--warn); }
.stat.stat-warn .stat-num { color: var(--warn); }

/* --- managers' journal (blog) --- */
.journal { max-width: 760px; }
.journal-head { margin-bottom: 24px; }
.journal-item { display: grid; grid-template-columns: 120px 1fr; gap: 18px; padding: 20px 0; border-top: 1px solid var(--border); }
.journal-item:first-of-type { border-top: 0; }
@media (max-width: 560px) { .journal-item { grid-template-columns: 1fr; gap: 8px; } }
.journal-voice { text-align: center; color: var(--muted); }
.journal-voice.big { display: inline-flex; align-items: baseline; gap: 8px; text-align: left; margin-bottom: 4px; }
.voice-emoji { font-size: 1.6rem; display: block; }
.journal-voice.big .voice-emoji { font-size: 1.1rem; }
.voice-name { display: block; font-weight: 700; color: var(--text); }
.journal-voice.big .voice-name { display: inline; }
.voice-sub { display: block; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.journal-voice.big .voice-sub { display: inline; }
.journal-item h2 { margin: 0 0 4px; font-size: 1.25rem; }
.journal-item h2 a { color: var(--text); text-decoration: none; }
.journal-item h2 a:hover { color: var(--accent); }
.journal-meta { font-size: .82rem; color: var(--muted); margin: 0 0 10px; }
.journal-excerpt { color: var(--text); }
/* A quiet accent stripe per voice, so entries are easy to tell apart without shouting. */
.voice-huginn .journal-body-col { border-left: 3px solid #6f9ceb; padding-left: 14px; }
.voice-muninn .journal-body-col { border-left: 3px solid #8a8f98; padding-left: 14px; }
.voice-odin   .journal-body-col { border-left: 3px solid var(--accent); padding-left: 14px; }
.journal-single { font-size: 1.05rem; }
.journal-prose { line-height: 1.75; max-width: 68ch; }
.journal-prose p { margin: 0 0 1em; }
.journal-actions { margin-top: 24px; }
.journal-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.journal-form select, .journal-form input[type=text] { font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }

/* --- arena weekly leaderboard --- */
.leaderboard { list-style: none; padding: 0; max-width: 560px; counter-reset: none; }
.lb-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.lb-rank { font-weight: 800; text-align: center; color: var(--muted); }
.lb-name { font-weight: 600; }
.lb-stat { font-size: .85rem; color: var(--muted); }
.lb-row.legend { background: var(--accent-soft); border-color: var(--accent); }
.lb-row.legend .lb-name { color: var(--text); }
.lb-row.legend + .lb-row:not(.legend) { margin-top: 16px; }
.lb-row.me { border-color: var(--good); }
.leaderboard.compact { max-width: 480px; }
.leaderboard.compact .lb-row { padding: 8px 12px; margin-bottom: 6px; }
.arena-rank-panel { margin: 12px 0 28px; }

/* --- arena weekly featured set --- */
.featured { margin: 16px 0 28px; }
.featured-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.featured-card { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); border-top: 4px solid var(--border); }
.featured-card h3 { margin: 2px 0 6px; }
.featured-card h3 a { color: var(--text); text-decoration: none; }
.featured-card h3 a:hover { color: var(--accent); }
.featured-card.tier-beginner { border-top-color: #6fcf97; }
.featured-card.tier-intermediate { border-top-color: #f2b45a; }
.featured-card.tier-expert { border-top-color: #e2726e; }

/* --- roles control panel & role landing --- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.role-card { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.role-card.owner { border-color: var(--accent); }
.role-card h3 { margin: 2px 0 6px; }
.can-list, .cannot-list { list-style: none; padding: 0; margin: 4px 0 10px; font-size: .9rem; }
.can-list li { color: var(--good); }
.cannot-list li { color: var(--muted); }
.role-search { display: flex; gap: 8px; margin-bottom: 12px; }
.role-search input { flex: 1; max-width: 320px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.role-people { width: 100%; border-collapse: collapse; }
.role-people th, .role-people td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.assign-form { display: flex; gap: 6px; flex-wrap: wrap; }
.assign-form select { padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }

/* --- decorated, animated error pages (404/403/400/500) --- */
.notfound { text-align: center; max-width: 640px; margin: 40px auto; }
.notfound .hero-cta { justify-content: center; }
.error-scene { width: 100%; max-width: 560px; height: auto; margin: 8px auto 20px; display: block; }
.error-raven { fill: var(--raven, #141413); }
.error-water { fill: var(--accent, #2f5fd0); opacity: .13; }
.error-wave { fill: none; stroke: var(--accent, #2f5fd0); opacity: .45; stroke-width: 2.5; stroke-linecap: round; }
.error-isle { fill: var(--muted, #5f5d57); opacity: .35; }
/* The ravens glide; the waves bob. Subtle on purpose. */
.bird { transform-box: fill-box; transform-origin: center; animation: raven-glide 4s ease-in-out infinite; }
.bird2 { animation-duration: 5.2s; animation-delay: -1.6s; }
@keyframes raven-glide { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-9px) rotate(-1.6deg); } }
.error-wave { animation: wave-bob 3.6s ease-in-out infinite; }
.error-wave.w2 { animation-duration: 4.4s; animation-delay: -0.8s; }
.error-wave.w3 { animation-duration: 4s; animation-delay: -1.8s; }
.error-wave.w4 { animation-duration: 3.2s; animation-delay: -0.4s; }
@keyframes wave-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .bird, .error-wave { animation: none; } }

/* Profile locked notice */
.locked-icon { font-size: 3rem; }

/* Control panel: Óðinn and the ravens */
.legend-card .legend-runes { margin: 0; font-size: 1.4rem; letter-spacing: .3em; color: var(--muted); }
.legend-post { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.legend-post textarea { font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); box-sizing: border-box; width: 100%; }
.legend-post button { align-self: flex-start; }
.avatar-raven { width: 1em; height: 1em; color: var(--raven); fill: currentColor; vertical-align: -0.12em; }

/* Long inline code (URLs, paths) wraps instead of widening the page; code blocks scroll instead. */
:not(pre) > code { overflow-wrap: anywhere; }

/* The owner's control panel (/manage/control/) */
.control-filter { margin: 1rem 0 1.5rem; }
.control-filter label { display: block; font-weight: 600; margin-bottom: .3rem; }
.control-filter input { width: min(100%, 32rem); font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); }
.control-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.control-section h2, .control-section h3 { margin-top: 0; }
.control-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.control-links a.muted { font-size: .85rem; margin-left: .35rem; }
.control-track { margin-bottom: .6rem; }
.control-track summary { cursor: pointer; }
.control-track .control-links { margin-top: .6rem; }

/* Dropdown menus in the top navigation (templates/base.html). */
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; color: var(--accent); padding: 4px 2px; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: " ▾"; font-size: .8em; }
.nav-menu[open] > summary::after { content: " ▴"; }
.nav-dropdown { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 14rem; max-height: 70vh;
  overflow-y: auto; display: flex; flex-direction: column; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.nav-menu-end .nav-dropdown { left: auto; right: 0; }
.nav-dropdown a, .nav-dropdown .link-button { display: block; padding: 8px 10px; border-radius: 6px; text-align: left; width: 100%; }
.nav-dropdown a:hover, .nav-dropdown a:focus-visible, .nav-dropdown .link-button:hover { background: var(--bg); }
@media (max-width: 600px) {
  .nav-menu { position: static; }
  .nav-dropdown { left: 16px; right: 16px; min-width: 0; }
}
.arena-filter a[aria-current="page"] { font-weight: 700; text-decoration: none; }

/* Progress and "pick up where you left off" (catalog/journey.py, templates/catalog/_pick_up.html) */
progress.course-progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; max-width: 32rem;
  height: 10px; border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0; }
progress.course-progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress.course-progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress.course-progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.pick-up { margin: 24px 0; padding: 20px; border-left: 4px solid var(--accent); }
.pick-up h2 { margin: 4px 0; }
.pick-up h2 a { text-decoration: none; }
.course-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.course-list li { display: grid; gap: 4px; padding: 14px; }
.track-progress { margin: 0 0 8px; }

/* The saga (/saga/) */
.saga { list-style: none; padding: 0; display: grid; gap: 14px; }
.saga-chapter { padding: 18px 20px; }
.saga-chapter h2 { margin: 2px 0 8px; }
.saga-chapter.locked { opacity: .7; }
.saga-text p { line-height: 1.7; }
.saga-source { font-size: .85rem; }

/* The legends' daily tasks and the rune calendar (templates/catalog/_daily.html) */
.daily { margin: 24px 0; padding: 18px 20px; }
.daily-tasks { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.daily-tasks li { display: grid; grid-template-columns: 1.4rem 1fr; gap: 6px; }
.daily-tasks li.done { color: var(--muted); }
.daily-mark { font-weight: 700; color: var(--accent); }
.rune-calendar { display: grid; grid-template-columns: repeat(14, 1.6rem); gap: 4px; margin-top: 8px; }
@media (max-width: 480px) { .rune-calendar { grid-template-columns: repeat(7, 1.6rem); } }
.rune-day { width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-size: .9rem; }
.rune-day.partial { outline: 1px solid var(--border); }
.rune-day.earned { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.rune-day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.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; }

/* The offline page (templates/offline.html) */
.offline-page { max-width: 32rem; margin: 12vh auto; padding: 0 16px; text-align: center; }
.offline-ravens { border-radius: 22px; }

/* G-code boxes (static/js/gcode-box.js) */
.gcode-view { width: 100%; height: 18rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.gcode-stock { fill: var(--surface); stroke: var(--border); stroke-width: .4; }
.gcode-axis { stroke: var(--muted); opacity: .5; }
.gcode-rapid { fill: none; stroke: var(--muted); }
.gcode-cut { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; }
.gcode-tool { fill: var(--text); }
.gcode-stats { font-size: .85rem; margin: 6px 0; }
.gcode-problems { list-style: none; padding: 0; margin: 0 0 6px; font-size: .85rem; display: grid; gap: 3px; }
.gcode-problems li { cursor: pointer; }
.gcode-problems .error { color: var(--bad); }
.gcode-problems .warning { color: var(--muted); }
