/* Design Tokens — Spacing, Radius, Z-Index, Shadows, Timing */

:root {
  /* Spacing scale (4px base) */
  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 0.125rem;  /* 2px */
  --space-1: 0.25rem;     /* 4px */
  --space-1-5: 0.375rem;  /* 6px */
  --space-2: 0.5rem;      /* 8px */
  --space-3: 0.75rem;     /* 12px */
  --space-4: 1rem;        /* 16px */
  --space-5: 1.25rem;     /* 20px */
  --space-6: 1.5rem;      /* 24px */
  --space-8: 2rem;        /* 32px */
  --space-10: 2.5rem;     /* 40px */
  --space-12: 3rem;       /* 48px */
  --space-16: 4rem;       /* 64px */
  --space-20: 5rem;       /* 80px */
  --space-24: 6rem;       /* 96px */
  --space-32: 8rem;       /* 128px */

  /* Border radius */
  --radius-none: 0;
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px */
  --radius-xl: 0.75rem;   /* 12px */
  --radius-2xl: 1rem;     /* 16px */
  --radius-full: 9999px;

  /* Z-index scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;

  /* Timing / duration */
  --duration-instant: 75ms;
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
  --duration-slower: 600ms;

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --rail-width: 240px;
  --rail-collapsed: 64px;
  /* Railnav typography — px, compact (admin 0.875rem + text-xs at data-mode=admin root). */
  --railnav-item-font-size: 12px;
  --railnav-group-font-size: 10px;
  --railnav-icon-size: 20px;
  --railnav-chevron-size: 18px;
  /* Railnav mark / switcher cluster (Debug-1 → BS-9r). 26/12/18 + menu width =
     --rail-width − 2× shell-metric space-4. gap:2px → --shell-metric-space-0-5. */
  --railnav-mark-size: 26px;
  --railnav-mark-font-size: 12px;
  --railnav-switcher-menu-width: calc(var(--rail-width) - 2 * var(--shell-metric-space-4));
  /* Shell Metric — mode-immune chrome geometry (BS-F → BS-9r). .shell__* regions
     rebind --space-*/--text-*/--radius-* to these so rem root scaling cannot drift chrome. */
  --shell-metric-space-0-5: 2px;
  --shell-metric-space-1: 4px;
  --shell-metric-space-1-5: 6px;
  --shell-metric-space-2: 8px;
  --shell-metric-space-3: 12px;
  --shell-metric-space-4: 16px;
  --shell-metric-space-5: 20px;
  --shell-metric-space-6: 24px;
  --shell-metric-space-8: 32px;
  --shell-metric-space-10: 40px;
  --shell-metric-space-12: 48px;
  --shell-metric-text-xs: 12px;
  --shell-metric-text-sm: 14px;
  --shell-metric-text-base: 16px;
  --shell-metric-text-lg: 18px;
  --shell-metric-radius-sm: 4px;
  --shell-metric-radius-md: 6px;
  --shell-metric-radius-lg: 8px;
  --shell-metric-radius-xl: 12px;
  /* Brandplate logo height budget (Polish-1 → BS-9r) — viewport mid of the clamp. */
  --brandplate-logo-vh-budget: 12vh;
  --crown-height: 56px;
  --crown-height-collapsed: 40px;
  --crown-logo-height: 36px;
  --participation-progress-height: 48px;
  --participation-footer-height: 64px;
  --content-max-width: 960px;
  --stage-max-width: 1280px; /* multi-zone Stage grid cap, left-anchored (shell/zones.css; approved 2026-07-08).
                                px, NOT rem — html[data-mode] scales the root (admin --text-sm vs participant
                                --text-base), so a rem cap rendered ~1120px on admin vs 1280px on member surfaces.
                                The ONE Stage width constraint is mode-immune (user ruling 2026-07-09). */
  --dashboard-home-max-width: 1080px;
  --participation-max-width: var(--content-max-width);
  --field-max-width-compact: 24rem; /* 384px — phone-input width; pairs with .form-input--compact / .form-select--compact at 640px+ */
  --admin-toolbar-search-min-width: 16rem; /* fits longest admin index "Search …" placeholder */
  --admin-toolbar-search-max-width: 40rem; /* command-bar search group on desktop */

  /* Breakpoints (for reference — use @media) */
  /* --bp-sm: 640px; */
  /* --bp-md: 768px; */
  /* --bp-lg: 1024px; */
  /* --bp-xl: 1440px; */
}

@media (max-width: 767px) {
  :root { --crown-height: 48px; }
}

/* ── CONTROL TEXT FLOOR · the iOS focus-zoom cure ─────────────────────────────
   iOS and iPadOS zoom the ENTIRE page when a focused text control renders below
   16px, and they never zoom back out — the member is left panned off the page
   with the field they were typing in half off-screen. The DS type scale bottoms
   out at 13-14px on phones (--text-sm / --text-base), so EVERY field in the app
   tripped it: members' sign-in, participation answers, message-board composer,
   admin forms (reported on /members/sign_in, polish session PS-1, 2026-07-23).

   The only other cure is `maximum-scale=1` on the viewport, which kills
   pinch-to-zoom app-wide — a WCAG 1.4.4 failure. So: a floor, not a rescale.
   0 on precise pointers, so desktop density is byte-identical; 16px on coarse
   ones. Controls compose it with their own designed size via
   `max(var(--control-min-font-size), <token>)`, which raises a control that
   would have rendered too small and leaves a bigger one exactly as designed. */
:root { --control-min-font-size: 0px; }

@media (pointer: coarse) {
  :root { --control-min-font-size: 16px; }
}
