/* LoL-Dojo - Oberflaeche
 *
 * Regeln aus .claude/rules/webseiten.md sind hier umgesetzt:
 * kein Text-Cursor ausserhalb von Eingabefeldern, jeder Knopf leuchtet beim
 * Klick auf, sichtbarer Tastaturfokus, Zustand nie nur ueber Farbe.
 */

/* -- Kein Text-Cursor, wo kein Text eingegeben wird ------------------- */
:root { caret-color: transparent; }
input, textarea, select, [contenteditable] { caret-color: auto; }

/* user-select nur auf Knoepfe. Tabellen und Listen bleiben markierbar,
   dort stehen Werte, die man kopieren koennen muss. */
button, .knopf, .werkzeug, summary, .reiter {
  user-select: none; -webkit-user-select: none;
}

/* Eigenes display: darf das hidden-Attribut nicht ueberstimmen. */
[hidden] { display: none !important; }

:root {
  --grund: #0b0f14;
  --flaeche: #131a22;
  --flaeche-hoch: #1b242f;
  --rand: #263140;
  --schrift: #e6edf3;
  --schrift-leise: #93a4b8;
  --akzent: #3bc9ff;
  --warn: #ffb03b;
  --gefahr: #ff5c5c;
  --gut: #3bff8f;
  --radius: 10px;
  --schmal: 1100px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--schrift);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Inhalt nutzt die Breite, klebt nicht links an. */
.bahn {
  width: min(1600px, 100% - 3rem);
  margin-inline: auto;
}

a { color: var(--akzent); }

/* -- Kopf -------------------------------------------------------------- */
.kopf {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 0; border-bottom: 1px solid var(--rand);
  flex-wrap: wrap;
}
.kopf h1 { font-size: 1.1rem; margin: 0; font-weight: 650; letter-spacing: .01em; }
.kopf .weg { color: var(--schrift-leise); font-size: .9rem; }

