/* ==========================================================================
   🌲 Forest Global Styles (styles.css), Warm Dark + Green/Orange accents
   Semantic, classless base with minimal layout utilities.
   MD-LD render() compatible.

   - Page / UI chrome: warm dark gray, light text, green + orange accents
   - .content-block (lesson text only): light warm gray, dark text, ≤75ch lines
   - Thin 1px borders + soft shadows. Hover = filter(), never movement.
   ========================================================================== */

/* ── 1. Tokens & Theme ─────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* Base palette: warm dark grays */
  --bg: #232220;
  --surface: #2c2a28;
  --surface-2: #383532;
  --fg: #eeebe6;
  --fg-muted: #a8a39b;
  --border: #413e3a;
  --border-light: #33312e;

  /* Accents: green (primary) + orange (secondary) */
  --accent: #6bd68f;
  --accent-hover: #8be6ab;
  --accent-fg: #11231a;
  --accent-2: #ff9a3c;
  --accent-2-fg: #2a1604;
  --mark: rgba(255, 154, 60, 0.32);
  --code-fg: #ffb877;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.35);

  /* Chromatone 12-step hue system (badges, highlights, semantic colors) */
  --chroma-0: hsl(0, 70%, 60%);
  --chroma-30: hsl(30, 85%, 58%);
  --chroma-60: hsl(50, 90%, 58%);
  --chroma-90: hsl(90, 60%, 52%);
  --chroma-120: hsl(130, 50%, 50%);
  --chroma-150: hsl(160, 55%, 48%);
  --chroma-180: hsl(185, 60%, 52%);
  --chroma-210: hsl(210, 70%, 62%);
  --chroma-240: hsl(240, 70%, 68%);
  --chroma-270: hsl(270, 60%, 66%);
  --chroma-300: hsl(300, 55%, 62%);
  --chroma-330: hsl(335, 70%, 64%);

  /* Subtle semantic backgrounds (dark) */
  --bg-success: #1b2a20;
  --bg-error: #33201f;
  --bg-info: #1f2733;
  --bg-warning: #332b1c;

  /* Geometry & Rhythm */
  --measure: 75ch;
  /* max line length for reading text */
  --maxw-page: 60rem;
  /* dark page column */
  --gap: 1rem;
  --radius: 12px;
  --radius-sm: 6px;
  --pad: 0.65rem 1rem;
  --stroke: 1px;

  /* Forest Gradient: green + orange blurred radial gradients at edges */
  --gradient-green-hue: 130;
  --gradient-green-sat: 50%;
  --gradient-green-light: 40%;
  --gradient-green-opacity: 0.18;
  --gradient-orange-hue: 30;
  --gradient-orange-sat: 85%;
  --gradient-orange-light: 55%;
  --gradient-orange-opacity: 0.12;

  /* Typography */
  --font-sans: "Helvetica Neue", Helvetica, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

/* CSS @property for animated gradient values - creates organic variation */
@property --gradient-green-pos-x {
  syntax: '<percentage>';
  initial-value: 85%;
  inherits: true;
}

@property --gradient-green-pos-y {
  syntax: '<percentage>';
  initial-value: -10%;
  inherits: true;
}

@property --gradient-green-anim-opacity {
  syntax: '<number>';
  initial-value: 0.18;
  inherits: true;
}

@property --gradient-orange-pos-x {
  syntax: '<percentage>';
  initial-value: 0%;
  inherits: true;
}

@property --gradient-orange-pos-y {
  syntax: '<percentage>';
  initial-value: 110%;
  inherits: true;
}

@property --gradient-orange-anim-opacity {
  syntax: '<number>';
  initial-value: 0.12;
  inherits: true;
}

