/* ==========================================================================
   SkriptPilot – Tokens, Reset, Basis, Komponenten
   Marke: #1d4f8f (Kobalt-/Broadcast-Blau, H 256 – abgesetzt von Indigo H 277)
   Schrift: Archivo (Display, wdth/wght-Achse) + Public Sans (Text/UI)
   ========================================================================== */

@layer tokens, reset, base, layout, komponenten;

/* ---------- Schriften: selbst gehostet, Fontsource, SIL OFL 1.1 ---------- */
@font-face {
  font-family: "Archivo Variable";
  src: url("assets/fonts/archivo-latin-wght.woff2") format("woff2-variations"),
       url("assets/fonts/archivo-latin-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("assets/fonts/public-sans-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("assets/fonts/public-sans-latin-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- 1. Tokens -------------------------------------------------- */
@layer tokens {
  :root {
    --h: 256.2;
    --brand: #1d4f8f;
    --brand-ink-light: #1d4f8f;
    --brand-ink-dark: oklch(74% 0.10 var(--h));
    --on-brand: #ffffff;

    --font-display: "Archivo Variable", "Archivo Fallback", system-ui, sans-serif;
    --font-text: "Public Sans", "Public Sans Fallback", system-ui, sans-serif;

    color-scheme: light dark;
    --paper: #f7faff; --surface: #ffffff; --surface-2: #eef2fa;
    --ink: #0d1219; --text-muted: #56606d; --line: #d8e0ec; --line-strong: #97a5b8;
    --brand-ink: var(--brand-ink-light);
    --brand-deep: #163d6d;
    --brand-soft: #e3ecfa;
    --danger: #a3251f; --danger-soft: #fbe7e5;
    --success: #1f6b3e;
  }
  @supports (color: light-dark(red, blue)) {
    :root {
      --paper:       light-dark(oklch(98.3% 0.008 var(--h)), oklch(17% 0.020 var(--h)));
      --surface:     light-dark(oklch(99.5% 0.004 var(--h)), oklch(21% 0.022 var(--h)));
      --surface-2:   light-dark(oklch(95.5% 0.012 var(--h)), oklch(25% 0.024 var(--h)));
      --ink:         light-dark(oklch(18% 0.020 var(--h)),   oklch(93% 0.012 var(--h)));
      --text-muted:  light-dark(oklch(46% 0.030 var(--h)),   oklch(76% 0.018 var(--h)));
      --line:        light-dark(oklch(88% 0.020 var(--h)),   oklch(32% 0.024 var(--h)));
      --line-strong: light-dark(oklch(65% 0.030 var(--h)),   oklch(52% 0.026 var(--h)));
      --brand-ink:   light-dark(var(--brand-ink-light),      var(--brand-ink-dark));
      --brand-deep:  light-dark(oklch(30% 0.075 var(--h)),   oklch(30% 0.075 var(--h)));
      --brand-soft:  light-dark(oklch(92% 0.035 var(--h)),   oklch(30% 0.045 var(--h)));
      --danger:      light-dark(oklch(42% 0.16 27),  oklch(74% 0.14 27));
      --danger-soft: light-dark(oklch(94% 0.04 27),  oklch(28% 0.05 27));
      --success:     light-dark(oklch(45% 0.12 150), oklch(74% 0.12 150));
    }
  }

  :root {
    --step--1: clamp(0.875rem, 0.851rem + 0.11vw, 0.9375rem);
    --step-0: clamp(1rem, 0.951rem + 0.22vw, 1.125rem);
    --step-1: clamp(1.2rem, 1.119rem + 0.36vw, 1.41rem);
    --step-2: clamp(1.44rem, 1.316rem + 0.55vw, 1.76rem);
    --step-3: clamp(1.73rem, 1.500rem + 0.90vw, 2.30rem);
    --step-4: clamp(2.14rem, 1.720rem + 1.60vw, 3.10rem);
    --step-5: clamp(2.60rem, 1.860rem + 2.90vw, 4.30rem);
    --step-6: clamp(3.10rem, 1.900rem + 4.80vw, 5.60rem);

    --space-3xs: 0.25rem;
    --space-2xs: 0.5rem;
    --space-xs: 0.75rem;
    --space-s: 1.25rem;
    --space-m: clamp(1.5rem, 1.2rem + 1.3vw, 2rem);
    --space-l: clamp(2.25rem, 1.6rem + 2.8vw, 3.25rem);
    --space-xl: clamp(3.25rem, 2.3rem + 4.2vw, 5.25rem);
    --space-2xl: clamp(4.5rem, 3rem + 6.5vw, 7.5rem);

    --gutter: clamp(1.25rem, 5vw, 5rem);
    --measure: 62ch;

    --radius-s: 3px;
    --radius-m: 6px;

    --shadow-float: 0 1px 2px oklch(25% 0.03 var(--h) / 0.14), 0 10px 26px -14px oklch(25% 0.05 var(--h) / 0.30);

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-std: cubic-bezier(0.2, 0.7, 0.2, 1);
    --dur-fast: 160ms;
    --dur-base: 220ms;
    --focus-ring: 2px solid var(--brand-ink);
  }
}

/* ---------- 2. Reset ---------------------------------------------------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: none; text-size-adjust: none; }
  img, picture, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  ol, ul { list-style: none; padding: 0; }
  :target { scroll-margin-block: 6ex; }
  button { background: none; border: 0; cursor: pointer; }
  [hidden] { display: none !important; }
}

/* ---------- 3. Basis ----------------------------------------------------- */
@layer base {
  html {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: 100%;
    font-synthesis: none;
    accent-color: var(--brand-ink);
    caret-color: var(--brand-ink);
    scrollbar-color: var(--line-strong) transparent;
    scroll-behavior: smooth;
  }
  body { font-size: var(--step-0); line-height: 1.6; min-height: 100svh; display: flex; flex-direction: column; }

  h1, h2, h3, h4 { font-family: var(--font-display); text-wrap: balance; color: var(--ink); font-weight: 800; }
  h1 { font-size: var(--step-6); line-height: 0.98; letter-spacing: -0.02em; font-variation-settings: "wdth" 110; max-width: 16ch; }
  h2 { font-size: var(--step-4); line-height: 1.05; letter-spacing: -0.015em; font-variation-settings: "wdth" 108; max-width: 22ch; }
  h3 { font-size: var(--step-2); line-height: 1.15; letter-spacing: -0.01em; font-variation-settings: "wdth" 105; }
  h4 { font-size: var(--step-1); line-height: 1.2; font-variation-settings: "wdth" 100; }

  p, li { text-wrap: pretty; }
  p, dd { max-width: var(--measure); }
  :lang(de) :is(p) { hyphens: auto; -webkit-hyphens: auto; }
  small, .meta { font-size: var(--step--1); color: var(--text-muted); }
  time, .tabular { font-variant-numeric: tabular-nums; }

  a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
  a:hover { text-decoration-thickness: 2px; }
  ::selection { background: var(--brand-soft); color: var(--ink); }
  :focus-visible { outline: var(--focus-ring); outline-offset: 3px; }

  label { display: block; margin-block-end: var(--space-3xs); font-weight: 600; font-size: var(--step--1); }
  input[type="text"], input[type="file"], textarea {
    border: 1px solid var(--line-strong); border-radius: var(--radius-m);
    background: var(--surface); color: var(--ink); padding: var(--space-2xs) var(--space-xs);
    width: 100%; font-size: var(--step-0);
  }
  input[type="text"]:focus-visible, textarea:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }
  textarea { resize: vertical; min-block-size: 6rem; }

  .visually-hidden { clip-path: inset(50%); height: 1px; width: 1px; overflow: hidden; position: absolute; white-space: nowrap; }
  .skip-link { position: absolute; inset-inline-start: var(--space-s); inset-block-start: -100px; z-index: 100;
    background: var(--ink); color: var(--paper); padding: var(--space-2xs) var(--space-s); border-radius: var(--radius-m); }
  .skip-link:focus { inset-block-start: var(--space-s); }
  .icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; stroke: currentColor; stroke-width: 1.9; fill: none; flex-shrink: 0; }

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

/* ---------- 4. Buttons & Layout-Grundlagen ------------------------------- */
@layer komponenten {
  .button {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs);
    min-block-size: 44px; padding-inline: var(--space-s); border-radius: var(--radius-s);
    font-weight: 600; font-size: var(--step--1); letter-spacing: 0.01em; white-space: nowrap;
    transition: background-color var(--dur-fast) var(--ease-std), color var(--dur-fast) var(--ease-std), border-color var(--dur-fast) var(--ease-std);
    border: 1px solid transparent;
  }
  .button:active { transform: translateY(1px); }
  .button--primary { background: var(--brand-ink); color: var(--on-brand); }
  .button--primary:hover { background: var(--brand-deep); }
  .button--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
  .button--ghost:hover { background: var(--surface-2); }
  .button--gefahr { background: var(--danger); color: #ffffff; }
  .button--gefahr:hover { filter: brightness(1.08); }
  .button--klein { min-block-size: 36px; padding-inline: var(--space-xs); font-size: var(--step--1); }
  .button--icon { min-inline-size: 44px; padding-inline: var(--space-2xs); }

  .fehlermeldung {
    display: flex; align-items: flex-start; gap: var(--space-2xs);
    background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-m);
    padding: var(--space-2xs) var(--space-s); font-size: var(--step--1); font-weight: 600;
    margin-block-start: var(--space-2xs);
  }
  .fehlermeldung .icon { margin-block-start: 0.15em; }

  .leerzustand { color: var(--text-muted); font-style: normal; padding-block: var(--space-s); border: 1px dashed var(--line-strong); border-radius: var(--radius-m); text-align: center; }
}

/* ---------- 5. Kopfzeile -------------------------------------------------- */
@layer layout {
  .kopfzeile {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-s) var(--gutter);
    border-bottom: 1px solid var(--line);
  }
  .marke { display: inline-flex; align-items: center; gap: var(--space-2xs); font-family: var(--font-display); font-weight: 800; font-size: var(--step-1); color: var(--ink); text-decoration: none; }
  .marke-icon { color: var(--brand-ink); width: 1.3em; height: 1.3em; }
  .kopfzeile-link { font-weight: 600; font-size: var(--step--1); text-decoration: none; }
  .kopfzeile-link:hover { text-decoration: underline; }

  /* ---------- Hero ---------- */
  .hero {
    position: relative;
    display: flex;
    padding: var(--space-2xl) var(--gutter) var(--space-xl);
    padding-inline-start: calc(var(--gutter) + 30px);
    max-width: 84rem;
  }
  .hero-schiene {
    position: absolute;
    inset-block: var(--space-l) var(--space-l);
    inset-inline-start: var(--gutter);
    width: 14px;
    background-color: var(--brand-deep);
    background-image: radial-gradient(circle at 7px 12px, var(--paper) 3px, transparent 3.6px);
    background-size: 14px 26px;
    background-repeat: repeat-y;
    border-radius: var(--radius-s);
  }
  .hero-inhalt { max-width: 42rem; }
  .hero-unterzeile { font-size: var(--step-1); color: var(--text-muted); margin-block-start: var(--space-s); max-width: 40ch; }
  .hero .button { margin-block-start: var(--space-l); }

  /* ---------- Problem / Lösung ---------- */
  .kontext {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-m) var(--gutter);
    padding: var(--space-l) var(--gutter) var(--space-2xl);
    max-width: 84rem;
  }
  .kontext-block { grid-column: span 12; }
  .kontext-block h2 { font-size: var(--step-3); margin-block-end: var(--space-2xs); }
  .kontext-block p { color: var(--text-muted); }
  @media (min-width: 64rem) {
    .kontext-problem { grid-column: 1 / span 5; }
    .kontext-loesung { grid-column: 7 / span 6; border-inline-start: 1px solid var(--line); padding-inline-start: var(--space-l); }
  }

  /* ---------- Werkzeug ---------- */
  .werkzeug { padding: var(--space-l) var(--gutter) var(--space-2xl); max-width: 84rem; }

  .projekt-gate { display: flex; justify-content: flex-start; padding-block: var(--space-l); }
  .projekt-gate-karte { max-width: 34rem; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--space-l); }
  .projekt-gate-karte h3 { margin-block-end: var(--space-2xs); }
  .projekt-gate-karte p { color: var(--text-muted); margin-block-end: var(--space-m); }
  .projekt-gate-karte form > * + * { margin-block-start: var(--space-xs); }

  .projekt-kopf {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-m);
    padding-block-end: var(--space-m); border-bottom: 1px solid var(--line); margin-block-end: var(--space-l);
  }
  .projekt-kopf h2 { font-size: var(--step-3); }
  .projekt-aktionen { display: flex; gap: var(--space-2xs); flex-wrap: wrap; }

  .werkzeug-raster {
    display: grid; grid-template-columns: 1fr; gap: var(--space-xl);
  }
  @media (min-width: 64rem) {
    .werkzeug-raster { grid-template-columns: 7fr 4fr; align-items: start; }
    .bereich-checkliste { position: sticky; top: var(--space-m); }
  }

  .bereich-kopf { margin-block-end: var(--space-m); }
  .bereich-kopf h3 { padding-block-end: var(--space-2xs); border-bottom: 2px solid var(--brand-ink); display: inline-block; }
}

