/*
 * Allergienapf, gemeinsame Grundlage aller Layout-Richtungen (reines CSS, kein Baukasten).
 * Aufbau und Maße folgen dem Skill stall-stil (assets/tokens.css), die Namen sind markenneutral.
 *
 * Jede Richtung setzt in ihrer eigenen Datei die Markenfarben (Abschnitt „JE RICHTUNG“ unten) und
 * darf alles hier überschreiben. Farben immer als light-dark(hell, nacht) auf `:root, [data-theme]`,
 * damit auch ein Teilbaum mit eigenem data-theme richtig rechnet.
 */

/* ---------- 1. Themenwahl ---------- */
:root { color-scheme: light dark; }
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

/* ---------- 2. Farben ---------- */
:root, [data-theme] {
  /* JE RICHTUNG (hier nur Rückfallwerte, damit nichts ohne Farbe dasteht):
     --bg --surface --surface-2 --surface-3 --line --line-strong --ink --ink-2 --ink-3
     --brand --brand-ink --primary --on-primary --accent --on-accent --accent-ink --glow */
  --bg: light-dark(#faf7f2, #15100c);
  --surface: light-dark(#fffdf9, #1f1813);
  --surface-2: light-dark(#f2ebe1, #2a2019);
  --surface-3: light-dark(#e8e0d5, #342920);
  --line: light-dark(#e4dacb, #3a2e24);
  --line-strong: light-dark(#9a866d, #85725e);
  --ink: light-dark(#2b1f16, #f3eadf);
  --ink-2: light-dark(#6b5744, #c9b9a6);
  --ink-3: light-dark(#7a6650, #9e8c78);
  --brand: var(--ink-2);
  --brand-ink: var(--ink-2);
  --primary: var(--ink);
  --on-primary: var(--bg);
  --accent: var(--surface-3);
  --on-accent: var(--ink);
  --accent-ink: var(--ink);
  --glow: transparent;

  /* Zustände */
  --ok: light-dark(#4e6649, #9db592);
  --info: light-dark(#3e6a8a, #8db8d8);
  --danger: light-dark(#a6473a, #e58b7b);
  --on-danger: light-dark(#ffffff, #1a120c);

  /* Fünf Stufen: Tönung (Fläche) / Schrift / Marke (Balken, Punkte). Immer mit Zeichen und Wort zeigen.
     0 ruhig, 1 gering, 2 mäßig, 3 hoch, 4 sehr hoch.
     Urteil im Futter-Check: passt = Stufe 0, unklar = Stufe 2, passt nicht = Stufe 4. */
  --level-0-tint: light-dark(#eef1ea, #1f2a1e);
  --level-0-ink: light-dark(#3f5a3a, #a9c79e);
  --level-0-mark: light-dark(#6e8a64, #7fa474);
  --level-1-tint: light-dark(#f3f0dc, #2a2814);
  --level-1-ink: light-dark(#5a5420, #d8cf83);
  --level-1-mark: light-dark(#8a8230, #b8ae52);
  --level-2-tint: light-dark(#fbebcb, #33260f);
  --level-2-ink: light-dark(#6e4a0c, #f0c76e);
  --level-2-mark: light-dark(#b07a12, #e0a63a);
  --level-3-tint: light-dark(#f8dccb, #3a1e12);
  --level-3-ink: light-dark(#8a3412, #f4a27e);
  --level-3-mark: light-dark(#c8582a, #e07445);
  --level-4-tint: light-dark(#f3d3d0, #3d1616);
  --level-4-ink: light-dark(#8a1f1f, #f59a9a);
  --level-4-mark: light-dark(#a8282b, #e05555);

  /* Tiefe. Nachts hebt ein Lichtrand oben statt eines Schattens. */
  --shadow-card: 0 1px 2px light-dark(rgb(30 24 18 / 0.06), transparent),
    0 4px 12px light-dark(rgb(30 24 18 / 0.05), transparent),
    inset 0 1px 0 light-dark(transparent, rgb(255 245 235 / 0.06));
  --shadow-sheet: 0 -1px 0 var(--line), 0 12px 32px light-dark(rgb(30 24 18 / 0.14), rgb(0 0 0 / 0.45));
  --shadow-magnet: 0 1px 0 light-dark(rgb(30 24 18 / 0.12), rgb(0 0 0 / 0.4)),
    0 2px 4px light-dark(rgb(30 24 18 / 0.08), rgb(0 0 0 / 0.3));
}

/* ---------- 3. Maße, Schrift, Bewegung ---------- */
:root {
  --font-serif: Fraunces, "Iowan Old Style", Georgia, serif;
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Atkinson Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-xs: 6px;   /* kleine Flächen, Fokusring */
  --r-sm: 10px;  /* Eingabefelder */
  --r-md: 16px;  /* Karten */
  --r-lg: 24px;  /* Unterblätter oben, große Karten, Fotos */
  --r-pill: 9999px;

  --dur-1: 100ms; /* Druck-Rückmeldung */
  --dur-2: 160ms; /* Auswahl, Hover */
  --dur-3: 240ms; /* Karten, Reiterwechsel */
  --dur-4: 360ms; /* Unterblatt */
  --dur-5: 600ms; /* großer Auftritt */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-in: cubic-bezier(0.3, 0, 0.8, 0.15);

  /* Rahmen der Anwendung */
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --handbar-h: 72px; /* Leiste mit Tier-Wechsler und Haupt-Handgriff */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --hit: 48px;
  --btn-sm: 2.5rem;
  --btn-md: 3rem;
  --btn-lg: 3.5rem;
  --btn-hand: 4rem; /* Haupt-Handgriff 64 px */

  --page: 1200px;
  --gutter: 16px;
}
@media (min-width: 37.5rem) { :root { --gutter: 24px; } }
@media (min-width: 64rem) { :root { --gutter: 32px; } }

/* ---------- 4. Grundlage ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "ss01";
  font-size: 1rem;
  line-height: 1.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
img, svg, picture { display: block; max-width: 100%; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; hyphens: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: color-mix(in oklab, var(--accent) 45%, transparent); color: var(--ink); }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -80px; z-index: 100; background: var(--surface); color: var(--ink); padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow-sheet); }
.skip:focus { top: 8px; }

/* ---------- 5. Schriftgrößen-Leiter ---------- */
.type-display { font-family: var(--font-serif); font-weight: 500; font-size: clamp(2.75rem, 8vw, 5.5rem); line-height: 1; letter-spacing: -0.03em; font-optical-sizing: auto; text-wrap: balance; }
.type-h1 { font-family: var(--font-serif); font-weight: 600; font-size: clamp(2rem, 1.804rem + 0.87vw, 2.5rem); line-height: clamp(2.25rem, 2.054rem + 0.87vw, 2.75rem); letter-spacing: -0.01em; text-wrap: balance; }
.type-h2 { font-family: var(--font-serif); font-weight: 600; font-size: clamp(1.5rem, 1.402rem + 0.435vw, 1.75rem); line-height: clamp(1.875rem, 1.777rem + 0.435vw, 2.125rem); text-wrap: balance; }
.type-h3 { font-family: var(--font-sans); font-weight: 600; font-size: clamp(1.125rem, 1.1rem + 0.109vw, 1.1875rem); line-height: clamp(1.5rem, 1.451rem + 0.217vw, 1.625rem); }
.type-gross { font-size: 1.125rem; line-height: 1.75rem; }
.type-text { font-size: 1rem; line-height: 1.5rem; }
.type-klein { font-size: 0.875rem; line-height: 1.25rem; }
.type-marke { font-size: 0.8125rem; line-height: 1rem; font-weight: 600; font-stretch: 85%; letter-spacing: 0.06em; text-transform: uppercase; }
.type-zahl-gross { font-size: 1.75rem; line-height: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.type-zahl-klein { font-size: 0.8125rem; line-height: 1rem; font-weight: 500; font-stretch: 85%; font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 6. Hilfsklassen ---------- */
/* Feine Körnung für große Flächen (Abschnitte, Fuß). Nie auf Text-Karten, nie im Druck. */
.korn { position: relative; isolation: isolate; }
.korn::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.5'/></svg>");
  opacity: 0.05; mix-blend-mode: multiply;
}
[data-theme="dark"] .korn::after, [data-theme="dark"].korn::after { mix-blend-mode: screen; opacity: 0.035; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .korn:not([data-theme="light"] *, [data-theme="light"])::after { mix-blend-mode: screen; opacity: 0.035; }
}

/* Milchglas nur für Leisten über dem Inhalt */
.glass { background: var(--surface); }
@supports (backdrop-filter: blur(1px)) {
  .glass { background: color-mix(in oklab, var(--surface) 82%, transparent); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); }
}
@media (prefers-reduced-transparency: reduce) { .glass { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; } }

/* 45-Grad-Linien in der Schriftfarbe: „offen“, „vergangen“, „unsicher“ */
.schraffur { background-image: repeating-linear-gradient(45deg, color-mix(in oklab, currentColor 35%, transparent) 0 1px, transparent 1px 6px); }

/* Trefferfläche auf 48 px erweitern, ohne das Aussehen zu ändern */
.hit-48 { position: relative; }
.hit-48::before { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, var(--hit)); height: max(100%, var(--hit)); transform: translate(-50%, -50%); }

.scrollbar-none { scrollbar-width: none; }
.scrollbar-none::-webkit-scrollbar { display: none; }

/* ---------- 7. Bewegung und Druck ---------- */
@keyframes rise-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop-in { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 120ms !important; scroll-behavior: auto !important; }
}
@page { margin: 12mm; }
@media print {
  html, body { background: #fff !important; color: #000 !important; }
  .korn::after { display: none; }
  [data-print="hide"] { display: none !important; }
}