/* Forest gradient for content pages - green + orange blurred radial gradients */
body.content-page {
  --gradient-green-pos-x: 85%;
  --gradient-green-pos-y: -10%;
  --gradient-green-anim-opacity: 0.18;
  --gradient-orange-pos-x: 0%;
  --gradient-orange-pos-y: 110%;
  --gradient-orange-anim-opacity: 0.12;

  background:
    radial-gradient(60rem 28rem at var(--gradient-green-pos-x) var(--gradient-green-pos-y),
      hsl(var(--gradient-green-hue) var(--gradient-green-sat) var(--gradient-green-light) / var(--gradient-green-anim-opacity)),
      transparent 60%),
    radial-gradient(50rem 24rem at var(--gradient-orange-pos-x) var(--gradient-orange-pos-y),
      hsl(var(--gradient-orange-hue) var(--gradient-orange-sat) var(--gradient-orange-light) / var(--gradient-orange-anim-opacity)),
      transparent 60%),
    var(--bg);

  animation: forest-drift 60s ease-in-out infinite alternate;
}

/* Slow organic drift animation for gradient positions */
@keyframes forest-drift {
  0% {
    --gradient-green-pos-x: 85%;
    --gradient-green-pos-y: -10%;
    --gradient-green-anim-opacity: 0.18;
    --gradient-orange-pos-x: 0%;
    --gradient-orange-pos-y: 110%;
    --gradient-orange-anim-opacity: 0.12;
  }

  25% {
    --gradient-green-pos-x: 90%;
    --gradient-green-pos-y: -5%;
    --gradient-green-anim-opacity: 0.22;
    --gradient-orange-pos-x: 5%;
    --gradient-orange-pos-y: 105%;
    --gradient-orange-anim-opacity: 0.15;
  }

  50% {
    --gradient-green-pos-x: 80%;
    --gradient-green-pos-y: -15%;
    --gradient-green-anim-opacity: 0.16;
    --gradient-orange-pos-x: -5%;
    --gradient-orange-pos-y: 115%;
    --gradient-orange-anim-opacity: 0.10;
  }

  75% {
    --gradient-green-pos-x: 88%;
    --gradient-green-pos-y: -8%;
    --gradient-green-anim-opacity: 0.20;
    --gradient-orange-pos-x: 3%;
    --gradient-orange-pos-y: 108%;
    --gradient-orange-anim-opacity: 0.14;
  }

  100% {
    --gradient-green-pos-x: 82%;
    --gradient-green-pos-y: -12%;
    --gradient-green-anim-opacity: 0.19;
    --gradient-orange-pos-x: -2%;
    --gradient-orange-pos-y: 112%;
    --gradient-orange-anim-opacity: 0.13;
  }
}

/* Apply same gradient to component pages */
body.component-page {
  --gradient-green-pos-x: 85%;
  --gradient-green-pos-y: -10%;
  --gradient-green-anim-opacity: 0.18;
  --gradient-orange-pos-x: 0%;
  --gradient-orange-pos-y: 110%;
  --gradient-orange-anim-opacity: 0.12;

  background:
    radial-gradient(60rem 28rem at var(--gradient-green-pos-x) var(--gradient-green-pos-y),
      hsl(var(--gradient-green-hue) var(--gradient-green-sat) var(--gradient-green-light) / var(--gradient-green-anim-opacity)),
      transparent 60%),
    radial-gradient(50rem 24rem at var(--gradient-orange-pos-x) var(--gradient-orange-pos-y),
      hsl(var(--gradient-orange-hue) var(--gradient-orange-sat) var(--gradient-orange-light) / var(--gradient-orange-anim-opacity)),
      transparent 60%),
    var(--bg);

  animation: forest-drift 60s ease-in-out infinite alternate;
}

/* Add slight delay for component pages so they don't sync perfectly */
body.component-page {
  animation-delay: -15s;
}

/* Light content tokens: lesson text only. Re-scoping the variables makes
   links, code, tables, forms, buttons and blockquotes inside adapt for free. */
