/* DentaPlan design tokens (VORAAA-7).
 * Based on the look of the HKP mockup (mockup/web/app.css). Only these variables
 * may carry raw colour, size or timing values; components use the variables.
 * Docs: docs/design/README.md
 */
:root, .theme-light {
  color-scheme: light;
  /* ---- Brand ---- */
  --accent: #0f9f8f;
  --accent-600: #0b8577;
  --accent-700: #08695e;
  --accent-50: #e8f7f4;
  --accent-100: #cdeee7;
  --accent-grad: linear-gradient(135deg, #19b9a6, var(--accent-600));
  --accent-text: #08695e;    /* links and accent-coloured text (6.58:1 on white); never use --accent for text */
  --primary-fill: #0b8577;   /* primary button fill: white text 4.53:1 (VORAAA-20 F5) */
  --primary-fill-hover: #08695e;
  --on-accent: #ffffff;      /* text on --primary-fill / --accent badges */

  /* ---- Neutrals ---- */
  --ink: #0f2a33;        /* text, headings */
  --ink-2: #4a6168;      /* secondary text (AA on white and --bg) */
  --ink-3: #637479;      /* tertiary text, 4.6:1 on --bg (mockup #8a9ca1 was too light) */
  --ink-4: #a9b8bc;      /* disabled, decorative only */
  --line: #e6eef0;
  --line-2: #d5e0e2;     /* stronger divider, input border on tablets */
  --bg: #f5f9fa;
  --card: #ffffff;
  --sunk: #f6fafb;       /* inset areas, list items */
  --neutral-50: #eef2f4;
  --raised: #ffffff;     /* popovers, dialogs */
  --field-bg: #fbfdfd;   /* input fill */
  --field-border: #7f9297; /* 3.25:1 vs card (WCAG 1.4.11) */
  --seg-bg: #eef3f4;     /* segmented control track */
  --seg-on: #ffffff;     /* selected segment */
  --chip-ink: #4f6369;   /* neutral chip text */
  --glass: rgba(255, 255, 255, .86); /* top bar, action bar */
  --backdrop: rgba(15, 42, 51, .45);
  --toast-bg: #0f2a33;  --toast-ink: #ffffff;  --toast-ok: #5eead4;
  --danger-fill: #b53131; --on-danger: #ffffff;
  --paper: #ffffff;      /* signature pad and document previews: always white */
  --row-line: #f0f4f5;   /* table row divider */
  --own-fill: #f2b544;   /* patient share in cost bars */

  /* ---- Status (UI) — each text colour has ≥ 4.5:1 on its own -50 tint ---- */
  --amber: #8f5a07;   --amber-50: #fdf4e3;   /* warnings, "erneuerungsbedürftig" */
  --red: #b53131;     --red-50: #fdecec;     /* errors, "nicht erhaltungswürdig" */
  --blue: #2a63c2;    --blue-50: #eaf1fd;    /* info, "eingereicht", intact prosthetics */
  --green: #157a40;   --green-50: #e6f6ec;   /* success, "genehmigt", patient choice */
  --violet: #6b46c1;  --violet-50: #f3eefe;  /* PKV, GOZ, special findings */
  --coral: #b34a3a;   --coral-50: #fdeeea;   /* partial defects (pw, ww) */
  /* text colour of alerts on their tint */
  --info-ink: #1f4f9e; --warn-ink: #7a4c06; --error-ink: #9c2b2b; --ok-ink: #17663a;

  /* ---- Tooth chart ---- */
  --tooth-enamel: #ffffff;
  --tooth-stroke: #c9d6d9;
  --tooth-root: #f3f6f7;
  --tooth-root-stroke: #d5e0e2;
  --tooth-metal: #7b8e94;        /* implants, posts */
  --tooth-gum: #f2a7a7;          /* denture saddle */
  --tooth-gum-50: #fbe3e3;
  --tooth-link: #4a6168;         /* bridge connector */
  --tooth-metal-fill: #dfe7ea;
  --tooth-renew-fill: #fff3dd;
  --tooth-remove-fill: #fde4e1;
  --tooth-intact-stroke: #7c9fe0;
  --tooth-defect-stroke: #e0796c;
  --tc-intact: #2a63c2; --tc-renew: #8f5a07; --tc-remove: #b53131; --tc-defect: #b34a3a; --tc-info: #6b46c1; --tc-ink: #4a6168;
  --tc-intact-50: #eaf1fd; --tc-defect-50: #fdeeea; --tc-gum-50: #fbe3e3;
  --st-intact: var(--blue);      --st-intact-50: var(--blue-50);
  --st-renew: var(--amber);      --st-renew-50: var(--amber-50);
  --st-remove: var(--red);       --st-remove-50: var(--red-50);
  --st-defect: var(--coral);     --st-defect-50: var(--coral-50);
  --st-info: var(--violet);      --st-info-50: var(--violet-50);
  --st-missing: #8a9ca1;         --st-missing-50: var(--neutral-50);

  /* ---- Treatment options (R / G / A) ---- */
  --opt-r: var(--accent-700);    --opt-r-50: var(--accent-50);    /* Regelversorgung */
  --opt-g: var(--blue);          --opt-g-50: var(--blue-50);      /* gleichartig */
  --opt-a: var(--violet);        --opt-a-50: var(--violet-50);    /* andersartig */

  /* ---- Illustrations (match the Astra images in web/img) ---- */
  --ill-bg: #fdf3e9;
  --ill-enamel: #fbfaf6;
  --ill-gum: #f2a7a7;
  --ill-bone: #f3e6cf;

  /* ---- Typography ---- */
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px;     /* captions, chart numbers */
  --fs-sm: 13px;     /* secondary text, table cells */
  --fs-md: 15px;     /* body */
  --fs-lg: 17px;     /* card titles on the patient page */
  --fs-xl: 20px;
  --fs-2xl: clamp(22px, 3vw, 30px); /* page title */
  --fs-num: 26px;    /* KPI, totals */
  --fs-hero: 40px;   /* patient share on the costs step */
  --fw-regular: 400; --fw-medium: 500; --fw-semi: 600; --fw-bold: 700;
  --lh-tight: 1.2; --lh: 1.5;
  --tracking-tight: -.02em;
  --tracking-caps: .06em;

  /* ---- Spacing (4 px grid) ---- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --gutter: clamp(14px, 4vw, 40px);
  --content-max: 1120px;
  --reading-max: 760px;
  /* 2.3 layout tiers (VORAAA-88, ADR 0004): only with <html class="l23"> (flag layout_v23, logged in).
   * Breakpoints – media queries can't read custom properties, so they are written out in the tier
   * rules below, in /layout23.css and in /shell23.js:
   *   phone < 600 (unchanged) · tablet 600–1023 · laptop 1024–1439 · desktop 1440–1919 · wide ≥ 1920 */
  --rail-w: 0px;          /* side rail (≥ 1024; the phone and the tablet keep the top bar) */
  --rail-w-icons: 76px;   /* rail with icons only (laptop default, "Leiste einklappen") */
  --rail-w-open: 232px;   /* rail with labels (desktop/wide default, "Leiste ausklappen") */
  --work-max: var(--content-max); /* page container: 1120 up to 1023, fluid from 1024, 2400 cap from 1920 */
  --read-max: var(--content-max); /* reading pages (Patientenseite, Einstellungen) */
  --pane-w: 400px;        /* non-modal side panel beside the content (UI.panel) */
  --pane-min: 320px; --pane-max: 720px; /* resize range of the side panel on wide screens */
  --gap-ws: var(--sp-4);  /* gap between workspace columns */
  --row-pad: 14px;        /* table/list row padding (comfortable) */
  --ctl-h: var(--touch);  /* control height (36 px when compact) */

  /* ---- Shape ---- */
  --r-xs: 6px;    /* code tags */
  --r-sm: 9px;    /* segment buttons */
  --r-md: 12px;   /* buttons, inputs, list rows */
  --r-lg: 14px;   /* inner cards, options */
  --radius: 18px; /* cards */
  --r-xl: 22px;   /* sheets, patient option cards */
  --r-pill: 999px;

  /* ---- Elevation ---- */
  --shadow: 0 1px 2px rgba(15, 42, 51, .04), 0 8px 24px rgba(15, 42, 51, .06);
  --shadow-lg: 0 24px 60px rgba(15, 42, 51, .25);
  --shadow-accent: 0 6px 16px rgba(15, 159, 143, .28);
  --ring: 0 0 0 3px var(--accent-50);
  --focus: 0 0 0 3px #fff, 0 0 0 5px var(--accent);

  /* ---- Touch ---- */
  --touch: 44px;      /* minimum hit target (WCAG 2.5.5 / Apple HIG) */
  --touch-tooth: 40px; /* minimum tooth cell width on tablets; phones scroll the chart */

  /* ---- Buttons: one scale (docs/design/buttons.md, VORAAA-70) ---- */
  --btn-h: 44px;      /* default: page, card and sheet-footer actions */
  --btn-h-sm: 36px;   /* compact: in-card/row actions on fine pointers; 44 px on touch */
  --btn-px: 18px;     /* side padding (phone: 14px) */
  --btn-px-sm: 12px;  /* side padding of compact and quiet buttons */
  --btn-icon: 18px;   /* icon size in a default button */
  --btn-icon-sm: 16px;

  /* ---- Motion ---- */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.3, 1.6, .5, 1);
  --t-fast: .12s; --t: .2s; --t-slow: .35s;

  /* ---- Layers ---- */
  --z-sticky: 20; --z-actionbar: 15; --z-backdrop: 40; --z-sheet: 41; --z-pop: 50; --z-toast: 60;

  /* ---- Print / PDF (A4) ---- */
  --pdf-margin-top: 18mm;
  --pdf-margin-side: 18mm;
  --pdf-margin-bottom: 20mm;
  --pdf-fs: 9.5pt;
  --pdf-fs-sm: 8pt;
  --pdf-fs-h1: 15pt;
  --pdf-fs-h2: 11pt;
  --pdf-line: #9fb0b4;
  --pdf-fill: #eef4f5;

  /* Breakpoints (media queries cannot read variables; keep these numbers in sync):
   *   phone   < 600px   one column, bottom sheets, chart scrolls sideways
   *   tablet  600–1023  two columns where useful, chart fits without scrolling
   *   desktop ≥ 1024    content max 1120px, three alternatives side by side
   * With the 2.3 layout (flag layout_v23) ≥ 1024 splits into laptop 1024–1439, desktop 1440–1919
   * and wide ≥ 1920 (see the 2.3 tier tokens above and the tier rules after this block).
   */
}

