/* ABDELCARO Learning - single stylesheet.
   Sections: fonts, tokens, base, layout, header/footer, components, hero, forms, prose, utilities.
   Light is paper under daylight; dark is the same paper under a desk lamp (prefers-color-scheme). */

/* ---------- Fonts ---------- */
/* One self-hosted display face (SIL OFL 1.1, licence beside the file), headings and numerals only. */
@font-face {
  font-family: "Familjen Grotesk";
  src: url("../fonts/familjen-grotesk-latin-700.b7b1af8d3185.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched stand-in so the swap does not move the layout. */
@font-face {
  font-family: "Familjen Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  font-weight: 700;
  size-adjust: 104.3%;
  ascent-override: 98.3%;
  descent-override: 21.6%;
  line-gap-override: 0%;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  /* Paper and ink */
  --bg: #f5f8fc;               /* paper */
  --surface: #e9eff8;          /* header, footer, quiet fills */
  --surface-raised: #ffffff;   /* index cards, form fields, lesson rows */
  --text: #18213a;             /* body ink */
  --ink: #0d1b4c;              /* blue-black: headings, primary button */
  --text-muted: #475372;       /* secondary text */
  --ghost-text: #566283;       /* locked rows: faint but above 4.5:1 on the grid */
  --border: #c9d3e3;           /* hairlines (decorative) */
  --border-strong: #6b7899;    /* control and key boundaries (3:1) */
  --rule: #10204a;             /* ruled lines under header, over footer */
  --rule-red: #c2362c;         /* the red rule: hero and how-it-works only */
  --grid: rgba(31, 78, 170, 0.085);
  --grid-major: rgba(31, 78, 170, 0.14);

  /* Pen colours */
  --accent: #1c46b8;           /* links, focus ring */
  --accent-hover: #112f8a;
  --btn: #0d1b4c;
  --btn-hover: #1c46b8;
  --btn-text: #f5f8fc;
  --note: #1a3f99;             /* annotations */

  /* Markers */
  --free: #0c6a38;
  --free-bg: #d9f2e3;
  --locked: #7a4a00;
  --locked-bg: #fcebc6;
  --done: #112f8a;
  --done-bg: #dfe8fb;
  --danger: #b3261e;
  --code-bg: #eaf0f8;
  --selection: #c3d4fa;

  /* Pasted-in panel: dark in both themes (a real output stuck onto the page). */
  --term-bg: #0d1429;
  --term-border: #2c3a5e;
  --term-text: #e8edfa;
  --term-muted: #a3b0cc;
  --term-accent: #9dbcff;
  --term-free: #86e6ae;
  --term-band: rgba(157, 188, 255, 0.16);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Familjen Grotesk", "Familjen Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --space: 1rem;
  --content-width: 72rem;
  --prose-width: 44rem;

  /* Code panel geometry: the annotation leaders are placed from these. */
  --code-size: 0.9rem;
  --code-lh: 1.44rem;
  --bar-h: 2.5rem;
  --pre-pad: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1022;
    --surface: #101a33;
    --surface-raised: #121d3a;
    --text: #e4eaf8;           /* chalk */
    --ink: #f1f4fc;
    --text-muted: #a6b2cf;
    --ghost-text: #97a4c4;
    --border: #26335a;
    --border-strong: #6b7ca6;
    --rule: #5d72a8;
    --rule-red: #ff7b6b;
    --grid: rgba(143, 176, 255, 0.07);
    --grid-major: rgba(143, 176, 255, 0.12);
    --accent: #8fb0ff;
    --accent-hover: #b4c9ff;
    --btn: #8fb0ff;
    --btn-hover: #b4c9ff;
    --btn-text: #0a1022;
    --note: #a9c1ff;
    --free: #86e6ae;
    --free-bg: #12301f;
    --locked: #ffd48a;
    --locked-bg: #3a2a0a;
    --done: #b4c9ff;
    --done-bg: #1a2a52;
    --danger: #ff8a80;
    --code-bg: #121d3a;
    --selection: #2c4aa0;
    /* Lift the panel off the blue-black paper so it reads as a surface, not a hole. */
    --term-bg: #141e3a;
    --term-border: #52649a;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scrollbar-color: var(--border-strong) var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  /* Graph paper: a 24px minor grid with a heavier line every 120px. Faint by design. */
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  color: var(--text);
  font: 1rem/1.6 var(--font);
  accent-color: var(--accent);
  caret-color: var(--accent);
}
/* Reading pages (lessons, legal text) get plain paper: no grid behind long text. */
body.read { background-image: none; }

::selection { background: var(--selection); color: var(--ink); }

main { flex: 1; padding-block: 2rem 4rem; }
main > section { margin-top: 3.5rem; }
main > section:first-child { margin-top: 0; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.12;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 2.9rem); letter-spacing: -0.015em; }
h2 { font-size: clamp(1.6rem, 1.3rem + 1.1vw, 2.1rem); letter-spacing: -0.01em; margin-top: 3rem; }
h3 { font-size: 1.3rem; line-height: 1.2; }
main > section > h2:first-child { margin-top: 0; }
p { margin: 0 0 1em; text-wrap: pretty; }

a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

img, iframe, video { max-width: 100%; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */
.container { width: min(100% - 2rem, var(--content-width)); margin-inline: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space);
}

/* The three featured courses: one column until three fit side by side (no two-and-an-orphan row). */
.grid-fit { grid-template-columns: 1fr; }
@media (min-width: 56rem) {
  .grid-fit { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--btn);
  color: var(--btn-text);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }
/* a:hover would turn this link's text pen blue on its pen-blue fill (1.3:1) while it is focused and hovered. */
.skip-link:hover { color: var(--btn-text); }

/* ---------- Header / footer ---------- */
.site-header { position: relative; border-bottom: 2px solid var(--rule); background: var(--surface); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0 0.5rem;
  padding-block: 0.25rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.logo:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; }

/* Phones: one row. The wordmark, the primary action, and a Menu disclosure (a plain details element,
   so it works without JavaScript) that opens the other links as a full-width list under the header.
   From 44rem the full link row replaces it. Every link is 44px tall for touch. */
.nav { display: none; }
.nav-phone { display: flex; align-items: center; gap: 0.25rem; }
.nav a, .nav .link-button, .menu-list a, .menu-list .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
/* Plain links only: the Sign up and Account buttons keep their own .button colours in every state. */
.nav a:not(.button), .menu-list a { color: var(--text); text-decoration: none; }
.nav a:not(.button):hover, .menu-list a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; }
/* The page you are on: ink, underlined. */
.nav a:not(.button)[aria-current="page"], .menu-list a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; }
.nav .inline-form { display: flex; }