.content-block,
article {
  color-scheme: light;

  --bg: #dcd8d1;
  --surface: #e8e5df;
  --surface-2: #cdc9c1;
  --fg: #1f1d1b;
  --fg-muted: #5a554e;
  --border: #b9b4aa;
  --border-light: #cdc8bf;

  --accent: #16683a;
  --accent-hover: #0f4d2b;
  --accent-fg: #ffffff;
  --accent-2: #bd5109;
  --accent-2-fg: #ffffff;
  --mark: rgba(255, 154, 60, 0.45);
  --code-fg: #9a3d06;
  --shadow: 0 1px 2px rgba(31, 29, 27, 0.12), 0 4px 12px rgba(31, 29, 27, 0.1);
  --shadow-lg: 0 2px 4px rgba(31, 29, 27, 0.14), 0 12px 28px rgba(31, 29, 27, 0.18);

  --bg-success: #cfe0cf;
  --bg-error: #ecd0cc;
  --bg-info: #cbd8e4;
  --bg-warning: #eadbb8;

  background: var(--bg);
  color: var(--fg);
}

/* ── 2. Modern Power-ups ───────────────────────────────────────────────── */
@view-transition {
  navigation: auto;
}

::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: 0.35s;
  animation-timing-function: ease-in-out;
}

::view-transition-old([class*="cover"]),
::view-transition-new([class*="cover"]) {
  animation-duration: 0.5s;
}

html {
  interpolate-size: allow-keywords;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
  background: var(--bg);
}

/* ── 3. Reset & Base ───────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body>header,
body>footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: var(--bg);
  border-bottom: var(--stroke) solid var(--border);
}

body>header {
  font-weight: 700;
  letter-spacing: -0.01em;
}

body>footer {
  border-bottom: 0;
  border-top: var(--stroke) solid var(--border);
  margin-top: auto;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

body>main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw-page);
  margin-inline: auto;
  padding: calc(var(--gap) * 1.5) var(--gap) calc(var(--gap) * 3);
}

/* Articles are light "paper" panels */
article {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 5rem);
  margin-inline: auto;
  padding: calc(var(--gap) * 2) calc(var(--gap) * 1.5);
  border-radius: var(--radius);
}

/* ── 4. Typography & Markdown Flow ─────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.15;
  margin: 1.6em 0 0.5em;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-wrap: balance;
  scroll-margin-top: 1.5em;
}

h1 {
  font-size: 2.4rem;
}

h2 {
  font-size: 1.7rem;
}

h3 {
  font-size: 1.3rem;
}

h4 {
  font-size: 1.05rem;
}

h5,
h6 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

header h1,
header p {
  margin: 0;
}

p,
ul,
ol,
dl,
blockquote,
pre,
table,
figure {
  margin-block: 0.9em;
  text-wrap: pretty;
}

/* Reading text never gets wider than the measure */
p,
li,
dd,
blockquote,
h1,
h2,
h3,
h4,
h5,
h6 {
  max-width: var(--measure);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s, filter 0.2s;
}

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

ul,
ol {
  padding-inline-start: 1.4em;
}

li+li {
  margin-top: 0.25em;
}

li::marker {
  color: var(--accent-2);
}

hr {
  border: 0;
  border-top: var(--stroke) solid var(--border);
  margin: 2em 0;
}

small,
sub,
sup {
  font-size: 0.85em;
}

strong,
b {
  font-weight: 750;
}

abbr[title] {
  text-decoration: underline dotted;
}

