/* =========================================================================
   Jamaity — design tokens
   Derived from the logo. Every value here has a reason; see design/README.md.

   The logo is monoline with fully-rounded terminals, generous corner arcs,
   deliberate open gaps, a repeated dot motif, and two-tone nesting.
   Those six traits are the whole system.
   ========================================================================= */

:root {

  /* ---------------------------------------------------------------------
     1. Brand colour — taken literally from jamaity-logo.svg
     --------------------------------------------------------------------- */

  --jam-blue:  #0028a1;   /* .cls-2 — hsl(225 100% 32%) — 11.6:1 on white */
  --jam-mint:  #a1e2b8;   /* .cls-1 — hsl(141  53% 76%) —  1.5:1 on white */
  --jam-ink:   #0a0a0a;   /* .cls-3 */

  /* Blue ramp, hue 225. The workhorse: text, buttons, links, focus. */
  --blue-50:  hsl(225 100% 97%);
  --blue-100: hsl(225 100% 93%);
  --blue-200: hsl(225 100% 86%);
  --blue-300: hsl(225  96% 73%);
  --blue-400: hsl(225  90% 56%);
  --blue-500: hsl(225 100% 42%);
  --blue-600: #0028a1;              /* brand */
  --blue-700: hsl(225 100% 25%);
  --blue-800: hsl(225 100% 18%);
  --blue-900: hsl(225  85% 12%);

  /* Mint ramp, hue 141. The brand mint is a *tint* — it is a surface, never
     a text colour on light. mint-600 is the derived text-safe green
     (#167d3a, 5.2:1 on white) for green-coded labels and icons. */
  --mint-50:  hsl(141  55% 96%);
  --mint-100: hsl(141  53% 91%);
  --mint-200: #a1e2b8;              /* brand */
  --mint-300: hsl(141  45% 64%);
  --mint-400: hsl(141  45% 50%);
  --mint-500: hsl(141  60% 38%);
  --mint-600: hsl(141  70% 29%);    /* text-safe green */
  --mint-700: hsl(141  75% 22%);

  /* Neutrals, cooled very slightly toward the blue so greys sit with the
     brand rather than fighting it. */
  --ink-50:   hsl(225  20% 98%);
  --ink-100:  hsl(225  18% 95%);
  --ink-200:  hsl(225  15% 90%);
  --ink-300:  hsl(225  12% 80%);
  --ink-400:  hsl(225  10% 62%);
  --ink-500:  hsl(225  10% 46%);
  --ink-600:  hsl(225  12% 34%);
  --ink-700:  hsl(225  15% 24%);
  --ink-800:  hsl(225  18% 15%);
  --ink-900:  #0a0a0a;

  /* Status. Kept deliberately narrow — a directory needs few. */
  --ok:     var(--mint-600);
  --ok-bg:  var(--mint-100);
  --warn:    hsl(38 95% 31%);   /* 4.8:1 on white; 38% L measured 3.6:1 */
  --warn-bg: hsl(38 95% 94%);
  --stop:    hsl(357 70% 44%);
  --stop-bg: hsl(357 85% 96%);

  /* ---------------------------------------------------------------------
     2. Semantic surface + text roles
     Components reference these, never the ramps directly. One swap here
     re-themes the site.
     --------------------------------------------------------------------- */

  --surface:          #ffffff;
  --surface-sunken:   var(--ink-50);
  --surface-raised:   #ffffff;
  --surface-brand:       var(--blue-600);
  --surface-brand-hover: var(--blue-500);
  --surface-brand-dp:    var(--blue-800);
  --surface-brand-soft:  var(--blue-50);   /* tinted ground: avatars, hovers */
  --surface-accent:      var(--mint-200);
  --surface-accent-soft: var(--mint-100);

  --text:          var(--ink-900);
  --text-muted:    var(--ink-500);
  --text-subtle:   var(--ink-400);
  --text-on-brand: #ffffff;
  --text-on-brand-muted: hsl(0 0% 100% / 0.7);
  --text-on-accent: var(--blue-800);   /* ink on mint: 8.0:1 */
  --text-link:     var(--blue-600);

  --border:        var(--ink-200);
  --border-strong: var(--ink-300);
  --border-brand:  var(--blue-600);
  --border-on-brand: hsl(0 0% 100% / 0.22);

  /* The mint is a SHAPE colour, never a typographic one.
     It draws marks, arcs, rules and fills — it never sets text, in any
     context, including on the blue. Text on blue is white or white-muted. */
  --shape-accent: var(--mint-200);

  /* The logo's own three fills, as tokens.
     The artwork is never redrawn — only these values change per theme, and a
     recoloured copy of the source file is served for the <img> case. On a
     dark ground the untouched logo measures 1.03:1 (wordmark) and 1.66:1
     (blue mark), i.e. invisible, so this is not optional. */
  --logo-ink:  var(--jam-ink);
  --logo-blue: var(--jam-blue);
  --logo-mint: var(--jam-mint);

  /* ---------------------------------------------------------------------
     3. Stroke — the monoline rule
     The logo uses ONE stroke weight for the wordmark and the mark alike.
     The site does the same: borders, icon strokes, rules, dividers and
     focus rings all use --stroke. Only --stroke-bold exists beside it,
     for the mark itself and hero-scale graphics.
     --------------------------------------------------------------------- */

  /* 2px, not 1px. The monoline is the identity — at hairline weight it read
     as a default browser border rather than a deliberate line, and on a
     high-DPI screen it all but vanished. --stroke-bold moves with it to keep
     the two weights distinguishable. */
  --stroke:      2px;
  --stroke-bold: 3px;

  /* ---------------------------------------------------------------------
     4. Radius — the generous-arc rule
     The house mark's corners are roughly 2.5-3x its stroke width: big
     quarter-circle arcs, not tight fillets. Radii here are correspondingly
     generous, and anything pill-shaped goes fully round because every
     terminal in the logo is a semicircle.
     --------------------------------------------------------------------- */

  --radius-xs:  6px;
  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  32px;
  --radius-2xl: 44px;
  --radius-pill: 999px;

  /* ---------------------------------------------------------------------
     5. Type — Cairo for both scripts
     One family, both scripts, so Arabic and Latin share a voice. Cairo's
     rounded, open, geometric skeleton is already close to the wordmark.
     Scale is a ~1.2 minor third, fluid between 380px and 1440px.
     --------------------------------------------------------------------- */

  --font: "Cairo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", monospace;

  /* -raw is the Latin scale. Components use --fs-*, which Arabic contexts
     redefine (see base.css). Anything that must NOT take the Arabic boost —
     card footers, chrome, metadata — reads --fs-*-raw directly. */
  --fs-2xs-raw: clamp(0.688rem, 0.66rem + 0.11vw, 0.75rem);
  --fs-xs-raw:  clamp(0.75rem,  0.72rem + 0.14vw, 0.813rem);
  --fs-sm-raw:  clamp(0.875rem, 0.85rem + 0.14vw, 0.938rem);
  --fs-md-raw:  clamp(1rem,     0.97rem + 0.16vw, 1.063rem);
  --fs-lg-raw:  clamp(1.125rem, 1.07rem + 0.27vw, 1.25rem);
  --fs-xl-raw:  clamp(1.375rem, 1.26rem + 0.49vw, 1.625rem);
  --fs-2xl-raw: clamp(1.75rem,  1.55rem + 0.87vw, 2.25rem);
  --fs-3xl-raw: clamp(2.25rem,  1.9rem + 1.5vw,   3rem);
  --fs-4xl-raw: clamp(2.75rem,  2.1rem + 2.8vw,   4.25rem);

  --fs-2xs: var(--fs-2xs-raw);
  --fs-xs:  var(--fs-xs-raw);
  --fs-sm:  var(--fs-sm-raw);
  --fs-md:  var(--fs-md-raw);
  --fs-lg:  var(--fs-lg-raw);
  --fs-xl:  var(--fs-xl-raw);
  --fs-2xl: var(--fs-2xl-raw);
  --fs-3xl: var(--fs-3xl-raw);
  --fs-4xl: var(--fs-4xl-raw);

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-black:    900;

  --lh-tight:  1.12;
  --lh-snug:   1.28;
  --lh-normal: 1.6;
  --lh-loose:  1.75;

  /* Arabic sits optically smaller than Latin at the same px and needs more
     leading. Applied via [lang="ar"] in base.css, not by changing the scale. */
  --ar-size-boost: 1.06;
  --ar-lh-boost:   1.12;

  --tracking-tight: -0.02em;
  --tracking-wide:   0.04em;
  --tracking-caps:   0.08em;

  /* ---------------------------------------------------------------------
     6. Space — 4px base
     --------------------------------------------------------------------- */

  --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;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;
  --sp-32: 128px;

  /* Section rhythm, fluid. */
  /* Tightened from clamp(3.5rem, 2rem + 6vw, 7rem). At 1440 that was 112px
     above and below every section — 224px of nothing between one heading and
     the next, which on a catalogue page reads as the site having run out of
     things to say rather than as breathing room. */
  --section-y: clamp(2.5rem, 1.5rem + 3.6vw, 4.5rem);
  --gutter:    clamp(1rem, 0.4rem + 2.4vw, 2.5rem);
  --measure:   68ch;

  --container:        1320px;
  --container-narrow: 820px;
  --container-wide:   1560px;

  /* ---------------------------------------------------------------------
     7. Elevation
     Shadows are tinted with the brand blue rather than neutral black, so
     depth reads as part of the palette.
     --------------------------------------------------------------------- */

  --shadow-sm: 0 1px 2px hsl(225 40% 20% / 0.05),
               0 1px 3px hsl(225 40% 20% / 0.04);
  --shadow-md: 0 2px 4px hsl(225 40% 20% / 0.04),
               0 6px 16px hsl(225 40% 20% / 0.07);
  --shadow-lg: 0 4px 8px hsl(225 40% 20% / 0.04),
               0 16px 36px hsl(225 40% 20% / 0.10);
  --shadow-xl: 0 8px 16px hsl(225 40% 20% / 0.05),
               0 32px 64px hsl(225 40% 20% / 0.14);

  /* Card hover. Its own token rather than --shadow-md, because a card lifting
     under the pointer is a hint and a popover sitting above the page is a
     statement — they want the same geometry at different weights, and --md is
     shared with things that do want the full value. */
  --shadow-hover: 0 2px 4px hsl(225 40% 20% / 0.022),
                  0 6px 16px hsl(225 40% 20% / 0.038);

  /* Focus ring — round-capped and offset, echoing the open-gap rule. */
  --focus-ring: 0 0 0 var(--stroke-bold) var(--surface),
                0 0 0 calc(var(--stroke-bold) + 2px) var(--blue-500);

  /* ---------------------------------------------------------------------
     8. Motion
     The logo is built from strokes that draw and forms that nest. Motion
     follows: things draw in, rise, and settle. Nothing bounces — this is a
     civil-society platform, not a consumer app.
     --------------------------------------------------------------------- */

  --ease-out:   cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0.05, 0.36, 1);
  --ease-entrance: cubic-bezier(0.16, 0.84, 0.44, 1);

  --dur-instant: 90ms;
  --dur-fast:    160ms;
  --dur-base:    260ms;
  --dur-slow:    420ms;
  --dur-slower:  720ms;
  /* The off-canvas nav travels a whole panel width, so it sits between base
     and slow: --base feels snatched away, --slow feels like waiting. */
  --dur-drawer:  320ms;

  --stagger: 70ms;

  /* ---------------------------------------------------------------------
     9. Layering
     --------------------------------------------------------------------- */

  --z-base: 0;
  --z-raised: 10;
  --z-sticky: 100;
  --z-header: 200;
  --z-overlay: 800;
  --z-modal: 900;
  --z-toast: 1000;
}

