/* =====================================================================
   Parkmelder MS – Komponenten-Styles. Konsumiert ausschließlich Tokens
   aus tokens.css. Refined-minimal, zivil & wertig; ein Primär-Button je Screen.
   ===================================================================== */

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  color: var(--ink);
  background:
    radial-gradient(130% 70% at 50% -20%, rgba(15,90,99,.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
  margin: 0;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  z-index: 100;
}
.skip-link:focus {
  left: var(--sp-3);
  top: var(--sp-3);
  background: var(--surface);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
}

/* ---- Kopfleiste ----------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: var(--z-appbar);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--appbar-h);
  padding: var(--sp-2) var(--sp-4);
  padding-top: calc(var(--sp-2) + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: var(--on-brand);
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 6px 18px -12px rgba(10,55,61,.5);
}
.appbar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
}
.appbar__logo { height: 22px; width: auto; display: block; }
.appbar__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: var(--ls-tight);
}
.appbar__back, .appbar__settings {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--on-brand);
  border-radius: var(--r-sm);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.appbar__back:hover, .appbar__settings:hover { background: rgba(255,255,255,.24); }
.appbar__back:active, .appbar__settings:active { transform: scale(.94); }
.appbar__back { font-size: 1.7rem; }

/* ---- Screen-Gerüst -------------------------------------------------- */
.app { flex: 1; display: flex; }
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  animation: screen-in var(--dur-slow) var(--ease-out) both;
}
.screen[hidden] { display: none; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
  -webkit-overflow-scrolling: touch;
}
.screen__body--center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
}
.screen__action {
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(242,245,240,0), var(--bg) 22%);
  position: sticky;
  bottom: 0;
}
.screen__title { font-size: var(--text-xl); margin-bottom: var(--sp-2); }
.screen__subtitle {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 0 0 var(--sp-5);
  line-height: var(--lh-snug);
}

/* ---- Hero / Branding ------------------------------------------------ */
.hero { text-align: center; }
.hero__logo {
  width: 92px; height: 92px;
  display: block;
  margin: 0 auto var(--sp-4);
  border-radius: var(--r-lg);
  filter: drop-shadow(0 14px 26px rgba(10,55,61,.28));
  animation: logo-pop var(--dur-slow) var(--ease-out) both;
}
@keyframes logo-pop {
  from { opacity: 0; transform: scale(.86); }
  to   { opacity: 1; transform: scale(1); }
}
.hero__title {
  font-size: var(--text-3xl);
  margin-bottom: var(--sp-1);
}
.hero__claim {
  color: var(--brand);
  font-weight: 600;
  font-size: var(--text-md);
  margin: 0;
  letter-spacing: var(--ls-normal);
}

/* ---- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 700;
  border: none;
  border-radius: var(--r-md);
  padding: 0 var(--sp-5);
  min-height: var(--tap-min);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn--block { width: 100%; }
.btn--xl { min-height: 4rem; font-size: var(--text-lg); border-radius: var(--r-lg); }

.btn--primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--on-accent);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn--primary:hover { box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.18); }
.btn--primary:focus-visible { box-shadow: var(--ring-accent), var(--shadow-md); }
.btn--primary:disabled {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}
.btn--ghost {
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn--ghost:hover { background: var(--surface-2); }
.btn__icon { font-size: 1.25em; line-height: 1; }

.linkbtn {
  background: none; border: none; padding: 0;
  color: var(--brand);
  font: inherit; font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.linkbtn:hover { color: var(--brand-strong); }

/* ---- Felder --------------------------------------------------------- */
.field { margin-bottom: var(--sp-4); }
.field__label {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink-2);
  margin-bottom: var(--sp-2);
}
.input {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0.8rem 0.9rem;
  min-height: var(--tap-min);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring-brand);
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none' stroke='%2366756f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.4rem;
}
.input--lg { font-size: var(--text-lg); font-weight: 600; min-height: 3.6rem; }
.input--plate {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  font-family: var(--font-display);
}
.field--highlight { position: relative; }
.field--highlight .input {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.field--highlight .input:focus { box-shadow: var(--ring-accent); }
.field--highlight .field__label { color: var(--accent-strong); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

.hint { color: var(--muted); font-size: var(--text-xs); margin: var(--sp-2) 0 0; line-height: var(--lh-snug); }
.hint--center { text-align: center; }
.error-text { color: var(--err); }

/* ---- Chips (Verstoß-Auswahl) --------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.chip {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-pill);
  padding: 0.65rem 1rem;
  min-height: 2.9rem;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip:active { transform: scale(.97); }
.chip--active {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}
.chip--active:hover { color: var(--on-brand); }
.chip--ghost {
  border-style: dashed;
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--accent-tint);
}
.queue-indicator { margin-top: var(--sp-2); }

/* ---- Umschalter (Behinderung) -------------------------------------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--line);
}
.toggle-row__label { font-weight: 600; display: block; }
.toggle-row__hint { color: var(--muted); font-size: var(--text-xs); }
.switch { position: relative; display: inline-block; width: 54px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--line-strong);
  border-radius: var(--r-pill);
  transition: background var(--dur) var(--ease);
}
.switch__track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring-brand); }

.switch-inline {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-3) 0;
  font-weight: 500;
  cursor: pointer;
}
.switch-inline input { width: 22px; height: 22px; accent-color: var(--brand); }

/* ---- Foto-Vorschau -------------------------------------------------- */
.photo-preview { margin: 0 0 var(--sp-5); }
.photo-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  box-shadow: var(--shadow-sm);
}
.photo-preview__status {
  font-size: var(--text-xs);
  margin-top: var(--sp-2);
  color: var(--muted);
}
.photo-preview__status[data-kind="ok"] { color: var(--ok); }
.photo-preview__status[data-kind="warn"] { color: var(--warn); }
.photo-preview__status[data-kind="pending"]::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid var(--brand);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ---- Reporter-Karte ------------------------------------------------- */
.reporter-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  line-height: var(--lh-snug);
}
.reporter-card #reporter-summary { font-size: var(--text-sm); }