/* -- Chips: Zustand ueber Form UND Text, nie nur ueber Farbe ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .6rem; border-radius: 999px;
  border: 1px solid var(--rand); background: var(--flaeche);
  font-size: .82rem; font-variant-numeric: tabular-nums;
}
.chip::before { content: "●"; font-size: .7em; }
.chip.gut::before { content: "✓"; color: var(--gut); }
.chip.warn::before { content: "!"; color: var(--warn); }
.chip.gefahr::before { content: "✕"; color: var(--gefahr); }
.chip.aus::before { content: "–"; color: var(--schrift-leise); }

/* -- Knoepfe ----------------------------------------------------------- */
button, .knopf {
  background: var(--flaeche-hoch); color: var(--schrift);
  border: 1px solid var(--rand); border-radius: var(--radius);
  padding: .5rem .8rem; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
}
button:hover, .knopf:hover { border-color: var(--akzent); }
button[disabled] { opacity: .45; cursor: not-allowed; }
button[aria-pressed="true"] { border-color: var(--akzent); background: #16303d; }
/* Gedrueckter Zustand zusaetzlich mit Zeichen, nicht nur Farbe. */
button[aria-pressed="true"]::after { content: "•"; color: var(--akzent); }

:focus-visible {
  outline: 2px solid var(--akzent); outline-offset: 2px;
}

/* Rueckmeldung auf jeden Klick - zentral gesetzt, siehe app.js.
   Ein Aufleuchten des Rahmens ist kein Bewegungsreiz und bleibt deshalb
   auch bei prefers-reduced-motion erhalten. */
.geklickt { animation: aufleuchten .45s ease-out; }
@keyframes aufleuchten {
  0%   { box-shadow: 0 0 0 0 rgba(59,201,255,.55); }
  100% { box-shadow: 0 0 0 10px rgba(59,201,255,0); }
}

/* -- Karten ------------------------------------------------------------ */
.gitter {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  margin: 1.2rem 0 3rem;
}
.karte {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1rem;
  display: flex; flex-direction: column; gap: .6rem;
  text-decoration: none; color: inherit;
}
.karte:hover { border-color: var(--akzent); }
.karte h2 { margin: 0; font-size: 1rem; }
.karte .satz { color: var(--schrift-leise); font-size: .92rem; }

/* -- Zahlenreihe ------------------------------------------------------- */
.zahlen { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.zahl { display: flex; flex-direction: column; }
.zahl b {
  font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.zahl span { color: var(--schrift-leise); font-size: .78rem; }

/* -- Spielansicht ------------------------------------------------------ */
.buehne {
  display: grid; gap: 1rem; margin: 1rem 0 2rem;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: start;
}
@media (max-width: 1100px) { .buehne { grid-template-columns: 1fr; } }

.leinwand-halter {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--rand);
  aspect-ratio: 16 / 9;
}
.leinwand-halter video { width: 100%; height: 100%; display: block; object-fit: contain; }
.leinwand-halter canvas {
  position: absolute; inset: 0; touch-action: none; cursor: crosshair;
}
.brett-eingabe {
  position: absolute; transform: translateY(-50%);
  background: rgba(0,0,0,.8); border: 1px solid var(--akzent);
  border-radius: 6px; padding: .25rem .5rem; font: inherit;
  min-width: 140px;
}

/* -- Werkzeugleiste ---------------------------------------------------- */
.werkzeuge {
  display: flex; gap: .4rem; flex-wrap: wrap; align-items: center;
  padding: .6rem; background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); margin-top: .6rem;
}
.werkzeug { padding: .45rem .6rem; min-width: 2.4rem; justify-content: center; }
.trenner { width: 1px; align-self: stretch; background: var(--rand); margin: 0 .3rem; }

/* Hilfsklassen statt style="" im HTML.
   Die Content-Security-Policy verbietet Inline-Styles; mit style-Attributen
   meldet der Browser bei jedem Laden einen Verstoss, und die Regel greift dann
   dort nicht. Gemessen 20.09.2026 im Browsertest. */
.dehnen { flex: 1; }
.abstand-gross { margin: 1.2rem 0; }
.abstand-unten { margin-bottom: 3rem; }
.farbreihe { display: flex; gap: .3rem; }
.regler { display: flex; align-items: center; gap: .4rem; }
.regler input[type="range"] { width: 80px; }
.brettstand { margin: .5rem 0 0; font-size: .85rem; }
.filterreihe { display: flex; gap: .4rem; margin: .8rem 0; flex-wrap: wrap; }
#datenlage-inhalt { padding: .5rem 0; }

.farbe {
  /* min-width aus .werkzeug wuerde den Kreis zum Oval ziehen - deshalb hier
     alle drei Masse setzen. Im Browsertest am 20.09.2026 aufgefallen. */
  width: 26px; height: 26px; min-width: 26px; flex: 0 0 26px;
  border-radius: 50%; padding: 0;
  border: 2px solid var(--rand);
}
.farbe[aria-pressed="true"] { border-color: var(--schrift); transform: scale(1.12); }
.farbe[aria-pressed="true"]::after { content: none; }

/* -- Zeitleiste -------------------------------------------------------- */
.leiste {
  position: relative; height: 46px; margin-top: .6rem;
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
}
.leiste .fortschritt {
  position: absolute; inset-block: 0; left: 0; width: 0;
  background: rgba(59,201,255,.16); pointer-events: none;
}
.leiste .marke {
  position: absolute; top: 4px; bottom: 4px; width: 3px;
  border-radius: 2px; background: var(--schrift-leise);
}
.leiste .marke.g5 { background: var(--gefahr); }
.leiste .marke.g4 { background: var(--warn); }
.leiste .marke.g3 { background: var(--akzent); }
.leiste .marke.zeichnung { background: var(--gut); top: 50%; }
.leiste .nadel {
  position: absolute; inset-block: 0; width: 2px; background: #fff;
  pointer-events: none;
}

/* -- Befundliste ------------------------------------------------------- */
.befunde { display: flex; flex-direction: column; gap: .5rem; max-height: 70vh; overflow-y: auto; }
.befund {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-left-width: 4px; border-radius: 8px; padding: .7rem .8rem;
  cursor: pointer; text-align: left; width: 100%; display: block;
}
.befund:hover { border-color: var(--akzent); }
.befund.g5 { border-left-color: var(--gefahr); }
.befund.g4 { border-left-color: var(--warn); }
.befund.g3 { border-left-color: var(--akzent); }
.befund .kopfzeile {
  display: flex; justify-content: space-between; gap: .6rem; align-items: baseline;
}
.befund .zeit {
  font-variant-numeric: tabular-nums; color: var(--schrift-leise);
  font-size: .82rem; white-space: nowrap;
}
.befund .titel { font-weight: 600; }
.befund .beleg { color: var(--schrift-leise); font-size: .88rem; margin-top: .3rem; }
.befund .rat { font-size: .88rem; margin-top: .4rem; }

/* Herkunft eines Befundes: gerechnet schlaegt gesehen schlaegt vermutet. */
.herkunft { font-size: .72rem; padding: .1rem .4rem; border-radius: 4px;
            border: 1px solid var(--rand); color: var(--schrift-leise); }

details > summary { cursor: pointer; padding: .4rem 0; }
details > summary::marker { color: var(--schrift-leise); }

.leise { color: var(--schrift-leise); }
.warnbalken {
  background: #2a1f10; border: 1px solid var(--warn); color: #ffd9a0;
  padding: .6rem .8rem; border-radius: var(--radius); margin: 1rem 0;
}

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--rand); }
th { color: var(--schrift-leise); font-weight: 500; }
td.zahl-spalte { font-variant-numeric: tabular-nums; text-align: right; }

