/* SPDX-License-Identifier: Apache-2.0 */
/* SPDX-FileCopyrightText: 2026 Finn Malte Hinrichsen */
/* Netz-Ansicht: naechtliches Messinstrument. Farbe kommt aus den Daten, die Bedienung bleibt leise. */
:root {
  --grund: #03060b;
  --tafel: rgba(7, 11, 19, 0.80);
  --tafel-fest: #070b13;
  --linie: rgba(150, 172, 206, 0.13);
  --linie-mittel: rgba(150, 172, 206, 0.22);
  --linie-stark: rgba(150, 172, 206, 0.38);
  --text: #d9e0ea;
  --text-leise: #8a97aa;
  --text-sehr-leise: #586477;
  --bernstein: #f2b134;
  --bernstein-hell: #ffd27a;
  --bernstein-hauch: rgba(242, 177, 52, 0.13);
  --rot: #ff6b5e;
  --sans: 'IBM Plex Sans Condensed', 'Arial Narrow', 'Liberation Sans Narrow', sans-serif;
  --mono: 'IBM Plex Mono', 'DejaVu Sans Mono', ui-monospace, monospace;
  --serif: 'IBM Plex Serif', 'DejaVu Serif', Georgia, serif;
  --rand: 14px;
  --spalte: 288px;
  --leiste: 64px;
  --fuss: 0px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--grund);
  color: var(--text);
  font: 400 13px/1.38 var(--sans);
  -webkit-font-smoothing: antialiased;
}

#buehne { position: fixed; inset: 0; }
#buehne canvas { display: block; width: 100%; height: 100%; outline: none; }

.tafel {
  background: var(--tafel);
  border: 1px solid var(--linie);
  backdrop-filter: blur(9px) saturate(115%);
  -webkit-backdrop-filter: blur(9px) saturate(115%);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}

/* ---------- linke Spalte ---------- */
#spalte-links {
  position: fixed;
  top: var(--rand);
  left: var(--rand);
  bottom: calc(var(--rand) * 2 + var(--leiste) + var(--fuss));
  width: var(--spalte);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
#spalte-links > * { pointer-events: auto; }

#kopf { flex: none; padding: 13px 15px 12px; position: relative; overflow: hidden; }
#kopf::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(var(--bernstein), rgba(242, 177, 52, 0));
}
.marke {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-leise);
}
.marke-trenner { width: 18px; height: 1px; background: var(--linie-stark); }
#titel {
  margin: 9px 0 10px;
  font: italic 400 19px/1.18 var(--serif);
  color: #f3f5f8;
  letter-spacing: 0.005em;
  text-wrap: balance;
}
.pflichtvermerk {
  display: inline-block;
  padding: 3px 7px 3px;
  border: 1px solid rgba(242, 177, 52, 0.7);
  background: var(--bernstein-hauch);
  color: var(--bernstein-hell);
  font: 500 10.5px/1.2 var(--sans);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.kopf-zeile { margin-top: 8px; color: var(--text-leise); font: 400 11px/1.3 var(--mono); }

#ebenen { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 0 10px; scrollbar-width: thin; scrollbar-color: var(--linie-stark) transparent; }

/* ---------- Abschnitte ---------- */
.abschnitt { padding: 10px 15px 4px; }
.abschnitt + .abschnitt { border-top: 1px solid var(--linie); }
.abschnitt-kopf {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 0 9px;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-leise);
}
.abschnitt-kopf::after { content: ''; flex: 1; height: 1px; background: var(--linie); }