/* ---- 2.3 tiers (flag layout_v23): fluid container, rail, panel width, density ---- */
@media (min-width: 1024px) {
  :root.l23 { --rail-w: var(--rail-w-icons); --work-max: none; --read-max: 1600px; --gutter: 28px; }
  :root.l23.rail-wide { --rail-w: var(--rail-w-open); }
  /* compact density: set by shell23.js for a fine pointer (mouse) or when chosen in Einstellungen */
  :root.l23.dense { --touch: 36px; --btn-h: 36px; --touch-tooth: 30px; --row-pad: 9px; --ctl-h: 36px; }
}
@media (min-width: 1440px) { :root.l23 { --gutter: 32px; --pane-w: 380px; } }
@media (min-width: 1920px) { :root.l23 { --work-max: 2400px; --read-max: 2000px; --gutter: 40px; --pane-w: var(--pane-w-user, 420px); --gap-ws: var(--sp-5); } }

/* ---- Dark theme (VORAAA-20 spec §8, VORAAA-21) ----
 * Screen only: PDFs and print always use the light values above. theme.js sets
 * <html data-theme="light|dark"> before first paint (system preference or the user's choice).
 * .theme-light forces the light set inside a dark page (document previews, signature pad). */
@media screen {
  :root[data-theme="dark"], .theme-dark {
    color-scheme: dark;
    --accent: #2bbfab;
    --accent-600: #25a897;
    --accent-700: #3fd0bc;
    --accent-50: #0f2f2b;
    --accent-100: #14403a;
    --accent-grad: linear-gradient(135deg, #2bbfab, #1b8f81);
    --accent-text: #3fd0bc;
    --primary-fill: #2bbfab;
    --primary-fill-hover: #3fd0bc;
    --on-accent: #04231f;

    --ink: #e6eff1;
    --ink-2: #a7bbc0;
    --ink-3: #8aa0a6;
    --ink-4: #4f6369;
    --line: #1f2e33;
    --line-2: #2a3c42;
    --bg: #0b1417;
    --card: #121e22;
    --sunk: #0e181b;
    --neutral-50: #1a272b;
    --raised: #1a282d;
    --field-bg: #0e181b;
    --field-border: #64808a;
    --seg-bg: #0e181b;
    --seg-on: #22343a;
    --chip-ink: #a7bbc0;
    --glass: rgba(18, 30, 34, .86);
    --backdrop: rgba(0, 0, 0, .6);
    --toast-bg: #e6eff1;  --toast-ink: #0f2a33;  --toast-ok: #0f766e;
    --danger-fill: #c43d3d; --on-danger: #ffffff;
    --row-line: #1a282d;

    --amber: #f2b85c;   --amber-50: #2b2213;
    --red: #ff8f8f;     --red-50: #2e1618;
    --blue: #8db6ff;    --blue-50: #15223b;
    --green: #62d49a;   --green-50: #10271b;
    --violet: #bba3ff;  --violet-50: #221b3b;
    --coral: #ff9d89;   --coral-50: #2d1915;
    --info-ink: #8db6ff; --warn-ink: #f2b85c; --error-ink: #ff8f8f; --ok-ink: #62d49a;

    --tooth-enamel: #f4f7f8;
    --tooth-stroke: #9fb0b4;
    --tooth-root: #c9d6d9;
    --tooth-root-stroke: #9fb0b4;
    --tooth-link: #a7bbc0;
    --st-missing: #7d9298;

    --ill-bg: #fdf3e9;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
    --shadow-accent: 0 6px 16px rgba(0, 0, 0, .35);
    --focus: 0 0 0 3px #0b1417, 0 0 0 5px #3fd0bc;
  }
}
