/* Basis und geteilte Komponenten aller Ansichten.
   Muster aus style/styletest.css und aushang/aushang.css übernommen. */

@import url("tokens.css");

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--grund-0);
  color: var(--text);
  font-family: var(--schrift-text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ol, ul, figure, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
/* hidden schlägt eigene display-Regeln – sonst bleiben ausgeblendete Blöcke sichtbar */
[hidden] { display: none !important; }

/* Sichtbarer Fokus überall, auch wo eigene Regeln greifen */
:focus-visible { outline: 3px solid var(--gold-hell); outline-offset: 3px; }

.nur-vorlesen { /* sichtbar nur für Screenreader */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Sprung zum Inhalt, erscheint erst beim Tabben */
.sprung {
  position: absolute;
  z-index: 200;
  top: 8px;
  left: 8px;
  min-height: var(--tippziel);
  padding: 11px 16px;
  background: var(--gold);
  color: var(--grund-0);
  font-weight: 700;
  border-radius: 4px;
  translate: 0 -200%;
}
.sprung:focus { translate: 0 0; }

/* ================================================================
   Platzhalter für fehlende GPT-Bilder (Mechanik aus dem Styletest)
   .ph = <img> mit CSS-Ersatz daneben; .fehlt setzt shared/platzhalter.js beim 404.
   Dateinamen-Etiketten erscheinen nur mit ?dev – im Betrieb sieht das niemand.
   ================================================================ */
.ph { position: relative; display: grid; }
.ph > * { grid-area: 1 / 1; }
.ph.fehlt > img { display: none; }
.ph:not(.fehlt) > .ph__ersatz { display: none; }

.dev .ph.fehlt { outline: 1px dashed rgb(245 210 122 / 0.45); outline-offset: 3px; }
.dev .ph-etikett.fehlt::after,
.dev .ph-bg.fehlt::after {
  content: "Platzhalter · " attr(data-datei) attr(data-ph-bg);
  position: absolute;
  z-index: 3;
  left: var(--etikett-x, 12px);
  bottom: var(--etikett-y, 12px);
  padding: 3px 8px;
  font: 600 15px/1.3 var(--schrift-text);
  color: var(--gold-hell);
  background: rgb(10 10 10 / 0.85);
  border: 1px dashed rgb(245 210 122 / 0.6);
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Sechseck-Icon ---------- */
.hex { --h: 72px; width: var(--h); height: var(--h); flex: none; }
.hex--32 { --h: 32px; }
.hex--40 { --h: 40px; }
.hex--48 { --h: 48px; }
.hex--56 { --h: 56px; }
.hex--88 { --h: 88px; }
.hex--120 { --h: 120px; }
.hex > img { width: 100%; height: 100%; object-fit: contain; }
.hex .ph__ersatz {
  place-self: center;
  display: grid;
  place-items: center;
  width: calc(var(--h) * 0.87);
  height: var(--h);
  clip-path: var(--hexagon);
  background: var(--gold-verlauf);
  font: 700 calc(var(--h) * 0.3) / 1 var(--schrift-titel);
  color: var(--gold-hell);
  position: relative;
  isolation: isolate;
}
.hex .ph__ersatz::before {
  content: "";
  position: absolute;
  inset: calc(var(--h) * 0.06);
  clip-path: var(--hexagon);
  background: radial-gradient(circle at 50% 35%, #3b3326, var(--grund-0) 75%);
  z-index: -1;
}

/* Spieler-Sechseck mit Initiale in Klassenfarbe */
.spieler-hex {
  --h: 66px;
  position: relative;
  display: grid;
  width: calc(var(--h) * 0.87);
  height: var(--h);
  flex: none;
}
.spieler-hex > * { grid-area: 1 / 1; }
.spieler-hex > b {
  place-self: center;
  display: grid;
  place-items: center;
  width: 84%;
  height: 84%;
  clip-path: var(--hexagon);
  background: radial-gradient(circle at 50% 30%, var(--k), color-mix(in srgb, var(--k) 65%, #000) 95%);
  font: 900 calc(var(--h) * 0.38) / 1 var(--schrift-titel);
  color: var(--grund-0);
}
.spieler-hex > img { width: 100%; height: 100%; object-fit: contain; }
.spieler-hex.fehlt { isolation: isolate; outline: none; }
.spieler-hex.fehlt > img { display: none; }
.spieler-hex.fehlt::before { /* Gold-Rahmen als Ersatz für hex-rahmen.png */
  content: "";
  grid-area: 1 / 1;
  clip-path: var(--hexagon);
  background: var(--gold-verlauf);
  z-index: -1;
}

/* ---------- Ornament-Trenner ---------- */
.trenner { margin: 20px 0; height: 26px; }
.trenner > img { width: 100%; height: 100%; object-fit: contain; }
.trenner .ph__ersatz {
  align-self: center;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
  position: relative;
}
.trenner .ph__ersatz::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  translate: -50% -50%;
  rotate: 45deg;
  background: var(--gold);
  box-shadow: 0 0 0 5px var(--grund-1), 0 0 0 6px var(--gold);
}

/* ================================================================
   Knöpfe – Mindesthöhe 44 px (Touch-Ziel)
   ================================================================ */
.knopf {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 8px 18px;
  border-radius: 4px;
  font: 700 17px/1.15 var(--schrift-text);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.knopf small { display: block; margin-top: 2px; font-size: 13px; font-weight: 600; opacity: 0.85; }
.knopf--gold {
  color: #1d1405;
  background: linear-gradient(180deg, #f5cf76, #e0a93b 55%, #c38a2a);
  border: 1px solid #7a5212;
  box-shadow: 0 3px 0 #7a5212;
}
.knopf--rand {
  color: var(--text);
  background: rgb(255 255 255 / 0.06);
  border: 2px solid var(--gold-linie);
}
/* Auf Pergament stehen die Rand-Knöpfe dunkel */
.pergament .knopf--rand { color: var(--tinte); background: rgb(255 255 255 / 0.12); border-color: var(--tinte-linie); }
.knopf--gefahr {
  color: var(--fehler);
  background: rgb(163 38 26 / 0.18);
  border: 2px solid var(--fehler);
}
.knopf--leise {
  color: var(--text-leise);
  background: none;
  border: 1px solid rgb(168 159 140 / 0.35);
}
.knopf--breit { width: 100%; }
.knopf:active { translate: 0 2px; }
.knopf[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.knopf[disabled]:active { translate: 0 0; }
.pergament .knopf:focus-visible { outline-color: var(--tinte-rot); }

/* ================================================================
   Formularfelder (Muster aus aushang/aushang.css)
   ================================================================ */
.feld { display: grid; gap: 6px; }
.feld__label { font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--text); }
.feld__optional {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border: 1px solid rgb(168 159 140 / 0.5);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-leise);
  vertical-align: 1px;
}
.feld__hinweis { font-size: 14px; line-height: 1.35; color: var(--text-leise); }
.feld__eingabe {
  width: 100%;
  min-height: var(--tippziel);
  padding: 10px 12px;
  font: 400 17px/1.45 var(--schrift-text); /* ≥ 16 px: iOS zoomt beim Fokus nicht */
  color: var(--text);
  background: rgb(0 0 0 / 0.35);
  border: 1px solid var(--gold-linie);
  border-radius: 4px;
}
.feld__eingabe::placeholder { color: rgb(168 159 140 / 0.7); }
.feld__eingabe:focus-visible { outline: 3px solid var(--gold-hell); outline-offset: 2px; background-color: rgb(0 0 0 / 0.55); }
.feld__eingabe[aria-invalid="true"] { border: 2px solid var(--fehler); }
textarea.feld__eingabe { resize: vertical; }
.feld__auswahl {
  appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.feld__auswahl option { background: var(--grund-2); }

.meldung {
  padding: 10px 12px 10px 14px;
  border-left: 4px solid var(--fehler);
  background: rgb(229 112 95 / 0.12);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--fehler);
}
.meldung--gut { border-left-color: var(--erfolg); background: rgb(143 206 122 / 0.12); color: var(--erfolg); }
.meldung:empty { display: none; }

/* ---------- Auswahl per Radio/Checkbox, als große Tippfläche ---------- */
.wahl {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tippziel);
  padding: 10px 14px;
  background: rgb(0 0 0 / 0.3);
  border: 1px solid var(--gold-linie);
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.3;
  cursor: pointer;
}
.wahl input { width: 22px; height: 22px; flex: none; accent-color: var(--gold); cursor: pointer; }
.wahl:has(input:checked) { border-color: var(--gold); background: rgb(224 169 59 / 0.12); }
.wahl:has(input:focus-visible) { outline: 3px solid var(--gold-hell); outline-offset: 2px; }
.wahl s { color: var(--text-leise); }

/* ---------- Fortschrittsbalken (Zeit, EP, Upload) ---------- */
.balken {
  position: relative;
  height: 8px;
  overflow: hidden;
  background: rgb(0 0 0 / 0.5);
  border-radius: 4px;
}
.balken > span {
  display: block;
  width: var(--wert, 0%);
  height: 100%;
  background: var(--gold-verlauf);
  transition: width 0.4s var(--wechsel-kurve);
}
.balken--knapp > span { background: linear-gradient(180deg, #f2a08c, var(--fehler) 60%, #8c3327); }

/* ---------- Karte: dunkle Panel-Fläche ---------- */
.panel {
  padding: 14px;
  background: rgb(24 24 24 / 0.82);
  border: 1px solid var(--gold-linie);
  border-radius: var(--radius);
}
.panel__kopf { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel__kopf h2 { font: 700 18px/1.1 var(--schrift-titel); color: var(--gold); }
.panel__kopf > :last-child:not(h2) { margin-left: auto; }

/* ---------- Plakette (Titelband) ---------- */
.plakette {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(180deg, #3b3630 0%, #1f1c19 55%, #151311 100%);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 5px #151311, inset 0 0 0 6px var(--gold-dunkel), 0 16px 40px rgb(0 0 0 / 0.6);
}
.plakette__stufe {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.plakette__name { margin-top: 4px; font: 700 26px/1.1 var(--schrift-titel); color: var(--text); }

/* ================================================================
   Szenen-Wechsler – nur für die Entwicklung, mit ?pur ausgeblendet
   ================================================================ */
.szenen {
  position: fixed;
  z-index: 150;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: rgb(8 8 8 / 0.94);
  border-top: 1px solid var(--gold-linie);
  font-size: 13px;
}
.szenen__titel {
  padding-right: 6px;
  font: 700 11px/1 var(--schrift-text);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-leise);
}
.szenen button,
.szenen a {
  min-height: 30px;
  padding: 5px 10px;
  color: var(--text-leise);
  background: rgb(255 255 255 / 0.05);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 999px;
  font: 600 13px/1 var(--schrift-text);
  text-decoration: none;
  cursor: pointer;
}
.szenen button:hover, .szenen a:hover { color: var(--text); }
.szenen button[aria-current="true"] { background: var(--gold); border-color: var(--gold); color: var(--grund-0); }
.szenen a { color: var(--gold); }
.pur .szenen { display: none; }
/* Platz, damit die Leiste nichts verdeckt – Seiten setzen padding-bottom: var(--szenen-luft) */
:root { --szenen-luft: 56px; }
.pur { --szenen-luft: 0px; }

/* ================================================================
   Weniger Bewegung: nichts fährt, dreht oder zoomt.
   Pauschal, damit keine Szene durchrutscht. Animationen mit fill-mode „both“
   springen dadurch auf ihren Endzustand; Szenen, deren Endzustand „unsichtbar“
   ist (TV-Schleifen), setzen in tv.css eine eigene Reduced-Motion-Regel.
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
