/* ============================================================
   ef-tokens.css: the design tokens of easiForms. Load it FIRST.
   ------------------------------------------------------------
   Structure and rules from Kolmena (kolmenapp/frontend/app/css/kol-tokens.css,
   2026-11-24, room kolmena-easiforms-css-design). Values are easiForms' own:
   a deep teal accent and cool neutrals. Decision: tracker note e94bfbf8.

   Load order on every page:
     js/theme.js (classic script, in <head>) -> ef-tokens.css -> app.css
     -> the page's own sheets (fields.css, field-app.css, designer.css).

   THE RULES
   1. One accent. Teal marks what is actionable or selected. Nothing else
      is teal, so the eye finds the next step without looking for it.
   2. Red is for destruction and errors only. A delete button is red in an
      organization whose colour is red.
   3. Never type a colour in a page stylesheet. Use a semantic name below,
      or a step of the brand ramp (--brand-23 ... --brand-98).
   4. Text ON the brand fill is var(--brand-on). Brand-coloured text on a
      light surface is var(--brand-ink). Never #fff by hand: an organization
      with a yellow colour needs dark text on its buttons (theme.js decides).
   5. Type floor 11px. Reading text 14px or more; form answers 16px, so a
      phone does not zoom into the field.
   6. Surfaces are flat. Shadows only on what floats: menus, dialogs, toasts.
   7. Defaults are written with :where() so a component's own rule wins
      without a fight. No !important outside [hidden] and reduced motion.
   ============================================================ */

:root {
  /* --- Brand ramp ------------------------------------------------------
     21 steps from Kolmena's theme.js (OKLab), computed for easiForms teal
     #0F6E6A. theme.js rewrites all of them when an organization has its own
     colour, and in dark mode. Low steps are ink, high steps are washes. */
  --brand-23: #101c1b; --brand-32: #0f2928; --brand-43: #0f3937; --brand-47: #0f3f3d;
  --brand-51: #084643; --brand-54: #064b48; --brand-58: #05514e; --brand-62: #025754;
  --brand-67: #005f5c; --brand-72: #006763; --brand-74: #036a66; --brand-76: #076d69;
  --brand-78: #1d7974; --brand-81: #398f8b; --brand-83: #4a9f9a; --brand-87: #6dbeb9;
  --brand-91: #a5dad6; --brand-93: #b7eae6; --brand-96: #dbf9f6; --brand-97: #defcfa;
  --brand-98: #e5fffc;

  --brand:         #0f6e6a;
  --brand-rgb:     15, 110, 106;
  --brand-2:       #27807c;
  --brand-hover:   #005c58;
  --brand-soft:    #f1fbfa;
  --brand-softer:  #f8fdfc;
  --brand-on:      #ffffff;
  --brand-ink:     #0f6e6a;
  --brand-muted:   #0f6e6a;
  --brand-on-dark: #439691;
  --ring:          0 0 0 3px rgba(15, 110, 106, .16);

  /* --- Ink (text). Each passes AA 4.5 on --surface and --canvas. ------- */
  --ink:          #162127;   /* headings, body, answers      */
  --ink-2:        #566269;   /* secondary text, labels' help */
  --ink-3:        #66727a;   /* meta, captions, placeholders */
  --ink-inverse:  #ffffff;

  /* --- Surfaces and lines ---------------------------------------------- */
  --canvas:         #f4f6f7;   /* the page behind everything */
  --surface:        #ffffff;   /* cards, sheets, dialogs     */
  --surface-subtle: #f9fafb;   /* table heads, wells         */
  --surface-muted:  #eef1f3;   /* hover fills, quiet buttons */
  --border-subtle:  #ebeef0;   /* hairlines inside a card    */
  --border:         #e1e5e8;   /* default control border     */
  --border-strong:  #c9d0d4;   /* hover, emphasis            */

  /* --- Status (never recoloured by an organization) -------------------- */
  --success: #1f7a45; --success-bg: #ebf6ef; --success-border: #cfe8d8;
  --danger:  #c0392b; --danger-bg:  #fdf1ef; --danger-border:  #f3d9d4;
  --warning: #9a6700; --warning-bg: #fff6e5; --warning-border: #f3e2bd;
  --info:    #2368c4; --info-bg:    #edf4fd; --info-border:    #d3e3f8;

  /* --- Type ------------------------------------------------------------
     Inter for reading (clear at small sizes, digits line up), Poppins for
     headings, as in Kolmena. Full fallbacks so a slow font load never
     mixes Arial and Poppins on one screen. */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Poppins", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --text-2xs: 11px;   /* the floor */
  --text-xs:  12px;
  --text-sm:  13px;
  --text-md:  14px;   /* body */
  --text-base: 15px;
  --text-lg:  16px;   /* form answers */
  --text-xl:  19px;
  --text-2xl: 24px;
  --text-3xl: 28px;

  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-base:  1.5;

  --track-title: -.015em;   /* h1. Headings only: Spanish runs long */
  --track-head:  -.005em;   /* h2, h3 */

  /* --- Space (4px base), shape, depth, layers, motion ------------------- */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  --radius-sm: 7px;     /* chips, badges       */
  --radius-ctl: 10px;   /* buttons, inputs     */
  --radius-md: 12px;    /* menus, table frames */
  --radius-lg: 16px;    /* cards, sections     */
  --radius-xl: 20px;    /* dialogs, sheets     */
  --radius-pill: 999px;

  --elev-1: 0 1px 2px rgba(16, 24, 40, .05), 0 3px 10px rgba(16, 24, 40, .045);
  --sh-menu: 0 18px 44px rgba(16, 26, 32, .14);
  --sh-dialog: 0 30px 80px rgba(16, 26, 32, .22);

  --z-dropdown: 80; --z-bar: 180; --z-nav: 190; --z-modal: 300; --z-toast: 400;

  --dur-fast: .16s;
  --dur-base: .2s;
  --ease: cubic-bezier(.4, 0, .2, 1);

  --side-w: 248px;
  --content-max: 1180px;
  --ctl-h: 40px;       /* buttons, inputs on desktop */
  --ctl-h-touch: 48px; /* inputs and buttons a thumb uses (fill page) */

  /* --- Older names, pointed at the tokens above --------------------------
     fields.css, field-app.css and designer.css were written with these.
     They keep working and take the new colours. New rules use the names
     above. */
  --bg: var(--canvas);
  --surface-2: var(--surface-muted);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --accent: var(--brand);
  --accent-ink: var(--brand-on);
  --accent-soft: var(--brand-soft);
  --danger-soft: var(--danger-bg);
  --ok: var(--success);
  --ok-soft: var(--success-bg);
  --warn: var(--warning);
  --warn-soft: var(--warning-bg);
  --radius: var(--radius-lg);
  --shadow: none;

  color-scheme: light;
}

