/* =========================================================================
   numerik.css — the subject layer of Numerik (Root-D161, Root-D173).

   The one layer after tokens → base → components. Since Plan 34/E19 it
   redefines only the role colours and the link: surfaces, lines, text
   tones and fonts come from tokens.css like on every other page (Root-D181),
   so Numerik and Complex Analysis share the ground and differ by their roles.

   What each role colour means on a Numerik page: public/mathe/Numerik/CLAUDE.md.
   Contrasts (computed, Plan 34/E19): every role colour ≥ 6 : 1 on
   --c-bg-0 … --c-bg-2, and ≥ 3 : 1 against --c-line-2 where it borders one.
   Never navy, turquoise or violet — those belong to Complex Analysis.
   ========================================================================= */

:root {
  /* ---- Role colours (meaning: Numerik/CLAUDE.md) ---------------------- *
   * Okabe–Ito, lifted for a dark ground. Zinnober is the signature. Every
   * colour has a second channel in a picture — dash or direct label —, and
   * Bernstein never stands next to Zinnober as the only pair.            */
  --c-z:    #56b4e9;   /* Blau      — data: nodes, measurements, start values */
  --c-w:    #f2783a;   /* Zinnober  — approximation: interpolant, iterate     */
  --c-path: #e69f00;   /* Bernstein — error, remainder, residual              */
  --c-sing: #e08dbe;   /* Rosa      — outlier, divergence, breakdown          */
  --c-zero: #2fc79a;   /* Grün      — exact solution, root, fixed point       */
  --c-vec:  #f0e442;   /* Gelb      — derivative, tangent, search direction   */
  --c-warn: #e69f00;   /* Bernstein — warning, sketch banner, "in Arbeit"     */

  --c-z-dim:    rgba(86, 180, 233, 0.16);
  --c-w-dim:    rgba(242, 120, 58, 0.16);
  --c-path-dim: rgba(230, 159, 0, 0.16);
  --c-sing-dim: rgba(224, 141, 190, 0.16);
  --c-zero-dim: rgba(47, 199, 154, 0.16);
  --c-vec-dim:  rgba(240, 228, 66, 0.16);
  --c-warn-dim: rgba(230, 159, 0, 0.16);

  /* ---- Text links: the signature, one step lighter on hover ----------- */
  --c-link: var(--c-w);
  --c-link-hover: #f7a274;
}

::selection { background: var(--c-w); color: var(--c-bg-0); }

/* =======================================================================
   Script boxes (core/kasten.js, Root-D171). The box itself comes from
   components.css; these are the parts kasten.js adds.
   ======================================================================= */
.box--nur-fundstelle .box__head { margin-bottom: 0; }
.box__bezug {
  font-size: var(--fs-small);
  border-left: 2px solid var(--c-line-2);
  padding-left: var(--sp-3);
  margin-bottom: var(--sp-4);
}
:where(body[data-chapter]) .box .box__bezug { color: var(--c-text-1); }
.box__bezug-etikett {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-2);
  margin-right: var(--sp-2);
}
.box__wortlaut { white-space: pre-line; }
.box__wortlaut .katex-display { white-space: normal; overflow-x: auto; overflow-y: hidden; padding: var(--sp-1) 0; }
.box__wortlaut > .katex-display:last-child { margin-bottom: 0; }
/* A citation after Root-D169 runs to 60 characters and more; it wraps
   instead of sticking out of the box — on a phone and in the docked text
   column alike (Plan 29/E7: the Lagrange box ran 20 px past it at 1440). */
.box .box__ref { white-space: normal; }
/* Azeret Mono sets "(P)" as ℗ through calt (Plan 45/E10: the box
   "Kubischer Spline mit (N), (H), (P)"); a citation stays letter by letter. */
.box .box__ref, .fundstellen__chip { font-feature-settings: 'calt' 0; }

