/* ==========================================================================
   SurveyPlanner Pro — design tokens
   --------------------------------------------------------------------------
   Single source of truth for color, type, spacing, borders and elevation.
   Brand values marked [guide] come from "Brand & Marketing Guidelines v0.1"
   (provisional working specifications). Values marked [derived] are
   proposed extensions needed for accessible web use; see
   docs/BRAND-NOTES.md before treating any of them as approved.
   Contrast ratios are checked by `npm run check` (scripts/check.mjs).
   ========================================================================== */

:root {
  /* ---- Brand primitives [guide] --------------------------------------- */
  --spp-navy: #0b2d3f;        /* Deep navy */
  --spp-teal: #0f7a7a;        /* Teal */
  --spp-orange: #f57c00;      /* Surveying orange — accent only */
  --spp-gray: #e6ebef;        /* Light gray */
  --spp-offwhite: #f7f9fb;    /* Off-white */

  /* ---- Extended primitives [derived] ---------------------------------- */
  --spp-navy-950: #071f2c;    /* deeper navy for layered dark surfaces */
  --spp-navy-800: #123c52;    /* raised dark surface */
  --spp-navy-700: #1d4d66;    /* hairlines / grid on dark surfaces */
  --spp-teal-700: #0b6464;    /* teal text on light gray (teal fails 4.5:1 there) */
  --spp-teal-300: #6fc9c3;    /* teal text and lines on navy (teal is 2.8:1 there) */
  --spp-slate-teal: #2f6b78;  /* middle layer tone sampled from the layer study */
  --spp-slate-600: #4a6474;   /* muted body text on light surfaces */
  --spp-slate-300: #a9bfcb;   /* muted body text on dark surfaces */
  --spp-gray-300: #c9d3da;    /* stronger dividers on light surfaces */
  --spp-white: #ffffff;

  /* ---- Typography ----------------------------------------------------- */
  --font-heading: "Montserrat Variable", "Montserrat", "Segoe UI", system-ui,
    -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Fluid type scale (min @ 360px → max @ 1280px) */
  --text-xs: 0.8125rem;                                  /* 13px labels */
  --text-sm: 0.9375rem;                                  /* 15px */
  --text-base: 1.0625rem;                                /* 17px body */
  --text-lg: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem);
  --text-xl: clamp(1.3125rem, 1.15rem + 0.7vw, 1.75rem);
  --text-2xl: clamp(1.625rem, 1.3rem + 1.4vw, 2.5rem);
  --text-3xl: clamp(2.25rem, 1.6rem + 2.9vw, 4rem);
  --text-display: clamp(2.75rem, 1.7rem + 4.6vw, 5.75rem);

  --leading-tight: 1.08;
  --leading-snug: 1.25;
  --leading-body: 1.6;
  --tracking-heading: -0.02em;
  --tracking-label: 0.12em;

  /* ---- Spacing (4px base) --------------------------------------------- */
  --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;
  --space-10: 8rem;
  --section-pad: clamp(4rem, 2.5rem + 6vw, 8rem);

  /* ---- Layout --------------------------------------------------------- */
  --container-max: 75rem;                    /* 1200px */
  --container-narrow: 46rem;
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem); /* 16px minimum on phones */

  /* ---- Borders, radii, elevation -------------------------------------- */
  --border-hair: 1px;
  --border-strong: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(11 45 63 / 0.06), 0 1px 1px rgb(11 45 63 / 0.04);
  --shadow-md: 0 6px 24px -8px rgb(11 45 63 / 0.18), 0 2px 6px rgb(11 45 63 / 0.06);
  --shadow-lg: 0 24px 60px -24px rgb(11 45 63 / 0.35);

  /* ---- Focus ---------------------------------------------------------- */
  --focus-width: 3px;
  --focus-offset: 3px;

  /* ---- Motion --------------------------------------------------------- */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration-slow: 900ms;
}

/* ==========================================================================
   Semantic surface themes. Apply .theme-light or .theme-dark to <body> or to
   a section; components read only these semantic tokens.
   ========================================================================== */

:root,
.theme-light {
  --color-bg: var(--spp-offwhite);
  --color-surface: var(--spp-white);
  --color-surface-muted: var(--spp-gray);
  --color-heading: var(--spp-navy);
  --color-text: var(--spp-navy);
  --color-text-muted: var(--spp-slate-600);
  --color-accent-text: var(--spp-teal);          /* 4.87:1 on off-white */
  --color-accent-text-on-muted: var(--spp-teal-700);
  --color-line: var(--spp-gray);
  --color-line-strong: var(--spp-gray-300);
  --color-map-line: var(--spp-teal);
  --color-focus: var(--spp-teal);
  --color-link: var(--spp-teal);
  --color-link-hover: var(--spp-navy);
}

.theme-dark {
  --color-bg: var(--spp-navy);
  --color-surface: var(--spp-navy-800);
  --color-surface-muted: var(--spp-navy-950);
  --color-heading: var(--spp-offwhite);
  --color-text: var(--spp-offwhite);
  --color-text-muted: var(--spp-slate-300);
  --color-accent-text: var(--spp-teal-300);      /* 7.4:1 on navy */
  --color-accent-text-on-muted: var(--spp-teal-300);
  --color-line: var(--spp-navy-700);
  --color-line-strong: #2b6280;
  --color-map-line: var(--spp-teal-300);
  --color-focus: var(--spp-teal-300);
  --color-link: var(--spp-teal-300);
  --color-link-hover: var(--spp-offwhite);
}

/* Sections that switch theme must also re-apply the text color. */
.theme-light,
.theme-dark {
  color: var(--color-text);
}
