/* Granaria Board -- Kartenoptik aus granaria_google_white.sty, fuer den Bildschirm. */

:root {
  --blue: #1a73e8;
  --red: #d93025;
  --green: #188038;
  --yellow: #f9ab00;
  --purple: #9334e6;
  --teal: #007b83;
  --orange: #e8710a;
  --cyan: #12b5cb;
  --ink: #202124;
  --muted: #5f6368;
  --border: #dadce0;
  --surface: #f8f9fa;

  --card-width: 640px;
  --card-gap: 34px;
  --column-gap: 46px;
  --zone-gap: 200px;

  --shadow: 0 1px 2px rgba(60, 64, 67, .18), 0 2px 8px rgba(60, 64, 67, .08);
  --shadow-lift: 0 2px 6px rgba(60, 64, 67, .22), 0 8px 24px rgba(60, 64, 67, .14);
  /* Die Karte schwebt ueber der Flaeche: drei Lagen, damit der Abstand zur
     Flaeche sichtbar wird und nicht nur ein Rand dunkler ist. */
  --shadow-float:
    0 2px 4px rgba(60, 64, 67, .16),
    0 10px 22px rgba(60, 64, 67, .16),
    0 26px 54px rgba(60, 64, 67, .13);

  --grid-dot: rgba(60, 64, 67, .34);
  --grid-dot-coarse: rgba(60, 64, 67, .22);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #fff;
}

/* --- Flaeche ------------------------------------------------------------- */

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  background-color: #fff;
  /* Board fängt alle Touch-Gesten ab -- kein Seiten-Scroll, kein Browser-Pinch. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  --grid-x: 0px;
  --grid-y: 0px;
  --grid-fine: 32px;
  --grid-coarse: 256px;
  --grid-fine-alpha: 1;
  --grid-coarse-alpha: 1;
}
#viewport.is-panning { cursor: grabbing; }
/* In Karten soll Text markierbar bleiben (Desktop); Touch-Pan greift trotzdem. */
#viewport .card {
  -webkit-user-select: text;
  user-select: text;
  touch-action: none;
}

/* Zwei Rasterweiten, beide in Weltmass: `viewport.js` setzt Ursprung und
   Schrittweite bei jeder Bewegung neu, damit die Punkte auf der Flaeche
   liegen und nicht auf dem Bildschirm kleben. */
#viewport::before,
#viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-position: var(--grid-x) var(--grid-y);
}
#viewport::before {
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1.4px);
  background-size: var(--grid-fine) var(--grid-fine);
  opacity: calc(var(--grid-fine-alpha) * .5);
}
#viewport::after {
  background-image: radial-gradient(circle, var(--grid-dot-coarse) 1.6px, transparent 2.2px);
  background-size: var(--grid-coarse) var(--grid-coarse);
  opacity: calc(var(--grid-coarse-alpha) * .75);
}

#world {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  transform-origin: 0 0;
  /* will-change setzt viewport.js nur waehrend des Ziehens. */
}
#world.is-flying { transition: none; }

/* Zwei Kantenebenen: das ganze Netz liegt als Textur unter den Karten, die
   Umgebung der gewaehlten Karte darueber -- sonst verschwindet gerade die
   Kante hinter einer Karte, auf die es ankommt. */
#edges, #edges-top {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}
#edges { z-index: 0; }
#edges-top { z-index: 3; }

/* Uebersichts-Canvas: ersetzt die 370 Karten-DOM-Knoten weit draussen.
   Liegt ueber Zonen, unter den (seltenen) echten Huellen und dem Top-Netz. */
.cards-overview {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: none;
  pointer-events: none;
}
.cards-overview.is-visible { display: block; }

.edge {
  fill: none;
  stroke-width: 2;
  opacity: .14;
}
/* Im Umgebungsmodus ist das Grundnetz nur Textur und muss hinter der
   gewaehlten Umgebung zurueckbleiben; im Netzmodus ist es die Hauptsache. */