.menu summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding-inline: 0.5rem;
  margin-right: -0.5rem;      /* the label sits on the gutter line, like the rows below it */
  cursor: pointer;
  list-style: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6l5 5 5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6l5 5 5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.menu[open] summary::after { rotate: 180deg; }
.menu-list {
  position: absolute;
  inset-inline: 0;
  top: 100%;
  z-index: 5;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border-block: 2px solid var(--rule);   /* the top edge redraws the header rule this panel sits over */
}
.menu-list li + li :is(a, .link-button) { border-top: 1px solid var(--border); }
.menu-list a, .menu-list .link-button { display: flex; width: 100%; padding: 0 max(1rem, calc((100% - var(--content-width)) / 2)); }
.menu-list a:focus-visible, .menu-list .link-button:focus-visible { outline-offset: -3px; border-radius: 0; }
.menu-list a:active, .menu-list .link-button:active { background: var(--border); }
.menu-list .inline-form { display: block; }
.menu-list .link-button { text-align: left; }

@media (min-width: 44rem) {
  .header-inner { flex-wrap: wrap; gap: 0 1.5rem; }
  .logo { font-size: 1.3rem; }
  .nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.6rem; margin-left: -0.25rem; }
  .nav a:not(.button), .nav .link-button { padding-inline: 0.25rem; }
  .nav .button { margin-left: 0.25rem; }
  .nav-phone { display: none; }
}