/* ---- Vorschau der E-Mail ------------------------------------------- */
.preview {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-top: var(--sp-6);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.preview__summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  list-style: none;
}
.preview__summary::-webkit-details-marker { display: none; }
.preview__summary::before { content: "▸ "; }
.preview[open] .preview__summary::before { content: "▾ "; }
.preview__subject { font-weight: 700; margin: var(--sp-4) 0 var(--sp-3); font-size: var(--text-sm); }
.preview__body {
  white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface-sunken);
  padding: var(--sp-4);
  border-radius: var(--r-sm);
  overflow-x: auto;
  margin: 0;
}

/* ---- Onboarding / Notice ------------------------------------------- */
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.notice__title {
  font-size: var(--text-md);
  margin-bottom: var(--sp-3);
  color: var(--brand);
}
.notice__list { margin: 0; padding-left: var(--sp-5); }
.notice__list li { margin-bottom: var(--sp-3); line-height: var(--lh-snug); }
.notice__list li:last-child { margin-bottom: 0; }

/* ---- Ergebnis (Erfolg/Fehler) -------------------------------------- */
.result { text-align: center; max-width: 22rem; }
.result__icon {
  width: 88px; height: 88px;
  margin: 0 auto var(--sp-5);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2.6rem; font-weight: 700;
  color: #fff;
  background: var(--ok);
  box-shadow: var(--shadow-lg);
  animation: pop var(--dur-slow) var(--ease-out) both;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result--error .result__icon { background: var(--err); }
.result__title { font-size: var(--text-xl); margin-bottom: var(--sp-3); }
.result__text { color: var(--muted); line-height: var(--lh-normal); }

/* ---- Overlay -------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10,55,61,.55);
  backdrop-filter: blur(2px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-4);
  z-index: var(--z-overlay);
  color: #fff;
}
.overlay[hidden] { display: none; }
.overlay__text { font-weight: 600; }
.spinner {
  width: 46px; height: 46px;
  border: 4px solid rgba(255,255,255,.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(6rem + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  max-width: min(90%, 30rem);
  background: var(--ink);
  color: #fff;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease-out);
  z-index: var(--z-toast);
}
.toast[hidden] { display: none; }
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { background: var(--err); }
.toast--success { background: var(--ok); }

/* ---- Standort-Status (Kontrollansicht) ----------------------------- */
.geo-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--text-sm);
}
.geo-status[hidden] { display: none; }
.geo-status__text { flex: 1 1 12rem; min-width: 0; line-height: var(--lh-snug); }
.geo-status .linkbtn { flex: none; }
.geo-status[data-kind="pending"] { border-color: var(--line-strong); color: var(--muted); }
.geo-status[data-kind="ok"] { border-color: var(--ok); background: var(--ok-tint); }
.geo-status[data-kind="warn"] { border-color: var(--warn); background: var(--accent-tint); }

/* ---- Selbsttest / Diagnose (Einstellungen) ------------------------- */
.selftest {
  margin-top: var(--sp-8);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
}
.selftest__title { font-size: var(--text-md); margin-bottom: var(--sp-2); }
.selftest__list {
  list-style: none;
  margin: var(--sp-4) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.selftest__list[hidden] { display: none; }
.selftest__row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--text-sm);
  line-height: var(--lh-snug);
}
.selftest__dot {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--line-strong);
}
.selftest__text { flex: 1 1 auto; min-width: 0; }
.selftest__row[data-state="pending"] .selftest__dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.selftest__row[data-state="ok"] .selftest__dot { background: var(--ok); }
.selftest__row[data-state="ok"] { border-color: var(--ok); }
.selftest__row[data-state="fail"] .selftest__dot { background: var(--err); }
.selftest__row[data-state="fail"] { border-color: var(--err); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
