/* ============================================
   Smart Home HMI — Design Tokens
   Eigenständiges HMI-Designsystem
   Quelle: docs/01-design-system.md (Phase 1)
   Regel: Änderungen IMMER synchron mit tokens.json
   ============================================ */

:root {
  --lamp-glow-day-strength: 0.45;
  --lamp-glow-min-strength: 0.25;
  --lamp-glow-center-opacity: 0.85;
  --lamp-glow-halo-opacity: 0.4;
  --ambient-map-edge-blur: 2px;
  --ambient-map-focus-mask: radial-gradient(ellipse 60% 65% at 50% 45%, transparent 50%, #000 100%);
  --ambient-map-water: #435c61;
  --ambient-map-green: #555d32;
  --ambient-map-water-opacity: 0.55;
  --ambient-map-green-opacity: 0.5;
  --glass-scrim: rgba(11, 14, 18, 0.35);
  --glass-fill: rgba(26, 28, 34, 0.42);
  --notification-face: rgba(26, 28, 34, 0.72);
  --glass-blur-radius: 18px;
  --glass-saturation: 1.2;
  --glass-text: #fff;
  --glass-text-secondary: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.22);
  --tablet-night-shade: rgba(0, 0, 0, 0.22);
  /* Android house-tablet shell and offline QWERTZ input method. */
  --tablet-panel: var(--glass-fill);
  --tablet-control: color-mix(in srgb, var(--color-text-primary) 12%, transparent);
  --tablet-bar-top: 48px;
  --tablet-bar-bottom: 64px;
  --tablet-dock-height: 60px;
  --tablet-panel-radius: 24px;
  --tablet-device-width: 360px;
  --tablet-content-width: 440px;
  --tablet-notification-width: 620px;
  --tablet-notification-toast-width: 520px;
  --tablet-notification-row-height: 72px;
  --tablet-slider-height: 148px;
  --tablet-slider-compact: 100px;
  --tablet-slider-width: 60px;
  --tablet-segment-gap: 3px;
  --tablet-app-height: 88px;
  --tablet-keyboard-width: 1040px;
  --tablet-keyboard-landscape-height: 280px;
  --tablet-keyboard-portrait-height: 320px;

  /* ── Surfaces (Dark Mode, Default) ──
     Kühler Unterton (Blau > Rot), für kühle, kontrastreiche Oberflächen abgestimmt:
     Screen #12171D, Panel #1E262E, Chips #313B46 */
  --color-surface-0: #0b0e12;
  --color-surface-1: #141920;
  --color-surface-2: #1d242d;
  --color-surface-3: #28313c;
  --color-surface-inverse: #e6eef6;

  /* Dark image-editing workspace, independent of the page theme. */
  --image-workspace-background: #12203e;
  --image-workspace-panel: rgba(20, 32, 50, 0.88);
  --image-workspace-control: rgba(255, 255, 255, 0.12);
  --image-workspace-foreground: #f5f8fc;
  --image-workspace-secondary: rgba(245, 248, 252, 0.78);
  --image-workspace-border: rgba(245, 248, 252, 0.24);
  --image-workspace-selected: #101822;

  /* ── Accent Colors ──
     Warmer Akzent, auf #F5B03C abgestimmt
     Kühler Akzent, auf #4E9CD0 abgestimmt */
  --color-accent-warm: #f5b03c;
  --color-accent-warm-hover: #ffc85e;
  --color-accent-cool: #4e9cd0;
  --color-accent-cool-hover: #6bb2de;

  /* ── Licht-„An"-Akzent (Bernstein/Amber) — eigenes Tokenpaar für die
     Licht-Kacheln, bewusst wärmer als der UI-Akzent (Hauser-OS-Wärme).
     fill = Icon-Feld-Fläche, icon = Glühbirne, border = Icon-Feld-Rand. ── */
  --accent-light-on-fill: #633806;
  --accent-light-on-icon: #fac775;
  --accent-light-on-border: #ba7517;

  /* Verlauf-Endpunkte der Farbtemperatur-Skala (Licht-Detail): warm ↔ kühl.
     Physikalische Lichtfarben, theme-unabhängig → einmal im :root definiert
     (der Light-Block erbt sie, weil er sie nicht überschreibt). */
  --light-temp-warm: #ff9636;
  --light-temp-cool: #cfe0ff;

  /* ── Semantic Colors ── */
  --color-success: #46b876;
  --color-warning: #f5b03c;
  --color-error: #e85050;
  --color-info: #4e9cd0;

  /* ── Text Colors (kühl getönt, wie Ausgangswert #E1F0FE/#C2CFDB) ── */
  --color-text-primary: #e6eef6;
  --color-text-secondary: #9aa7b4;
  --color-text-tertiary: #5a6470; /* nur nicht-essenzielle Labels ≥14px */
  --color-text-on-accent: #0b0e12;
  --color-text-on-inverse: #0b0e12;

  /* ── Deep Night (Ambient 22:00–06:00) ── */
  --color-ambient-deep-night-background: #000000;
  --color-ambient-deep-night-clock: #8f1820;

  /* ── Deckkraft ──
     Der Ambient-Stadtplan liegt als Maske über der primären Schriftfarbe.
     Genau ein Wert für Light und Dark — ein einziges Asset, keine
     Theme-Varianten (docs/18 §3.1). Theme-unabhängig, deshalb nur hier. */
  --opacity-ambient-map: 0.1;

  /* ── Borders (Ghost-Buttons, outlined Cards) ── */
  --color-border: #2c353f;

  /* ── Status-Dots (referenzieren Semantik — eine Quelle) ── */
  --color-dot-online: var(--color-success);
  --color-dot-warning: var(--color-warning);
  --color-dot-offline: var(--color-error);
  --color-dot-presence: var(--color-success);

  /* ── Typography ──
     Hausers Handschrift (R48, docs/23): eine Familie, zwei Stimmen.
     Alegreya Sans steuert, Alegreya erzählt — self-hosted, System-Stack nur
     als Fallback. Inter und Instrument Serif sind abgelöst. */
  --font-family: 'Alegreya Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --font-family-display: 'Alegreya', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; /* Papier: Begrüßung, Zettel, Kalender, Energiezahlen */
  --font-family-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

  /* Type Scale — dramatische Spreizung (Mikro-Labels ↔ Hero-Werte).
     2026-07-05: global ×≈1.125 angehoben (Smoke-Test Pad 3: „einen Tick
     zu klein" auf 13,2" @ 1696px) — Herleitung/Beschluss: docs/01 */
  --text-3xs: 11px;  /* Einheiten, Caps-Mikro-Labels */
  --text-2xs: 12px;  /* Status-Chips, Badges, Timestamps */
  --text-xs: 14px;   /* Card-Labels */
  --text-sm: 16px;   /* Body in Cards */
  --text-base: 18px; /* Primärer Lesetext, Nav-Labels */
  --text-md: 20px;   /* Card-Titel */
  --text-lg: 24px;   /* Bereichs-Titel */
  --text-xl: 32px;   /* Sekundäre Datenwerte */
  --text-2xl: 40px;  /* Screen-Titel */
  --text-3xl: 54px;  /* Raumtemperatur, große KPIs */
  --text-4xl: 72px;  /* Hero-Werte (Detailansicht) */
  --text-display: 104px; /* Dominante Raumwerte in großen Steuerkarten */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --leading-hero: 1.05;   /* 48–64px Werte */
  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-normal: 1.4;
  --leading-relaxed: 1.5;

  /* Negative Laufweiten halbiert mit R48: Alegreya Sans läuft von sich aus
     enger als Inter, für das die alten Werte gemessen waren. */
  --tracking-tightest: -0.03em; /* nur 4xl */
  --tracking-tighter: -0.025em;
  --tracking-tight: -0.015em;
  --tracking-snug: -0.01em;
  --tracking-normal: 0;
  --tracking-wide: 0.01em;
  --tracking-caps: 0.08em; /* nur uppercase Mikro-Labels (3xs/2xs) */

  /* ── Spacing (8px rhythm) ── */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* ── Border Radii ── */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px; /* Hero-Karten, Nav-Container */
  --radius-full: 9999px;

  /* ── Elevation ──
     Dark Mode: Tiefe über Surface-Level + Border, Schatten nur für Overlays */
  --elevation-overlay-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 4px 24px rgba(0, 0, 0, 0.5);

  /* ── Overlay-Scrim (Room Overlay u. a.): Dim + Blur, Tap schließt.
     Blur wird NIE animiert — nur die Scrim-Opacity (docs/01) ── */
  --overlay-scrim: rgba(11, 14, 18, 0.55);
  --overlay-blur: 20px;
  /* Glass-Ebenen: Der diagonale Tonverlauf bricht große monotone Flächen auf.
     Controls bleiben deutlich heller als das Panel und damit als bedienbare
     Ebene erkennbar — auch wenn iOS den Backdrop-Blur reduziert. */
  --overlay-panel-background: linear-gradient(145deg, color-mix(in srgb, var(--color-surface-2) 86%, transparent), color-mix(in srgb, var(--color-surface-1) 78%, transparent));
  --overlay-control-background: color-mix(in srgb, var(--color-surface-3) 96%, transparent);
  --overlay-border: color-mix(in srgb, var(--color-text-primary) 24%, transparent);

  /* ── Motion: Easing ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-glider: cubic-bezier(0.34, 1.4, 0.64, 1);

  /* ── Motion: Duration (Startwerte, Validierung Phase 2) ── */
  --duration-instant: 0ms;
  --duration-fast: 80ms;    /* Pressed-Scale, Toggle-Snap */
  --duration-quick: 120ms;  /* Release mit Spring */
  --duration-normal: 180ms; /* State-Wechsel, Fades */
  --duration-slow: 240ms;   /* Screen-Transitions (Budget-Obergrenze) */
  --duration-enter: 300ms;  /* Modal/Overlay-Entrance (Budget-Maximum) */
  --duration-wobble: 200ms;  /* Toggle-Widerspruch: Zurückspringen mit Wobble (docs/02) */
  --duration-correct: 300ms; /* Slider-/Wert-Korrektur interpolieren (docs/02) */
  --duration-tabfade: 200ms;  /* Tab-Crossfade der Panel-Screens */
  --duration-glider: 460ms;  /* Bestehende Feder der Navigationspille */
  --duration-emphasis: 400ms; /* Erfolgsmoment, gestaffelter Balkenaufbau — nie für Bedienrückmeldung */
  --duration-dusk: 1200ms;    /* Dämmerung und Nachdimmen des Hero-Bildes (Paket 4) — reine
                                 Opacity über dem Compositor, nie für Bedienrückmeldung */

  /* ── Touch Targets ── */
  --touch-min: 44px;
  --touch-preferred: 48px;
  /* ValueSlider (das Hauser-Thumb-Pattern): Wert sitzt IM Thumb-Badge; aktiv via scale */
  --slider-thumb: 40px;
  --slider-thumb-active: 44px;

  /* ── Icons (Outline, 1.5px Stroke, currentColor) ── */
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
  --icon-xl: 32px;

  /* ── Grid ── */
  --grid-gap: 16px;
  --grid-gap-section: 24px;
  --grid-padding: 32px;

  /* ── Breakpoints (Dokumentationskonstanten — in Media Queries
       als Literalwerte verwenden, CSS-Variablen sind dort ungültig) ──
     Abgeleitet vom OnePlus Pad 3 (ADR-010), Viewport dpr 2 —
     am Gerät verifiziert (Smoke-Test 2026-07-04):
     tablet-min: 1024px   | pad3-portrait: 1200px
     desktop-dev: 1440px  | pad3-landscape: 1696px (Design-Primärformat) */

  /* Local Hauser website presentation: editorial composition. */
  --story-gutter:clamp(var(--space-5),3vw,var(--space-7));
  --story-header:calc(var(--space-8) + var(--space-4));
  --story-footer:calc(var(--space-8) + var(--space-5));
  --story-rule:1px;
  --story-touch:calc(var(--space-6) + var(--space-3));
  --story-guide:360px;
  --story-guide-reserve:178px;
  --story-title:clamp(var(--text-3xl),7.7vw,calc(var(--text-display) + var(--space-3)));
  --story-shade:color-mix(in srgb,var(--color-surface-0) 82%,transparent);
  --story-ink:var(--color-text-primary);
  --story-paper:var(--color-surface-1);
  --story-border:color-mix(in srgb,var(--color-text-primary) 16%,transparent);
  --story-panel-width:1440px;
  --story-panel-aspect:1.6;
  --story-panel-min-aspect:1.3333333333;
  --story-rail-width:calc(var(--space-8) * 3 + var(--space-4));
  --story-sheet-width:620px;

}