/* --- Dark mode: a second token block, nothing else (Kolmena's lesson). The
   brand ramp itself is rewritten by theme.js in dark mode. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6ecee;  --ink-2: #a3afb5;  --ink-3: #87949a;
    --canvas: #11181b; --surface: #182124; --surface-subtle: #1c2629; --surface-muted: #222d31;
    --border-subtle: #233034; --border: #2b383d; --border-strong: #3a4a50;
    --brand-ink: var(--brand-on-dark); --brand-muted: var(--brand-on-dark);
    --brand-soft: #122120; --brand-softer: #101c1b;
    --success: #5cc488; --success-bg: #15281d; --success-border: #22412f;
    --danger:  #ee7a6d; --danger-bg:  #2f1a18; --danger-border:  #4a2723;
    --warning: #e9b44c; --warning-bg: #2d2412; --warning-border: #463819;
    --info:    #78aef0; --info-bg:    #15233a; --info-border:    #22385a;
    --elev-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-menu: 0 18px 44px rgba(0, 0, 0, .5);
    --sh-dialog: 0 30px 80px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* --- Base. Written with :where() so any component rule wins. ----------- */
:where(*, *::before, *::after) { box-sizing: border-box; }
:where(html) { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:where(body) {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
:where(h1, h2, h3) {
  margin: 0 0 .5em;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-snug);
  color: var(--ink);
}
:where(h1) { font-size: clamp(22px, 2vw, 26px); letter-spacing: var(--track-title); line-height: 1.2; }
:where(h2) { font-size: 17px; letter-spacing: var(--track-head); }
:where(h3) { font-size: var(--text-base); letter-spacing: var(--track-head); }
:where(p) { margin: 0 0 .75em; }
:where(a) { color: var(--brand-ink); text-decoration: none; }
:where(a:hover) { text-decoration: underline; text-underline-offset: 2px; }
:where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(img, video) { max-width: 100%; }
/* Icons (js/icons.js) are line drawings that set fill="none" and draw with
   currentColor. They keep their size inside flex rows. */
:where(svg) { flex: none; }
:where(table) { font-variant-numeric: tabular-nums; }
:where(p, li, dd, td, th, h1, h2, h3) { overflow-wrap: anywhere; }

[hidden] { display: none !important; }

/* Focus: visible for keyboards, quiet for mice. */
:where(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
:where(:focus:not(:focus-visible)) { outline: none; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