blockquote {
  padding: 0.4em 1.1em;
  border-left: 3px solid var(--accent-2);
  color: var(--fg-muted);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

mark {
  background: var(--mark);
  color: inherit;
  padding: 0.05em 0.25em;
  border-radius: 4px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: var(--stroke) solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 0.1em 0.45em;
}

code,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

code,
samp {
  color: var(--code-fg);
}

pre {
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  padding: 0.9em 1.1em;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

pre code {
  color: inherit;
  background: none;
  padding: 0;
  font-size: inherit;
}

/* ── 5. Media & Embeds ─────────────────────────────────────────────────── */
img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

img {
  border-radius: var(--radius);
}

figure img {
  margin-bottom: 0.35em;
}

figcaption {
  font-size: 0.85em;
  color: var(--fg-muted);
  text-align: center;
}

iframe {
  width: 100%;
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ── 6. Tables ─────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95em;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

caption {
  text-align: left;
  font-size: 0.85em;
  color: var(--fg-muted);
  padding-bottom: 0.4em;
}

th,
td {
  padding: 0.6em 0.9em;
  border-bottom: var(--stroke) solid var(--border-light);
  text-align: left;
}

thead th,
tfoot th {
  background: var(--surface-2);
  font-weight: 750;
  border-bottom-color: var(--border);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--surface-2);
}

/* ── 7. Forms ──────────────────────────────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

fieldset {
  display: flex;
  flex-direction: column;
  gap: calc(var(--gap) * 0.75);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  margin-block: var(--gap);
}

legend {
  padding-inline: 0.4em;
  font-weight: 700;
  font-size: 0.9em;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  font-weight: 600;
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  flex-direction: row;
  align-items: center;
  gap: 0.55em;
  font-weight: 400;
}

input,
select,
textarea {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  width: 100%;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, filter 0.2s;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:hover,
select:hover,
textarea:hover {
  filter: brightness(1.08);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[readonly],
textarea[readonly] {
  background: var(--surface-2);
}

textarea {
  resize: vertical;
  min-height: 6em;
  field-sizing: content;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.15em;
  height: 1.15em;
  accent-color: var(--accent);
  box-shadow: none;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
  border: 0;
  background: none;
  box-shadow: none;
}

input[type="color"] {
  padding: 0.15em;
  height: 2.4em;
  width: 3.4em;
}

input[type="file"] {
  padding: 0.45em;
}

::placeholder {
  color: var(--fg-muted);
  opacity: 0.8;
}

/* ── 8. Buttons ────────────────────────────────────────────────────────── */
button,
input[type="submit"],
input[type="button"],
input[type="reset"],
a[role="button"],
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-fg);
  background: var(--accent);
  border: var(--stroke) solid transparent;
  border-radius: var(--radius);
  padding: var(--pad);
  cursor: pointer;
  width: fit-content;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: filter 0.2s;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
a[role="button"]:hover,
.btn:hover {
  color: var(--accent-fg);
  filter: brightness(1.12) saturate(1.1);
}

button:active,
input[type="submit"]:active {
  filter: brightness(0.95);
}

button[type="reset"],
input[type="reset"] {
  color: var(--fg);
  background: var(--surface);
  border-color: var(--border);
}

button[type="reset"]:hover,
input[type="reset"]:hover {
  color: var(--fg);
}

form button,
form input[type="submit"] {
  align-self: flex-start;
}

/* ── 9. Interactive Extras ─────────────────────────────────────────────── */
details {
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  padding: 0.6em 1em;
  box-shadow: var(--shadow);
}

details[open] {
  padding-bottom: 1em;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

dialog {
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  padding: 1.4em;
  max-width: min(90vw, 46ch);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s, translate 0.25s, overlay 0.25s, display 0.25s;
  transition-behavior: allow-discrete;
}

@starting-style {
  dialog {
    opacity: 0;
    translate: 0 12px;
  }
}

dialog::backdrop {
  background: rgba(15, 14, 13, 0.7);
  transition: opacity 0.25s, display 0.25s;
  transition-behavior: allow-discrete;
}

@starting-style {
  dialog::backdrop {
    opacity: 0;
  }
}

/* ── 10. MD-LD Render Hooks ────────────────────────────────────────────── */
.mdld-heading {
  position: relative;
}

/* typed = carries rdf:type, a discreet superscript affordance */
.typed::after {
  content: "";
  display: inline-block;
  width: 0.32em;
  height: 0.32em;
  margin-left: 0.4em;
  border-radius: 50%;
  background: var(--accent-2);
  opacity: 0.85;
  vertical-align: 0.65em;
}

/* retracted = polarity `-` diff, visibly struck, muted */
.retracted,
.retracted * {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  opacity: 0.6;
}

/* Anchor navigation flash */
:target {
  animation: target-flash 1.2s ease-out;
}

@keyframes target-flash {
  0% {
    background: var(--mark);
  }

  100% {
    background: transparent;
  }
}

/* ── 11. Forest Layout Utilities ───────────────────────────────────────── */
/* Card: thin border + soft shadow; hover is a filter, nothing moves */
.card {
  display: block;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: filter 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  filter: brightness(1.14) saturate(1.1);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  color: inherit;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 750;
  color: var(--fg);
}

.card p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

/* Cover: optional photo (.cover-bg) with the generated art (.cover-art)
   stacked on top. The art is a transparent SVG overlay when a photo exists. */
.cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
}

.cover img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

.cover-bg {
  filter: saturate(0.6);
}

/* Card with a cover on top */
.card-media {
  padding: 0;
  overflow: hidden;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.card-body {
  padding: 1.1rem 1.25rem 1.3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  flex: 1;
}

/* Responsive Grid */
.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

/* Breadcrumb — aligned to the same reading measure as the text column */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  margin-inline: auto;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--fg-muted);
}

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