.site-footer { border-top: 2px solid var(--rule); background: var(--surface); color: var(--text-muted); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; padding-block: 0.5rem; align-items: center; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; gap: 0 0.5rem; flex-wrap: wrap; margin-inline: -0.5rem; }
.footer-inner nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.5rem; color: var(--text); }
.footer-inner nav a:hover { color: var(--accent); }

.messages { margin-top: 1rem; }
.message { padding: 0.75rem 1rem; border-radius: var(--radius); background: var(--done-bg); color: var(--done); margin: 0 0 0.5rem; }
.message-error { background: var(--locked-bg); color: var(--danger); }

/* ---------- Components ---------- */
.button, .link-button {
  font: inherit;
  cursor: pointer;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.15rem;
  border: 2px solid var(--btn);
  border-radius: var(--radius);
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}
.button:hover { background: var(--btn-hover); border-color: var(--btn-hover); color: var(--btn-text); }
.button:active { filter: brightness(0.9); transform: translateY(1px); }
.button-secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.button-secondary:hover { background: var(--surface); color: var(--accent-hover); border-color: var(--accent-hover); }
.button-secondary:active { background: var(--border); color: var(--accent-hover); filter: none; }
.button-small { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.3rem 0.8rem; }

.link-button { background: none; border: 0; padding: 0; color: var(--text); }
.link-button:hover { color: var(--accent); text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.actions a:not(.button) { display: inline-flex; align-items: center; min-height: 44px; }

/* Legend: one fixed key for the markers used on cards and lesson rows. */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.75rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0.6rem 0;
  border-block: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.legend li { display: inline-flex; align-items: center; gap: 0.5rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.5;
}
.badge-free { background: var(--free-bg); color: var(--free); }
/* Locked is dashed as well as amber, and says so in words: never colour alone. */
.badge-locked { background: var(--locked-bg); color: var(--locked); border-style: dashed; }
.badge-done { background: var(--done-bg); color: var(--done); }
.badge-free::before, .badge-locked::before {
  content: "";
  width: 0.8em;
  height: 0.8em;
  background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
.badge-free { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.8'/%3E%3C/svg%3E"); }
.badge-locked { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='10' height='7' rx='1.5'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2'/%3E%3C/svg%3E"); }

.time-mark {
  display: inline-block;
  padding: 0 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-muted);
  font: 0.8rem/1.5 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Home: hero ---------- */
.hero { padding-block: 1.5rem 0.5rem; max-width: var(--prose-width); }
.hero h1 { font-size: clamp(2.25rem, 1.4rem + 3.5vw, 3.5rem); line-height: 1.05; letter-spacing: -0.02em; }
.lead { font-size: 1.15rem; color: var(--text-muted); }
.hero .actions { margin-top: 1.5rem; margin-bottom: 0; }
/* Who teaches: named once under the hero actions (from settings), then not repeated on this page. */
.byline { margin: 0.5rem 0 0; color: var(--text-muted); }
.byline strong { color: var(--ink); }

.hero-split { max-width: none; }
.hero-copy { container-type: inline-size; }
.hero-copy h1 { font-size: clamp(2.25rem, 12cqi, 3.5rem); }
.margin-rule { display: none; }
.pasted { position: relative; margin-top: 2rem; max-width: 40rem; }

/* From 70rem the hero is a two-sided spread: copy, the red rule, then the pasted-in
   panel with its notes in the right margin. Below that the notes become a numbered list. */
@media (min-width: 70rem) {
  .hero-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 3rem auto;
    align-items: start;
    padding-block: 2.5rem 0.5rem;
  }
  .hero-split .hero-copy { max-width: 30rem; padding-top: 0.5rem; }
  .margin-rule {
    display: block;
    width: 2px;
    justify-self: center;
    align-self: stretch;
    margin-block: -1rem;
    background: var(--rule-red);
  }
  .pasted { margin-top: 0; max-width: none; width: 44rem; padding-right: 13rem; }
}

/* ---------- Pasted-in panel ---------- */
.excerpt {
  margin: 0;
  min-width: 0;
  background: var(--term-bg);
  color: var(--term-text);
  border: 1px solid var(--term-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
}
.excerpt-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--bar-h);
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--term-border);
  font-size: 0.8rem;
  line-height: 1.4;
}
.excerpt-lang { color: var(--term-muted); }
.excerpt-tag { color: var(--term-free); font-weight: 700; }
.excerpt pre {
  margin: 0;
  padding: var(--pre-pad) 0;
  overflow-x: auto;
  font: var(--code-size)/var(--code-lh) var(--font-mono);
  tab-size: 4;
  scrollbar-color: var(--term-border) transparent;
}
.excerpt pre:focus-visible { outline: 3px solid var(--term-accent); outline-offset: -3px; border-radius: 0; }
.excerpt code { display: block; font: inherit; }
/* Lines wrap (with a hanging indent that follows each line's own indent, --ind) so nothing is clipped on a
   phone. The two-sided spread from 70rem keeps one line per row so the leaders can be placed by arithmetic. */
.ln {
  position: relative;
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-right: 1rem;
  padding-left: calc(var(--gut, 1.9rem) + (var(--ind, 0) + 2) * 1ch);
  text-indent: calc(-1 * (var(--ind, 0) + 2) * 1ch);
}
.ln[data-n] { background: var(--term-band); }
.ln[data-n]::before {
  content: attr(data-n);
  text-indent: 0;
  position: absolute;
  left: 0.45rem;
  top: 50%;
  translate: 0 -50%;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--term-accent);
  color: var(--term-bg);
  font: 700 0.75rem/1.1rem var(--font);
  text-align: center;
}
.excerpt ::selection { background: var(--term-accent); color: var(--term-bg); }
.excerpt figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1rem;
  padding: 0.25rem 1rem;
  border-top: 1px solid var(--term-border);
  font-size: 0.9rem;
  line-height: 1.5;
}
.excerpt-meta { margin: 0.5rem 0; color: var(--term-muted); }
.excerpt .time-mark { border-color: var(--term-muted); color: var(--term-muted); }
.excerpt-meta strong { color: var(--term-text); font-weight: 600; }
.excerpt-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--term-accent);
  font-size: 0.9rem;
  font-weight: 600;
}
.excerpt-link:hover { color: var(--term-text); }
.excerpt-link:focus-visible { outline-color: var(--term-accent); }

