/*
 * Design tokens.
 *
 * Palette from the INCEIF University logo: brand cyan #05a4d5 and brand
 * green #62b446 (--color-brand-*). They are used as they are where they are
 * decoration (the brand gradient, tree node fills); where a colour is text
 * or carries white text, a deeper shade of the same hue is used instead
 * (--color-accent, --color-primary, --color-accent-2), so contrast stays at
 * 4.5:1 or more. In dark mode the accents are lighter shades.
 *
 * Light palette lives on bare :root. Dark overrides live under
 * [data-theme="dark"] AND under prefers-color-scheme:dark guarded with
 * :not([data-theme="light"]), so:
 *   - no explicit choice yet  -> follows OS
 *   - explicit "light"        -> always light, even in a dark OS
 *   - explicit "dark"         -> always dark, even in a light OS
 */

/*
 * Inter (variable font, one file for every weight), served from our own
 * origin: frontend/fonts/InterVariable.woff2, from https://rsms.me/inter/
 * (SIL Open Font License). `swap` shows the system font until it has loaded.
 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterVariable.woff2") format("woff2");
}

:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-surface-alt: #f0f1f4;
  --color-border: #e0e2e8;
  --color-text: #1c1e26;
  --color-text-muted: #6b6f7b;
  --color-brand-cyan: #05a4d5;
  --color-brand-green: #62b446;
  --color-accent: #027ca8; /* brand cyan, deepened: 4.7:1 on white */
  --color-accent-2: #378429; /* brand green, deepened: 4.7:1 on white */
  --color-danger: #e63946;

  --brand-gradient: linear-gradient(90deg, #05a4d5 0%, #62b446 100%);

  --topbar-height: 3.5rem;
  --footer-height: 2.25rem;
  --sidebar-width: 15rem;
  --sidebar-width-collapsed: 4rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;

  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 20, 30, 0.08);

  --transition-fast: 150ms ease;
  --transition-medium: 240ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Typography. Not colours, so declared once here (no dark copy).
     Every font-size, font-weight and font-family in the app's CSS is one of
     these; the printed report (report-doc.css) keeps its own sizes. */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Sizes, at the 16px root: 12 / 13 / 14 / 16 / 18 / 22 / 26px. */
  --text-xs: 0.75rem; /* smallest allowed: badges, uppercase labels, footnotes */
  --text-sm: 0.8125rem; /* secondary text, hints, dense table cells */
  --text-base: 0.875rem; /* body, tables, inputs, buttons */
  --text-md: 1rem; /* step and dialog headings, the guide's text */
  --text-lg: 1.125rem; /* page and section headings */
  --text-xl: 1.375rem; /* brand, large titles */
  --text-2xl: 1.625rem; /* sign-in page brand */

  --weight-regular: 400; /* body */
  --weight-medium: 500; /* labels, buttons, tabs, table headers, error lines */
  --weight-semibold: 600; /* headings, names, totals */
  --weight-bold: 800; /* the brand only */

  --leading-normal: 1.5; /* text */
  --leading-tight: 1.3; /* headings */

  /* ---- Spacing scale (padding, margin, gap): 2 / 4 / 6 / 8 / 10 / 12 / 16 /
     20 / 24 / 32 / 40px. Layout-specific sizes (3rem and up, negative
     offsets, 1px nudges) stay as written where they are used. */
  --space-0-5: 0.125rem;
  --space-1: 0.25rem;
  --space-1-5: 0.375rem;
  --space-2: 0.5rem;
  --space-2-5: 0.625rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* ---- Controls: one height for buttons and inputs, one focus ring. */
  --control-height: 2.25rem;
  --focus-ring: 2px solid var(--color-accent);

  --color-node-deceased: #e63946;
  --color-node-heir: #05a4d5;
  /* Family tree after Step 2 runs: heirs it found Terhalang / Layak. */
  --color-node-blocked: #6b7280;
  --color-node-eligible: #378429;
  --color-node-incomplete-border: #d0a900;
  /* Notice (.notice in components.css, e.g. the heir disclaimers): a
     yellow caution box -- background, edge and text, text >7:1 on its fill. */
  --color-notice-bg: #fff6d1;
  --color-notice-border: #d0a900;
  --color-notice-text: #4d3d00;
  --color-edge: #9498a3;
  --color-edge-label: #6b6f7b;
  /* Lateral relationships (spouse, sibling -- same generation, no
     ancestor/descendant direction) are still drawn as directed edges
     (see family-tree.js) but in this color instead of --color-edge, so
     "peer-level" reads at a glance without needing a different line
     style (dashing) to do it. */
  --color-edge-lateral: #2f6feb;
  /* Both node fills above are saturated enough, in both themes, that a
     single constant works as the color drawn on top of them (the person
     icon inside each node circle -- see family-tree.js and the report's
     tree-svg.js). Still declared per-theme block per this file's own
     convention rather than assumed constant, in case a future palette
     tweak needs it to diverge. */
  --color-node-label-on-fill: #ffffff;
  /* The family tree's own state colours (both trees -- family-tree.css and
     the report's tree in report-doc.css -- nodes and their legend
     swatches): lighter shades of deceased / Layak / Terhalang than the
     --color-node-* ones above, so the rings around the person avatars are
     easy to tell apart. The --color-node-* ones stay as they are for
     everything else (status labels with white text, borders). The "not
     stated" icon sits on these light fills, so it is drawn dark. */
  --color-tree-node-deceased: #f4a1a6;
  --color-tree-node-eligible: #a3d68c;
  --color-tree-node-blocked: #c3c8d0;
  /* An heir who gave up their share (Tanazul, Steps 13-15): light orange. */
  --color-tree-node-tanazul: #ffc48a;
  --color-tree-node-icon-on-light: #2b2f3a;
  /* The family tree's canvas (behind the nodes), lighter than --color-surface-alt. */
  --color-tree-stage: #f8f9fb;

  /* Backdrop behind a modal dialog (see session-io.css) -- a dedicated
     token rather than an inline rgba() so light/dark get independently
     tuned opacity instead of one value that's wrong in one of them. */
  --color-scrim: rgba(20, 20, 30, 0.35);
  --color-scrim-strong: rgba(10, 10, 15, 0.82); /* behind a full-size image (admin image viewer) */

  /* Guided-input card's filled action button -- a fixed, high-contrast
     pair (white text on this deep cyan is 4.7:1 in both themes; the regular
     dark-theme --color-accent is too light to carry white text). */
  --color-guide-action: #027ca8;
  --color-guide-action-text: #ffffff;

  /* Primary filled button (Next, Proceed, sign-in, dialogs): the same
     high-contrast pair in both themes -- white on this deep cyan is 4.7:1. */
  --color-primary: #027ca8;
  --color-on-primary: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #14151a;
    --color-surface: #1b1d24;
    --color-surface-alt: #22242c;
    --color-border: #2c2f39;
    --color-text: #e9eaee;
    --color-text-muted: #9498a3;
    --color-brand-cyan: #05a4d5;
    --color-brand-green: #62b446;
    --color-accent: #2bb8e6;
    --color-accent-2: #7cc95f;
    --color-danger: #ff6b6b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);

    --color-node-deceased: #ff6b6b;
    --color-node-heir: #2bb8e6;
    --color-node-blocked: #6b7280;
    --color-node-eligible: #378429;
    --color-node-incomplete-border: #e0c341;
    --color-notice-bg: #3a3112;
    --color-notice-border: #e0c341;
    --color-notice-text: #f5e7b0;
    --color-edge: #4a4e5a;
    --color-edge-label: #9498a3;
    --color-edge-lateral: #5b9dff;
    --color-node-label-on-fill: #ffffff;
    --color-tree-node-deceased: #ff9a9a;
    --color-tree-node-eligible: #8fd36f;
    --color-tree-node-blocked: #a3a9b4;
    --color-tree-node-tanazul: #ffb26b;
    --color-tree-node-icon-on-light: #1b1d24;
    --color-tree-stage: #22242c;
    --color-scrim: rgba(0, 0, 0, 0.55);
    --color-scrim-strong: rgba(0, 0, 0, 0.88);
    --color-guide-action: #027ca8;
    --color-guide-action-text: #ffffff;
    --color-primary: #027ca8;
    --color-on-primary: #ffffff;
  }
}

