/* LassZocken – Basis-Designsystem (gemeinsam für Kinder-App und Elternbereich) */

:root {
  color-scheme: dark;

  /* Flächen */
  --bg: #0c1222;
  --bg-2: #111a2e;
  --surface: #16213a;
  --surface-2: #1c2a48;
  --surface-3: #24355a;
  --line: #2a3b60;
  --line-strong: #3a5080;

  /* Text */
  --text: #eef3ff;
  --text-2: #b4c2df;
  --text-3: #8496bb;

  /* Akzente */
  --brand: #2ee6d6;
  --brand-ink: #04201e;
  --danger: #ff6b6b;
  --danger-ink: #2a0606;
  --warn: #ffc857;
  --warn-ink: #2a1e02;
  --ok: #4ade80;

  /* Themenfarben (Kinder & Spiele) */
  --c-cyan: #22d3ee;
  --c-green: #4ade80;
  --c-purple: #a78bfa;
  --c-orange: #fb923c;
  --c-pink: #f472b6;
  --c-yellow: #facc15;
  --c-red: #f87171;
  --c-blue: #60a5fa;
  --c-slate: #5eead4;

  /* Skin-abhängige Effekte */
  --glow-1: rgba(46, 230, 214, 0.10);
  --glow-2: rgba(167, 139, 250, 0.10);
  --grid-line: rgba(255, 255, 255, 0.025);
  --sheen: rgba(255, 255, 255, 0.03);
  --hover: rgba(255, 255, 255, 0.06);
  --header-bg: rgba(12, 18, 34, 0.88);
  --backdrop: rgba(5, 9, 20, 0.72);
  --focus-color: #ffe66d;
  --warn-text: #ffe2a3;
  --error-text: #ffc2c2;
  --ok-text: #c4f5d6;
  --offline-bg: #3a2a05;
  --pattern: none;

  /* Typografie: Systemschriften, keine externen Fonts */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: clamp(1.6rem, 5vw, 2.1rem);
  --fs-xxl: clamp(2.6rem, 14vw, 4.6rem);

  /* Maße */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --tap: 48px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px var(--bg), 0 0 0 6px var(--focus-color);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 110% -10%, var(--glow-1), transparent 60%),
    radial-gradient(900px 500px at -20% 110%, var(--glow-2), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 24px 24px, 24px 24px;
  transition: background-color 0.25s ease, color 0.25s ease;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }

h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.01em; }

p { margin: 0; }

a { color: var(--brand); }

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
/* Überschriften erhalten nur programmatisch Fokus (Screenwechsel für Screenreader) – ohne Fokusrahmen */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 18px;
  border: 2px solid var(--btn-line);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 650;
  font-size: var(--fs-md);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { --btn-bg: var(--surface-3); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--brand-ink); --btn-line: var(--brand); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: var(--danger-ink); --btn-line: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { --btn-bg: transparent; --btn-line: transparent; }
.btn-ghost:hover { --btn-bg: var(--hover); }
.btn-outline { --btn-bg: transparent; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn-xl { min-height: 64px; font-size: 1.25rem; border-radius: var(--radius); padding: 14px 24px; }

.btn .icon { width: 20px; height: 20px; flex: none; }

/* ---------- Formulare ---------- */

.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }

.input, select.input, textarea.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--text);
}
.input:focus-visible { border-color: var(--focus-color); }
.input[aria-invalid="true"] { border-color: var(--danger); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input[type="datetime-local"].input, input[type="date"].input { color-scheme: dark; }

.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }

/* ---------- Karten, Badges, Meldungen ---------- */

.card {
  background: linear-gradient(180deg, var(--sheen), transparent 40%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.02em;
  background: var(--surface-3); color: var(--text-2);
}
.badge-live { background: rgba(74, 222, 128, 0.15); color: var(--ok); }
.badge-warn { background: rgba(255, 200, 87, 0.16); color: var(--warn); }
.badge-danger { background: rgba(255, 107, 107, 0.16); color: var(--danger); }
.badge-muted { background: transparent; border: 1px solid var(--line-strong); color: var(--text-3); }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  font-size: var(--fs-sm);
}
.notice-warn { background: rgba(255, 200, 87, 0.10); border-color: rgba(255, 200, 87, 0.45); color: var(--warn-text); }
.notice-error { background: rgba(255, 107, 107, 0.10); border-color: rgba(255, 107, 107, 0.5); color: var(--error-text); }
.notice-ok { background: rgba(74, 222, 128, 0.10); border-color: rgba(74, 222, 128, 0.45); color: var(--ok-text); }

