/* ============================================================================
   FunFlight Startliste — Komponenten
   ----------------------------------------------------------------------------
   Die Bausteine der Flight-Strip-Formensprache:
   Kontrollstreifen (.strip), Zeitinstrumente (.tfield), Übungs-Chips (.chip),
   Aktionsbuttons (.btn-*), Segmente, Fortschritts-Schwung, Dock, Toast.
   Kein Hover (Zielplattform iPhone) — Feedback über :active / Pressed-States.
   ========================================================================== */

/* ═══════════════════════════════════════════════════════════════════════ */
/* KONTROLLSTREIFEN — die zentrale Metapher                                  */
/* Aufbau: schmale Halteleiste links (wie im Strip-Board der Flugsicherung), */
/* Streifenkörper rechts. Abgeschlossene Legs kompakt, aktives Leg groß.     */
/* ═══════════════════════════════════════════════════════════════════════ */

.strip {
  position: relative;
  display: grid;
  grid-template-columns: var(--holder-w) 1fr;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-strip);
  box-shadow: var(--shadow-strip);
}

/* Halteleiste mit vertikaler Leg-Nummer */
.strip-holder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  border-radius: calc(var(--radius-strip) - 2px) 0 0 calc(var(--radius-strip) - 2px);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

/* Abrisskante: zwei "Lochungen" an der Naht zwischen Leiste und Körper */
.strip::before,
.strip::after {
  content: '';
  position: absolute;
  left: calc(var(--holder-w) - 5.5px);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bay);
  border: 1.5px solid var(--ink);
}
.strip::before { top: -6px; }
.strip::after  { bottom: -6px; }

.strip-body {
  padding: 10px 12px 11px;
  min-width: 0;
}

/* Route: Startort → Landeort */
.strip-route {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: 0.02em;
}
.strip-route .route-arrow {
  align-self: center;
  flex: none;
  color: var(--ink-faint);
}
.strip-route .route-tbd { color: var(--ink-faint); letter-spacing: 0.14em; }
.strip-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: var(--fs-small);
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Kompakte Zeitzeile abgeschlossener Streifen */
.strip-times {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.strip-times .mini-t { display: grid; gap: 1px; }
.strip-times .mini-t .microlabel { font-size: 8.5px; }
.strip-times .mini-t .mono {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

/* ---- Aktiver Streifen: aufgeklappt, rote Halteleiste -------------------- */
.strip--active {
  border-width: 2px;
  box-shadow: var(--shadow-active);
}
.strip--active .strip-holder {
  background: var(--red);
  font-weight: 700;
}
.strip--active .strip-body { padding: 14px 14px 12px; }
.strip--active .strip-route {
  font-size: var(--fs-strip);
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════ */
/* ZEITINSTRUMENTE — UTC führend (Zulu), Lokalzeit klein darunter            */
/* Im aktiven Streifen als 2×2-Raster; jedes Feld ist tappbar (Editieren).   */
/* ═══════════════════════════════════════════════════════════════════════ */

.tgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tfield {
  display: grid;
  gap: 2px;
  justify-items: start;
  text-align: left;
  min-height: var(--tap-min);
  padding: 8px 10px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--paper);
  transition: background var(--t-press);
}
.tfield:active { background: var(--bay); }

.tfield-utc {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--fs-time);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.tfield-utc .tz {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 2px;
}
.tfield-local {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink-faint);
  min-height: 0.9em;
}

/* Ungesetzte Zeit: "--:--", zurückhaltend */
.tfield.is-unset .tfield-utc { color: var(--ink-faint); font-weight: 400; }

/* Frisch gestempelt: kurzer roter Blitz als visuelles Feedback
   (iOS hat keine Vibration — Feedback ist rein visuell) */
@keyframes stamp-flash {
  0%   { background: var(--red-tint); border-color: var(--red); }
  100% { background: var(--paper);    border-color: var(--line); }
}
.tfield.just-set { animation: stamp-flash 900ms var(--ease-snap); }

/* ═══════════════════════════════════════════════════════════════════════ */
/* CHIPS — Übungen als Kniebrett-Zähler mit roten Tally-Badges               */
/* ═══════════════════════════════════════════════════════════════════════ */

.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 8px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 18px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  transition: transform var(--t-press), background var(--t-press), color var(--t-press);
}
.chip:active {
  background: var(--ink);
  color: var(--paper);
  transform: scale(0.95);
}

/* Roter Tally-Zähler, überlappt die Chip-Ecke */
.chip .tally {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--paper);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1;
}
@keyframes tally-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.45); }
  100% { transform: scale(1); }
}
.tally.pop { animation: tally-pop 260ms var(--ease-snap); }