/* ---------- 6. Szenen ------------------------------------------------- */
@layer komponenten {
  .szenen-liste { display: flex; flex-direction: column; gap: var(--space-m); margin-block-end: var(--space-l); }
  .szene-karte { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--space-m); }
  .szene-kopf { display: flex; align-items: flex-start; gap: var(--space-s); }
  .szene-nummer { font-family: var(--font-display); font-weight: 800; font-size: var(--step-2); color: var(--brand-ink); font-variant-numeric: tabular-nums; min-inline-size: 2ch; }
  .szene-kopf-text { flex: 1; min-inline-size: 0; }
  .szene-titel { font-size: var(--step-1); margin: 0; }
  .szene-meta { margin-block-start: 0.2em; }
  .szene-aktionen { display: flex; gap: var(--space-3xs); flex-wrap: wrap; }
  .szene-text { margin-block-start: var(--space-s); color: var(--ink); white-space: pre-wrap; }

  .szene-bearbeiten-form { margin-block-start: var(--space-2xs); }
  .szene-bearbeiten-form > * + * { margin-block-start: var(--space-xs); }
  .szene-bearbeiten-aktionen { display: flex; gap: var(--space-2xs); }

  .feedback { margin-block-start: var(--space-m); padding-block-start: var(--space-m); border-top: 1px solid var(--line); }
  .feedback h4 { font-size: var(--step-0); margin-block-end: var(--space-2xs); color: var(--text-muted); font-family: var(--font-text); font-weight: 700; text-transform: none; }
  .notiz-liste { display: flex; flex-direction: column; gap: var(--space-2xs); margin-block-end: var(--space-xs); }
  .notiz {
    display: flex; align-items: flex-start; gap: var(--space-2xs);
    background: var(--surface-2); border-radius: var(--radius-s); padding: var(--space-2xs) var(--space-xs);
  }
  .notiz-checkbox { margin-block-start: 0.3em; width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--brand-ink); }
  .notiz-text { flex: 1; }
  .notiz.ist-erledigt .notiz-text { text-decoration: line-through; color: var(--text-muted); }
  .notiz-loeschen { flex-shrink: 0; color: var(--text-muted); border-radius: var(--radius-s); padding: var(--space-3xs); }
  .notiz-loeschen:hover { color: var(--danger); background: var(--danger-soft); }
  .notiz-leer { color: var(--text-muted); font-size: var(--step--1); margin-block-end: var(--space-xs); }

  .notiz-form { display: flex; gap: var(--space-2xs); align-items: flex-start; flex-wrap: wrap; }
  .notiz-form input { flex: 1; min-inline-size: 12rem; }
  .notiz-form label { flex-basis: 100%; }

  .szene-neu-karte { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-m); padding: var(--space-m); }
  .szene-neu-karte h4 { margin-block-end: var(--space-xs); }
  .szene-neu-karte form > * + * { margin-block-start: var(--space-xs); }
}

