/*
 * Krimispiele – Designsystem
 * Übernimmt Farben, Schrift und Grundzüge von ostfriesen-krimis.de (v2/docs/DESIGN_SYSTEM.md):
 * Tiefwasser-Blau, Backstein-Rot, Wattsand, Open Sans, ruhige redaktionelle Flächen.
 */

@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/open-sans-v40-latin-regular.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/open-sans-v40-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/open-sans-v40-latin-700.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('../fonts/open-sans-v40-latin-800.woff2') format('woff2'); }

:root {
  --ink: #1c2b33;
  --ink-soft: #46595f;
  --sea: #123f4c;
  --sea-deep: #0b2e38;
  --brick: #a8442f;
  --brick-deep: #8a3625;
  --sand: #f4efe6;
  --paper: #fdfcf9;
  --mist: #d8e0e2;
  --gold: #c19a3d;
  --focus: #0d6efd;
  --ok: #1d7a4d;
  --ok-bg: #e6f4ec;
  --warn-bg: #fff5e6;
  --err: #b02a2a;
  --err-bg: #fbe9e9;

  --font: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem;
  --r-s: 4px; --r-m: 8px; --r-l: 14px;
  --shadow-1: 0 1px 3px rgba(11, 46, 56, .12), 0 1px 2px rgba(11, 46, 56, .08);
  --shadow-2: 0 10px 30px rgba(11, 46, 56, .25);
  --w-content: 72rem;
  --w-prose: 46rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--font); font-size: 1rem; line-height: 1.65; color: var(--ink); background: var(--paper);
}
main { flex: 1; width: 100%; max-width: var(--w-content); margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-7); }
main:focus { outline: none; }
img, video { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { color: var(--sea); line-height: 1.25; letter-spacing: -.01em; margin: 0 0 var(--s-3); }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); font-weight: 800; }
h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 var(--s-3); }
a { color: var(--sea); text-underline-offset: 2px; }
a:hover { color: var(--brick); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--paper); padding: var(--s-2) var(--s-3); z-index: 100; }
.skip-link:focus { left: var(--s-2); }
.loading { color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }

/* ---------- Kopf & Fuß ---------- */
.site-header { background: var(--sea); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow-1); }
.site-header__inner { max-width: var(--w-content); margin: 0 auto; padding: var(--s-2) var(--s-4); display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.brand { display: flex; align-items: center; gap: var(--s-3); color: #fff; text-decoration: none; min-height: 44px; }
.brand img { width: 130px; height: auto; }
.brand__sub { font-weight: 700; font-size: .9rem; letter-spacing: .04em; text-transform: uppercase; color: var(--gold); border-left: 1px solid rgba(255,255,255,.35); padding-left: var(--s-3); }
.brand:hover { color: #fff; }
.site-nav { display: flex; gap: var(--s-2); }
.site-nav a { color: #fff; text-decoration: none; font-weight: 600; padding: var(--s-2) var(--s-3); border-radius: var(--r-s); min-height: 44px; display: inline-flex; align-items: center; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--sea-deep); color: #fff; }
.status-bar { background: var(--sea-deep); font-size: .85rem; text-align: center; padding: 0 var(--s-4); }
.status-bar:empty { display: none; }
.status-bar .dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .4em; background: var(--gold); }
.status-bar--offline .dot { background: #e36b5a; }
.site-footer { background: var(--sea-deep); color: var(--mist); font-size: .85rem; padding: var(--s-4); text-align: center; }
.site-footer a { color: #fff; }
.site-footer p { margin: 0 0 var(--s-1); }
.site-footer__version { opacity: .6; }
@media (max-width: 30em) { .brand img { width: 104px; } .brand__sub { font-size: .75rem; } }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: var(--s-2) var(--s-4); border-radius: var(--r-m); border: 2px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; line-height: 1.2;
  transition: background-color .15s, color .15s;
}
.btn--primary { background: var(--brick); color: #fff; }
.btn--primary:hover { background: var(--brick-deep); color: #fff; }
.btn--secondary { background: transparent; color: var(--sea); border-color: var(--sea); }
.btn--secondary:hover { background: var(--sea); color: #fff; }
.btn--ghost { background: transparent; color: var(--sea); border-color: transparent; text-decoration: underline; }
.btn--small { min-height: 36px; padding: var(--s-1) var(--s-3); font-size: .9rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin: var(--s-3) 0; }
.field { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-4); }
.field label { font-weight: 600; }
.field input, .field textarea, .field select, input.input, textarea.input, select.input {
  font: inherit; padding: var(--s-2) var(--s-3); min-height: 44px; border: 1px solid #9fb0b5; border-radius: var(--r-m); background: #fff; color: var(--ink); width: 100%;
}
.field textarea, textarea.input { min-height: 8rem; resize: vertical; }
.field__hint { font-size: .85rem; color: var(--ink-soft); }
.form-narrow { max-width: 28rem; }
.code-input { font-size: 1.6rem; letter-spacing: .3em; text-align: center; max-width: 14rem; }

/* ---------- Hinweise & Status ---------- */
.notice { background: var(--sand); border-left: 4px solid var(--sea); padding: var(--s-3) var(--s-4); border-radius: var(--r-s); margin: var(--s-3) 0; }
.notice--ok { background: var(--ok-bg); border-color: var(--ok); }
.notice--warn { background: var(--warn-bg); border-color: var(--gold); }
.notice--error { background: var(--err-bg); border-color: var(--err); }
.notice p:last-child { margin: 0; }
.badge { display: inline-flex; align-items: center; gap: .3em; background: var(--sand); color: var(--ink); border-radius: 999px; padding: .1em .7em; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge--sea { background: var(--sea); color: #fff; }
.badge--brick { background: var(--brick); color: #fff; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: #7a5a12; }
.badge--outline { background: transparent; border: 1px solid var(--mist); }
.badges { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); margin: var(--s-2) 0; }
.difficulty { letter-spacing: .1em; color: var(--brick); }
.progress { height: .6rem; background: var(--mist); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--sea); width: 0; transition: width .15s; }

/* ---------- Übersicht / Karten ---------- */
.page-intro { max-width: var(--w-prose); margin-bottom: var(--s-5); }
.page-intro p { font-size: 1.05rem; color: var(--ink-soft); }
.case-grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.case-card { background: #fff; border: 1px solid var(--mist); border-radius: var(--r-l); overflow: hidden; box-shadow: var(--shadow-1); display: flex; flex-direction: column; }
.case-card__cover { aspect-ratio: 3 / 2; background: var(--sea); object-fit: cover; width: 100%; }
.case-card__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.case-card__body h2 { margin: 0; font-size: 1.3rem; }
.case-card__subtitle { color: var(--ink-soft); margin: 0; font-weight: 600; }
.case-card__summary { margin: 0; }
.case-card__actions { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-2); }
.offline-state { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: var(--s-2); }
.offline-state--ready { color: var(--ok); }
.section { margin: var(--s-6) 0; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.list-item { background: #fff; border: 1px solid var(--mist); border-radius: var(--r-m); padding: var(--s-3) var(--s-4); }
.list-item h3 { margin: 0 0 var(--s-1); font-size: 1.05rem; }
.empty { color: var(--ink-soft); font-style: italic; }

/* ---------- Fallakte ---------- */
.dossier { max-width: var(--w-prose); margin: 0 auto; }
.dossier__head { background: var(--sand); border-radius: var(--r-l); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); border-top: 6px solid var(--brick); }
.dossier__case { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brick); font-weight: 700; margin: 0; }
.dossier__head h1 { margin: 0; font-size: clamp(1.3rem, 1.1rem + 1vw, 1.8rem); }
.dossier__meta { font-size: .85rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); margin-top: var(--s-1); }
.task-line { background: var(--sea); color: #fff; border-radius: var(--r-m); padding: var(--s-2) var(--s-4); margin: 0 0 var(--s-4); font-weight: 600; }
.task-line strong { color: var(--gold); text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; display: block; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 0 var(--s-4); border-bottom: 2px solid var(--sea); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; font: inherit; font-weight: 700; font-size: .9rem; background: var(--sand); color: var(--sea); border: 0; padding: var(--s-2) var(--s-3); min-height: 44px; border-radius: var(--r-m) var(--r-m) 0 0; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--sea); color: #fff; }
.tab .count { display: inline-block; min-width: 1.4em; margin-left: .3em; padding: 0 .35em; border-radius: 999px; background: var(--brick); color: #fff; font-size: .75rem; }
@media (max-width: 40em) {
  .dossier { padding-bottom: 4.5rem; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; background: var(--sea-deep); border: 0; padding: var(--s-1) var(--s-1) calc(var(--s-1) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-2); }
  .tab { flex: 1 1 0; font-size: .75rem; padding: var(--s-1); border-radius: var(--r-m); background: transparent; color: var(--mist); min-width: 0; }
  .tab[aria-selected="true"] { background: var(--sea); color: #fff; }
}
.panel { animation: none; }
.block { margin: 0 0 var(--s-4); }
.block--narration { font-size: 1.05rem; }
.block--dialog { background: #fff; border: 1px solid var(--mist); border-left: 4px solid var(--sea); border-radius: var(--r-m); padding: var(--s-3) var(--s-4); }
.block--dialog .speaker { font-weight: 700; color: var(--sea); display: block; font-size: .9rem; }
.block--dialog p { font-family: var(--font-serif); font-style: italic; font-size: 1.05rem; }
.block--document { background: #fffdf5; border: 1px solid #e6dcc3; padding: var(--s-4); font-family: var(--font-serif); box-shadow: var(--shadow-1); }
.block--note { background: var(--warn-bg); border-left: 4px solid var(--gold); padding: var(--s-3) var(--s-4); border-radius: var(--r-s); font-style: italic; }
.block p:last-child { margin-bottom: 0; }
.media-figure { margin: 0 0 var(--s-4); background: #fff; border: 1px solid var(--mist); border-radius: var(--r-m); overflow: hidden; }
.media-figure img, .media-figure video { width: 100%; background: var(--ink); }
.media-figure audio { width: 100%; display: block; padding: var(--s-2); }
.media-figure figcaption { padding: var(--s-2) var(--s-3); font-size: .9rem; color: var(--ink-soft); }
.transcript { margin: 0 var(--s-3) var(--s-3); font-size: .9rem; }
.transcript summary { cursor: pointer; font-weight: 600; color: var(--sea); min-height: 44px; display: flex; align-items: center; }
.task { background: #fff; border: 2px solid var(--sea); border-radius: var(--r-l); padding: var(--s-4); margin: 0 0 var(--s-4); }
.task--solved { border-color: var(--ok); background: #fbfefc; }
.task__label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brick); font-weight: 700; margin: 0 0 var(--s-1); display: flex; justify-content: space-between; gap: var(--s-2); }
.task__label .ok { color: var(--ok); }
.task h3 { margin-bottom: var(--s-3); }
.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.option { width: 100%; text-align: left; justify-content: flex-start; background: var(--sand); color: var(--ink); border: 2px solid transparent; font-weight: 600; }
.option:hover { border-color: var(--sea); }
.option--correct { background: var(--ok-bg); border-color: var(--ok); }
.feedback { margin: var(--s-3) 0 0; font-weight: 600; }
.feedback--ok { color: var(--ok); }
.feedback--no { color: var(--err); }
.code-form { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: stretch; }
.clue-find { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; }
.decision { background: var(--sea); color: #fff; border-radius: var(--r-l); padding: var(--s-4); margin: var(--s-5) 0 var(--s-4); }
.decision h3 { color: #fff; }
.decision .option { background: rgba(255,255,255,.1); color: #fff; }
.decision .option:hover { background: rgba(255,255,255,.2); border-color: var(--gold); }
.decision--locked { background: var(--mist); color: var(--ink); }
.decision--locked h3 { color: var(--sea); }
.cards { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.clue-card, .person-card { background: #fff; border: 1px solid var(--mist); border-radius: var(--r-m); padding: var(--s-3) var(--s-4); }
.clue-card img { border-radius: var(--r-s); margin-bottom: var(--s-2); cursor: zoom-in; }
.clue-card__cat { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brick); font-weight: 700; }
.clue-card h3, .person-card h3 { margin: 0 0 var(--s-1); }
.person-card { display: flex; gap: var(--s-3); }
.avatar { flex: 0 0 3rem; width: 3rem; height: 3rem; border-radius: 50%; background: var(--sea); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.person-card__role { color: var(--ink-soft); font-size: .9rem; margin: 0 0 var(--s-1); }
.tip-list { list-style: none; padding: 0; margin: 0 0 var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.tip-list li { background: var(--warn-bg); border-left: 4px solid var(--gold); padding: var(--s-2) var(--s-3); border-radius: var(--r-s); }
.solution { background: var(--err-bg); border-left: 4px solid var(--brick); padding: var(--s-2) var(--s-3); border-radius: var(--r-s); }
.ending { text-align: left; }
.ending__badge { font-size: 1rem; }
.ending h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--s-2); margin: var(--s-4) 0; }
.stat { background: var(--sand); border-radius: var(--r-m); padding: var(--s-2) var(--s-3); }
.stat b { display: block; font-size: 1.3rem; color: var(--sea); }
.save-state { font-size: .8rem; color: var(--ink-soft); text-align: right; margin: 0 0 var(--s-2); min-height: 1.3em; }

/* ---------- Dialog & Toast ---------- */
dialog { border: 0; border-radius: var(--r-l); padding: var(--s-5); max-width: min(34rem, calc(100vw - 2rem)); box-shadow: var(--shadow-2); color: var(--ink); }
dialog::backdrop { background: rgba(11, 46, 56, .6); }
dialog.lightbox { padding: 0; max-width: 96vw; background: transparent; box-shadow: none; }
dialog.lightbox img { max-height: 90vh; width: auto; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin: var(--s-3) 0; }
.compare > div { background: var(--sand); border-radius: var(--r-m); padding: var(--s-3); font-size: .9rem; }
.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: var(--s-2) var(--s-4); border-radius: var(--r-m); box-shadow: var(--shadow-2); z-index: 50; max-width: calc(100vw - 2rem); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Kauf ---------- */
.payment { border-collapse: collapse; margin: var(--s-2) 0; font-size: .95rem; }
.payment th, .payment td { text-align: left; padding: .15rem var(--s-3) .15rem 0; vertical-align: top; }
.payment td { font-family: ui-monospace, 'DejaVu Sans Mono', monospace; word-break: break-all; }
.field--check label { font-weight: 400; display: block; }
.field--check input { width: 1.1rem; height: 1.1rem; vertical-align: -2px; margin-right: .3rem; }
.radio-option { display: block; padding: var(--s-2) var(--s-3); border: 1px solid var(--mist); border-radius: var(--r-m); margin-bottom: var(--s-2); cursor: pointer; }
.radio-option:has(input:checked) { border-color: var(--sea); background: var(--sand); }
