/* Wie ein Druck entsteht: Seiten-CSS.
   Marke: KI-Druckwerkstatt (druckwerk/DESIGN.md). IBM Plex Sans + Plex Mono,
   FL-Blau als einziger Akzent, Papier mit Karo, ein Nachtkapitel (04).
   Grammatik: chaptered editorial. Jedes Kapitel hat einen eigenen, harten
   Grund, keine Drift. Die Engine-Selektoren werden nicht umgestylt. */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
}

:root {
  /* Druckwerk-Töne auf die sechs Rollen der Engine */
  --sc-canvas: #FAFBFD;
  --sc-surface: #FFFFFF;
  --sc-ink: #0B1220;
  --sc-ink-soft: #475467;
  --sc-accent: #155EEF;
  --sc-accent-ink: #FFFFFF;
  --sc-font-display: "IBM Plex Sans", system-ui, sans-serif;
  --sc-font-text: "IBM Plex Sans", system-ui, sans-serif;
  --sc-font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --sc-shadow-color: 220 45% 20%;

  --dw-paper-alt: #F2F4F7;
  --dw-line: rgba(11, 18, 32, 0.10);
  --dw-nacht: #0B1220;
  --dw-nacht-ink: #F2F4F7;
  --dw-nacht-soft: #A9B4C6;
  --dw-nacht-accent: #8FBBFF;   /* gleicher Blauton, hell für den dunklen Grund */
  --dw-pla: #F0563A;            /* das Material, nicht der Akzent: nur im Bett */

  --folio-w: 17rem;
}

body { font-weight: 400; }

.dw-skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: 10px 18px; background: var(--sc-ink); color: #fff;
  font-weight: 600; text-decoration: none; border-radius: 0 0 10px 0;
}
.dw-skip:focus-visible { left: 0; }

a { color: var(--sc-accent); }
a:hover { color: #0F47B8; }

/* ---------------------------------------------------------------- folio --
   Breite Bildschirme: feste Randspalte links. Sie wechselt ihren Grund mit
   dem Kapitel (hart, keine Interpolation). */
.folio {
  position: fixed; inset: 0 auto 0 0; width: var(--folio-w);
  z-index: var(--sc-z-chrome);
  display: flex; flex-direction: column; gap: var(--sc-5);
  padding: var(--sc-6) var(--sc-5);
  background: var(--sc-canvas);
  border-right: 1px solid var(--dw-line);
  color: var(--sc-ink);
}
.folio__marke {
  display: inline-flex; align-items: center; gap: var(--sc-3);
  color: var(--sc-ink); text-decoration: none; font-weight: 600; font-size: var(--sc-t-sm);
}
.folio__marke:hover { color: var(--sc-ink); }
.folio__kapitel {
  margin: var(--sc-4) 0 0; font-size: var(--sc-t-sm); font-weight: 600; line-height: 1.3;
}
.folio__nr {
  display: block; font-family: var(--sc-font-mono); font-weight: 400;
  font-size: var(--sc-t-xs); color: var(--sc-ink-soft); letter-spacing: 0.04em;
}
.folio__stand {
  margin: calc(var(--sc-3) * -1) 0 0; font-family: var(--sc-font-mono); font-size: var(--sc-t-xs);
  color: var(--sc-ink-soft); font-variant-numeric: tabular-nums;
}
.folio__nav { margin-top: auto; }
.folio__nav ol { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sc-1); counter-reset: k; }
.folio__nav li { counter-increment: k; }
.folio__nav a {
  display: flex; gap: var(--sc-3); padding: 4px 0; font-size: var(--sc-t-sm);
  color: var(--sc-ink-soft); text-decoration: none;
  transition: color var(--sc-d-fast) var(--sc-ease-out);
}
.folio__nav a::before {
  content: "0" counter(k); font-family: var(--sc-font-mono); font-size: var(--sc-t-xs);
  padding-top: 2px; opacity: 0.8;
}
.folio__nav a:hover, .folio__nav a[aria-current="true"] { color: var(--sc-ink); }
.folio__nav a[aria-current="true"] { font-weight: 600; }

body.ist-nacht .folio {
  background: var(--dw-nacht); color: var(--dw-nacht-ink); border-right-color: rgba(242, 244, 247, 0.12);
}
body.ist-nacht .folio__marke, body.ist-nacht .folio__nav a:hover,
body.ist-nacht .folio__nav a[aria-current="true"] { color: var(--dw-nacht-ink); }
body.ist-nacht .folio__nr, body.ist-nacht .folio__stand, body.ist-nacht .folio__nav a { color: var(--dw-nacht-soft); }
body.ist-nacht :focus-visible { outline-color: var(--dw-nacht-accent); }