/* Annotations: italic text, joined to a highlighted code line. Below the spread each note sits inside the
   panel directly beneath its line (.ln-note, not selectable, so copying the code stays clean); from 70rem
   they move to the right margin as a list (.notes) and the inline ones are hidden. */
.ln-note {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr);
  gap: 0 0.65rem;
  align-items: start;
  padding: 0.4rem 1rem 0.55rem 0.45rem;
  color: var(--term-accent);
  font: italic 0.9rem/1.45 var(--font);
  white-space: normal;
  -webkit-user-select: none;
  user-select: none;
}
.ln-note .note-n { width: 1.1rem; height: 1.1rem; margin-top: 0.12rem; border-width: 1px; border-color: currentColor; color: inherit; font-size: 0.7rem; }
.notes { display: none; list-style: none; margin: 1.25rem 0 0; padding: 0; gap: 0.9rem; }
.notes li { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.notes p { margin: 0; color: var(--note); font-style: italic; line-height: 1.45; }
.note-n {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid var(--note);
  border-radius: 50%;
  color: var(--note);
  font: 700 0.85rem/1 var(--font);
  font-style: normal;
}
@media (min-width: 70rem) {
  .ln-note { display: none; }
  .hero .excerpt code { width: max-content; min-width: 100%; }
  .hero .ln { white-space: pre; overflow-wrap: normal; padding-left: 1.9rem; text-indent: 0; }
  .notes { position: absolute; top: 0; right: 0; width: 11.5rem; margin: 0; display: block; }
  .notes li {
    position: absolute;
    left: 0;
    right: 0;
    /* centre of the annotated line, less half the number badge */
    top: calc(var(--bar-h) + var(--pre-pad) + (var(--n) - 0.5) * var(--code-lh) - 0.75rem);
  }
  .notes li::before {
    content: "";
    position: absolute;
    left: -1.5rem;
    top: 0.75rem;
    width: 1.5rem;
    height: 1px;
    background: var(--note);
    transform-origin: left;
  }
  .notes li::after {
    content: "";
    position: absolute;
    left: calc(-1.5rem - 3px);
    top: calc(0.75rem - 2.5px);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--note);
  }
}
@media (min-width: 70rem) and (prefers-reduced-motion: no-preference) {
  .notes li { animation: note-in 0.5s 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
  .notes li::before { animation: leader-draw 0.6s 0.55s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
  @keyframes note-in { from { opacity: 0; } }
  @keyframes leader-draw { from { transform: scaleX(0); } }
}

/* ---------- Home: track entries ---------- */
.track-group + .track-group { margin-top: 3rem; }
.group-body { margin-top: 1rem; }
.group-body-excerpt { display: grid; gap: var(--space); align-items: start; }
.group-body-excerpt .grid-fit { grid-template-columns: minmax(0, 1fr); max-width: 26rem; }
@media (min-width: 70rem) {
  .group-body-excerpt { grid-template-columns: 17.5rem minmax(0, 1fr); }
  .group-body-excerpt .grid-fit { max-width: none; }
}

/* The second pasted-in artifact (Infrastructure & Cloud): one dark panel holding a lesson's first two code
   blocks, side by side from 56rem and stacked below it. No notes, so its lines wrap freely. */
.excerpt-pair { --gut: 1rem; }
.pair-cols { display: grid; grid-template-columns: minmax(0, 1fr); }
.excerpt-col { min-width: 0; }
.excerpt-col + .excerpt-col { border-top: 1px solid var(--term-border); }
.excerpt-label { color: var(--term-text); font-weight: 600; }
@media (min-width: 56rem) {
  .pair-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .excerpt-col + .excerpt-col { border-top: 0; border-left: 1px solid var(--term-border); }
}
.entry {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.entry-icon { color: var(--ink); line-height: 1; }
.entry .track-svg { display: block; width: 2.5rem; height: 2.5rem; }
.entry .track-glyph { font-size: 2rem; }
.entry h3 { font-size: 1.5rem; }
.entry .card-action { margin-left: -0.25rem; padding-inline: 0.25rem; }
.entry p { color: var(--text-muted); margin-bottom: 0.25rem; }
.track-heading { display: flex; align-items: center; gap: 0.6rem; }
.track-mark { display: inline-flex; color: var(--ink); }
.track-mark .track-svg { width: 1.5em; height: 1.5em; }

/* How it works: numbers in the margin, the red rule, then the entry. */
.how { display: grid; gap: 0.5rem 3rem; }
@media (min-width: 56rem) {
  .how { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
}
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; position: relative; }
.steps::before {
  content: "";
  position: absolute;
  left: 3.25rem;
  top: -0.5rem;
  bottom: -0.5rem;
  width: 2px;
  background: var(--rule-red);
}
.steps li { counter-increment: step; position: relative; padding: 0 0 1.5rem 4.75rem; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.2rem;
  width: 2.5rem;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}
.steps h3 { font-size: 1.5rem; margin-bottom: 0.15em; }
.steps p { margin: 0; color: var(--text-muted); font-size: 1.05rem; }

.pricing-note { border-top: 2px solid var(--rule); padding-top: 1.25rem; }
.pricing-note > .lead { margin-bottom: 1rem; }
/* The intro line is prose: a plain Paper sheet, not the grid. */
.lead-sheet { background: var(--bg); padding: 0.5rem 0.75rem; }
/* The one pre-launch statement: plain ink on Paper between ruled lines. Amber is for Locked, not for this. */
.launch-note {
  margin: 0 0 1.25rem;
  padding: 0.75rem 0.75rem;
  background: var(--bg);
  color: var(--text);
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--border-strong);
}

/* Answers are prose, so they sit on plain Paper, not the grid. */
.faq details { background: var(--bg); padding: 0.2rem 0.75rem; border-bottom: 1px solid var(--border-strong); }
.faq details:first-of-type { border-top: 2px solid var(--rule); }
/* Own marker; the summary stays a real summary and keeps the 44px target. */
.faq summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  padding-block: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font: 700 1.5rem/1 var(--font-display); color: var(--ink); flex: none; }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin: 0 0 0.75rem; color: var(--text-muted); }