/* =========================================================================
   Dark mode

   The semantic block above is the only thing that changes. Components never
   branch on theme — they read --surface, --text, --border and so on.

   Two rules, because the theme can come from the system or from the toggle,
   and a no-JS visitor with a dark system must still get dark. The values are
   deliberately written out in both rather than hidden behind an indirection.

   Notes on the palette:
   - The page is a deep blue-black, not neutral grey and not pure black.
     #0028A1 is already a dark blue, so a neutral dark ground would make the
     brand read as muddy navy-on-grey.
   - The brand blue is too dark to sit on a dark ground, so --surface-brand
     steps up to --blue-400 (white on it: 5.3:1). This is the one token whose
     hue shifts between themes, and it is why components must not hardcode
     --blue-600.
   - The mint gets 12:1 on this ground and is genuinely legible here, but it
     stays a shape colour in both themes. One rule, no exceptions.
   ========================================================================= */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --surface:          hsl(225 28% 7%);
    --surface-sunken:   hsl(225 30% 5%);
    --surface-raised:   hsl(225 24% 11%);
    --surface-brand:       var(--blue-400);
    --surface-brand-hover: var(--blue-300);
    --surface-brand-dp:    hsl(225 45% 14%);
    --surface-brand-soft:  hsl(225 40% 16%);
    --surface-accent:      var(--mint-200);
    --surface-accent-soft: hsl(141 30% 14%);

    --text:          hsl(225 14% 93%);
    --text-muted:    hsl(225 10% 66%);
    --text-subtle:   hsl(225  9% 50%);
    --text-on-brand: #ffffff;
    --text-on-brand-muted: hsl(0 0% 100% / 0.72);
    --text-on-accent: var(--blue-900);
    --text-link:     var(--blue-300);

    --border:        hsl(225 16% 18%);
    --border-strong: hsl(225 14% 28%);
    --border-brand:  var(--blue-400);
    --border-on-brand: hsl(0 0% 100% / 0.28);

    --logo-ink:  hsl(225 14% 93%);
    --logo-blue: var(--blue-400);
    --logo-mint: var(--jam-mint);

    --ok:     var(--mint-300);
    --ok-bg:  hsl(141 35% 14%);
    --warn:    hsl(38 90% 66%);
    --warn-bg: hsl(38 40% 14%);
    --stop:    hsl(357 85% 72%);
    --stop-bg: hsl(357 40% 15%);

    /* Shadows read as almost nothing on a dark ground; depth comes from the
       raised surface and the border instead. */
    --shadow-sm: 0 1px 2px hsl(225 60% 2% / 0.5);
    --shadow-md: 0 2px 6px hsl(225 60% 2% / 0.5);
    --shadow-lg: 0 8px 24px hsl(225 60% 2% / 0.6);
    --shadow-xl: 0 16px 48px hsl(225 60% 2% / 0.7);
    --shadow-hover: 0 2px 6px hsl(225 60% 2% / 0.26);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --surface:          hsl(225 28% 7%);
  --surface-sunken:   hsl(225 30% 5%);
  --surface-raised:   hsl(225 24% 11%);
  --surface-brand:       var(--blue-400);
  --surface-brand-hover: var(--blue-300);
  --surface-brand-dp:    hsl(225 45% 14%);
  --surface-brand-soft:  hsl(225 40% 16%);
  --surface-accent:      var(--mint-200);
  --surface-accent-soft: hsl(141 30% 14%);

  --text:          hsl(225 14% 93%);
  --text-muted:    hsl(225 10% 66%);
  --text-subtle:   hsl(225  9% 50%);
  --text-on-brand: #ffffff;
  --text-on-brand-muted: hsl(0 0% 100% / 0.72);
  --text-on-accent: var(--blue-900);
  --text-link:     var(--blue-300);

  --border:        hsl(225 16% 18%);
  --border-strong: hsl(225 14% 28%);
  --border-brand:  var(--blue-400);
  --border-on-brand: hsl(0 0% 100% / 0.28);

  --logo-ink:  hsl(225 14% 93%);
  --logo-blue: var(--blue-400);
  --logo-mint: var(--jam-mint);

  --ok:     var(--mint-300);
  --ok-bg:  hsl(141 35% 14%);
  --warn:    hsl(38 90% 66%);
  --warn-bg: hsl(38 40% 14%);
  --stop:    hsl(357 85% 72%);
  --stop-bg: hsl(357 40% 15%);

  --shadow-sm: 0 1px 2px hsl(225 60% 2% / 0.5);
  --shadow-md: 0 2px 6px hsl(225 60% 2% / 0.5);
  --shadow-lg: 0 8px 24px hsl(225 60% 2% / 0.6);
  --shadow-xl: 0 16px 48px hsl(225 60% 2% / 0.7);
  --shadow-hover: 0 2px 6px hsl(225 60% 2% / 0.26);
}