/* ---------- Ebenen-Karten ---------- */
.ebene { padding: 6px 0 7px; border-bottom: 1px dashed rgba(150, 172, 206, 0.08); }
.ebene:last-child { border-bottom: 0; }
.ebene-kopf { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.ebene-name { flex: 1; min-width: 0; }
.ebene-name b { display: block; font-weight: 500; font-size: 13px; color: var(--text); letter-spacing: 0.01em; }
.ebene-name small { display: block; color: var(--text-sehr-leise); font: 400 10.5px/1.25 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ebene.aus .ebene-name b { color: var(--text-leise); }
.muster { width: 46px; height: 7px; border: 1px solid var(--linie-mittel); image-rendering: pixelated; flex: none; }
.ebene.aus .muster { opacity: 0.35; }
.ebene-regler { margin: 7px 0 2px 22px; display: grid; gap: 5px; }
.ebene.aus .ebene-regler { display: none; }

/* Schalter (Kaestchen) */
.kaestchen { appearance: none; -webkit-appearance: none; flex: none; width: 13px; height: 13px; margin: 0; border: 1px solid var(--linie-stark); background: transparent; display: grid; place-content: center; cursor: pointer; }
.kaestchen::after { content: ''; width: 7px; height: 7px; background: var(--bernstein); transform: scale(0); transition: transform 0.12s ease-out; }
.kaestchen:checked { border-color: var(--bernstein); }
.kaestchen:checked::after { transform: scale(1); }
.kaestchen:focus-visible { outline: 1px solid var(--bernstein-hell); outline-offset: 2px; }

/* Regler */
.regler { display: grid; grid-template-columns: 76px 1fr 52px; align-items: center; gap: 8px; }
.regler-name { color: var(--text-leise); font-size: 11.5px; white-space: nowrap; }
.regler output { font: 400 10.5px/1 var(--mono); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 1px; background: var(--linie-stark); }
input[type='range']::-moz-range-track { height: 1px; background: var(--linie-stark); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 9px; height: 9px; margin-top: -4px; background: var(--tafel-fest); border: 1px solid var(--bernstein); }
input[type='range']::-moz-range-thumb { width: 9px; height: 9px; border-radius: 0; background: var(--tafel-fest); border: 1px solid var(--bernstein); }
input[type='range']:hover::-webkit-slider-thumb { background: var(--bernstein); }
input[type='range']:focus-visible { outline: none; }
input[type='range']:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--bernstein-hauch); }

