/*
 * Qidaya design tokens — emitted from DESIGN.md
 * Loaded before every other stylesheet in base.html.
 * Do not hardcode hex values in other CSS files; reference these vars instead.
 */
:root {
  /* ---------- Colors: surfaces ---------- */
  --color-bg:               #FAF7F0;
  --color-surface:          #FFFDF8;
  --color-surface-muted:    #F2EDE3;
  --color-surface-strong:   #E5DED1;
  /* Lifted surface for sections that are dark-on-light in light mode
   * (sidebar, footer, CTA band). Equals --color-surface in light so
   * components stay correct; in dark mode it elevates one step above
   * the page bg so dark-on-dark sections remain visually distinct. */
  --color-surface-elevated: #FFFDF8;
  /* Sticky-nav background. Translucent so the page can blur through. */
  --color-nav-bg:           rgba(250, 247, 240, 0.92);

  /* ---------- Colors: text ---------- */
  --color-text:           #1B1A17;
  --color-text-muted:     #5F5A50;
  --color-text-inverse:   #FAF7F0;

  /* ---------- Colors: borders ---------- */
  --color-border:         #E2DBCD;
  --color-border-strong:  #C9C0AF;

  /* ---------- Colors: sidebar ---------- */
  --color-sidebar-bg:     #1B1A17;
  --color-sidebar-text:   #D9D2C5;
  --color-sidebar-muted:  #A39B8C;
  --color-sidebar-active: #7FCBDA;
  --color-sidebar-hover:  #2B2925;

  /* ---------- Colors: accent + semantic ---------- */
  --color-accent:        #0F3D4C;
  --color-accent-hover:  #1A5A6E;
  --color-accent-soft:   #DCE9EC;
  /* Text ON an accent fill (primary buttons, active page link). The accent is
   * the logo teal; the dark blocks swap in a light tint of it with dark text,
   * because the logo teal is only 1.5:1 on the dark page. Contrast is pinned
   * by test_design_fixes. */
  --color-on-accent:     #FFFFFF;
  /* Accent-coloured TEXT (links, eyebrows, small labels). Redefined (brighter)
   * in the dark blocks below. Contrast is pinned by test_design_fixes. */
  --color-accent-text:   #134A5C;

  --color-success:       #2F7D4F;
  --color-success-soft:  #DDEEDF;
  --color-warning:       #B7791F;
  --color-warning-soft:  #F7EBD0;
  --color-danger:        #B3261E;
  --color-danger-soft:   #F9DEDC;
  --color-info:          #2B6CB0;
  --color-info-soft:     #DCE8F5;

  /* Text ON the matching -soft background (alerts, warning badges).
   * Dark hues here; the dark theme swaps in light tints so the pair
   * keeps >= 4.5:1 on its 18%-alpha tint. */
  --color-success-text:  #1E5B38;
  --color-warning-text:  #7A4B0C;
  --color-danger-text:   #8C1D18;
  --color-info-text:     #1D4E80;

  /* ---------- Type ---------- */
  --type-family:        "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --type-family-display: "Newsreader", Georgia, "Times New Roman", serif;
  --type-family-mono:   ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;

  --type-size-xs:       12px;
  --type-size-sm:       13px;
  --type-size-base:     15px;
  --type-size-md:       16px;
  --type-size-lg:       17px;
  --type-size-xl:       20px;
  --type-size-2xl:      24px;
  --type-size-3xl:      32px;
  --type-size-4xl:      44px;
  --type-size-5xl:      60px;

  /* Fluid display scale — headline sizes that track the viewport.
     xl: home hero h1 · lg: page-hero h1 / section h2 · md: card h3 */
  --type-display-xl:    clamp(2.75rem, 2.4vw + 2rem, 4.5rem);
  --type-display-lg:    clamp(1.9rem, 1.6vw + 1.4rem, 2.75rem);
  --type-display-md:    clamp(1.15rem, 0.5vw + 1rem, 1.4rem);

  --type-weight-regular:  400;
  --type-weight-medium:   500;
  --type-weight-semibold: 600;
  --type-weight-bold:     700;

  --type-leading-tight: 1.2;
  --type-leading-base:  1.5;
  --type-leading-loose: 1.7;

  /* ---------- Spacing (4px scale) ---------- */
  --space-0:  0;
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* ---------- Radii ---------- */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-pill: 9999px;

  /* ---------- Layout ---------- */
  /* Reading-width blocks on marketing pages (fit panel, shipped list). Card
   * grids use the full 1200px column; nothing sits in between. */
  --layout-reading: 760px;

  /* ---------- Shadows ---------- */
  --shadow-xs:    0 1px 2px rgba(27, 26, 23, 0.04);
  --shadow-sm:    0 1px 3px rgba(27, 26, 23, 0.08), 0 1px 2px rgba(27, 26, 23, 0.04);
  --shadow-md:    0 4px 12px rgba(27, 26, 23, 0.08), 0 2px 4px rgba(27, 26, 23, 0.04);
  --shadow-lg:    0 12px 24px rgba(27, 26, 23, 0.10), 0 4px 8px rgba(27, 26, 23, 0.06);
  --shadow-focus: 0 0 0 3px rgba(15, 61, 76, 0.28);
  --shadow-focus-danger: 0 0 0 3px rgba(179, 38, 30, 0.25);

  /* ---------- Motion ---------- */
  --motion-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --motion-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --motion-slow: 260ms cubic-bezier(0.4, 0, 0.2, 1);

  --ease-out-expo:  cubic-bezier(0.19, 1, 0.22, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ---------- Sidebar shell ---------- */
  --sidebar-width:           240px;
  --sidebar-width-collapsed: 64px;
}

/* Honor reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms linear;
    --motion-base: 0ms linear;
    --motion-slow: 0ms linear;
  }
}

/* ============================================================
 * Dark mode tokens.
 *
 * Two activation paths:
 *   1. Explicit:  <html data-theme="dark">           (user picked dark)
 *   2. Auto:      <html data-theme="auto"> + OS dark (follow system)
 *
 * Tokens not overridden here keep their light values. Only colors,
 * shadow opacities, and the lifted-surface stack change.
 *
 * The two selector blocks are duplicates by design — CSS doesn't have
 * a clean way to share a declaration block across both a selector and
 * a media-query without preprocessing, and ~15 lines of duplication is
 * cheaper than a build step.
 * ============================================================ */
:root[data-theme="dark"] {
  --color-bg:               #171613;
  --color-surface:           #211F1B;
  --color-surface-muted:     #211F1B;
  --color-surface-strong:    #35322C;
  --color-surface-elevated:  #211F1B;
  --color-nav-bg:            rgba(23, 22, 19, 0.88);

  --color-text:              #F3EEE4;
  --color-text-muted:        #BDB5A6;
  /* --color-text-inverse stays light: it's used for text ON dark surfaces
     (sidebar, footer, CTA band, hero) which remain dark in both themes. */

  --color-border:            #35322C;
  --color-border-strong:     #4A463E;

  /* Sidebar lifts one step in dark so it stays distinct from page bg. */
  --color-sidebar-bg:        #211F1B;
  --color-sidebar-text:      #E5DED1;
  --color-sidebar-muted:     #A39B8C;
  --color-sidebar-hover:     #35322C;

  --color-accent:            #7FCBDA;

  --color-accent-hover:      #A3DCE7;

  --color-on-accent:         #0F2A33;

  --color-accent-soft:       rgba(127, 203, 218, 0.16);
  --color-accent-text:       #7FCBDA;

  --color-success-soft:      rgba(47, 125, 79, 0.28);
  --color-warning-soft:      rgba(183, 121, 31, 0.24);
  --color-danger-soft:       rgba(179, 38, 30, 0.28);
  --color-info-soft:         rgba(43, 108, 176, 0.28);

  --color-success-text:      #A5DDB8;
  --color-warning-text:      #F2CD87;
  --color-danger-text:       #F6B8B3;
  --color-info-text:         #A9CDF0;

  --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.30);
  --shadow-lg:    0 12px 24px rgba(0, 0, 0, 0.50), 0 4px 8px rgba(0, 0, 0, 0.35);
  /* The light theme's teal ring is ~1.1:1 on the dark page: use the dark accent. */
  --shadow-focus: 0 0 0 3px rgba(127, 203, 218, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --color-bg:               #171613;
    --color-surface:           #211F1B;
    --color-surface-muted:     #211F1B;
    --color-surface-strong:    #35322C;
    --color-surface-elevated:  #211F1B;
    --color-nav-bg:            rgba(23, 22, 19, 0.88);

    --color-text:              #F3EEE4;
    --color-text-muted:        #BDB5A6;
    /* --color-text-inverse stays light here too — same rationale as the
       explicit-dark block: it colors text ON surfaces that are dark in
       both themes (sidebar, footer, CTA band, hero). */

    --color-border:            #35322C;
    --color-border-strong:     #4A463E;

    --color-sidebar-bg:        #211F1B;
    --color-sidebar-text:      #E5DED1;
    --color-sidebar-muted:     #A39B8C;
    --color-sidebar-hover:     #35322C;

    --color-accent:            #7FCBDA;

    --color-accent-hover:      #A3DCE7;

    --color-on-accent:         #0F2A33;

    --color-accent-soft:       rgba(127, 203, 218, 0.16);
    --color-accent-text:       #7FCBDA;

    --color-success-soft:      rgba(47, 125, 79, 0.28);
    --color-warning-soft:      rgba(183, 121, 31, 0.24);
    --color-danger-soft:       rgba(179, 38, 30, 0.28);
    --color-info-soft:         rgba(43, 108, 176, 0.28);

    --color-success-text:      #A5DDB8;
    --color-warning-text:      #F2CD87;
    --color-danger-text:       #F6B8B3;
    --color-info-text:         #A9CDF0;

    --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.30);
    --shadow-lg:    0 12px 24px rgba(0, 0, 0, 0.50), 0 4px 8px rgba(0, 0, 0, 0.35);
    --shadow-focus: 0 0 0 3px rgba(127, 203, 218, 0.6);
  }
}

/* Print: the light palette in every theme, so a page printed from the dark
 * theme is ink on paper, not light text on white. Same values as :root. */
@media print {
  :root[data-theme="dark"], :root[data-theme="auto"], :root {
    --color-bg:            #FAF7F0;
    --color-surface:       #FFFDF8;
    --color-surface-muted: #F2EDE3;
    --color-surface-strong: #E5DED1;
    --color-text:          #1B1A17;
    --color-text-muted:    #5F5A50;
    --color-border:        #E2DBCD;
    --color-border-strong: #C9C0AF;
    --color-accent:        #0F3D4C;
    --color-accent-hover:  #1A5A6E;
    --color-accent-soft:   #DCE9EC;
    --color-on-accent:     #FFFFFF;
    --color-accent-text:   #134A5C;
  }
}
