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

:root {
  --blue: #1a73e8;
  --red: #d93025;
  --green: #188038;
  --yellow: #f9ab00;
  --purple: #9334e6;
  --teal: #007b83;
  --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;
  --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; }

/* 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: transform;
}
#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; }

.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;
  transition: box-shadow .18s ease, transform .18s ease, opacity .18s ease;
}
/* 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: translateY(-2px);
}
.card.is-focus {
  z-index: 4;
  transform: translateY(-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);
}
.card.is-away {
  opacity: .16;
  filter: saturate(.25);
}

/* Ausgeraeumte Karte (js/cards.js): haelt ihren Platz ueber die gemessene
   Hoehe, damit die Anordnung nicht davon abhaengt, wo der Leser gerade
   hinsieht. `overflow` schneidet nichts ab -- es ist nichts drin. */
.card.is-hollow {
  height: var(--h);
  overflow: hidden;
}


.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-beispiel    { --accent: var(--yellow); background: #fefaed; }
.card-bemerkung   { --accent: #9aa0a6;       background: var(--surface); }
.card-checkerbox  { --accent: var(--purple); background: #f9f4fe; }
.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-beispiel    .card-head { color: #a06d00; }
.card-checkerbox  .card-head { color: var(--purple); }
.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); }

.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; }
#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; }

/* Messplatz: haelt waehrend der Messfahrt genau eine Karte, ausserhalb des
   Bildes und ausserhalb des Umbruchs der Flaeche. Ohne ihn muesste jede der
   343 Messungen das ganze Brett neu umbrechen. `contain` sperrt die Wirkung
   nach aussen ab, `visibility` haelt die Karte messbar, ohne sie zu zeigen. */
#measure {
  position: absolute;
  top: 0;
  left: -20000px;
  width: var(--card-width);
  contain: layout style;
  visibility: hidden;
  pointer-events: none;
}

/* Nachmessen einer einzelnen, aufgeklappten Karte an Ort und Stelle: fuer die
   Dauer des Ablesens gibt die Karte ihre festgesetzte Hoehe frei. Muss hinter
   den Zoomstufen stehen, die dieselbe Hoehe festnageln. */
#world .card.is-measuring { height: auto; }

/* --- Tiefenfilter --------------------------------------------------------- */

/* Weggeblendet, nicht ausgeblendet: der Platz bleibt, damit das
   Ortsgedaechtnis nicht bei jedem Umschalten neu gelernt werden muss.
   Der `#world`-Vorsatz ist noetig, nicht schmueckend: die Zoomstufen setzen
   die Deckkraft mit derselben ID und wuerden den Filter sonst zurueckdrehen. */
#world .card.is-tief-weg {
  opacity: .08;
  filter: saturate(.2);
  pointer-events: none;
}
/* Ein Suchtreffer wiegt schwerer als der Filter -- gesucht wird im ganzen Band. */
#world .card.is-tief-weg.is-match {
  opacity: .9;
  filter: none;
  pointer-events: auto;
}
#world .edge.is-muted { opacity: .05; }
#world .edge.is-active.is-muted { opacity: .22; }

/* --- 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;
}
#topbar { top: 14px; left: 14px; right: 14px; }
#pathbar { bottom: 16px; left: 50%; transform: translateX(-50%); }

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

button.tool, .bar select {
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  color: var(--ink);
}
button.tool:hover { background: var(--surface); }
button.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;
}
#search-count { color: var(--muted); font-size: 12.5px; min-width: 46px; }
#path-label { min-width: 260px; color: var(--muted); }
#path-label b { color: var(--ink); }

/* --- 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-beispiel    { --accent: var(--yellow); }
.rel-chip-checkerbox  { --accent: var(--purple); }
.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: 14px;
  bottom: 16px;
  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;
}
#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; }