/* Auswahl-Chips (Stammdaten auf dem Start-Screen): Zustand = Anthrazit */
.chip--select.is-selected {
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.chip--ghost { border-style: dashed; color: var(--ink-soft); }

/* ═══════════════════════════════════════════════════════════════════════ */
/* BUTTONS                                                                   */
/* ═══════════════════════════════════════════════════════════════════════ */

/* Der eine dominante Aktionsbutton (morpht durch die Vier-Tap-Sequenz) */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 0 20px;
  background: var(--red);
  color: #fff;
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: transform var(--t-press), background var(--t-press);
}
.btn-primary:active {
  background: var(--red-press);
  transform: translateY(1px) scale(0.985);
}
.btn-primary .btn-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity var(--t-morph), transform var(--t-morph);
}
/* Morph: Inhalt taucht kurz ab und mit neuem Text/Icon wieder auf */
.btn-primary .btn-inner.morph-out { opacity: 0; transform: translateY(8px); }

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 18px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  transition: transform var(--t-press), background var(--t-press), color var(--t-press);
}
.btn-ghost:active {
  background: var(--ink);
  color: var(--paper);
  transform: scale(0.985);
}
.btn-ghost .tally { position: static; margin-left: 4px; border-color: transparent; }

/* Kleiner runder Zusatzbutton (z.B. Rückgängig) */
.btn-round {
  flex: none;
  width: var(--tap-min);
  height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  transition: transform var(--t-press), background var(--t-press), color var(--t-press);
}
.btn-round:active { background: var(--ink); color: var(--paper); transform: scale(0.92); }

/* Textbutton (unauffällige Nebenaktion) */
.btn-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 10px;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-inline:active { color: var(--ink); }

/* ═══════════════════════════════════════════════════════════════════════ */
/* SEGMENTE (z.B. Modus FI/Solo, Export-Tabs) — Zustand in Anthrazit         */
/* ═══════════════════════════════════════════════════════════════════════ */

.segmented {
  display: flex;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-field);
  background: var(--paper);
  overflow: hidden;
}
.segmented > button {
  flex: 1;
  min-height: var(--tap-min);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--ink-soft);
  border-right: 1.5px solid var(--line);
  transition: background var(--t-press), color var(--t-press);
}
.segmented > button:last-child { border-right: none; }
.segmented > button.is-selected {
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.segmented > button:active:not(.is-selected) { background: var(--bay); }

/* ═══════════════════════════════════════════════════════════════════════ */
/* TAGS & FELDER                                                             */
/* ═══════════════════════════════════════════════════════════════════════ */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.tag--fill { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Eingabefeld im Instrumenten-Stil (Zähler, ICAO-Code) */
.field {
  display: grid;
  gap: 4px;
}
.field input {
  width: 100%;
  min-height: var(--tap-min);
  padding: 6px 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-field);
  background: var(--paper);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.625rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-tint);
}
.field .field-hint {
  font-size: var(--fs-small);
  color: var(--ink-faint);
}

/* ═══════════════════════════════════════════════════════════════════════ */
/* DOCK — fixe Aktionszone unten, in Daumenreichweite, Safe-Area beachtet    */
/* ═══════════════════════════════════════════════════════════════════════ */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  padding: 10px var(--space) calc(12px + var(--safe-bottom));
  background: var(--paper);
  border-top: 1.5px solid var(--ink);
  box-shadow: var(--shadow-dock);
}
.dock > * { max-width: 480px; width: 100%; margin: 0 auto; }
.dock-actions { display: grid; gap: 10px; }

/* ---- Fortschritts-Schwung: die Vier-Tap-Sequenz als roter Bogen --------- */
/* Der dynamische Schwung aus dem FunFlight-Logo, als Fortschrittsanzeige.   */
/* Die rote Linie füllt sich pro gesetztem Zeitstempel um ein Viertel;       */
/* gesteuert über die CSS-Variable --p (0–4) am <svg>-Element.               */
.swoosh-progress { width: 100%; }
.swoosh-progress .track { stroke: var(--line); }
.swoosh-progress .fill {
  stroke: var(--red);
  stroke-dasharray: var(--p, 0) 4;
  transition: stroke-dasharray 450ms var(--ease-snap);
}
.swoosh-progress .node { fill: var(--paper); stroke: var(--ink-faint); }
.swoosh-progress .node.done { fill: var(--red); stroke: var(--red); }
.swoosh-progress .node.now  { fill: var(--paper); stroke: var(--red); stroke-width: 3; }
.swoosh-progress .node-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  fill: var(--ink-faint);
}
.swoosh-progress .node-label.now { fill: var(--red); font-weight: 700; }

/* ═══════════════════════════════════════════════════════════════════════ */
/* SPLIT-CHIPS — Chip + eigene Minus-Fläche (Spec-Änderung 3a)               */
/* Ab Zählerstand ≥ 1 bekommt jeder Chip eine klar sichtbare Minus-Taste     */
/* direkt am Chip (Tap-Ziel ≥ 44pt); der Tally-Badge sitzt auf der Ecke.     */
/* ═══════════════════════════════════════════════════════════════════════ */