/* Closing band: the last thing on the home page. A plain sheet ruled off top and bottom like the header and
   footer, one sentence and the primary action. No grid under it, no extra colour. */
.closing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 1.5rem 1.25rem;
  background: var(--surface-raised);
  border-block: 2px solid var(--rule);
}
.closing h2 { margin: 0 0 0.15em; }
.closing p { margin: 0; color: var(--text-muted); }
/* The lesson itself as the ending: title, course, length and summary on the left, the action on the right. */
.closing-lesson .closing-body { flex: 1 1 24rem; max-width: 40rem; }
.closing-lesson h2 { margin-bottom: 0.3em; }
.closing .closing-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; margin-bottom: 0.4rem; }
.closing .closing-summary { color: var(--text); }
.closing-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; }
.closing-link { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Cards (index cards) ---------- */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card :is(h3, h4) { margin-bottom: 0.15em; }
.card h4 { font-family: var(--font-display); font-weight: 700; color: var(--ink); font-size: 1.3rem; line-height: 1.2; text-wrap: balance; margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-meta { color: var(--text-muted); font-size: 0.9rem; }

/* Whole card is one link (stretched title link); secondary actions sit above it. */
.card-course { position: relative; display: flex; flex-direction: column; transition: border-color 0.15s ease-out; }
.card-course:hover, .card-course:focus-within { border-color: var(--ink); }
.card-link { color: var(--ink); text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card-link:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 2px; }
.card-stats { margin: auto 0 0; padding-top: 0.75rem; border-top: 1px dashed var(--border-strong); font-variant-numeric: tabular-nums; }
.card-course > p:not(.card-meta):not(.card-actions) { margin-top: 0.5rem; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.75rem; margin-top: 0.25rem; }
.card-stats + .card-actions { margin-top: 0.25rem; }
.card-free { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.75rem; margin-top: 0.5rem; margin-bottom: 0.75rem; }
.card-free-summary { flex-basis: 100%; margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.card-action { position: relative; z-index: 1; display: inline-flex; align-items: center; min-height: 44px; }

/* Plan cards: two cards for the two ways to pay. The better-value card (only when a saving is shown)
   takes the 2px ink border of the ruled lines and a "Best value" badge; no extra colour. */
.pricing-layout { display: grid; gap: 1.5rem var(--space); align-items: start; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 22rem)); gap: var(--space); }
@media (min-width: 70rem) {
  /* The two cards fill the row and the trust statements sit beside them, so no third of it is left empty. */
  .pricing-layout { grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.5rem 2.5rem; }
  .pricing-layout .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pricing-layout .trust { grid-template-columns: minmax(0, 1fr); border-top: 2px solid var(--rule); }
}
.plans > p { grid-column: 1 / -1; }
.plan { display: flex; flex-direction: column; }
.plan-best { border: 2px solid var(--ink); padding: calc(1.25rem - 1px); }
.plan-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 0.75rem; }
.plan-head h3 { margin: 0; }
.plan .price { margin: 0.5rem 0 0; font-family: var(--font-display); color: var(--ink); line-height: 1.05; letter-spacing: -0.02em; }
.price-num { font-size: 3rem; font-weight: 700; font-variant-numeric: lining-nums; }
.plan .per { font: 400 1rem var(--font); letter-spacing: 0; color: var(--text-muted); }
.plan-gst { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.9rem; }
.plan-saving { margin: 0.75rem 0 0; font-weight: 600; color: var(--ink); }
.plan .checklist { margin-top: 1rem; }
.plan-foot { margin-top: auto; padding-top: 1rem; border-top: 1px dashed var(--border-strong); }
.plan-foot .button { display: block; }
.checklist { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.checklist li { padding-left: 1.5rem; position: relative; margin-bottom: 0.35rem; }
.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4em;
  width: 0.9em;
  height: 0.9em;
  background: var(--free);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.8'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.8'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Trust strip: who teaches and what happens if it is not for you. Two plain statements under a hairline. */
.trust { display: grid; gap: 0.5rem 3rem; padding: 1rem 0.75rem 0.5rem; background: var(--bg); border-top: 1px solid var(--border-strong); }
.trust p { margin: 0; }
.trust a { display: inline-flex; align-items: center; min-height: 44px; }
@media (min-width: 48rem) {
  .trust-two { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
}
.refunds + p { margin-top: 2rem; }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.15rem; color: var(--text-muted); font-size: 0.9rem; margin: 0 0 0.5rem -0.25rem; }
.breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.25rem; }
.page-header { margin-bottom: 1.5rem; }