/* ── Light Mode (Day-Theme, aus den Tagesbetrieb ausgelegt) ──
   Umschaltung via data-theme-Attribut, NICHT prefers-color-scheme:
   Day/Night wird von der App gesteuert (Phase 2: manueller Switcher,
   Phase 3: sun.sun-Automatik mit Crossfade — docs/07, Screen 9).
   Das OS-Theme des Kiosk-Geraets ist bewusst irrelevant. */
:root[data-theme='light'] {
    --color-surface-0: #f2f0ec;
    --color-surface-1: #f5f3ef;
    --color-surface-2: #faf8f4;
    --color-surface-3: #fffdf9;
    --color-surface-inverse: #212121;

    --color-accent-warm: #f5a81c;
    --color-accent-warm-hover: #e09305;
    --color-accent-cool: #1b6fa8;
    --color-accent-cool-hover: #15597f;

    /* Licht-„An"-Akzent im Day-Theme (heller Bernstein) */
    --accent-light-on-fill: #faeeda;
    --accent-light-on-icon: #ba7517;
    --accent-light-on-border: #ef9f27;

    --color-success: #2e8f55;
    --color-warning: #b87a14;
    --color-error: #c43c3c;
    --color-info: #1b6fa8;

    --color-text-primary: #212121;
    --color-text-secondary: #494949;
    --color-text-tertiary: #7e7e7e;
    --color-text-on-accent: #212121;
    --color-text-on-inverse: #fafafa;

    --color-border: #d5d3cf;

    /* Light Mode darf echte Schatten (weiße Cards mit Soft-Shadow) */
    --elevation-overlay-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --overlay-scrim: rgba(242, 240, 236, 0.55);
    --overlay-panel-background: linear-gradient(145deg, color-mix(in srgb, var(--color-surface-3) 90%, transparent), color-mix(in srgb, var(--color-surface-1) 82%, transparent));
    --overlay-control-background: color-mix(in srgb, var(--color-surface-0) 94%, transparent);
    --overlay-border: color-mix(in srgb, var(--color-text-primary) 20%, transparent);
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-quick: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-enter: 0ms;
    --duration-wobble: 0ms;
    --duration-correct: 0ms;
    --duration-tabfade: 0ms;
    --duration-glider: 0ms;
    --duration-emphasis: 0ms;
    --duration-dusk: 0ms;
  }
}