.breadcrumb span {
  color: var(--fg-muted);
}

/* Slot pinned to the right edge of a breadcrumb — cross-component links
   (e.g. progress% on content pages, account on progress pages) */
.breadcrumb .bc-progress {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.bc-progress a {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  border: var(--stroke) solid var(--accent);
  border-radius: 999px;
}

.bc-progress a:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

/* Previous/Next Navigation */
.prev-next {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: var(--stroke) solid var(--border);
}

.prev-next-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition: filter 0.2s, border-color 0.2s;
}

.prev-next-link:hover {
  filter: brightness(1.12);
  border-color: var(--accent);
  color: var(--fg);
}

.prev-next-link.prev {
  text-align: left;
}

.prev-next-link.next {
  text-align: right;
}

.prev-next-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.prev-next-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.prev-next-spacer {
  flex: 1;
}

.prev-next-up {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg-muted);
  transition: filter 0.2s, border-color 0.2s, color 0.2s;
}

.prev-next-up:hover {
  filter: brightness(1.12);
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 560px) {
  .prev-next {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .prev-next-up {
    order: -1;
    margin-inline: auto;
  }

  .prev-next-spacer {
    display: none;
  }
}

/* Inline SVG icons (public/images/icons/) — size in em so they scale with context.
   The SVGs use fill="currentColor", which <img> can't inherit — flatten to
   white via filter since the UI is dark-themed. */
.ui-icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.125em;
  filter: brightness(0) invert(1);
}

/* Badge icons need to be readable at badge font sizes */
.content-badge .ui-icon,
.concept-badge .ui-icon {
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.3em;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--accent-2);
  color: var(--accent-2-fg);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Content Badges - show what's inside a unit card */
.content-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.content-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: var(--surface-2);
  color: var(--fg-muted);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

/* Page header pieces (dark UI) */
.hero {
  margin-bottom: 2rem;
  /* border: var(--stroke) solid var(--border); */
  border-radius: var(--radius);
  /* box-shadow: var(--shadow-lg); */
}

.hero:not(.cover) img {
  max-width: 400px;
}

.lead {
  font-size: 1.15rem;
  color: var(--fg-muted);
  margin-bottom: 2rem;
}

/* Forest Gradient Utilities: green + orange blurred radial gradients at edges */
/* Hero gradient: green top-right, orange bottom-left */
.gradient-hero {
  background:
    radial-gradient(60rem 28rem at 85% -10%, hsl(130 50% 40% / 0.18), transparent 60%),
    radial-gradient(50rem 24rem at 0% 110%, hsl(30 85% 55% / 0.12), transparent 60%);
}

/* CTA gradient: green glow from top */
.gradient-cta {
  background:
    radial-gradient(30rem 14rem at 50% 0%, hsl(130 50% 40% / 0.22), transparent 70%),
    var(--surface);
}