:root[data-theme="dark"] {
  --color-bg: #14151a;
  --color-surface: #1b1d24;
  --color-surface-alt: #22242c;
  --color-border: #2c2f39;
  --color-text: #e9eaee;
  --color-text-muted: #9498a3;
  --color-brand-cyan: #05a4d5;
  --color-brand-green: #62b446;
  --color-accent: #2bb8e6;
  --color-accent-2: #7cc95f;
  --color-danger: #ff6b6b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);

  --color-node-deceased: #ff6b6b;
  --color-node-heir: #2bb8e6;
  --color-node-blocked: #6b7280;
  --color-node-eligible: #378429;
  --color-node-incomplete-border: #e0c341;
  --color-notice-bg: #3a3112;
  --color-notice-border: #e0c341;
  --color-notice-text: #f5e7b0;
  --color-edge: #4a4e5a;
  --color-edge-label: #9498a3;
  --color-edge-lateral: #5b9dff;
  --color-node-label-on-fill: #ffffff;
  --color-tree-node-deceased: #ff9a9a;
  --color-tree-node-eligible: #8fd36f;
  --color-tree-node-blocked: #a3a9b4;
  --color-tree-node-tanazul: #ffb26b;
  --color-tree-node-icon-on-light: #1b1d24;
  --color-tree-stage: #22242c;
  --color-scrim: rgba(0, 0, 0, 0.55);
  --color-scrim-strong: rgba(0, 0, 0, 0.88);
  --color-guide-action: #027ca8;
  --color-guide-action-text: #ffffff;
  --color-primary: #027ca8;
  --color-on-primary: #ffffff;
}