/* The citation line: one chip per box on the page, each a link to it. */
.fundstellen { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.fundstellen[hidden] { display: none; }
.fundstellen__chip {
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  line-height: 1.3;
  color: var(--c-text-1);
  text-decoration: none;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  padding: 6px 12px;
}
.fundstellen__chip:hover { color: var(--c-text-0); border-color: var(--c-text-2); }
.fundstellen__typ { color: var(--c-w); }

/* =======================================================================
   The docking stage (core/dock.js, NU-D2). Stacked by default — narrow,
   zoomed, without JS; dock.js adds `ist-breit` for two columns and
   `ist-angedockt` once the reader has scrolled past the first screen.
   Styled here because Numerik is the first subject to use it; the second
   one moves this block into components.css (core rule 2).
   ======================================================================= */
.dock {
  max-width: 1680px;
  margin: var(--sp-6) auto var(--sp-8);
  padding-inline: var(--page-pad);
  container-type: inline-size;   /* 100cqw below: the stage spans both columns */
}
.dock__buehne {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  scroll-margin-top: calc(var(--kopf-h) + var(--sp-3)); /* a click brings it back below the bar */
}
.dock__bild {
  position: relative;
  height: clamp(340px, 90vw, 460px);
  background: var(--c-bg-1);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.dock__bild canvas.layer { position: absolute; inset: 0; touch-action: none; } /* absolute: never feeds back into the layout; touch: dragging must not pan the page */
.dock__text { min-width: 0; }
.dock:not(.ist-breit) .dock__text { margin-top: var(--sp-6); }

.dock.ist-breit {
  display: grid;
  grid-template-columns: minmax(0, 58fr) minmax(0, 42fr);
  column-gap: var(--sp-7);
}
.dock.ist-breit .dock__buehne {
  position: sticky;
  top: calc(var(--kopf-h) + var(--sp-3));
  z-index: 5;
  width: 100cqw;
  transition: width 0.4s var(--ease) 0.3s;
}
.dock.ist-breit .dock__bild {
  height: clamp(320px, calc(100dvh - var(--topbar-h) - 320px), 760px);
  transition: height 0.4s var(--ease);
}
/* Docking narrows first, then grows; undocking shrinks first, then widens.
   Wide and tall at once would cover the first lines of the text column,
   which only the wide height keeps free (dock.js, .dock__platz). */
.dock.ist-angedockt .dock__buehne { width: 100%; transition: width 0.4s var(--ease); }
.dock.ist-angedockt .dock__bild { height: var(--dock-bild-h, 60dvh); transition: height 0.4s var(--ease) 0.3s; }
.dock.ist-messend .dock__buehne, .dock.ist-messend .dock__bild { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .dock.ist-breit .dock__buehne, .dock.ist-breit .dock__bild { transition: none; }
}

/* Pills above the picture: each control the scene puts in is one pill.
   Docked the column is narrower than the row — compact, not wrapped. */
.dock__pillen {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--sp-2);
}
.dock__pillen > * {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 2px var(--sp-4);
  background: var(--c-bg-1);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
}
.dock__pillen > .chips, .dock__pillen > .ctrl:has(.chips) { padding: 3px; }
/* The word in front of the chips (Daten, Rand) sits in the middle of its
   own space: as far from the pill's edge as from the first chip (Plan 47/E1;
   with 3 px on the left it hung at the edge). */
.dock__pillen > .ctrl:has(.chips) { gap: 0; }
.dock__pillen > .ctrl:has(.chips) > .ctrl__label { padding-inline: calc(var(--sp-3) - 4px) var(--sp-3); }
/* A slider's word (Punkte, Grad n) likewise: the gap to the track as wide as the pill's padding. */
.dock__pillen > .ctrl:not(:has(.chips)) { gap: var(--sp-4); }
.dock__pillen .ctrl__label { gap: var(--sp-2); }
.dock__pillen input[type='range'] { width: 150px; }
.dock__pillen .chip { min-height: 32px; border-color: transparent; background: none; }
/* On like a chip on the Labortisch: filled with the signature, dark text (6,9 : 1). */
.dock__pillen .chip.is-on { border-color: var(--c-w); background: var(--c-w); color: var(--c-bg-0); box-shadow: none; }
/* ⏮ or ⏭ at an end of the steps (assets/js/schema.js): dimmed, still focusable. */
.dock__pillen .chip[aria-disabled='true'] { opacity: 0.4; cursor: default; }
.dock__pillen .btn { border: 0; background: none; padding: 0; font-size: var(--fs-micro); }
/* Docked the pills wrap (Plan 47/E1): in one scrolling row "Punkte" and
   "mehr" lay outside the column at 1440, reachable only by a sideways scroll
   nobody sees; dock.js measures the stage again when the row grows. */
.dock.ist-angedockt .dock__pillen {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.dock.ist-angedockt .dock__pillen > * { flex: none; padding-inline: var(--sp-3); }
.dock.ist-angedockt .dock__pillen > .ctrl:has(.chips) { padding-inline: 3px; }
.dock.ist-angedockt .dock__pillen > .ctrl:not(:has(.chips)) { gap: var(--sp-3); }
.dock.ist-angedockt .dock__pillen input[type='range'] { width: 96px; }

/* The tour ①–④ below the picture; docked one line: digits, then caption. */
.dock__leiste { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.dock__ziffern { display: flex; gap: var(--sp-2); }
.dock__ziffern button {
  min-width: 40px;
  min-height: 40px;
  font: inherit;
  font-size: 1.15rem;
  color: var(--c-w);
  background: var(--c-bg-1);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.dock__ziffern button:hover { border-color: var(--c-text-2); }
.dock__ziffern button[aria-pressed='true'] { background: var(--c-w); border-color: var(--c-w); color: var(--c-bg-0); }
.dock__unterschrift {
  margin: 0;
  min-height: 1.6em;
  font-size: var(--fs-small);
  color: var(--c-text-1);
  text-align: center;
}
.dock.ist-angedockt .dock__leiste { flex-direction: row; gap: var(--sp-3); }
.dock.ist-angedockt .dock__unterschrift {
  flex: 1;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The tasks below the picture (assets/js/aufgaben.js, Plan 47/E3), in place
   of the tour: wide and not yet docked three side by side, else one row
   each. A solved one gets its tick; the text stays in text colour. */
.aufgaben { align-items: stretch; }
.aufgaben__liste {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.aufgaben__liste > li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--c-text-1);
  background: var(--c-bg-1);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
}
.aufgaben__haken {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--c-text-2);
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
}
.aufgaben__liste > li.ist-geloest { border-color: var(--c-text-2); }
.aufgaben__liste > li.ist-geloest .aufgaben__haken { border-color: var(--c-text-0); background: var(--c-text-0); color: var(--c-bg-0); }
.aufgaben__liste > li.ist-geloest .aufgaben__haken::before { content: '✓'; font-weight: 700; }
.aufgaben .zeig { min-height: 36px; padding: 0 var(--sp-3); white-space: nowrap; }
.dock.ist-breit:not(.ist-angedockt) .aufgaben__liste { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dock.ist-breit:not(.ist-angedockt) .aufgaben__liste > li { align-items: start; }
.dock.ist-breit:not(.ist-angedockt) .aufgaben__haken { margin-top: 1px; }
/* A page with two pictures in one (main picture and convergence picture)
   needs more height while it is stacked. */
.dock:not(.ist-breit) .dock__bild--zwei { height: clamp(480px, 125vw, 580px); }
/* Docked it needs 400 px (data-dock-min on the page), else the stage stacks.
   Wide it keeps the height of every stage: the stage sticks, so pills,
   picture and tasks must fit the window together. */

/* "▶ zeig" in the text: calls up a named state of the picture. */
.zeig {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--sp-4);
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  color: var(--c-w);
  background: var(--c-bg-1);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.zeig:hover { border-color: var(--c-text-2); }
.zeig[aria-pressed='true'] { background: var(--c-w); border-color: var(--c-w); color: var(--c-bg-0); }

/* The gallery of functions (scenes/runge.js, Plan 47/E2): a field over the
   top of the picture, opened by the pill "Funktion". A small picture per
   function, the own curve last, below them the formula field. It scrolls
   inside itself where the picture is flat (stacked on a phone). */
.galerie {
  position: absolute;
  inset: var(--sp-2) var(--sp-2) auto;
  z-index: 3;
  max-height: calc(100% - 2 * var(--sp-2));
  overflow-y: auto;
  padding: var(--sp-3);
  background: var(--c-bg-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
}
.galerie[hidden] { display: none; }
.galerie__raster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: var(--sp-2);
}
.galerie__kachel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-1);
  font: inherit;
  font-size: var(--fs-micro);
  line-height: 1.25;
  text-align: center;
  hyphens: auto;
  overflow-wrap: anywhere;
  color: var(--c-text-1);
  background: var(--c-bg-1);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  cursor: pointer;
}
.galerie__kachel canvas { width: 84px; height: 46px; }
.galerie__kachel:hover { border-color: var(--c-text-2); color: var(--c-text-0); }
.galerie__kachel[aria-pressed='true'] { border-color: var(--c-w); color: var(--c-text-0); }
.galerie__formel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  font-size: var(--fs-small);
  color: var(--c-text-1);
}
.galerie__formel input {
  flex: 1;
  min-width: 140px;
  min-height: 36px;
  padding: 0 var(--sp-3);
  font-family: var(--f-mono);
  font-size: var(--fs-small);
  color: var(--c-text-0);
  background: var(--c-bg-0);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
}
.galerie__formel input:focus-visible { outline: 2px solid var(--c-text-0); outline-offset: 1px; }
.galerie__formel .btn { min-height: 36px; }
.galerie__meldung { margin: var(--sp-2) 0 0; font-size: var(--fs-small); color: var(--c-text-0); }
.galerie__meldung:empty { display: none; }
/* Drawing an own curve: a cross where a stroke would start, the hand stays on a node. */
.dock__bild.ist-stift canvas.layer:not(.is-over):not(.is-dragging) { cursor: crosshair; }

/* =======================================================================
   The tiles of the visualisations (assets/js/kacheln.js, NU-D6): on the hub
   one section per topic with full tiles (.card from components.css, picture
   on its dark ground), on a page the small ones without picture or sentence,
   this one marked "hier". Every tile in a row as high as its neighbours.
   ======================================================================= */
.thema + .thema { margin-top: var(--sp-7); }
.thema__titel { margin: 0; }
.thema .cardgrid { margin-top: var(--sp-4); }
/* A tile that is no link: dimmed by its title tone, the badge and a quiet
   picture ground, not by opacity — at 0.55 the description fell to
   3,3 : 1. The description stays running text at 7 : 1 (kontrast.mjs). */
.thema .card--soon { opacity: 1; }
.thema .card--soon .card__title { color: var(--c-text-1); }
.thema .card--soon .card__thumb { background: var(--c-bg-1); }
.card--klein .card__body { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
.card--klein .card__title { font-size: var(--fs-body); }
.card--klein[aria-current='page'] { background: var(--c-bg-3); }
.card__hier {
  margin-left: var(--sp-2);
  font-family: var(--f-mono);
  font-size: var(--fs-micro);
  font-weight: 400;
  color: var(--c-text-1);
}
.leiste .pager { margin-top: var(--sp-7); }