#edges.edges-alles .edge { opacity: .4; stroke-width: 2.5; }
.edge-ref { stroke: var(--blue); }
.edge-begriff { stroke: var(--purple); stroke-dasharray: 7 7; }
.edge.is-active {
  opacity: .9;
  stroke-width: 3;
}
.edge-label {
  font-family: Roboto, Arial, sans-serif;
  font-size: 17px;
  font-weight: 600;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.edge-label-ref { fill: var(--blue); }
.edge-label-begriff { fill: var(--purple); }

/* --- Kapitelbaender ------------------------------------------------------- */

/* Ein Band je Kapitel, uebereinander gestapelt. Der Titel ist Welt-Schrift:
   er muss noch lesbar sein, wenn der ganze Band bei ~10 % ins Bild passt. */
.band {
  position: absolute;
  border-radius: 40px;
  background: rgba(232, 240, 254, .34);
  pointer-events: none;
}
.band-title {
  position: absolute;
  font-size: 200px;
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink);
  pointer-events: none;
  padding: 40px 54px 0;
}
.band-title .band-kind {
  display: block;
  font-size: .16em;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .35em;
}
.band-title .band-number { color: var(--blue); margin-right: .3em; }

/* --- Zonen --------------------------------------------------------------- */

.zone {
  position: absolute;
  border-radius: 22px;
  border: 1px solid transparent;
  background: rgba(248, 249, 250, .5);
  pointer-events: none;
}
.zone-title {
  position: absolute;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
}
.zone-title .zone-number { color: var(--blue); margin-right: .4em; }
.zone-title .zone-kind {
  display: block;
  font-size: .32em;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3em;
}

/* --- Karten -------------------------------------------------------------- */

.card {
  position: absolute;
  z-index: 2;
  width: var(--card-width);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--border));
  border-radius: 12px;
  background: var(--surface);
  padding: 20px 24px 18px;
  box-shadow: var(--shadow);
  font-size: 16.5px;
  line-height: 1.58;
  /* Parallax-Offsets: im flachen Modus 0, im Raum setzt viewport.js die
     Einheiten und rank multipliziert sie (siehe #world.is-raum). */
  --para-x: 0px;
  --para-y: 0px;
  /* Containment begrenzt Style/Layout-Folgen einer Karte auf sich selbst.
     content-visibility: auto waere hier falsch: die Flaeche scrollt per
     transform, nicht per Overflow -- der Browser saehe fast alles als
     offscreen und wuerde sichtbare Karten auslassen. */
  contain: layout style paint;
  transition: box-shadow .18s ease, transform .18s ease, opacity .18s ease;
}
/* Stockwerk-z ohne Inline-Style (spart 368 style-Schreibvorgaenge beim Bau). */
.card[data-layer-rank="0"] { z-index: 2; }
.card[data-layer-rank="1"] { z-index: 3; }
.card[data-layer-rank="2"] { z-index: 4; }
.card[data-layer-rank="3"] { z-index: 5; }
.card[data-layer-rank="4"] { z-index: 6; }
.card[data-layer-rank="5"] { z-index: 7; }
.card[data-layer-rank="6"] { z-index: 8; }
/* Tiefe als leise Dauerauskunft: je tiefer die Karte im Unterbau des Bandes
   liegt, desto flacher liegt sie auf der Flaeche. Kein Abzeichen, kein zweites
   Farbsystem -- das Auge liest Höhe ohnehin am Schatten ab. Muss vor den
   Zustandsregeln stehen, damit Fokus und Bezug den Schatten überschreiben. */
.card[data-tiefe="1"] { box-shadow: 0 1px 2px rgba(60, 64, 67, .16); }
.card[data-tiefe="2"] { box-shadow: 0 1px 1px rgba(60, 64, 67, .13); }

#world.zoom-near .card:hover {
  box-shadow: var(--shadow-lift);
  transform: translate(var(--para-x), calc(var(--para-y) - 2px));
}
.card.is-focus {
  /* Ueber allen Stockwerken (rank 0..6 → z-index 2..8). */
  z-index: 20 !important;
  transform: translate(var(--para-x), calc(var(--para-y) - 4px));
  box-shadow: var(--shadow-float), 0 0 0 3px rgba(26, 115, 232, .4);
}
.card.is-match { box-shadow: var(--shadow-lift), 0 0 0 3px rgba(249, 171, 0, .55); }
.card.is-dimmed { opacity: .38; }

/* Bezugszustaende: worauf die gewaehlte Karte aufbaut, und was auf ihr
   aufbaut. Zwei Farben, damit die Richtung ohne Pfeilverfolgung ablesbar ist. */