/* ----------------------------------------------------------------- bett --
   Das Druckbett: 256 x 256 mm, Draufsicht, Punktraster wie das PEI-Blech. */
.bett { margin: 0; }
.bett__svg { width: 100%; height: auto; aspect-ratio: 1; }
.bett--folio {
  width: 100%; max-width: 13rem;
  border-radius: 14px; overflow: hidden;
  box-shadow: var(--sc-e1), inset 0 0 0 1px var(--dw-line);
}
.bett__platte { fill: #2A2F38; }
.bett__punkte { fill: url(#bett-raster); }
.bett__fertig path { fill: none; stroke: var(--dw-pla); stroke-opacity: 0.38; stroke-width: 0.5; }
.bett__aktiv path { fill: none; stroke: #FFB4A3; stroke-width: 0.7; stroke-linecap: round; stroke-linejoin: round; }
.bett__aktiv .bett__fuell { stroke-opacity: 0.75; stroke-width: 0.45; }

/* --------------------------------------------------------------- seite -- */
.seite { margin-left: var(--folio-w); }

.kap { position: relative; }
.kap--papier { background: var(--sc-canvas); }
.kap--papier-alt { background: var(--dw-paper-alt); }
.kap--nacht {
  background: var(--dw-nacht);
  --sc-ink: var(--dw-nacht-ink); --sc-ink-soft: var(--dw-nacht-soft);
  --sc-accent: var(--dw-nacht-accent); --sc-accent-ink: var(--dw-nacht);
  color: var(--sc-ink);
}
.kap--papier, .kap--papier-alt, .kap--titel, .kap--kolophon { color: var(--sc-ink); }

.kap__nr {
  margin: 0; font-family: var(--sc-font-mono); font-size: var(--sc-t-sm);
  color: var(--sc-ink-soft); letter-spacing: 0.04em;
}
.kap__h2 {
  margin: var(--sc-2) 0 var(--sc-5);
  font-size: var(--sc-t-2xl); font-weight: 600; line-height: var(--sc-leading-tight);
  letter-spacing: var(--sc-track-snug); text-wrap: balance; max-width: 18em;
}
.kap p:not([class]) { margin: 0 0 var(--sc-4); max-width: 38rem; color: var(--sc-ink-soft); text-wrap: pretty; }
.kap p:not([class]):last-child { margin-bottom: 0; }

figure { margin: 0; }
figcaption {
  margin-top: var(--sc-3); font-size: var(--sc-t-sm); color: var(--sc-ink-soft); line-height: 1.5;
}

/* --------------------------------------------------------------- titel -- */
.kap--titel {
  min-height: 92svh; display: grid; align-items: end;
  padding: var(--sc-9) var(--sc-gutter) var(--sc-9);
  background-color: var(--sc-canvas);
  background-image: radial-gradient(120% 80% at 8% 0%, #E9EFFF 0%, rgba(233, 239, 255, 0) 58%),
    linear-gradient(var(--dw-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--dw-line) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
  border-bottom: 1px solid var(--dw-line);
}
.titel { max-width: 60rem; }
.titel__zeile {
  margin: 0 0 var(--sc-5); font-family: var(--sc-font-mono); font-size: var(--sc-t-sm); color: var(--sc-ink-soft);
}
.titel__h1 {
  margin: 0; font-size: clamp(3rem, 1.6rem + 6vw, 7rem); font-weight: 600;
  line-height: 0.98; letter-spacing: -0.035em; text-wrap: balance;
}
.titel__unter {
  margin: var(--sc-6) 0 0; max-width: 34rem; font-size: var(--sc-t-lg); line-height: 1.45; color: var(--sc-ink-soft);
}

/* ----------------------------------------------------------- aufschlag --
   Asymmetrische Doppelseite: Text schmal, Bild breit, Bild bekommt eine
   Bildunterschrift statt Text darüber. */
.aufschlag {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--sc-8); align-items: center;
  max-width: 76rem; margin-inline: auto;
  padding: var(--sc-section) var(--sc-gutter);
}
.aufschlag--breit { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.aufschlag--probe { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; row-gap: var(--sc-8); }

.bild-relief__rahmen {
  overflow: hidden; border-radius: 18px; background: #F8F8F8;
  box-shadow: var(--sc-e2), inset 0 0 0 1px var(--dw-line);
  aspect-ratio: 820 / 340;
}
.bild-relief__rahmen img { width: 100%; height: auto; transform-origin: center; scale: 1.08; }

/* ------------------------------------------------------- schichtbild -- */
.schichtbild {
  display: grid; gap: var(--sc-4);
  padding: var(--sc-5); border-radius: 20px;
  background: #FFFFFF; box-shadow: var(--sc-e2), inset 0 0 0 1px var(--dw-line);
}
.schichtbild__svg {
  width: 100%; height: auto; aspect-ratio: 2.2 / 1;
  background-color: #1E232B;
  background-image: radial-gradient(circle 1px at center, rgba(255, 255, 255, 0.10) 90%, transparent 100%);
  background-size: 14px 14px; border-radius: 12px;
}
.schichtbild__svg .s-wand { fill: none; stroke: #F4F6FA; stroke-width: 0.45; stroke-linejoin: round; }
.schichtbild__svg .s-fuell { fill: none; stroke: #7FA6F5; stroke-width: 0.35; }
.schichtbild__svg .s-deck { fill: none; stroke: #FF8A6E; stroke-width: 0.35; }
.schichtbild__steuer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sc-4); }
.schichtbild__steuer label { font-weight: 600; font-size: var(--sc-t-sm); white-space: nowrap; }
.schichtbild__steuer output { font-variant-numeric: tabular-nums; display: inline-block; min-width: 2ch; text-align: right; }
.schichtbild__steuer input { width: 100%; min-height: 44px; cursor: pointer; }
.schichtbild__werte { margin: 0; font-family: var(--sc-font-mono); font-size: var(--sc-t-xs); color: var(--sc-ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.legende { display: flex; flex-wrap: wrap; gap: var(--sc-5); margin: 0; padding: 0; list-style: none; font-size: var(--sc-t-sm); color: var(--sc-ink-soft); }
.legende li { display: inline-flex; align-items: center; gap: var(--sc-2); }
.legende__farbe { width: 18px; height: 4px; border-radius: 2px; }
.legende__farbe--wand { background: #F4F6FA; box-shadow: inset 0 0 0 1px #98A2B3; }
.legende__farbe--fuell { background: #7FA6F5; }
.legende__farbe--deck { background: #FF8A6E; }

/* --------------------------------------------------------------- heizen -- */
.heiz {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--sc-8); align-items: center;
  padding: var(--sc-7) var(--sc-gutter);
  max-width: 76rem; margin-inline: auto;
  background: var(--sc-canvas);
}
.kurve { width: 100%; height: auto; overflow: visible; }
.kurve .k-achse { stroke: var(--dw-line); stroke-width: 1; }
.kurve .k-gitter { stroke: var(--dw-line); stroke-width: 1; stroke-dasharray: 2 4; }
.kurve .k-text { font-family: var(--sc-font-mono); font-size: 12px; fill: var(--sc-ink-soft); }
.kurve .k-duese { fill: none; stroke: var(--sc-ink); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.kurve .k-bett { fill: none; stroke: var(--sc-accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.kurve .k-name { font-size: 13px; font-weight: 600; }
.kurve .k-name--duese { fill: var(--sc-ink); }
.kurve .k-name--bett { fill: var(--sc-accent); }

/* ---------------------------------------------------------------- druck -- */
.druck {
  display: grid; grid-template-rows: auto auto; align-content: center; gap: var(--sc-5);
  padding: var(--sc-6) var(--sc-gutter);
  background: var(--dw-nacht);
}
.druck__kopf { max-width: 64rem; }
.druck__kopf .kap__h2 { margin-bottom: 0; font-size: var(--sc-t-2xl); max-width: 22em; }
.druck__film {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sc-3); align-content: start;
  max-width: min(70rem, calc((100svh - 15rem) * 2)); width: 100%;
}
.druck__bild {
  position: relative; aspect-ratio: 2 / 1; overflow: hidden; border-radius: 16px;
  background: #11161F; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(242, 244, 247, 0.10);
}
.druck__film figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sc-2) var(--sc-6); margin-top: var(--sc-2); }
.druck__stand {
  font-family: var(--sc-font-mono); font-size: var(--sc-t-base); color: var(--sc-ink);
  font-variant-numeric: tabular-nums;
}
.druck__quelle { color: var(--sc-ink-soft); }
.bett--film { display: none; }

/* ------------------------------------------------------------ gegenprobe -- */
.probe { display: grid; gap: var(--sc-6); }
.probe__tabelle { width: 100%; border-collapse: collapse; font-size: var(--sc-t-sm); }
.probe__tabelle caption { text-align: left; color: var(--sc-ink-soft); padding-bottom: var(--sc-3); }
.probe__tabelle code { font-family: var(--sc-font-mono); font-size: 0.92em; }
.probe__tabelle th, .probe__tabelle td { text-align: left; padding: var(--sc-3) var(--sc-3) var(--sc-3) 0; border-bottom: 1px solid var(--dw-line); vertical-align: top; }
.probe__tabelle thead th { font-weight: 600; color: var(--sc-ink-soft); font-size: var(--sc-t-xs); letter-spacing: 0.02em; }
.probe__tabelle tbody th { font-family: var(--sc-font-mono); font-weight: 400; width: 3.5rem; }
.probe__fehl td:nth-child(3) { color: #B42318; font-weight: 600; }
.probe__dieser { background: #E9EFFF; }
.probe__dieser th { padding-left: var(--sc-3); }
.probe__dieser td:last-child { padding-right: var(--sc-3); }
.probe__marke {
  display: inline-block; margin-left: var(--sc-2); padding: 2px 10px; border-radius: 6px;
  background: var(--sc-accent); color: #fff; font-size: var(--sc-t-xs); font-weight: 600;
}
.probe__zahl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--sc-5); align-items: baseline; }
.probe__ziffer {
  font-size: var(--sc-t-3xl); font-weight: 600; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.probe__zahl span:last-child { color: var(--sc-ink-soft); max-width: 22rem; }
.probe__bilder { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--sc-6); align-items: end; }
.probe__bilder img { width: 100%; height: auto; border-radius: 14px; box-shadow: var(--sc-e2); }

/* ------------------------------------------------------------- kolophon -- */
.kap--kolophon { background: var(--dw-paper-alt); border-top: 1px solid var(--dw-line); }
.kolophon {
  max-width: 76rem; margin-inline: auto; padding: var(--sc-9) var(--sc-gutter) var(--sc-8);
  display: grid; gap: var(--sc-6);
}
.kolophon__satz { margin: 0; font-size: var(--sc-t-lg); max-width: 34rem; line-height: 1.45; }
.kolophon__daten { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--sc-4) var(--sc-6); font-size: var(--sc-t-sm); }
.kolophon__daten dt { font-family: var(--sc-font-mono); font-size: var(--sc-t-xs); color: var(--sc-ink-soft); }
.kolophon__daten dd { margin: 2px 0 0; }
.kolophon__klein { margin: 0; max-width: 34rem; font-size: var(--sc-t-xs); color: var(--sc-ink-soft); }

/* ------------------------------------------------------------- schmal -- */
@media (max-width: 1099px) {
  :root { --folio-w: 0px; }
  .folio {
    inset: 0 0 auto 0; width: auto; height: auto;
    flex-direction: row; align-items: center; gap: var(--sc-4);
    padding: 10px var(--sc-gutter);
    border-right: 0; border-bottom: 1px solid var(--dw-line);
    background: color-mix(in oklab, var(--sc-canvas) 94%, transparent);
  }
  body.ist-nacht .folio { border-bottom-color: rgba(242, 244, 247, 0.12); }
  .folio__marke span, .bett--folio, .folio__nav { display: none; }
  .folio__kapitel { margin: 0; display: flex; gap: var(--sc-2); align-items: baseline; }
  .folio__nr { display: inline; }
  .folio__stand { margin: 0 0 0 auto; }
  .kap--titel { padding-top: var(--sc-10); }
  .aufschlag, .aufschlag--breit, .aufschlag--probe, .heiz { grid-template-columns: minmax(0, 1fr); gap: var(--sc-6); }
  .heiz { padding-top: var(--sc-9); align-content: center; }
  .druck { padding-top: 4.5rem; align-content: center; }
  .druck__film { max-width: none; }
  .bett--film { display: block; width: min(62%, 16rem); justify-self: center; margin-top: var(--sc-3); border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(242, 244, 247, 0.12); }
  .probe__bilder { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .titel__h1 { font-size: clamp(2.6rem, 11vw, 3.4rem); }
  .kap__h2, .druck__kopf .kap__h2 { font-size: var(--sc-t-xl); }
  .druck__stand { font-size: var(--sc-t-sm); }
  .schichtbild { padding: var(--sc-4); }
  .schichtbild__steuer { grid-template-columns: 1fr; gap: var(--sc-2); }
  .probe__tabelle td:nth-child(2), .probe__tabelle th:nth-child(2) { display: none; }
  .heiz { gap: var(--sc-5); }
}

@media (prefers-reduced-motion: reduce) {
  .folio__nav a { transition: none; }
}