/* ---------- Course page: curriculum ---------- */
.module { margin-bottom: 1.75rem; }
.lesson-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule); }
.lesson-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--border-strong);
}
.lesson-list a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.lesson-free { background: var(--surface-raised); }
/* Locked lessons stay on the page as ghosts: plain paper (no grid under the text), dashed ruling, quieter ink. */
.lesson-locked { background: var(--bg); border-bottom-style: dashed; }
.lesson-locked a { color: var(--ghost-text); font-weight: 400; text-decoration: underline dotted; text-decoration-thickness: 1px; }
.lesson-locked a:hover { color: var(--accent-hover); text-decoration-style: solid; }
.lesson-locked .time-mark { border-style: dashed; color: var(--ghost-text); }
.lesson-meta { color: var(--text-muted); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; }

.paywall {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2rem 1.5rem;
  max-width: var(--prose-width);
}
.paywall h2 { margin-top: 0; }

.pager { display: flex; justify-content: space-between; gap: 0.5rem 1rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.pager a { display: inline-flex; align-items: center; min-height: 44px; }
.pager-next { margin-left: auto; text-align: right; justify-content: flex-end; }

.video { position: relative; aspect-ratio: 16 / 9; margin-bottom: 1.5rem; max-width: var(--prose-width); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

.notice { background: var(--locked-bg); color: var(--locked); padding: 0.6rem 1rem; border-radius: var(--radius); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--space); margin: 0 0 1.5rem; }
.stat { background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 1rem; }
.stat dt { color: var(--text-muted); font-size: 0.9rem; }
.stat dd { margin: 0; font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--ink); }