/* -- Handy (15.10.2026) -------------------------------------------------
 * Desktop bleibt unveraendert; alles hier greift erst unterhalb der Umbrueche.
 * Ab 1100 px steht die Befundliste unter dem Video: dort keine eigene
 * Scrollbox mehr, sonst schneidet sie mitten in einer Karte ab und der Daumen
 * scrollt zwei Ebenen. */
@media (max-width: 1100px) {
  .befunde { max-height: none; overflow-y: visible; }
}

/* Handy hoch und quer (Querformat ist breiter als 700 px): Tippflaechen und
   Eingabeschrift. Maus-Geraete sind ueber pointer: coarse ausgenommen. */
@media (max-width: 700px), (pointer: coarse) and (max-height: 500px) {
  /* Querformat: Kerbe links oder rechts. */
  .bahn {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  button, .knopf { min-height: 44px; }
  .werkzeug { min-width: 44px; }
  /* Farbe: 44 px Tippflaeche, sichtbarer Kreis 26 px. Der Rand in Leistenfarbe
     deckt den Hintergrund (style.background aus spiel.js) aussen ab; der feine
     Innenring macht auch Schwarz auf dunkler Leiste sichtbar. */
  .farbe {
    width: 44px; height: 44px; min-width: 44px; flex: 0 0 44px;
    padding: 0; border: 9px solid var(--flaeche);
    box-shadow: inset 0 0 0 1px var(--rand);
  }
  .farbe[aria-pressed="true"] {
    border-color: var(--flaeche); transform: none;
    box-shadow: inset 0 0 0 1px var(--rand), 0 0 0 2px var(--schrift);
  }
  .werkzeug { white-space: nowrap; }
  select {
    background: var(--flaeche-hoch); color: var(--schrift);
    border: 1px solid var(--rand); border-radius: var(--radius);
    padding: 0 8px;
  }
  .regler { min-height: 44px; }
  .regler input[type="range"] { height: 44px; margin: 0; }
  /* Ab 16 px Schrift zoomt iOS beim Antippen nicht in das Feld. */
  select, input, textarea, .brett-eingabe { font-size: 16px; }
  select { min-height: 44px; }
  details > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; }
}