/* ── Global Resets ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
  background-color: var(--color-surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  background-color: var(--color-surface-0);
}

/* ── Utility: Surface Levels ── */
.surface-0 { background-color: var(--color-surface-0); }
.surface-1 { background-color: var(--color-surface-1); }
.surface-2 { background-color: var(--color-surface-2); }
.surface-3 { background-color: var(--color-surface-3); }

/* ── Utility: Text Levels ── */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }

/* Arbeitsweg: gemeinsame Karten- und Glaswerte. */
:root {
  --commute-map-duration: 900ms;
  --commute-route-duration: 1400ms;
  --commute-map-zoom: 0.24;
  --commute-route-width: 3px;
  --commute-line-thin: 1px;
  --commute-pin-width: 1.5px;
  --commute-route-halo-opacity: 0.12;
  --commute-card-opacity: 88%;
  --commute-card-top: 55%;
  --commute-card-width: calc(var(--space-8) * 9);
  --commute-clock-top: 8%;
  --commute-card-compact-top: 54%;
  --commute-phone-bottom: 21%;
  --commute-phone-clock-top: 10%;
}

:root[data-theme='light'] {
  --ambient-map-water: #98b4b7;
  --ambient-map-green: #b2ba8a;
}

:root {
  --time-picker-selection-opacity: 0.35;
  --time-picker-width: calc(var(--space-8) * 12);
  --time-picker-dial-size: calc(var(--space-8) * 5);
}
