/* EMBRACE CHANGE — Ebene 2: Komponenten
 *
 * Anatomie und Zustände nach shadcn/ui (Button, Field, Input, Textarea,
 * Toggle, Slider, Skeleton, Alert): jede Komponente hat einen sichtbaren
 * Fokusring, einen gedrückten Zustand und einen deaktivierten Zustand.
 * Der Feinschliff (Chip-Reihe, Auswahlkacheln, Bewertungszeile) folgt den
 * Mustern aus 21st.dev, statt sie pro Bildschirm neu zu erfinden.
 *
 * Mobil zuerst. Basiswerte gelten fürs Telefon, Medienabfragen erweitern
 * nach oben. Touch-Ziele mindestens 44px, Abstand dazwischen mindestens 8px.
 */

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

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

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  background: var(--background);
  color: var(--body);
  font-family: var(--font-sans);
  font-size: 16px;          /* verhindert das Auto-Zoom von iOS in Feldern */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* height:auto ist Pflicht, sobald das Bild width/height-Attribute trägt:
   sonst gewinnt das Attribut und jedes aspect-ratio läuft ins Leere. */
img { max-width: 100%; height: auto; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }

h1, h2, h3 {
  margin: 0;
  color: var(--foreground);
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -.02em;
  text-wrap: balance;
}

p { margin: 0; }
[hidden] { display: none !important; }

/* Ein Fokusring für alles. Nie entfernen, nur verschieben. */
:where(a, button, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- Button */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-3) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background var(--exit), border-color var(--exit),
              transform var(--exit), box-shadow var(--exit);
}

.btn:hover { background: var(--secondary-hover); }
/* Gedrückt: nur Skalierung, damit die Umgebung nicht springt. */
.btn:active { transform: scale(.98); }

.btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn--ghost {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 500;
}
.btn--ghost:hover { background: var(--muted); color: var(--foreground); }

.btn--block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ----------------------------------------------------------------- Field */

.field { display: grid; gap: var(--space-2); }

.field__label {
  color: var(--foreground);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.field__hint { color: var(--muted-foreground); font-size: .875rem; }

/* Fehler tragen nie nur Farbe: dunklerer Rotton plus Zeichen davor. */
.field__error {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  color: var(--destructive-strong);
  font-size: .875rem;
  font-weight: 500;
}
.field__error::before { content: "✗"; flex: none; }

.input, .textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input);
  color: var(--foreground);
  font-size: 1rem;
  line-height: 1.55;
  transition: border-color var(--exit), box-shadow var(--exit);
}

.input::placeholder, .textarea::placeholder { color: var(--placeholder); }

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(63, 125, 76, .18);
}

.textarea {
  min-height: 120px;
  max-height: 240px;
  resize: none;
  font-family: inherit;
}

.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--destructive);
}

/* ------------------------------------------------- Chip (Mehrfachauswahl) */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--body);
  font-size: .9375rem;
  line-height: 1.35;
  text-align: left;
  white-space: normal;         /* ganze Sätze dürfen umbrechen */
  cursor: pointer;
  transition: background var(--exit), border-color var(--exit),
              color var(--exit), transform var(--exit);
}

.chip:hover { border-color: var(--ring); }
.chip:active { transform: scale(.97); }

/* Gewählt: Farbe UND ein Häkchen, damit die Auswahl nicht nur farblich lesbar ist. */
.chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: 600;
}
.chip[aria-pressed="true"]::before { content: "✓ "; color: var(--ring); }

/* Starthilfe unter dem offenen Feld: ganze Sätze, wie jemand sie sagen würde.
   Auf dem Telefon einer je Zeile, damit kein Satz zerhackt wird. */
.chips--starter { flex-direction: column; align-items: stretch; }
.chip--starter { background: var(--muted); border-color: transparent; color: var(--body); }
.chip--starter:hover { background: var(--secondary); color: var(--secondary-foreground); }
@media (min-width: 560px) {
  .chips--starter { flex-direction: row; }
  .chips--starter .chip { flex: 1 1 calc(50% - var(--space-2)); }
}

/* -------------------------------------------------- Auswahlkachel (Liste) */

.options { display: grid; gap: var(--space-2); }

.option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: var(--space-3);
  align-items: center;
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--body);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--exit), background var(--exit), transform var(--exit);
}

.option:hover { border-color: var(--ring); }
.option:active { transform: scale(.99); }

.option__mark {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  color: transparent;
  font-size: .75rem;
  transition: background var(--exit), border-color var(--exit), color var(--exit);
}

.option[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--accent);
  color: var(--accent-foreground);
}
.option[aria-pressed="true"] .option__mark {
  border-color: var(--ring);
  background: var(--ring);
  color: #fff;
}
.option[aria-pressed="true"] .option__mark::before { content: "✓"; }

/* ---------------------------------------------------------------- Slider */

.slider { display: grid; gap: var(--space-3); }

.slider__value {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  color: var(--foreground);
  font-family: var(--font-serif);
  font-size: 2.5rem;
  line-height: 1;
}
.slider__value small {
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: .875rem;
}

.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;              /* volle Touch-Höhe, sichtbare Schiene ist dünner */
  background: transparent;
  cursor: pointer;
}

.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--primary) calc(var(--fill, 0) * 100%),
    var(--muted) calc(var(--fill, 0) * 100%)
  );
}
.slider input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--muted);
}
.slider input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--primary);
}

.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  margin-top: -11px;
  border: 3px solid var(--card);
  border-radius: var(--radius-full);
  background: var(--ring);
  box-shadow: var(--shadow-md);
}
.slider input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px;
  border: 3px solid var(--card);
  border-radius: var(--radius-full);
  background: var(--ring);
  box-shadow: var(--shadow-md);
}

.slider__scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted-foreground);
  font-size: .8125rem;
}

/* Solange der Regler unberührt ist, steht die Zahl blass da:
   sie ist noch keine Antwort, nur ein Startpunkt. */
.slider--unberuehrt .slider__value { color: var(--muted-foreground); }
.slider--unberuehrt input[type="range"]::-webkit-slider-thumb { background: var(--card); border-color: var(--ring); }
.slider--unberuehrt input[type="range"]::-moz-range-thumb { background: var(--card); border-color: var(--ring); }

/* --------------------------------------- Bewertungszeile (Korrekturzeile) */

.judgement {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.judgement .option { min-height: 52px; grid-template-columns: 20px 1fr; }

@media (min-width: 560px) {
  .judgement { grid-template-columns: repeat(4, 1fr); }
  .judgement .option { grid-template-columns: 1fr; justify-items: center; text-align: center; font-size: .9375rem; }
  .judgement .option__mark { display: none; }
}

/* ----------------------------------------------------------------- Karte */

.card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.card--quiet { background: var(--muted); border-color: transparent; box-shadow: none; }

/* ---------------------------------------------------------------- Hinweis */

.alert {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--destructive);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: #fff5f5;
  color: var(--destructive-strong);
  font-size: .9375rem;
}
.alert strong { display: block; }

.note {
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  font-size: .875rem;
}

/* -------------------------------------------------------------- Skeleton */

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--muted) 25%, #f7f2e6 37%, var(--muted) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--line { height: 14px; }
.skeleton--title { height: 30px; }

@keyframes shimmer { to { background-position: -135% 0; } }

/* ------------------------------------------------------ Fortschrittsleiste */

.rail { display: flex; gap: var(--space-2); }

.rail__seg {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--muted);
  overflow: hidden;
}
.rail__seg span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 420ms var(--ease);
}

/* --------------------------------------------------------------- Bewegung */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