.offline-banner {
  position: sticky; top: 0; z-index: 50;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: var(--offline-bg); color: var(--warn-text); border-bottom: 1px solid rgba(255, 200, 87, 0.5);
  font-size: var(--fs-sm); text-align: center;
}

.toast-region {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(12px + var(--safe-top)); z-index: 100; /* oben: verdeckt nie Start/Stopp */
  display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  animation: toast-in 0.2s ease-out;
}
.toast.toast-error { border-color: var(--danger); }
.toast.toast-ok { border-color: var(--ok); }
.toast.toast-warn { border-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Dialoge ---------- */

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.dialog-body { padding: var(--space-5); display: grid; gap: var(--space-4); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }

/* ---------- Theme-Klassen ---------- */

.theme-cyan { --accent: var(--c-cyan); }
.theme-green { --accent: var(--c-green); }
.theme-purple { --accent: var(--c-purple); }
.theme-orange { --accent: var(--c-orange); }
.theme-pink { --accent: var(--c-pink); }
.theme-yellow { --accent: var(--c-yellow); }
.theme-red { --accent: var(--c-red); }
.theme-blue { --accent: var(--c-blue); }
.theme-slate { --accent: var(--c-slate); }

.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--accent, var(--brand)); flex: none; }

/* ---------- Pixel-Logo ---------- */

.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; font-size: 1.15rem; }
.logo img { width: 34px; height: 34px; border-radius: 9px; }
.logo small { display: block; font-weight: 500; font-size: var(--fs-xs); color: var(--text-3); letter-spacing: 0; }

.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--surface-3); border-top-color: var(--brand);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* =====================================================================
   Skins – überschreiben nur Design-Tokens. Auswahl über <html data-skin="…">
   nacht (Standard) · neon · dschungel · lava · arktis (hell)
   ===================================================================== */

:root[data-skin="neon"] {
  --bg: #12051f;
  --bg-2: #1a0a2c;
  --surface: #221038;
  --surface-2: #2c1647;
  --surface-3: #3a1f5c;
  --line: #3f2466;
  --line-strong: #5a3590;
  --text: #fbefff;
  --text-2: #d6bdf0;
  --text-3: #a88bc9;
  --brand: #ff3fd0;
  --brand-ink: #2b0022;
  --glow-1: rgba(255, 63, 208, 0.18);
  --glow-2: rgba(34, 211, 238, 0.16);
  --grid-line: rgba(255, 63, 208, 0.05);
  --header-bg: rgba(18, 5, 31, 0.88);
  --backdrop: rgba(10, 2, 20, 0.75);
  --focus-color: #22d3ee;
}

:root[data-skin="dschungel"] {
  --bg: #0b1a10;
  --bg-2: #0f2216;
  --surface: #14301d;
  --surface-2: #1a3b25;
  --surface-3: #23502f;
  --line: #2a5a37;
  --line-strong: #3a7a4a;
  --text: #effbe9;
  --text-2: #c2e3b4;
  --text-3: #8fb882;
  --brand: #a3e635;
  --brand-ink: #142400;
  --glow-1: rgba(163, 230, 53, 0.12);
  --glow-2: rgba(250, 204, 21, 0.08);
  --grid-line: rgba(163, 230, 53, 0.04);
  --header-bg: rgba(11, 26, 16, 0.88);
  --backdrop: rgba(4, 12, 6, 0.75);
  --focus-color: #facc15;
}

:root[data-skin="lava"] {
  --bg: #1a0b07;
  --bg-2: #22100a;
  --surface: #2e160e;
  --surface-2: #3a1d12;
  --surface-3: #4c2617;
  --line: #5a2e1b;
  --line-strong: #7d4024;
  --text: #fff3ea;
  --text-2: #f2c9ad;
  --text-3: #c99377;
  --brand: #ff7a1a;
  --brand-ink: #2a0e00;
  --glow-1: rgba(255, 122, 26, 0.16);
  --glow-2: rgba(239, 68, 68, 0.12);
  --grid-line: rgba(255, 122, 26, 0.04);
  --header-bg: rgba(26, 11, 7, 0.88);
  --backdrop: rgba(14, 4, 2, 0.75);
  --focus-color: #fde047;
}