/* Top gradient: green glow from top edge */
.gradient-top {
  background:
    radial-gradient(40rem 20rem at 50% -10%, hsl(130 50% 40% / 0.15), transparent 70%);
}

/* Bottom gradient: orange glow from bottom edge */
.gradient-bottom {
  background:
    radial-gradient(40rem 20rem at 50% 110%, hsl(30 85% 55% / 0.12), transparent 70%);
}

/* Full forest gradient: both green and orange at opposite edges */
.gradient-forest {
  background:
    radial-gradient(60rem 28rem at 85% -10%, hsl(130 50% 40% / 0.18), transparent 60%),
    radial-gradient(50rem 24rem at 0% 110%, hsl(30 85% 55% / 0.12), transparent 60%);
}

/* Section with gradient + border */
.section-gradient {
  background:
    radial-gradient(60rem 28rem at 85% -10%, hsl(130 50% 40% / 0.18), transparent 60%),
    radial-gradient(50rem 24rem at 0% 110%, hsl(30 85% 55% / 0.12), transparent 60%);
  border-bottom: var(--stroke) solid var(--border);
}

/* Content Block: light reading surface for lesson text only.
   Width = measure + padding, so lines never exceed 75ch. Tokens are
   re-scoped in section 1, so nested elements follow automatically. */
.content-block {
  max-width: calc(var(--measure) + 5rem);
  margin: 2rem auto;
  padding: 2.5rem;
  border: var(--stroke) solid var(--border);
  border-radius: calc(var(--radius) * 1.25);
  box-shadow: var(--shadow-lg);
  font-size: 1.0rem;
  line-height: 1.7;
}

.content-block> :first-child {
  margin-top: 0;
}

.content-block> :last-child {
  margin-bottom: 0;
}

.content-block h1 {
  font-size: 2.4rem;
  border-bottom: var(--stroke) solid var(--border);
  padding-bottom: 0.5rem;
}

.content-block h2 {
  font-size: 1.7rem;
  margin-top: 2.5rem;
}

.content-block h3 {
  font-size: 1.35rem;
  margin-top: 2rem;
}

.content-block img {
  max-width: 100%;
}

/* Asset Containers */
.asset {
  margin-bottom: 2rem;
}

.asset:last-child {
  margin-bottom: 0;
}

.embed {
  aspect-ratio: var(--ratio, 16 / 9);
  overflow: hidden;
  background: #000;
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.asset-caption {
  margin-top: 0.6rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.asset-reflections {
  margin: 1rem 0 0;
}

.asset-reflections-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  color: var(--fg-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}

.asset-reflections-title .ui-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.asset-reflections-hint {
  margin: 0 0 0.7rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  opacity: 0.65;
}

.asset-reflections ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.asset-reflections li {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 1rem;
  line-height: 1.45;
}

.asset-reflections li::before {
  content: "?";
  flex-shrink: 0;
  font-weight: 700;
  color: var(--accent);
}

.asset-reflections li > * {
  margin: 0;
}

.asset-image img {
  width: 100%;
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.asset-audio audio {
  width: 100%;
}

/* Status & Feedback */
.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.status.success {
  background: var(--bg-success);
  border-color: var(--chroma-120);
  color: var(--fg);
}

.status.error {
  background: var(--bg-error);
  border-color: var(--chroma-0);
  color: var(--fg);
}

/* Progress Bar */
.progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

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

/* ── 12. Reduced Motion & Narrow Screens ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 1rem;
  }

  body>header,
  body>footer {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .content-block {
    padding: 1.25rem;
    font-size: 1.0625rem;
    margin-block: 1.5rem;
  }

  h1,
  .content-block h1 {
    font-size: 2rem;
  }
}

/* Concept Bar — lateral navigation through the knowledge graph */
.concept-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem;
}

.concept-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  text-decoration: none;
  transition: all 0.2s, border-color 0.2s;
}

.concept-badge:hover {
  filter: brightness(1.15);
  background: transparent;
  color: var(--accent-hover);
}

/* Semantic relation styles */
.concept-teaches {
  background: var(--accent);
  color: var(--accent-fg);
  border: var(--stroke) solid var(--accent);
}

.concept-applies {
  background: var(--surface-2);
  color: var(--fg);
  border: var(--stroke) solid var(--accent-2);
}

.concept-applies:hover {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.concept-mentions {
  background: var(--surface-2);
  color: var(--fg-muted);
  border: var(--stroke) solid var(--border-light);
}

.concept-mentions:hover {
  color: var(--fg);
  border-color: var(--border);
}

.concept-requires {
  background: var(--bg-warning);
  color: var(--fg);
  border: var(--stroke) solid var(--chroma-60);
}

.concept-requires:hover {
  filter: brightness(1.15);
}

/* ── Landing Page Styles ───────────────────────────────────────────────── */

/* Eyebrow */
.eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
}

/* Hero grid layout */
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  margin-bottom: 2rem;
}