.chip-wrap {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.chip-wrap--grow { flex: 1; }
.chip-wrap--grow > :first-child { flex: 1; }

/* Chip verliert rechts die Rundung, Minus-Fläche schließt bündig an */
.chip--joined {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right-style: dashed !important;
}
.chip-minus {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border: 1.5px solid var(--ink);
  border-left: none;
  border-radius: 0 999px 999px 0;
  background: var(--paper);
  color: var(--ink);
  transition: background var(--t-press), color var(--t-press);
}
.chip-minus:active { background: var(--ink); color: var(--paper); }
.chip-minus--tall { border-radius: 0 var(--radius-btn) var(--radius-btn) 0; }
.chip-wrap > .tally {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--paper);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1;
  pointer-events: none;
}

/* Kompakter Chip (Filter, Vorschläge) */
.chip--small { min-height: 44px; padding: 0 14px; font-size: 0.8125rem; }

/* ═══════════════════════════════════════════════════════════════════════ */
/* STEPPER — Zähler-Korrektur im Leg-Editor (Spec-Änderung 3c)               */
/* ═══════════════════════════════════════════════════════════════════════ */

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-field);
  background: var(--paper);
  overflow: hidden;
}
.stepper-btn {
  width: 52px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-press), color var(--t-press);
}
.stepper-btn:active { background: var(--ink); color: var(--paper); }
.stepper-v {
  min-width: 40px;
  text-align: center;
  font-weight: 700;
  font-size: 1.125rem;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Zeile "Name ..... Stepper" im Leg-Editor */
.counter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.counter-row:last-of-type { border-bottom: none; }
.counter-row--big { border-bottom: none; padding-top: 14px; }
.counter-row--big .counter-name { font-weight: 700; }
.counter-name { font-family: var(--font-ui); font-size: 0.875rem; }

/* ═══════════════════════════════════════════════════════════════════════ */
/* HINWEIS-BOX — weiche Warnungen (Reihenfolge, Plausibilität, Fehler)       */
/* ═══════════════════════════════════════════════════════════════════════ */

.warn-box {
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--red-tint);
  border: 1.5px solid var(--red);
  border-radius: var(--radius-field);
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--ink);
}
.warn-box svg {
  display: inline-block;
  vertical-align: -2px;
  color: var(--red);
  margin-right: 3px;
}

/* ═══════════════════════════════════════════════════════════════════════ */
/* BOTTOM-SHEET — Editor-Fläche in Daumenreichweite                          */
/* ═══════════════════════════════════════════════════════════════════════ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  background: rgba(22, 24, 29, 0);
  transition: background 180ms;
}
.sheet-backdrop.show { background: rgba(22, 24, 29, 0.5); }
.sheet {
  width: 100%;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  border-radius: 18px 18px 0 0;
  transform: translateY(24px);
  opacity: 0;
  transition: transform 200ms var(--ease-snap), opacity 160ms;
}
.sheet-backdrop.show .sheet { transform: none; opacity: 1; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px var(--space) 8px;
}
.sheet-title { font-family: var(--font-ui); font-size: 1.125rem; }
.sheet-close {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
}
.sheet-close:active { background: var(--ink); color: var(--paper); }
.sheet-body {
  padding: 4px var(--space) calc(20px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet-text { font-size: var(--fs-small); color: var(--ink-soft); margin-bottom: 12px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 18px; }
.section-h--sheet { margin-top: 16px; }

/* Formular-Bausteine in Sheets */
.form-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.field--sheet input, .field--sheet textarea {
  width: 100%;
  min-height: 52px;
  padding: 6px 12px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-field);
  background: var(--paper);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
}
.field--sheet textarea {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  min-height: 72px;
  resize: none;
}
.field--sheet { display: grid; gap: 4px; margin-bottom: 8px; }
.field--sheet input:focus, .field--sheet textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-tint);
}
input.is-invalid { border-color: var(--red) !important; color: var(--red); }

/* ═══════════════════════════════════════════════════════════════════════ */
/* RÜCKGÄNGIG-LEISTE (Spec-Änderung 3b) — sitzt im Live-Dock                 */
/* ═══════════════════════════════════════════════════════════════════════ */

.undo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 4px 6px 4px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-field);
  animation: undo-in 200ms var(--ease-snap);
}
@keyframes undo-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.undo-bar .undo-label {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.undo-bar button {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 9px;
  color: var(--paper);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.875rem;
}
.undo-bar button:active { background: var(--paper); color: var(--ink); }

/* Runde Zusatz-Buttons in Zeilen (Stift am Sitzungskopf) */
.btn-round--small { width: 44px; height: 44px; border-color: var(--line); color: var(--ink-soft); }

/* Gefährliche Nebenaktion (Löschen): rote Kontur, niemals Füllung */
.btn-ghost--danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap-min);
  border: 1.5px solid var(--red);
  border-radius: var(--radius-btn);
  background: var(--paper);
  color: var(--red);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  transition: background var(--t-press), color var(--t-press);
}
.btn-ghost--danger:active { background: var(--red); color: #fff; }

/* ═══════════════════════════════════════════════════════════════════════ */
/* TOAST — kurze Hinweise                                                    */
/* ═══════════════════════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + var(--safe-bottom));
  transform: translateX(-50%) translateY(6px);
  z-index: 60;
  max-width: min(86vw, 340px);
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms var(--ease-snap);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