/* ---------- 7. Checkliste ------------------------------------------------ */
@layer komponenten {
  .fortschritt-wrapper { margin-block-end: var(--space-m); }
  .fortschritt { block-size: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
  .fortschritt-leiste { block-size: 100%; background: var(--brand-ink); transition: width var(--dur-base) var(--ease-std); }
  .fortschritt-text { margin-block-start: var(--space-2xs); font-weight: 600; font-size: var(--step--1); }

  .todo-liste { display: flex; flex-direction: column; gap: var(--space-2xs); margin-block-end: var(--space-m); }
  .todo {
    display: flex; align-items: center; gap: var(--space-2xs);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
    padding: var(--space-2xs) var(--space-xs);
  }
  .todo-checkbox { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--brand-ink); }
  .todo-text { flex: 1; }
  .todo.ist-erledigt .todo-text { text-decoration: line-through; color: var(--text-muted); }
  .todo-loeschen { flex-shrink: 0; color: var(--text-muted); border-radius: var(--radius-s); padding: var(--space-3xs); }
  .todo-loeschen:hover { color: var(--danger); background: var(--danger-soft); }

  .todo-eingabe-zeile { display: flex; gap: var(--space-2xs); }
  .todo-eingabe-zeile input { flex: 1; }
}

/* ---------- 8. Dialoge ---------------------------------------------------- */
@layer komponenten {
  dialog {
    border: 1px solid var(--line); border-radius: var(--radius-m); padding: var(--space-l);
    max-width: 30rem; width: calc(100% - 2 * var(--space-s));
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float);
  }
  dialog::backdrop { background: oklch(15% 0.02 var(--h) / 0.45); }
  dialog h3 { margin-block-end: var(--space-2xs); }
  dialog p { color: var(--text-muted); }
  .dialog-aktionen { display: flex; justify-content: flex-end; gap: var(--space-2xs); margin-block-start: var(--space-m); }
}

/* ---------- 9. Fußzeile --------------------------------------------------- */
@layer layout {
  .fusszeile {
    margin-block-start: auto;
    padding: var(--space-m) var(--gutter);
    border-top: 1px solid var(--line);
    color: var(--text-muted);
    font-size: var(--step--1);
  }
}

/* ---------- 10. Responsive Feinschliff ------------------------------------ */
@media (max-width: 40rem) {
  .hero { padding-inline-start: calc(var(--gutter) + 22px); }
  .hero-schiene { width: 10px; background-size: 10px 22px; background-image: radial-gradient(circle at 5px 10px, var(--paper) 2.2px, transparent 2.6px); }
  .projekt-kopf { align-items: stretch; }
  .projekt-aktionen { width: 100%; }
  .projekt-aktionen .button { flex: 1; }
}