/* Wahl (Segmente) */
.zeile { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 8px; }
.wahl { display: flex; border: 1px solid var(--linie-mittel); }
.wahl button { flex: 1; padding: 3px 6px; border: 0; border-left: 1px solid var(--linie); background: transparent; color: var(--text-leise); font: 500 11px/1.2 var(--sans); letter-spacing: 0.03em; cursor: pointer; }
.wahl button:first-child { border-left: 0; }
.wahl button:hover { color: var(--text); background: rgba(150, 172, 206, 0.06); }
.wahl button.an { color: #120c02; background: var(--bernstein); }
select {
  width: 100%;
  padding: 3px 6px;
  background: var(--tafel-fest);
  color: var(--text);
  border: 1px solid var(--linie-mittel);
  font: 400 11.5px/1.2 var(--sans);
  border-radius: 0;
}

/* Knoepfe */
.knopf { padding: 4px 9px; background: transparent; color: var(--text-leise); border: 1px solid var(--linie-mittel); font: 500 11px/1.2 var(--sans); letter-spacing: 0.04em; cursor: pointer; }
.knopf:hover { color: var(--text); border-color: var(--linie-stark); }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- rechte Spalte ---------- */
#rechts {
  position: fixed;
  top: var(--rand);
  right: var(--rand);
  bottom: calc(var(--rand) * 2 + var(--leiste) + var(--fuss));
  width: var(--spalte);
  overflow-y: auto;
  padding: 4px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--linie-stark) transparent;
}
.tabelle { display: grid; grid-template-columns: 70px 1fr; row-gap: 3px; column-gap: 8px; font-size: 12px; }
.tabelle dt { color: var(--text-leise); }
.tabelle dd { margin: 0; font: 400 11.5px/1.35 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.zeit-gross { font: 500 22px/1 var(--mono); color: #f4f6f9; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.zeit-gross small { font: 400 11px/1 var(--mono); color: var(--text-leise); margin-left: 4px; letter-spacing: 0; }
.zeit-zeile { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.bildnr { font: 400 11px/1 var(--mono); color: var(--text-leise); }

.diagnose { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; margin-bottom: 9px; }
.diagnose-name { font: 400 11px/1.3 var(--mono); color: var(--text-leise); }
.diagnose-wert { font: 500 11.5px/1.3 var(--mono); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.diagnose canvas { grid-column: 1 / -1; width: 100%; height: 26px; }
.diagnose-spanne { grid-column: 1 / -1; font: 400 10px/1.2 var(--mono); color: var(--text-sehr-leise); }

.legende { margin-bottom: 11px; }
.legende-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.legende-kopf b { font-weight: 500; font-size: 12px; }
.legende-kopf span { font: 400 10px/1.2 var(--mono); color: var(--text-sehr-leise); text-align: right; }
.legende canvas { display: block; width: 100%; height: 9px; border: 1px solid var(--linie-mittel); image-rendering: pixelated; }
.legende-ticks { position: relative; height: 14px; margin-top: 2px; font: 400 10px/1 var(--mono); color: var(--text-leise); font-variant-numeric: tabular-nums; }
.legende-ticks span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }
.legende-ticks span:first-child { transform: none; }
.legende-ticks span:last-child { transform: translateX(-100%); }
.legende-ticks span::before { content: ''; position: absolute; left: 50%; top: -4px; width: 1px; height: 3px; background: var(--linie-stark); }
.legende-ticks span:first-child::before { left: 0; }
.legende-ticks span:last-child::before { left: auto; right: 0; }
.legende-text { font-size: 11px; color: var(--text-leise); line-height: 1.35; }
.achsfarben i { display: inline-block; width: 9px; height: 2px; margin: 0 4px 2px 0; vertical-align: middle; }

.leistung { font: 400 10.5px/1.45 var(--mono); color: var(--text-leise); font-variant-numeric: tabular-nums; }
.leistung b { color: var(--text); font-weight: 500; }
.quelle { font: 400 10.5px/1.4 var(--mono); color: var(--text-leise); overflow-wrap: anywhere; }

/* ---------- Zeitleiste ---------- */
#zeitleiste {
  position: fixed;
  left: var(--rand);
  right: var(--rand);
  bottom: calc(var(--rand) + var(--fuss));
  height: var(--leiste);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}
.transport { display: flex; gap: 2px; }
.transport button { width: 32px; height: 30px; display: grid; place-content: center; padding: 0; background: transparent; border: 1px solid transparent; color: var(--text-leise); cursor: pointer; }
.transport button:hover { color: var(--text); border-color: var(--linie-mittel); }
.transport button svg { width: 14px; height: 14px; fill: currentColor; }
.transport button.spielen { width: 38px; height: 34px; border-color: var(--bernstein); color: var(--bernstein); }
.transport button.spielen:hover { background: var(--bernstein-hauch); color: var(--bernstein-hell); }
.spur { flex: 1; position: relative; height: 34px; display: flex; flex-direction: column; justify-content: center; }
.spur-puffer { position: absolute; left: 0; top: 12px; width: 100%; height: 3px; pointer-events: none; }
.spur input[type='range'] { position: relative; z-index: 1; }
.spur input[type='range']::-webkit-slider-runnable-track { background: var(--linie-mittel); }
.spur input[type='range']::-webkit-slider-thumb { width: 3px; height: 16px; margin-top: -8px; background: var(--bernstein); border: 0; }
.spur input[type='range']::-moz-range-thumb { width: 3px; height: 16px; background: var(--bernstein); border: 0; }
.spur-marken { display: flex; justify-content: space-between; font: 400 10px/1 var(--mono); color: var(--text-sehr-leise); margin-top: 4px; }
.zeitanzeige { min-width: 172px; text-align: right; }
.zeitanzeige .zeit-gross { font-size: 17px; }
.tempo { display: flex; align-items: center; gap: 6px; color: var(--text-leise); font-size: 11px; }
.tempo select { width: auto; }
.schalter-klein { display: flex; align-items: center; gap: 6px; color: var(--text-leise); font-size: 11.5px; cursor: pointer; user-select: none; }

/* ---------- Meldungen, Laden, Start ---------- */
#meldungen { position: fixed; top: var(--rand); left: 50%; transform: translateX(-50%); display: grid; gap: 6px; width: min(560px, calc(100vw - 2 * var(--spalte) - 60px)); z-index: 5; }
.meldung { padding: 8px 12px; background: rgba(28, 10, 8, 0.92); border: 1px solid rgba(255, 107, 94, 0.55); color: #ffd9d4; font-size: 12px; }
.meldung.hinweis { background: rgba(26, 20, 6, 0.92); border-color: rgba(242, 177, 52, 0.5); color: #ffe7b8; }
#laden { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 12px; color: var(--text-leise); font: 400 12px/1 var(--mono); letter-spacing: 0.04em; transition: opacity 0.4s; }
#laden.fertig { opacity: 0; pointer-events: none; }
.laden-strich { width: 140px; height: 1px; background: linear-gradient(90deg, transparent, var(--bernstein), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: strich 1.1s linear infinite; }
@keyframes strich { from { background-position: -100% 0; } to { background-position: 200% 0; } }

.start { position: fixed; inset: 0; display: grid; place-items: center; }
.start-tafel { width: min(560px, 92vw); padding: 26px 28px 22px; }
.start-tafel h2 { margin: 6px 0 12px; font: italic 400 26px/1.15 var(--serif); }
.start-tafel p { color: var(--text-leise); margin: 0 0 12px; }
.start-tafel a { color: var(--bernstein-hell); text-decoration: none; border-bottom: 1px solid rgba(242, 177, 52, 0.35); }
.start-tafel a:hover { border-bottom-color: var(--bernstein); }
.start-tafel ul { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 6px; font: 400 12px/1.3 var(--mono); }
.start-tafel code { font: 400 11.5px/1.3 var(--mono); color: var(--text); }

/* ---------- Auftritt ---------- */
@media (prefers-reduced-motion: no-preference) {
  #kopf, #ebenen, #rechts, #zeitleiste { animation: auftritt 0.75s cubic-bezier(0.2, 0.7, 0.15, 1) both; }
  #kopf { animation-delay: 0.05s; }
  #ebenen { animation-delay: 0.16s; }
  #rechts { animation-delay: 0.24s; }
  #zeitleiste { animation-delay: 0.32s; }
  #buehne { animation: aufblenden 1.4s ease-out both; }
}
@keyframes auftritt { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes aufblenden { from { opacity: 0; } to { opacity: 1; } }

body.ohne-daten #spalte-links, body.ohne-daten #rechts, body.ohne-daten #zeitleiste { display: none; }

/* Fotomodus (?foto=1): keine Auftritts- und Uebergangsanimationen, damit Bildschirmfotos reproduzierbar sind */
.foto *, .foto *::before, .foto *::after { animation: none !important; transition: none !important; }
.diagnose[hidden] { display: none; }
#rechts .knopf { margin: 2px 0 8px; }
.zeit-gross small.zeit-name { margin: 0 6px 0 0; text-transform: uppercase; letter-spacing: 0.12em; font: 600 10px/1 var(--sans); }
.achsfarben i.achse-x { background: #ff6e5e; }
.achsfarben i.achse-y { background: #75eb85; }
.achsfarben i.achse-z { background: #6ba8ff; }

/* ---------- Kinomodus (?ui=0): nur das Bild ---------- */
.ohne-ui #spalte-links, .ohne-ui #rechts, .ohne-ui #zeitleiste, .ohne-ui #meldungen, .ohne-ui #rechtliches { display: none !important; }

/* ---------- Seitentafeln ein/aus ---------- */
body.tafeln-aus #ebenen, body.tafeln-aus #rechts { display: none; }
.tafel-knopf[aria-pressed='false'] { color: var(--bernstein); border-color: rgba(242, 177, 52, 0.5); }

/* ---------- Fusszeile (oeffentliche Fassung) ---------- */
body.mit-fuss { --fuss: 20px; }
#rechtliches {
  position: fixed;
  left: var(--rand);
  right: var(--rand);
  bottom: 5px;
  height: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  font: 400 10.5px/18px var(--sans);
  letter-spacing: 0.02em;
  color: var(--text-sehr-leise);
  white-space: nowrap;
}
#rechtliches .fuss-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#rechtliches .fuss-links { flex: none; }
#rechtliches a { color: var(--text-leise); text-decoration: none; border-bottom: 1px solid var(--linie-mittel); }
#rechtliches a:hover { color: var(--bernstein-hell); border-bottom-color: var(--bernstein); }
.kopf-hinweis { margin-top: 6px; color: var(--text-leise); font: 400 11px/1.35 var(--sans); }
.kopf-hinweis a { color: var(--bernstein-hell); text-decoration: none; border-bottom: 1px solid rgba(242, 177, 52, 0.35); }

/* ---------- schmale Bildschirme ---------- */
@media (max-width: 820px) {
  :root { --spalte: min(320px, calc(100vw - 28px)); }
  #zeitleiste { gap: 8px; padding: 0 8px; }
  #zeitleiste .tempo, #zeitleiste .schalter-klein, .spur-marken { display: none; }
  .zeitanzeige { min-width: 0; }
  .zeitanzeige .zeit-gross { font-size: 13px; }
  .transport button { width: 26px; }
}
.marke a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.marke a:hover { color: var(--bernstein-hell); border-bottom-color: var(--bernstein); }
