/* ==========================================================================
   ColdGuard Theme – wiederverwendbar für Website und spätere Webapp
   Enthält: Design-Tokens (Light/Dark), Basis-Stile, UI-Komponenten.
   Seiten-Layouts gehören NICHT hierher, sondern in site.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   Light/Dark über light-dark(): folgt color-scheme.
   - Standard: System-Präferenz
   - data-theme="light" | "dark" am <html> erzwingt einen Modus
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Markenfarben (konstant) */
  --brand-navy: #142b50;
  --brand-royal: #2563eb;
  --brand-ice: #dbeafe;

  /* Semantische Farben */
  --color-bg: light-dark(#f4f7fc, #0b1424);
  --color-surface: light-dark(#ffffff, #142138);
  --color-surface-muted: light-dark(#dbeafe, #1e3151);
  --color-surface-sunken: light-dark(#eaf1fb, #0f1b2f);
  --color-text: light-dark(#17243a, #f1f5f9);
  --color-text-muted: light-dark(#475569, #b0bdd0);
  --color-heading: light-dark(#142b50, #f1f5f9);
  --color-primary: light-dark(#2563eb, #93c5fd);
  --color-action-bg: #2563eb;
  --color-action-bg-hover: #1d4ed8;
  --color-action-text: #ffffff;
  --color-border: light-dark(#cbd5e1, #384b65);
  --color-border-subtle: light-dark(#e2e8f0, #23344f);
  --color-focus: light-dark(#2563eb, #93c5fd);

  --color-danger: light-dark(#b42318, #fca5a5);
  --color-danger-bg: light-dark(#fef3f2, #3b1219);
  --color-success: light-dark(#166534, #86efac);
  --color-success-bg: light-dark(#ecfdf3, #0f2e1f);
  --color-warning: light-dark(#92400e, #fcd34d);
  --color-warning-bg: light-dark(#fffaeb, #33260b);

  /* Logo */
  --logo-shield: light-dark(#142b50, #ffffff);
  --logo-flake: light-dark(#2563eb, #dbeafe);

  /* Typografie */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
  --text-2xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.5rem);
  --text-3xl: clamp(2.25rem, 1.5rem + 3.2vw, 4rem);
  --leading-tight: 1.12;
  --leading-normal: 1.6;

  /* Abstände */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Formen */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px light-dark(rgb(20 43 80 / 0.06), rgb(0 0 0 / 0.3));
  --shadow-md: 0 4px 12px -2px light-dark(rgb(20 43 80 / 0.08), rgb(0 0 0 / 0.35)),
    0 2px 4px -2px light-dark(rgb(20 43 80 / 0.06), rgb(0 0 0 / 0.25));
  --shadow-lg: 0 24px 48px -16px light-dark(rgb(20 43 80 / 0.22), rgb(0 0 0 / 0.55));

  --transition: 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* --------------------------------------------------------------------------
   2. Basis (bewusst zurückhaltend, keine aggressiven Resets)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--space-4);
  color: var(--color-heading);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  font-weight: 750;
  text-wrap: balance;
}
h1 { font-size: var(--text-3xl); letter-spacing: -0.035em; }
h2 { font-size: var(--text-2xl); letter-spacing: -0.03em; }
h3 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); text-wrap: pretty; }

a {
  color: var(--color-primary);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

img, svg { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--brand-royal); color: #fff; }

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-action-bg);
  color: var(--color-action-text);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: var(--space-4); }

/* --------------------------------------------------------------------------
   3. Komponenten (opt-in über Klassen)
   -------------------------------------------------------------------------- */

/* Logo-Icon (inline SVG) */
.fg-logo-shield { stroke: var(--logo-shield); }
.fg-logo-flake { stroke: var(--logo-flake); }
.fg-logo-dot { fill: var(--logo-flake); stroke: var(--logo-flake); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0.75rem 1.375rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition),
    color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 1.125em; height: 1.125em; flex: none; }

.btn-primary {
  background: var(--color-action-bg);
  color: var(--color-action-text);
  box-shadow: 0 8px 20px -8px rgb(37 99 235 / 0.6);
}
.btn-primary:hover { background: var(--color-action-bg-hover); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-heading);
  border-color: var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }

.btn-ghost {
  background: transparent;
  color: var(--color-text);
}
.btn-ghost:hover { background: var(--color-surface-muted); }

.btn-sm { min-height: 40px; padding: 0.5rem 1rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1.5px solid var(--color-border-subtle);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.icon-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.icon-btn svg { width: 20px; height: 20px; }

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

/* Badges & Status */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--color-surface-muted);
  color: var(--color-heading);
}
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* Icon-Kachel */
.icon-tile {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  color: var(--color-primary);
  flex: none;
}
.icon-tile svg { width: 26px; height: 26px; }

/* Formulare */
.field { display: grid; gap: var(--space-2); }
.field label,
.field legend {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-heading);
}
.field .hint { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 400; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.95rem;
  font: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { min-height: 120px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--color-text-muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-focus) 25%, transparent);
}
.input:user-invalid, .textarea:user-invalid, .select:user-invalid { border-color: var(--color-danger); }

.checkbox {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.checkbox input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--brand-royal);
  flex: none;
}

/* Hinweise / Alerts */
.notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-surface-sunken);
  font-size: var(--text-sm);
}
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.notice-success { background: var(--color-success-bg); color: var(--color-success); border-color: transparent; }
.notice-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: transparent; }
.notice-info { background: var(--color-surface-muted); color: var(--color-heading); border-color: transparent; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border-subtle); }
.table th { color: var(--color-heading); font-weight: 650; }

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