@media (max-width: 700px) {
  .bahn {
    width: auto;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Kopf und Kennzahlen enger, damit das Video im ersten Bildschirm steht. */
  .kopf { gap: 8px 12px; padding: 12px 0; }
  .zahlen { gap: 12px 16px; }
  .abstand-gross { margin: 16px 0; }

  .werkzeug { padding: .45rem .5rem; flex: 1 1 44px; }

  /* Werkzeugleiste in Zeilen: Abspielen | Zeichnen | Farben + Staerke | Verlauf.
     Die Trenner werden zu Zeilenumbruechen. */
  .werkzeuge { gap: 4px; padding: 8px; }
  .trenner { flex-basis: 100%; width: auto; height: 1px; margin: 4px 0; }
  #tempo { flex: 1 1 64px; }

  .farbreihe { flex: 1 1 100%; justify-content: space-between; gap: 4px; }

  .regler { flex: 1 1 100%; }
  .regler input[type="range"] { flex: 1; width: auto; }

  .filterreihe .werkzeug { flex: 0 1 auto; min-width: 72px; }
  .befund { padding: 12px; }
}

/* Handy: Schrift und Abstaende auf die Skala aus tokens.css (12 · 14 · 16 · 20 ·
   24 px; Abstaende 4 · 8 · 12 · 16 px). Am Desktop bleiben die rem-Werte. Die
   Abstaende in den Kartenfuessen setzt das Skript als style=, deshalb !important. */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .kopf h1 { font-size: 20px; }
  .kopf .weg, .chip, .brettstand, .karte .satz, .befund .zeit,
  .befund .beleg, .befund .rat, table { font-size: 14px; }
  .zahl b { font-size: 24px; }
  .zahl span, .herkunft { font-size: 12px; }
  .karte h2 { font-size: 16px; }

  button, .knopf { padding: 8px 12px; gap: 8px; }
  .werkzeug { padding: 8px; }
  .chip { padding: 4px 8px; gap: 4px; }
  .herkunft { padding: 2px 8px; }
  .karte { gap: 8px; }
  .gitter { margin: 16px 0 48px; }
  .leiste, .werkzeuge { margin-top: 8px; }
  .regler { gap: 8px; }
  .brettstand { margin: 8px 0 0; }
  .filterreihe { gap: 8px; margin: 12px 0; }
  #datenlage-inhalt { padding: 8px 0; }
  .befund .kopfzeile { gap: 8px; }
  .befund .beleg { margin-top: 4px; }
  .befund .rat { margin-top: 8px; }
  .befund > div:last-child, .karte > div:last-child { gap: 4px 8px !important; margin-top: 8px !important; }
  .karte > div:first-child { gap: 8px !important; }
  details > summary { padding: 8px 0; }
  .warnbalken { padding: 8px 12px; margin: 16px 0; }
  th, td { padding: 8px; }
  .abstand-unten { margin-bottom: 48px; }
}

/* Handy, Runde 2 (design-kritiker/alltags-tester 15.10.2026) ------------
 * Kopf: beide Chips gemeinsam in Zeile 2. Uebersicht: Spiele als kompakte
 * Zeilen (Kernsatz steht auf der Detailseite). Detail: Video bleibt beim
 * Scrollen oben stehen, Zeichenwerkzeuge erst auf Tipp ("Zeichnen"). */
@media (min-width: 701px) {
  #zeichnen-auf { display: none; }
}
@media (max-width: 700px) {
  .kopf .dehnen { flex: 0 0 100%; height: 0; }

  .gitter .karte {
    display: grid; grid-template-columns: 1fr auto; align-items: end;
    gap: 8px 12px; padding: 12px;
  }
  .gitter .karte > div:first-child { grid-column: 1 / -1; }
  .gitter .karte .satz { display: none; }
  .gitter .karte > .zahlen { gap: 16px; }
  .gitter .karte .zahl b { font-size: 20px; }
  .gitter .karte > div:last-child { margin-top: 0 !important; justify-content: flex-end; }
  .gitter .karte > div:last-child .chip:not(.warn) { display: none; }
  .gitter { gap: 8px; }

  /* Die Spalten-Huellen der Buehne loesen sich auf, damit das Video ueber
     Werkzeuge und Befundliste hinweg oben kleben bleibt. */
  .buehne { display: block; }
  .buehne > div { display: contents; }
  .buehne > aside { display: block; margin-top: 16px; }
  .leinwand-halter {
    position: sticky; top: env(safe-area-inset-top); z-index: 5;
  }

  #zeichnen-auf { flex: 1 1 100%; }
  .werkzeuge.zu #zeichnen-auf ~ * { display: none; }

  #kern .herkunft { border: 0; padding: 0; font-size: 12px; }

  /* Eingeklappt: Finger auf dem (klebenden) Video scrollt die Seite statt zu
     malen; der Stand-Hinweis erscheint erst mit den Werkzeugen. */
  .leinwand-halter.zu canvas { pointer-events: none; touch-action: auto; }
  .werkzeuge.zu + .brettstand { display: none; }

  /* Schwere als Wort, nicht nur als Randfarbe (gewicht 1 Hinweis … 5 kostet
     Spiele, s3_makro.py; ab 4 "schwer" wie auf der Uebersicht). */
  .befund .titel::before {
    display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px;
    color: var(--schrift-leise); content: "Hinweis";
  }
  .befund.g5 .titel::before { content: "! kostet Spiele"; color: var(--gefahr); }
  .befund.g4 .titel::before { content: "! schwer"; color: var(--warn); }
  .befund.g3 .titel::before { content: "mittel"; }
}

/* Nur Groessen- und Positionsaenderungen entfallen, das Aufleuchten bleibt. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .farbe[aria-pressed="true"] { transform: none; }
}

@media print {
  .werkzeuge, .leiste, video { display: none; }
  body { background: #fff; color: #000; }
}