.hero-copy h1 {
  margin: 0 0 1.1rem;
  font-size: clamp(2.5rem, 6.2vw, 4.3rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

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

.hl-b {
  color: var(--accent-2);
}

.hero-sub {
  margin: 0 0 1.8rem;
  font-size: 1.2rem;
  color: var(--fg-muted);
  max-width: 34rem;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  margin: 1.8rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.hero-facts li {
  margin: 0;
}

.hero-facts strong {
  color: var(--fg);
}

.hero-visual {
  display: grid;
  justify-items: center;
  gap: 1rem;
}

/* Band sections */
.band-tight {
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

.band-tight+section,
section+section {
  margin-top: clamp(3rem, 7vw, 5rem);
}

/* Value grid */
.value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Value grid — selling points: quiet cards, chromatic headings */
.value-grid li {
  margin: 0;
  padding: 1.4rem 1.4rem 1.5rem;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.value-grid h3 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--hue);
}

.value-grid p {
  margin: 0;
  color: var(--fg);
  font-size: 0.97rem;
  opacity: 0.85;
}

/* Section headers */
.section-head {
  margin-bottom: 2.2rem;
}

.section-head h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}

.section-head p:last-child {
  margin: 0;
  color: var(--fg-muted);
  font-size: 1.1rem;
}

/* Programs */
.program {
  margin-bottom: 2rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border: 2px solid var(--hue);
  border-radius: calc(var(--radius) * 1.25);
  box-shadow: var(--shadow-lg);
}

.program:last-child {
  margin-bottom: 0;
}

.program-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem 2.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.program-info h3 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.program-desc {
  margin: 0 0 0.8rem;
  color: var(--fg-muted);
  max-width: 40rem;
}

.program-meta {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--hue);
}

/* Offer cards */
.offer {
  min-width: 15rem;
  max-width: 18rem;
  padding: 1.1rem 1.2rem;
  background: var(--bg);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  display: grid;
  gap: 0.5rem;
}

.offer-price {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.offer-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.offer-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.offer .btn {
  margin-top: 0.4rem;
}

.offer-save {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.offer-save s {
  opacity: 0.8;
}

.offer-save strong {
  color: var(--accent);
}

/* Landing pages set --h (a bare hue number); map it to the --hue color token */
.course,
.program,
.program-head,
.offer-card,
.value-grid li,
.steps li {
  --hue: hsl(var(--h, 30) 70% 60%);
}

/* Course list */
.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.course {
  margin: 0;
}

.course-link {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  height: 100%;
  padding: 0.9rem 1rem;
  background: var(--surface-2);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: filter 0.2s, border-color 0.2s;
}

.course-link:hover {
  color: var(--fg);
  filter: brightness(1.12);
  border-color: var(--hue);
}

.course-dot {
  flex: none;
  width: 0.8rem;
  height: 0.8rem;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: var(--hue);
}

.course-body {
  flex: 1;
  min-width: 0;
}

.course-body h4 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.course-body p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.45;
}

.course-arrow {
  color: var(--fg-muted);
  transition: color 0.2s;
}

.course-link:hover .course-arrow {
  color: var(--hue);
}

/* Course with individual offer */
.course {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  transition: filter 0.2s, border-color 0.2s;
}

.course:hover {
  filter: brightness(1.12);
  border-color: var(--hue);
}

.course .course-link {
  flex: 1;
  background: none;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.course .course-link:hover {
  filter: none;
  border-color: transparent;
}

.course-buy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem 0.75rem;
}

.course-price {
  font-weight: 800;
  font-size: 1.05rem;
}

.course-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.standalone-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  gap: 1rem;
}

.standalone-offer {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-left: 4px solid hsl(var(--h) 70% 60%);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.standalone-offer:hover {
  border-color: hsl(var(--h) 70% 60%);
  box-shadow: var(--shadow-lg);
}

.standalone-body {
  padding: 1rem 1.1rem 0.75rem;
  flex: 1;
}

.standalone-body h4 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.standalone-body p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.course-body h4 a {
  color: inherit;
  text-decoration: none;
}

.course-body h4 a:hover {
  color: var(--hue);
}

.empty {
  color: var(--fg-muted);
}

/* Offer grid */
.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.offer-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 1.3rem;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-top: 3px solid var(--hue);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.offer-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.offer-card p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.offer-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: auto;
  padding-top: 0.6rem;
}

.offer-card-price {
  font-size: 1.35rem;
  font-weight: 800;
}

/* Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

/* Steps — numbered badges on open columns, matching the value grid */
.steps li {
  position: relative;
  margin: 0;
  padding: 0;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-bottom: 0.7rem;
  border-radius: 50%;
  background: var(--hue);
  color: #17120d;
  font-weight: 800;
  font-size: 0.95rem;
}

.steps h3 {
  margin: 0 0 0.3rem;
  font-size: 1.2rem;
}

.steps p {
  margin: 0;
  color: var(--fg-muted);
}

/* Final CTA */
.final-cta {
  padding: clamp(2rem, 6vw, 3.5rem);
  text-align: center;
  background:
    radial-gradient(30rem 14rem at 50% 0%, hsl(130 50% 40% / 0.22), transparent 70%),
    var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg);
}

