/* ================================================================
   ui.css — die Bausteine aller drei Oberflaechen
   Wortmarke, Brett, Knoepfe, Felder, Karten,
   Chips, Toast.

   Hier steht KEIN einziger Farb- oder Masswert: alles kommt aus
   tokens.css (Leitplanke 6). Was nur eine Seite betrifft -- ihr
   Raster --, steht im <style> dieser Seite, ebenfalls nur aus Tokens.
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background-color: var(--color-bg);
  background-image:
    radial-gradient(70rem 45rem at 0% -10%, var(--color-bg-glow-1), transparent 62%),
    radial-gradient(60rem 45rem at 100% 110%, var(--color-bg-glow-2), transparent 62%);
  background-attachment: fixed;
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

/* ----------------------------------------------------------------
   Wortmarke: GUESS als fuenf Kacheln, "together" daneben.
   Groesse haengt allein an font-size -- einmal setzen, alles skaliert.
---------------------------------------------------------------- */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-black);
  line-height: 1;
  text-decoration: none;
  color: var(--color-text);
}
.wordmark-tiles { display: inline-flex; gap: 0.14em; }
.wordmark-tiles i {
  display: grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 0.28em;
  font-style: normal;
  font-size: 0.82em;
  background: var(--color-absent);
  color: var(--color-on-absent);
}
.wordmark-tiles i:nth-child(1),
.wordmark-tiles i:nth-child(5) { background: var(--color-correct); color: var(--color-on-correct); box-shadow: var(--glow-correct); }
.wordmark-tiles i:nth-child(3) { background: var(--color-present); color: var(--color-on-present); box-shadow: var(--glow-present); }
.wordmark-text { font-size: 1.28em; letter-spacing: -0.03em; }

/* Gestapelt und gross: Beitritts- und Wirt-Seite */
.wordmark--hero {
  flex-direction: column;
  gap: 0.3em;
  font-size: clamp(1.6rem, 8vw, 2.5rem);
}
.wordmark--hero .wordmark-text { font-size: 1.5em; }
.wordmark--hero .wordmark-tiles i { animation: tile-drop 0.6s var(--ease-out) both; }
.wordmark--hero .wordmark-tiles i:nth-child(2) { animation-delay: 0.07s; }
.wordmark--hero .wordmark-tiles i:nth-child(3) { animation-delay: 0.14s; }
.wordmark--hero .wordmark-tiles i:nth-child(4) { animation-delay: 0.21s; }
.wordmark--hero .wordmark-tiles i:nth-child(5) { animation-delay: 0.28s; }

@keyframes tile-drop {
  from { opacity: 0; transform: translateY(-0.5em) rotateX(-80deg); }
  to   { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------------
   Brett und Kacheln
   Die Groesse kommt aus --tile-size; die Leinwand setzt sie am Brett
   einfach groesser, der Rest rechnet mit.
---------------------------------------------------------------- */
.board {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  grid-auto-rows: var(--tile-size);
  gap: var(--tile-gap);
  perspective: 50rem;
}

.tile {
  display: grid;
  place-items: center;
  border: var(--tile-border-w) solid var(--color-tile-border);
  border-radius: calc(var(--tile-size) * var(--tile-radius-ratio));
  background: var(--color-tile-bg);
  color: var(--color-text);
  font-size: calc(var(--tile-size) * var(--tile-font-ratio));
  font-weight: var(--font-weight-black);
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}

/* Getippt, noch nicht gewertet */
.tile[data-state="active"] {
  background: var(--color-tile-bg-active);
  border-color: var(--color-tile-border-active);
  animation: tile-pop var(--dur-pop) var(--ease-out);
}

/* Gewertet: die Kachel dreht sich um und zeigt ihre Farbe. */
.tile[data-state="correct"] { background: var(--color-correct); border-color: var(--color-correct); color: var(--color-on-correct); box-shadow: var(--glow-correct); }
.tile[data-state="present"] { background: var(--color-present); border-color: var(--color-present); color: var(--color-on-present); box-shadow: var(--glow-present); }
.tile[data-state="absent"]  { background: var(--color-absent);  border-color: var(--color-absent);  color: var(--color-on-absent); }

.tile[data-state="correct"],
.tile[data-state="present"],
.tile[data-state="absent"] { animation: tile-reveal var(--dur-flip) ease both; }

/* Von links nach rechts, eine nach der anderen. Die Kacheln liegen flach im
   Brett (30 Geschwister), die Spalte ergibt sich also aus 5n+k. */
.tile:nth-child(5n+2):is([data-state="correct"], [data-state="present"], [data-state="absent"]) { animation-delay: calc(var(--flip-stagger) * 1); }
.tile:nth-child(5n+3):is([data-state="correct"], [data-state="present"], [data-state="absent"]) { animation-delay: calc(var(--flip-stagger) * 2); }
.tile:nth-child(5n+4):is([data-state="correct"], [data-state="present"], [data-state="absent"]) { animation-delay: calc(var(--flip-stagger) * 3); }
.tile:nth-child(5n+5):is([data-state="correct"], [data-state="present"], [data-state="absent"]) { animation-delay: calc(var(--flip-stagger) * 4); }

@keyframes tile-pop {
  from { transform: scale(0.86); }
  60%  { transform: scale(1.06); }
  to   { transform: scale(1); }
}

/* Erste Haelfte: die ungewertete Kachel kippt weg. Auf der Kante springt die
   Farbe um (step-start), zweite Haelfte: sie kommt gefaerbt zurueck. Bis
   dahin -- auch waehrend des Versatzes -- sieht sie aus wie getippt. */
@keyframes tile-reveal {
  0% {
    transform: rotateX(0);
    background: var(--color-tile-bg-active);
    border-color: var(--color-tile-border-active);
    color: var(--color-text);
    box-shadow: none;
  }
  49.9% {
    transform: rotateX(-90deg);
    background: var(--color-tile-bg-active);
    border-color: var(--color-tile-border-active);
    color: var(--color-text);
    box-shadow: none;
    animation-timing-function: step-start;
  }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0); }
}