:root[data-skin="arktis"] {
  color-scheme: light;
  --bg: #e8f1fb;
  --bg-2: #f5f9ff;
  --surface: #ffffff;
  --surface-2: #eef4fc;
  --surface-3: #dce8f7;
  --line: #c9d9ee;
  --line-strong: #9fb8d8;
  --text: #0e1c33;
  --text-2: #33476a;
  --text-3: #5b6f91;
  --brand: #0e7fd8;
  --brand-ink: #ffffff;
  --danger: #dc2626;
  --danger-ink: #ffffff;
  --warn: #b45309;
  --warn-ink: #ffffff;
  --ok: #15803d;
  --glow-1: rgba(14, 127, 216, 0.14);
  --glow-2: rgba(94, 234, 212, 0.18);
  --grid-line: rgba(14, 28, 51, 0.05);
  --sheen: rgba(255, 255, 255, 0.6);
  --hover: rgba(14, 28, 51, 0.06);
  --header-bg: rgba(232, 241, 251, 0.9);
  --backdrop: rgba(14, 28, 51, 0.45);
  --focus-color: #f59e0b;
  --warn-text: #7c3a00;
  --error-text: #8f1515;
  --ok-text: #0f5a2a;
  --offline-bg: #fde8b0;
  --shadow: 0 8px 24px rgba(14, 28, 51, 0.12);
}
:root[data-skin="arktis"] input[type="datetime-local"].input,
:root[data-skin="arktis"] input[type="date"].input { color-scheme: light; }

/* Skin-Auswahl (Vorschau-Karten) */
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.skin-card {
  position: relative; display: grid; gap: 8px; padding: 10px; text-align: left; cursor: pointer;
  border-radius: var(--radius); border: 2px solid var(--line-strong); background: var(--surface-2); color: var(--text);
}
.skin-card[aria-checked="true"] { border-color: var(--focus-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-color) 35%, transparent); }
.skin-card[aria-checked="true"]::after {
  content: "✓"; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; background: var(--focus-color); color: #111; font-weight: 900;
}
.skin-preview { height: 64px; border-radius: 10px; position: relative; overflow: hidden; }
.skin-preview::before, .skin-preview::after { content: ""; position: absolute; border-radius: 6px; }
.skin-preview::before { left: 10px; top: 12px; width: 44%; height: 16px; background: var(--p-surface); }
.skin-preview::after { left: 10px; bottom: 10px; width: 62%; height: 14px; background: var(--p-brand); }
.skin-name { font-weight: 750; }
.skin-preview.nacht { background: linear-gradient(135deg, #0c1222, #16213a); --p-surface: #24355a; --p-brand: #2ee6d6; }
.skin-preview.neon { background: linear-gradient(135deg, #12051f, #3a1f5c); --p-surface: #5a3590; --p-brand: #ff3fd0; }
.skin-preview.dschungel { background: linear-gradient(135deg, #0b1a10, #23502f); --p-surface: #3a7a4a; --p-brand: #a3e635; }
.skin-preview.lava { background: linear-gradient(135deg, #1a0b07, #4c2617); --p-surface: #7d4024; --p-brand: #ff7a1a; }
.skin-preview.arktis { background: linear-gradient(135deg, #e8f1fb, #ffffff); --p-surface: #c9d9ee; --p-brand: #0e7fd8; border: 1px solid #c9d9ee; }

/* ---------- Zugangssperre (Master-Passwort) ---------- */

/* Bis zur Freischaltung ist von der App nichts zu sehen – nur das Passwortfeld. */
body[data-master-gate]:not(.master-ok) > :not(#master-gate):not(#toasts):not(main) { display: none !important; }
/* Während der Prüfung nur der Ladekreis; ist das Passwortfeld offen, nur das Passwortfeld */
body[data-master-gate]:not(.master-ok) main > :not(#screen-loading),
body[data-master-gate].master-gate-open main { display: none !important; }
.master-gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.master-card {
  width: min(360px, 100%);
  display: grid; gap: var(--space-4); justify-items: center;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.master-card .input, .master-card .btn, .master-card .form-error { width: 100%; }
.master-card .form-error { min-height: 1.4em; margin: 0; text-align: center; color: var(--error-text); font-weight: 600; font-size: var(--fs-sm); }
.master-logo { width: 64px; height: 64px; }
.master-title { font-size: var(--fs-lg); font-weight: 800; }