.details { max-width: 32rem; margin: 0 0 1.5rem; }
.details div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border-strong); }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; text-align: right; }

/* ---------- Forms ---------- */
.form-card { max-width: 26rem; margin-inline: auto; }
.form-card p a { display: inline-flex; align-items: center; min-height: 44px; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
}
.help { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.help ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.field-error, .form-errors { color: var(--danger); font-size: 0.9rem; margin: 0.25rem 0 0; }
.form-errors { margin-bottom: 1rem; }

/* ---------- Prose (rendered markdown and static pages) ---------- */
/* On a grid page (a course description) the prose sits on a plain sheet; on reading pages
   the page itself is plain, so the sheet drops its frame. */
.prose {
  max-width: var(--prose-width);
  background: var(--bg);
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.7;
}
body.read .prose { padding: 0; border: 0; background: none; }
.prose > :last-child { margin-bottom: 0; }
.prose h2 { margin-top: 2rem; }
.prose li { margin-bottom: 0.35em; }
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.55;
}
.prose code { font-family: var(--font-mono); background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.9em; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; margin-bottom: 1em; display: block; overflow-x: auto; font-variant-numeric: tabular-nums; }
.prose th, .prose td { border: 1px solid var(--border-strong); padding: 0.5rem 0.75rem; text-align: left; }
.prose th { background: var(--surface); }
.prose blockquote { margin: 0 0 1em; padding-left: 1rem; border-left: 1px solid var(--border-strong); color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .button:active { transform: none; }
}