/* ----------------------------------------------------------------
   Knoepfe
---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.8rem var(--space-5);
  border: var(--border-w) solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-key-bg);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; }

.btn-primary { background: var(--color-correct); color: var(--color-on-correct); box-shadow: var(--glow-button); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }

.btn-neutral { background: var(--color-surface-raised); border-color: var(--color-border); }
.btn-neutral:hover:not(:disabled) { border-color: var(--color-border-strong); }

.btn-danger { background: transparent; border-color: var(--color-error); color: var(--color-error); }
.btn-danger:hover:not(:disabled) { background: var(--color-error-soft); }

.btn-ghost {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border-color: var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}
.btn-ghost:hover { border-color: var(--color-border-strong); color: var(--color-text); }

/* ----------------------------------------------------------------
   Felder
---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }
.field-label { font-size: var(--font-size-sm); color: var(--color-text-muted); }
.field-hint  { font-size: var(--font-size-xs); color: var(--color-text-faint); }

.input {
  width: 100%;
  padding: 0.8rem var(--space-4);
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-empty);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-base);   /* 16px: darunter zoomt iOS beim Antippen */
  text-align: center;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input::placeholder { color: var(--color-text-faint); }
.input:focus { outline: none; border-color: var(--color-correct); box-shadow: var(--focus-ring); }

/* Fuenf Buchstaben, weit gesperrt: Beitrittscode und Wortschlange */
.input-code {
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-code);
  padding-left: calc(var(--space-4) + var(--tracking-code));  /* gleicht die Sperrung rechts aus */
}
.input-code::placeholder { font-weight: var(--font-weight-regular); letter-spacing: 0.04em; text-transform: none; }

/* Sprachwahl: zwei Pillen statt zweier Radioknoepfe */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-empty);
}
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented span {
  display: block;
  padding: 0.6rem var(--space-3);
  border-radius: calc(var(--radius-md) - var(--space-1));
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-align: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.segmented input:checked + span { background: var(--color-correct-soft); color: var(--color-correct); font-weight: var(--font-weight-bold); }
.segmented input:focus-visible + span { box-shadow: var(--focus-ring); }

/* ----------------------------------------------------------------
   Karten, Etiketten, Chips, Abzeichen
---------------------------------------------------------------- */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-5);
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}
.card-title { font-size: var(--font-size-md); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); }
.card-text  { font-size: var(--font-size-sm); color: var(--color-text-muted); }

.label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; }
.chips li {
  padding: var(--space-1) var(--space-3);
  border: var(--border-w) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1.4;
}
.chips li.me { border-color: var(--color-correct); color: var(--color-correct); }

.badge {
  display: inline-block;
  padding: 0.15rem var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  border: var(--border-w) solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  line-height: 1.6;
}

/* ----------------------------------------------------------------
   "Wer tippt gerade" -- eine Pille, die nur da ist, wenn sie etwas sagt.
   data-kind setzen game.js/bar.js: mine (du tippst), other (jemand
   anderes), wait (du musst warten).
---------------------------------------------------------------- */
.typing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--color-present-soft);
  color: var(--color-present);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-align: center;
}
.typing:empty { visibility: hidden; }
.typing[data-kind="mine"] { background: var(--color-correct-soft); color: var(--color-correct); }
.typing[data-kind="wait"] { background: var(--color-surface-raised); color: var(--color-text-muted); font-weight: var(--font-weight-medium); }

/* ----------------------------------------------------------------
   Toast
---------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  z-index: 100;
  max-width: calc(100vw - var(--space-6));
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--color-text);
  color: var(--color-bg);
  box-shadow: var(--shadow-pop);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(1rem);
  transition: opacity 0.2s, transform 0.2s var(--ease-out);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----------------------------------------------------------------
   Fusszeile: Rechtstexte und Kaffee
---------------------------------------------------------------- */
.legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
}
.legal a { text-decoration: none; }
.legal a:hover { color: var(--color-text); }

/* Ein Knopf, aber ein kleiner: violett umrandet, damit man ihn findet, und
   am Ende der Seite, damit er niemanden vom Spiel abhaelt. */
.coffee {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: var(--space-2);
  margin: var(--space-4) auto;
  padding: var(--space-2) var(--space-4);
  border: var(--border-w) solid var(--color-coffee);
  border-radius: var(--radius-pill);
  background: var(--color-coffee-soft);
  color: var(--color-coffee);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  line-height: 1.4;
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.coffee:hover, .coffee:focus-visible {
  background: var(--color-coffee);
  color: var(--color-on-coffee);
  box-shadow: var(--glow-coffee);
  transform: translateY(-1px);
}

/* Testlauf: sichtbar, aber nicht schoen -- wer das Band sieht, weiss, dass
   diese Session nicht im Bericht landet. */
.testbanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: var(--space-1) var(--space-3);
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.04em;
  color: var(--color-testbanner-text);
  background: var(--color-testbanner-bg);
}

/* ----------------------------------------------------------------
   Wer keine Bewegung will, bekommt keine.
---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
  }
}