/* -------------------------------------------------------------------------
   Ground — the surface revealed by the circle wipe, and carried by every
   section after it.

   It is the INVERSE of the page, not a fixed colour: deep blue under a light
   page, near-white under a dark one. That is what the inversion asks for —
   the wipe always reveals the opposite of what you were just looking at, so
   the gesture reads the same in both themes. Defined here rather than in the
   component so the two themes sit side by side and cannot drift.
   ------------------------------------------------------------------------- */

:root {
  --ground-1:    hsl(225 85% 17%);
  --ground-2:    hsl(225 90% 12%);
  --ground-glow: hsl(225 90% 34%);
  --ground-dot:  hsl(0 0% 100% / 0.07);

  --ground-surface:        hsl(225 50% 16%);
  /* Translucent, not a flat colour: a full-width --sunken section painting an
     opaque fill over the ground cuts a visible band across the gradient right
     where the wipe hands over. A tint lets the ground continue through it. */
  --ground-surface-sunken: hsl(0 0% 100% / 0.045);
  /* Cards read --surface-RAISED, not --surface. Leaving it out is what left
     white cards carrying white text on the blue ground. A touch lighter than
     --ground-surface so a card still reads as lifted off it. */
  --ground-raised:         hsl(225 45% 20%);
  --ground-brand-soft:     hsl(0 0% 100% / 0.08);
  --ground-accent-soft:    hsl(141 45% 64% / 0.18);
  --ground-text:           hsl(0 0% 100%);
  --ground-text-muted:     hsl(0 0% 100% / 0.72);
  --ground-text-subtle:    hsl(0 0% 100% / 0.5);
  --ground-link:           var(--mint-200);
  --ground-border:         hsl(0 0% 100% / 0.16);
  --ground-border-strong:  hsl(0 0% 100% / 0.3);
  --ground-shape:          var(--mint-300);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground-1:    hsl(0 0% 99%);
    --ground-2:    hsl(220 18% 93%);
    --ground-glow: hsl(141 58% 88%);
    --ground-dot:  hsl(225 40% 20% / 0.07);

    --ground-surface:        hsl(0 0% 100%);
    --ground-surface-sunken: hsl(225 40% 20% / 0.045);
    --ground-raised:         hsl(0 0% 100%);
    --ground-brand-soft:     var(--blue-50);
    --ground-accent-soft:    var(--mint-100);
    --ground-text:           var(--jam-ink);
    --ground-text-muted:     hsl(225 10% 38%);
    --ground-text-subtle:    hsl(225 8% 54%);
    --ground-link:           var(--blue-600);
    --ground-border:         hsl(225 16% 87%);
    --ground-border-strong:  hsl(225 14% 76%);
    --ground-shape:          var(--jam-mint);
  }
}

:root[data-theme="dark"] {
  --ground-1:    hsl(0 0% 99%);
  --ground-2:    hsl(220 18% 93%);
  --ground-glow: hsl(141 58% 88%);
  --ground-dot:  hsl(225 40% 20% / 0.07);

  --ground-surface:        hsl(0 0% 100%);
  --ground-surface-sunken: hsl(225 40% 20% / 0.045);
  --ground-raised:         hsl(0 0% 100%);
  --ground-brand-soft:     var(--blue-50);
  --ground-accent-soft:    var(--mint-100);
  --ground-text:           var(--jam-ink);
  --ground-text-muted:     hsl(225 10% 38%);
  --ground-text-subtle:    hsl(225 8% 54%);
  --ground-link:           var(--blue-600);
  --ground-border:         hsl(225 16% 87%);
  --ground-border-strong:  hsl(225 14% 76%);
  --ground-shape:          var(--jam-mint);
}

/* Reduced motion: collapse durations to near-zero but keep the tokens so
   nothing has to branch. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant: 1ms;
    --dur-fast:    1ms;
    --dur-base:    1ms;
    --dur-slow:    1ms;
    --dur-slower:  1ms;
    --dur-drawer:  1ms;
    --stagger:     0ms;
  }
}