.final-cta h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.final-cta p {
  margin: 0 auto 1.6rem;
  color: var(--fg-muted);
  font-size: 1.1rem;
}

.final-cta .hero-cta {
  justify-content: center;
}

/* Footer extras */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  width: 100%;
  max-width: var(--maxw-page);
  margin-inline: auto;
}

.footer-grid nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-grid nav h4 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
}

.footer-grid nav a {
  color: var(--fg-muted);
  text-decoration: none;
}

.footer-grid nav a:hover {
  color: var(--fg);
}

.footer-bottom {
  width: 100%;
  max-width: var(--maxw-page);
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: var(--stroke) solid var(--border);
  color: var(--fg-muted);
  font-size: 0.85rem;
}

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

.footer-note {
  margin: 0.6rem 0 0;
}

/* Button variants */
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover {
  color: var(--accent-fg);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--fg);
  border-color: var(--border);
}

.btn-secondary:hover {
  color: var(--fg);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--fg);
  border-color: var(--accent-2);
}

.btn-lg {
  padding: 0.95rem 1.7rem;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
  box-shadow: none;
}

/* Brand styling */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.brand:hover {
  color: var(--fg);
}

.brand-mark {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: conic-gradient(hsl(0 70% 60%), hsl(30 85% 58%), hsl(50 90% 58%), hsl(90 60% 52%),
      hsl(130 50% 50%), hsl(160 55% 48%), hsl(185 60% 52%), hsl(210 70% 62%),
      hsl(240 70% 68%), hsl(270 60% 66%), hsl(300 55% 62%), hsl(335 70% 64%),
      hsl(0 70% 60%));
}

/* Responsive */
@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    order: -1;
  }

  .program-head {
    grid-template-columns: 1fr;
  }

  .offer {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .hero-cta .btn {
    flex: 1 1 100%;
  }
}