.card.is-basis {
  box-shadow: var(--shadow-lift), 0 0 0 2.5px rgba(147, 52, 230, .55);
}
.card.is-folge {
  box-shadow: var(--shadow-lift), 0 0 0 2.5px rgba(0, 123, 131, .5);
}
/* Umgebung: der Rest tritt zurueck -- per Welt-Klasse, nicht per 368 is-away. */
#world.is-umgebung-focus .card {
  opacity: .16;
  filter: saturate(.25);
}
#world.is-umgebung-focus .card.is-focus,
#world.is-umgebung-focus .card.is-basis,
#world.is-umgebung-focus .card.is-folge,
#world.is-umgebung-focus .card.is-match {
  opacity: 1;
  filter: none;
}

/* Die Karte ist ein Kasten fester Hoehe -- immer, nicht nur ausgeraeumt.
   `--h` kommt aus board/heights.py und steht schon im Geruest; darum muss der
   Browser beim Laden nichts messen, und darum sieht das Brett auf jedem Geraet
   gleich aus. Was nicht hineinpasst, wird abgeschnitten und ueber `.card-more`
   freigegeben. */
.card {
  height: var(--h);
  overflow: hidden;
}

/* Freigegebene Karte: legt sich ueber ihre Nachbarn, statt sie zu schieben.
   Ein Neuumbruch waere genau das, was das Ortsgedaechtnis zerstoert.

   Die Regel gilt bewusst nur im Lesezoom: die Zoomstufen weiter unten nageln
   die Hoehe mit gleichem Gewicht, stehen dahinter und gewinnen darum. Das ist
   richtig so -- in der Uebersicht ist der Rumpf verborgen, und eine Karte auf
   `height: auto` fiele dort zur Linie zusammen. */
#world .card.is-expanded {
  height: auto;
  min-height: var(--h);
  z-index: 21 !important;
  box-shadow: var(--shadow-float);
}

/* Angeschnitten: ein Verlauf sagt, dass da noch etwas ist, und der Knopf gibt
   es frei. Beides erscheint nur, wenn wirklich abgeschnitten wurde -- die
   Schaetzung liegt bei den meisten Karten richtig. */
.card-more { display: none; }
.card.is-overflow::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--surface) 78%);
}
.card-definition.is-overflow::after  { background: linear-gradient(to bottom, transparent, #f5f9ff 78%); }
.card-theorem.is-overflow::after     { background: linear-gradient(to bottom, transparent, #fef6f6 78%); }
.card-lemma.is-overflow::after       { background: linear-gradient(to bottom, transparent, #f5faf6 78%); }
.card-korollar.is-overflow::after    { background: linear-gradient(to bottom, transparent, #faf5fe 78%); }
.card-proof.is-overflow::after       { background: linear-gradient(to bottom, transparent, #f3f4f5 78%); }
.card-beispiel.is-overflow::after    { background: linear-gradient(to bottom, transparent, #fefaed 78%); }
.card-checkerbox.is-overflow::after  { background: linear-gradient(to bottom, transparent, #f9f4fe 78%); }
.card-expertbox.is-overflow::after   { background: linear-gradient(to bottom, transparent, #fef6ef 78%); }
.card-labbox.is-overflow::after      { background: linear-gradient(to bottom, transparent, #fff 78%); }
.card-verstaendnis.is-overflow::after{ background: linear-gradient(to bottom, transparent, #f2fbfc 78%); }
.card-intuition.is-overflow::after   { background: linear-gradient(to bottom, transparent, #f4faf5 78%); }
.card-fehler.is-overflow::after      { background: linear-gradient(to bottom, transparent, #fefaeb 78%); }
.card-ergebnisbox.is-overflow::after { background: linear-gradient(to bottom, transparent, #f3f7ff 78%); }
.card-prose.is-overflow::after       { background: linear-gradient(to bottom, transparent, #fff 78%); }

.card.is-overflow .card-more,
.card.is-expanded .card-more {
  position: absolute;
  z-index: 1;
  right: 14px;
  bottom: 10px;
  display: block;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 26px;
  cursor: pointer;
}
.card.is-overflow .card-more::before { content: "⌄"; }
.card.is-expanded .card-more::before { content: "⌃"; }
.card .card-more:hover { color: var(--ink); border-color: var(--muted); }

/* Ohne Formelsatz bleibt der Quelltext stehen. Er soll als solcher erkennbar
   sein und nicht als Satzfehler. */
.card.is-unset .card-body { font-family: ui-monospace, "SF Mono", Menlo, monospace; }


.card-head {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--muted);
}
.card-subtitle { font-weight: 400; }
.card-badge {
  position: absolute;
  top: -14px;
  left: 18px;
  display: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 26px;
  font-weight: 700;
  white-space: nowrap;
}

.card p { margin: 0 0 .7em; }
.card p:last-child { margin-bottom: 0; }
.card strong { font-weight: 700; }

/* `--accent` ist die Leitfarbe des Kartentyps: linker Rand im Lesezoom,
   Flaeche in der Uebersicht, Punkt auf der Minikarte. */
.card-prose {
  --accent: #dfe1e3;
  background: #fff;
  border-color: #eceef0;
  box-shadow: none;
}

.card-definition  { --accent: var(--blue);   background: #f5f9ff; }
.card-theorem     { --accent: var(--red);    background: #fef6f6; }
.card-lemma       { --accent: var(--green);  background: #f5faf6; }
.card-korollar    { --accent: var(--purple); background: #faf5fe; }
.card-proof       { --accent: #5f6368;       background: #f3f4f5; }
.card-beispiel    { --accent: var(--yellow); background: #fefaed; }
.card-bemerkung   { --accent: #9aa0a6;       background: var(--surface); }
.card-checkerbox  { --accent: var(--purple); background: #f9f4fe; }
.card-expertbox   { --accent: var(--orange); background: #fef6ef; }
/* Weiss wie im Band: eine Flaechentoenung arbeitet gegen die Bildfarben. */
.card-labbox      { --accent: var(--cyan);   background: #fff; }
.card-verstaendnis{ --accent: var(--teal);   background: #f2fbfc; }
.card-intuition   { --accent: var(--green);  background: #f4faf5; }
.card-fehler      { --accent: var(--yellow); background: #fefaeb; }
.card-ergebnisbox { --accent: var(--blue);   background: #f3f7ff; }

.card-definition  .card-head { color: var(--blue); }
.card-theorem     .card-head { color: var(--red); }
.card-lemma       .card-head { color: var(--green); }
.card-korollar    .card-head { color: var(--purple); }
.card-proof       .card-head { color: #3c4043; }
.card-beispiel    .card-head { color: #a06d00; }
.card-checkerbox  .card-head { color: var(--purple); }
.card-expertbox   .card-head { color: #c05f08; }
.card-labbox      .card-head { color: #0d8fa1; }
.card-verstaendnis .card-head { color: var(--teal); }
.card-intuition   .card-head { color: var(--green); }
.card-fehler      .card-head { color: var(--red); }
.card-ergebnisbox .card-head { color: var(--blue); }

/* --- Checkerbox: Loesung erst auf Anforderung ---------------------------- */

.reveal {
  margin-top: 16px;
  border-top: 1px dashed rgba(147, 52, 230, .45);
  padding-top: 14px;
}
.reveal-button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple);
  background: #fff;
  border: 1px solid rgba(147, 52, 230, .4);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
}
.reveal-button:hover { background: #faf5ff; }
.reveal-body {
  display: none;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #fdfbff;
}
.card.is-revealed .reveal-body { display: block; }
.card.is-revealed .reveal-button { color: var(--muted); border-color: var(--border); }

/* Die Expertbox teilt die Mechanik, nicht die Farbe. */
.card-expertbox .reveal        { border-top-color: rgba(232, 113, 10, .45); }
.card-expertbox .reveal-button { color: #c05f08; border-color: rgba(232, 113, 10, .4); }
.card-expertbox .reveal-button:hover { background: #fef6ef; }
.card-expertbox .reveal-body   { background: #fffaf5; }

/* --- Labbox: Lesehilfe unter dem Bild ------------------------------------ */

/* Kein Knopf: Das Bild ohne seine Lesehilfe waere eine halbe Karte. Die Hoehe
   ist darum in board/heights.py voll mitgerechnet (CAPTION_FRAME). */
.card-caption {
  margin-top: 16px;
  border-top: 1px dashed rgba(18, 181, 203, .45);
  padding-top: 14px;
  font-size: 15px;
  color: #3c4043;
}
.card-caption p:last-child { margin-bottom: 0; }

.proof-head { font-style: italic; color: var(--muted); margin-right: .35em; }
.qed { color: var(--blue); margin-left: .3em; }
.ohnebeweis { font-size: 14px; color: var(--muted); }

/* --- Inhalte ------------------------------------------------------------- */

.tex-list { margin: .5em 0 .6em; padding-left: 1.6em; }
.tex-list li { margin-bottom: .35em; }
.tex-list-alpha { list-style: none; counter-reset: alpha; padding-left: 2.1em; }
.tex-list-alpha > li { counter-increment: alpha; position: relative; }
.tex-list-alpha > li::before {
  content: "(" counter(alpha, lower-alpha) ")";
  position: absolute;
  left: -2.1em;
  color: var(--purple);
  font-weight: 500;
}
.tex-center { text-align: center; }
.tex-table {
  margin: .4em auto;
  border-collapse: collapse;
  font-size: 15.5px;
}
.tex-table th, .tex-table td {
  padding: 5px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tex-table th { border-top: 1px solid var(--border); font-weight: 600; }
.tex-GooglePurple { color: var(--purple); }
.tex-GoogleBlue { color: var(--blue); }

/* Abbildungen kommen als SVG aus board/figures.py -- LaTeX hat sie gesetzt,
   der Browser skaliert sie nur noch in die Kartenbreite. */
.tex-figure {
  margin: .8em 0;
  text-align: center;
}
.tex-figure img {
  max-width: 100%;
  height: auto;
}
.tex-figure-missing {
  margin: .8em 0;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.tex-minipage { display: inline-block; vertical-align: top; }

.antwort {
  font-size: 15px;
  margin-top: .6em;
}
.antwort strong { color: var(--teal); }

/* Eine Kartenumgebung im Rumpf einer anderen -- der Extraktor sieht nur die
   aeussere, die innere wird hier als Kasten gesetzt. */
.card-nested {
  margin: .7em 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent, var(--border));
  border-radius: 8px;
  background: #fff;
}
.card-nested-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.card-nested.card-ergebnisbox { background: #f3f7ff; }
.card-nested.card-beispiel { background: #fefaed; }
.card-nested.card-bemerkung { background: var(--surface); }

.xref {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(26, 115, 232, .35);
}
.xref-missing { color: var(--muted); }

/* --- Semantischer Zoom --------------------------------------------------- */


#world.zoom-far .card-body,
#world.zoom-far .reveal,
#world.zoom-far .card-head { visibility: hidden; }
/* Anschnittsverlauf und Aufklappknopf gehoeren zum Text; ohne ihn haben sie
   nichts zu sagen und wuerden die Farbflaeche nur verschmutzen. */
#world.zoom-far .card::after,
#world.zoom-overview .card::after { display: none; }
#world.zoom-far .card-more,
#world.zoom-overview .card-more { display: none; }
#world.zoom-far .card {
  height: var(--h);
  overflow: hidden;
  border-left-width: 10px;
}
#world.zoom-far .card-badge { display: block; color: var(--accent); }

/* In der Uebersicht traegt nicht mehr der Text, sondern die Farbe: jede Karte
   wird zu ihrem Typ, und der Band liest sich als Muster aus Definitionen,
   Saetzen und Aufgaben statt als graue Flaeche. */
#world.zoom-overview .card-body,
#world.zoom-overview .reveal,
#world.zoom-overview .card-head,
#world.zoom-overview .card-badge { visibility: hidden; display: none; }
#world.zoom-overview .card {
  height: var(--h);
  overflow: hidden;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  opacity: .82;
  box-shadow: none;
  transform: none;
}
#world.zoom-overview .card-prose { opacity: .5; }
#world.zoom-overview .zone { border-color: var(--border); }
/* Strichstaerken sind Weltmass und schrumpfen mit dem Zoom: bei 4 % wird aus
   2 px ein Zwanzigstel Pixel. Damit das Netz aus der Ferne ueberhaupt eine
   Linie bleibt, wachsen die Striche gegenlaeufig zum Zoom. */
#world.zoom-far .edge { stroke-width: 7; }
#world.zoom-far .edge.is-active { stroke-width: 11; }
#world.zoom-far .edge-label { display: none; }

/* Nur die Staerke, nicht die Deckkraft: die gehoert der Betriebsart, sonst
   sehen Umgebungs- und Netzmodus aus der Ferne gleich aus. */
#world.zoom-overview .edge { stroke-width: 34; }
#world.zoom-overview .edge.is-active { opacity: .95; stroke-width: 60; }
#world.zoom-overview .edge-begriff { stroke-dasharray: 90 70; }
#world.zoom-overview .edge-label { display: none; }

/* --- Tiefen- und Ebenenfilter -------------------------------------------- */

/* Filter laufen ueber data-* an #world, nicht ueber Klassen an jeder Karte.
   Umschalten kostet einen Attribut-Schreibvorgang statt 368 classList-Toggles.
   Weggeblendet, nicht ausgeblendet: der Platz bleibt (Ortsgedaechtnis).
   Suchtreffer (.is-match) stechen den Filter. */

#world[data-depth="0"] .card[data-tiefe="1"]:not(.is-match),
#world[data-depth="0"] .card[data-tiefe="2"]:not(.is-match),
#world[data-depth="1"] .card[data-tiefe="2"]:not(.is-match) {
  opacity: .08;
  filter: saturate(.2);
  pointer-events: none;
}

#world[data-layer-filter="kern"] .card:not([data-layer="kern"]):not(.is-match),
#world[data-layer-filter="kern-stuetzen"] .card:not([data-layer="kern"]):not([data-layer="stuetzen"]):not(.is-match),
#world[data-layer-filter="mit-beweisen"] .card:not([data-layer="kern"]):not([data-layer="stuetzen"]):not([data-layer="beweise"]):not(.is-match),
#world[data-layer-filter="ohne-ueben"] .card[data-layer="ueben"]:not(.is-match) {
  opacity: .08;
  filter: saturate(.2);
  pointer-events: none;
}

#world .edge.is-muted { opacity: .05; }
#world .edge.is-active.is-muted { opacity: .22; }

/* Raum-Modus: hoehere Stockwerke werfen laengere Schatten und reagieren
   staerker auf den Pan (Parallax). Die Basis-Position setzt app.js ueber
   left/top; --para-unit-* kommt aus viewport.js. */
#world {
  --para-unit-x: 0px;
  --para-unit-y: 0px;
}
#world.is-raum .card {
  transform: translate(var(--para-x), var(--para-y));
  transition:
    box-shadow .22s ease,
    opacity .18s ease,
    left .28s ease,
    top .28s ease;
  /* transform bewusst ohne Transition: sonst haengt der Parallax nach. */
}
#world.is-raum .card[data-layer-rank="0"] {
  --para-x: 0px;
  --para-y: 0px;
  box-shadow: 0 1px 2px rgba(60, 64, 67, .12);
}
#world.is-raum .card[data-layer-rank="1"] {
  --para-x: calc(var(--para-unit-x) * 1);
  --para-y: calc(var(--para-unit-y) * 1);
  box-shadow:
    0 2px 4px rgba(60, 64, 67, .14),
    0 6px 14px rgba(60, 64, 67, .1);
}
#world.is-raum .card[data-layer-rank="2"] {
  --para-x: calc(var(--para-unit-x) * 2);
  --para-y: calc(var(--para-unit-y) * 2);
  box-shadow:
    0 3px 6px rgba(60, 64, 67, .15),
    0 10px 22px rgba(60, 64, 67, .12);
}
#world.is-raum .card[data-layer-rank="3"] {
  --para-x: calc(var(--para-unit-x) * 3);
  --para-y: calc(var(--para-unit-y) * 3);
  box-shadow:
    0 4px 8px rgba(60, 64, 67, .16),
    0 14px 28px rgba(60, 64, 67, .13);
}
#world.is-raum .card[data-layer-rank="4"] {
  --para-x: calc(var(--para-unit-x) * 4);
  --para-y: calc(var(--para-unit-y) * 4);
  box-shadow:
    0 5px 10px rgba(60, 64, 67, .17),
    0 18px 36px rgba(60, 64, 67, .14);
}
#world.is-raum .card[data-layer-rank="5"] {
  --para-x: calc(var(--para-unit-x) * 5);
  --para-y: calc(var(--para-unit-y) * 5);
  box-shadow:
    0 6px 12px rgba(60, 64, 67, .18),
    0 20px 40px rgba(60, 64, 67, .15);
}
#world.is-raum .card[data-layer-rank="6"] {
  --para-x: calc(var(--para-unit-x) * 6);
  --para-y: calc(var(--para-unit-y) * 6);
  box-shadow:
    0 7px 14px rgba(60, 64, 67, .19),
    0 24px 48px rgba(60, 64, 67, .16);
}
#world.is-raum .card.is-focus {
  box-shadow: var(--shadow-float), 0 0 0 3px rgba(26, 115, 232, .4);
}

/* Legende der Stockwerke (rechts unten, ueber der Minikarte). */
#layer-legend {
  position: fixed;
  z-index: 10;
  right: 14px;
  bottom: 178px;
  display: none;
  min-width: 132px;
  padding: 10px 12px 11px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--ink);
  pointer-events: none;
}
#layer-legend.is-visible { display: block; }
.layer-legend-head {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.layer-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  opacity: 1;
  transition: opacity .18s ease;
}
.layer-legend-row:last-child { margin-bottom: 0; }
.layer-legend-row.is-off { opacity: .28; }
.layer-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, .2);
}
.layer-swatch-text      { background: #dadce0; }
.layer-swatch-einstieg  { background: var(--green); }
.layer-swatch-kern      { background: var(--blue); }
.layer-swatch-stuetzen  { background: #188038; }
.layer-swatch-beweise   { background: #5f6368; }
.layer-swatch-begleitung{ background: var(--yellow); }
.layer-swatch-ueben     { background: var(--purple); }
.layer-legend-label { line-height: 1.2; }

/* --- Bedienleisten ------------------------------------------------------- */

.bar {
  position: fixed;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  /* Safe Area: Home-Indicator / Notch auf dem iPad. */
  max-width: calc(100vw - 28px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
}
#topbar {
  top: max(14px, env(safe-area-inset-top, 0px));
  left: max(14px, env(safe-area-inset-left, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  max-width: none;
  flex-wrap: wrap;
  row-gap: 8px;
}
#pathbar {
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
}

.bar-title { font-weight: 700; margin-right: 4px; min-width: 0; }
.bar-title small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.spacer { flex: 1; min-width: 8px; }

.bar-core {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.zoom-level {
  min-width: 46px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Sekundaerwerkzeuge: Desktop sichtbar, Touch hinter „Mehr“. */
.bar-more {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.bar-more[hidden] { display: none !important; }
#btn-more { display: none; }

button.tool, .bar select, a.tool {
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button.tool:hover, a.tool:hover { background: var(--surface); }
button.tool.is-active, a.tool.is-active {
  background: #e8f0fe;
  border-color: var(--blue);
  color: var(--blue);
}
button.tool:disabled { opacity: .4; cursor: default; }

#search {
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  width: 220px;
  min-width: 0;
  max-width: 40vw;
}
#search-count { color: var(--muted); font-size: 12.5px; min-width: 46px; }
#path-label { min-width: 160px; max-width: 50vw; color: var(--muted); }
#path-label b { color: var(--ink); }

/* Der Touch-Hinweis ist die Ausnahme, nicht der Regelfall -- und diese
   Grundregel muss VOR die Medienabfrage, die sie aufhebt. Eine gleich schwere
   Regel dahinter gewinnt unabhaengig von der Medienabfrage; stand sie unten,
   blieb auf dem Handy beides verborgen und der Hinweiskasten leer. */
.hint-touch { display: none; }

/* Touch / schmale Viewports: groessere Treffer, kompakte Leiste. */
@media (max-width: 960px), (pointer: coarse) {
  #btn-more { display: inline-flex; align-items: center; }
  /* Mehr-Menue erst auf Klick; Desktop behält die offene Leiste. */
  .bar-more {
    display: none;
    width: 100%;
    order: 20;
    padding-top: 4px;
    border-top: 1px solid var(--border);
  }
  #topbar.is-more-open .bar-more,
  .bar-more:not([hidden]) {
    display: flex;
  }
  .bar-more[hidden] { display: none !important; }

  .bar-title small { display: none; }
  #board-source { display: none; }
  button.tool, .bar select, a.tool {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
    font-size: 15px;
  }
  #search {
    flex: 1 1 120px;
    width: auto;
    max-width: none;
    min-height: 44px;
    font-size: 16px; /* iOS zoomt Inputs sonst hoch */
  }
  #chapters { max-width: 42vw; min-height: 44px; }
  #path-label { font-size: 13px; min-width: 0; }
  #pathbar { gap: 12px; padding: 10px 14px; }
  #minimap {
    width: 150px;
    height: 104px;
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: max(72px, calc(env(safe-area-inset-bottom, 0px) + 64px));
  }
  #layer-legend {
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: max(190px, calc(env(safe-area-inset-bottom, 0px) + 180px));
  }
  #relations {
    top: max(72px, calc(env(safe-area-inset-top, 0px) + 58px));
    left: max(10px, env(safe-area-inset-left, 0px));
    max-height: calc(100vh - 200px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    width: min(280px, calc(100vw - 24px));
  }
  .hint-desktop { display: none; }
  .hint-touch { display: inline; }
}

@media (min-width: 961px) and (pointer: fine) {
  /* Desktop: alle Werkzeuge sichtbar, „Mehr“ unnoetig. */
  #btn-more { display: none !important; }
  .bar-more { display: flex !important; }
  .bar-more[hidden] { display: flex !important; }
}

/* --- Bezugsleiste --------------------------------------------------------- */

/* Das gezeichnete Netz zeigt, wohin es geht; die Leiste sagt, was dort steht.
   Beides zusammen macht aus den Kanten einen Weg statt einer Verzierung. */
#relations {
  position: fixed;
  z-index: 10;
  top: 72px;
  left: 14px;
  display: none;
  width: 268px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  padding: 12px 14px 14px;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
#relations.is-visible { display: block; }

.rel-head {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
.rel-group { margin-bottom: 10px; }
.rel-group:last-child { margin-bottom: 0; }
.rel-kind {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.rel-chip {
  font: inherit;
  font-size: 12.5px;
  margin: 0 5px 5px 0;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--border));
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.rel-chip:hover { background: var(--surface); }
.rel-chip-definition  { --accent: var(--blue); }
.rel-chip-theorem     { --accent: var(--red); }
.rel-chip-lemma       { --accent: var(--green); }
.rel-chip-korollar    { --accent: var(--purple); }
.rel-chip-proof       { --accent: #5f6368; }
.rel-chip-beispiel    { --accent: var(--yellow); }
.rel-chip-checkerbox  { --accent: var(--purple); }
.rel-chip-expertbox   { --accent: var(--orange); }
.rel-chip-labbox      { --accent: var(--cyan); }
.rel-chip-verstaendnis{ --accent: var(--teal); }
.rel-chip-intuition   { --accent: var(--green); }
.rel-chip-fehler      { --accent: var(--yellow); }
.rel-chip-ergebnisbox { --accent: var(--blue); }

.rel-term {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1e9fd;
  color: #6b21a8;
  font-weight: 500;
}
.rel-more, .rel-empty { color: var(--muted); font-size: 12px; }

#minimap {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 10;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .93);
  box-shadow: var(--shadow);
  cursor: pointer;
}

#hint {
  position: fixed;
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 10;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  background: rgba(255, 255, 255, .85);
  border-radius: 10px;
  padding: 8px 12px;
  max-width: min(340px, calc(100vw - 180px));
  pointer-events: none;
}
@media (max-width: 960px), (pointer: coarse) {
  #hint {
    bottom: max(72px, calc(env(safe-area-inset-bottom, 0px) + 58px));
    font-size: 13px;
    max-width: min(320px, calc(100vw - 24px));
  }
}
@media (max-height: 500px) {
  #hint { display: none; }
}
#hint kbd {
  font: inherit;
  font-size: 11px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  background: #fff;
}

#error {
  position: fixed;
  z-index: 20;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  max-width: 620px;
  padding: 12px 18px;
  border-radius: 10px;
  background: #fce8e6;
  border: 1px solid var(--red);
  color: #6b1e18;
  font-size: 14px;
}
#error.is-visible { display: block; }
