/* ==========================================================================
   rb-2040-tokens.css — RingBD 2040 design tokens (WEB, Sunshine theme)
   Package W26 · 2026-11-22 · STAGING ONLY
   Source: ~/workspace/logs/ringbd-2040/w26-design-tokens.md (§1 token table)
   Binding source of truth: rebuild FINAL DESIGN-DECISIONS-FINAL.md §1.
   Status key: KEPT = verbatim from FINAL. NEW (2040) = added by W26 spec,
   needs D1 approval before any surface uses it. HELD = proposed but held
   until D1 rules — declared ONLY as comments below, never as live vars.
   Conflicts C1–C4 (§7 of the spec) are FLAGGED, never overridden:
     C1 primary stays #00A651 (brand-500); #006A4E is brand-700 / flag green.
     C2 brand glow stays splash/onboarding/app-icon only; soft glows HELD.
     C3 system-font fallback stays (resilience rule, not the designed look).
     C4 bottom sheets stay solid surface, 24px top corners; glass sheet HELD.
   Rule: no hex literal in component CSS — all colour comes from these vars.
   ========================================================================== */

:root {
  /* ---- 1.1 Brand green (KEPT) ---- */
  --rb-brand-50: #E6F7EE;
  --rb-brand-100: #C2EBD4;
  --rb-brand-200: #8FDDB1;
  --rb-brand-300: #4CCB8A;
  --rb-brand-400: #1FBF63;
  --rb-brand-500: #00A651; /* PRIMARY (C1: FINAL, not #006A4E) */
  --rb-brand-600: #008A44;
  --rb-brand-700: #006A4E; /* flag green / own-bubble fill */
  --rb-brand-800: #00573E;
  --rb-brand-900: #003D2B;

  /* ---- 1.2 Flag red, gold, navy hero (KEPT) ---- */
  --rb-flag-red-500: #F42A41;
  --rb-flag-red-600: #D21F33;
  --rb-flag-red-50: #FDECEF;
  --rb-gold-500: #C9A227;
  --rb-gold-400: #D4AF37;
  --rb-gold-50: #FBF6E3;
  --rb-navy-950: #050D1A;
  --rb-navy-900: #071A33;
  --rb-navy-800: #0A2547;
  --rb-navy-700: #123A63;

  /* ---- 1.3 Neutrals — light theme (KEPT) ---- */
  --rb-white: #FFFFFF; /* white text on brand fills; tokenised so no hex
                          literal appears in component CSS (Gate grep rule) */
  --rb-surface: #FFFFFF;
  --rb-background: #F0F2F5;
  --rb-surface-2: #E4E6EB;
  --rb-border: #E0E3E7;
  --rb-divider: #EBEDF0;
  --rb-ink-900: #111827;
  --rb-ink-700: #374151;
  --rb-ink-500: #6B7280;
  --rb-ink-400: #9CA3AF;

  /* ---- 1.5 Semantic colours — light values (KEPT) ---- */
  --rb-success: #00A651;
  --rb-online: #00A651;
  --rb-error: #D92D20;
  --rb-warning: #DC6803;
  --rb-info: #1570EF;
  --rb-link-blue: #1877F2;

  /* ---- 1.6 Reels Studio accent — SCOPED, never global (KEPT) ---- */
  --rb-reels-500: #8B5CF6;
  --rb-reels-600: #7C3AED;
  --rb-reels-700: #C026D3;
  --rb-reels-400: #A78BFA;

  /* ---- 1.7 Chat bubbles (KEPT) ---- */
  --rb-bubble-out: #006A4E; /* flat fill, white text */
  --rb-bubble-out-pressed: #00573E;
  --rb-bubble-in-light: #FFFFFF;
  --rb-bubble-in-border: #E0E3E7;
  --rb-bubble-system: #E4E6EB;
  --rb-tick-read: #BDEBFF;
  --rb-tick-sent-light: #44507A;
  --rb-tick-sent-dark: #A9B6D8;

  /* ---- 1.8 Opacity scale (KEPT) ---- */
  --rb-overlay-scrim: rgba(0, 0, 0, 0.5);
  --rb-overlay-strong: rgba(0, 0, 0, 0.65);
  --rb-disabled-fill: rgba(156, 163, 175, 0.4);
  --rb-pressed-overlay: rgba(0, 0, 0, 0.08);
  --rb-brand-glow: rgba(0, 166, 81, 0.35); /* C2: splash/onboarding/app-icon ONLY */

  /* ---- 1.8 Frosted-glass tokens — NEW (2040), D1 approval pending ---- */
  --rb-glass-light: rgba(255, 255, 255, 0.72);
  --rb-glass-dark: rgba(17, 28, 46, 0.72);
  --rb-glass-border-light: rgba(255, 255, 255, 0.5);
  --rb-glass-border-dark: rgba(255, 255, 255, 0.12);
  --rb-glass-blur-sm: blur(8px) saturate(1.2);
  --rb-glass-blur-lg: blur(24px) saturate(1.6);
  --rb-glass-blur: blur(16px) saturate(1.4);
  /* Mandatory solid fallback — NEVER backdrop-filter without a solid
     background behind it. @supports (backdrop-filter: blur(1px)) gates
     the glass fill; otherwise the solid surface shows. */
  --rb-glass-fallback: #FFFFFF;

  /* HELD (C2 / N4 / N5) — NOT live until D1 rules. Do not uncomment.
     --rb-gradient-ambient-light: linear-gradient(180deg, #E6F7EE 0%, #F0F2F5 100%);
     --rb-gradient-ambient-dark:  linear-gradient(180deg, #0A2547 0%, #0B1220 100%);
     --rb-glow-brand-soft: rgba(0, 166, 81, 0.12);  (blur 32px)
     --rb-glow-reels-soft: rgba(139, 92, 246, 0.12); (blur 32px) */

  /* ---- 1.9 Typography (KEPT) ---- */
  --rb-font-display: "Baloo Da 2", "Noto Sans Bengali", system-ui, sans-serif;
  --rb-font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rb-font-mono: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
  /* Type scale — Latin / Bangla (+1px) at 390px base. C3: system-font
     fallback stays as a resilience rule. */
  --rb-type-display: 32px;
  --rb-type-display-bn: 34px;
  --rb-type-h1: 28px;
  --rb-type-h1-bn: 30px;
  --rb-type-h2: 22px;
  --rb-type-h2-bn: 24px;
  --rb-type-h3: 18px;
  --rb-type-h3-bn: 20px;
  --rb-type-title: 16px;
  --rb-type-title-bn: 17px;
  --rb-type-body: 15px;
  --rb-type-body-bn: 16px;
  --rb-type-caption: 13px;
  --rb-type-caption-bn: 14px;
  --rb-type-button: 16px;
  --rb-type-button-bn: 17px;
  --rb-type-overline: 11px;
  --rb-type-overline-bn: 12px;
  --rb-type-tagline: 11px;
  --rb-type-tagline-bn: 12px;
  /* Fluid type scale — NEW (2040), D1 approval pending (Q4) */
  --rb-type-display-fluid: clamp(32px, 6vw, 48px);
  --rb-type-h1-fluid: clamp(28px, 4.5vw, 36px);
  --rb-type-h2-fluid: clamp(22px, 3.2vw, 28px);
  --rb-type-fluid-min-vw: 390px;
  --rb-type-fluid-max-vw: 1280px;

  /* ---- 1.10 Spacing, radii, elevation (KEPT) ---- */
  --rb-space-1: 4px;
  --rb-space-2: 8px;
  --rb-space-3: 12px;
  --rb-space-4: 16px;
  --rb-space-5: 20px;
  --rb-space-6: 24px;
  --rb-space-8: 32px;
  --rb-space-10: 40px;
  --rb-space-12: 48px;
  --rb-space-16: 64px;
  --rb-screen-margin: 16px; /* 24px at >=600px widths */
  --rb-content-max-width: 640px;
  --rb-section-gap: 24px;
  --rb-card-gap: 12px;

  --rb-radius-xs: 4px;
  --rb-radius-sm: 8px;
  --rb-radius-md: 12px;
  --rb-radius-lg: 16px;
  --rb-radius-xl: 24px;
  --rb-radius-full: 999px;

  --rb-elev-0: none;
  --rb-elev-1: 0 1px 3px rgba(0, 0, 0, 0.08);
  --rb-elev-2: 0 2px 8px rgba(0, 0, 0, 0.1);
  --rb-elev-3: 0 4px 12px rgba(0, 0, 0, 0.14);
  --rb-elev-4: 0 8px 24px rgba(0, 0, 0, 0.16);

  /* Layered glass elevation — NEW (2040), D1 approval pending (Q3) */
  --rb-elev-glass-1: 0 2px 12px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.06);
  --rb-elev-glass-2: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  --rb-elev-glass-3: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(0, 0, 0, 0.1);

  /* ---- 1.11 Motion (KEPT) ---- */
  --rb-motion-instant: 0ms;
  --rb-motion-micro: 80ms;
  --rb-motion-fast: 150ms;
  --rb-motion-base: 250ms;
  --rb-motion-medium: 350ms;
  --rb-motion-slow: 500ms;
  --rb-motion-skeleton: 1200ms;
  --rb-motion-typing: 900ms;
  --rb-ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);

  /* Gradients (KEPT exceptions) */
  --rb-gradient-header: linear-gradient(180deg, #00A651 0%, #008A44 100%);
  --rb-gradient-header-dark: linear-gradient(180deg, #008A44 0%, #006A4E 100%);
  --rb-gradient-primary: linear-gradient(180deg, #00A651 0%, #008A44 100%);
  --rb-gradient-signin: linear-gradient(180deg, #E8112D 0%, #FF2D55 100%);
  --rb-gradient-reels: linear-gradient(135deg, #8B5CF6 0%, #C026D3 100%);
  --rb-gradient-story-ring: linear-gradient(135deg, #00A651 0%, #D4AF37 100%);

  /* Dark-theme values live under [data-theme="dark"] / prefers-color-scheme
     below; light values above are the default. */
  --rb-dark-bg: #0B1220;
  --rb-dark-surface: #111C2E;
  --rb-dark-surface-2: #1A2A42;
  --rb-dark-border: #24344D;
  --rb-dark-divider: #1C2A40;
  --rb-dark-ink-900: #F3F6F9;
  --rb-dark-ink-700: #C7D0DC;
  --rb-dark-ink-500: #8A97A8;
  --rb-dark-ink-400: #5F6E82;
  --rb-bubble-in-dark: #1A2A42;
  --rb-bubble-system-dark: #24344D;
}

/* ---- 1.4 Neutrals — dark theme (KEPT) ----
   Default is light; dark follows the OS with an in-app override
   (Light / Dark / System). Green header stays green in dark mode.
   Reels viewer is always dark in both themes. Elevation in dark mode
   is surface lightening, not shadow. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rb-surface: #111C2E;
    --rb-background: #0B1220;
    --rb-surface-2: #1A2A42;
    --rb-border: #24344D;
    --rb-divider: #1C2A40;
    --rb-ink-900: #F3F6F9;
    --rb-ink-700: #C7D0DC;
    --rb-ink-500: #8A97A8;
    --rb-ink-400: #5F6E82;
    --rb-success: #34D399;
    --rb-online: #34D399;
    --rb-error: #F97066;
    --rb-warning: #FDB022;
    --rb-info: #53B1FD;
    --rb-link-blue: #53B1FD;
    --rb-bubble-in-light: #1A2A42;
    --rb-bubble-system: #24344D;
    --rb-pressed-overlay: rgba(255, 255, 255, 0.08);
    --rb-glass-fallback: #111C2E;
    --rb-elev-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --rb-elev-2: 0 2px 4px rgba(0, 0, 0, 0.3);
    --rb-elev-3: 0 4px 6px rgba(0, 0, 0, 0.3);
    --rb-elev-4: 0 8px 12px rgba(0, 0, 0, 0.3);
    --rb-elev-glass-1: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.3);
    --rb-elev-glass-2: 0 4px 8px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
    --rb-elev-glass-3: 0 12px 16px rgba(0, 0, 0, 0.3), 0 2px 2px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --rb-surface: #111C2E;
  --rb-background: #0B1220;
  --rb-surface-2: #1A2A42;
  --rb-border: #24344D;
  --rb-divider: #1C2A40;
  --rb-ink-900: #F3F6F9;
  --rb-ink-700: #C7D0DC;
  --rb-ink-500: #8A97A8;
  --rb-ink-400: #5F6E82;
  --rb-success: #34D399;
  --rb-online: #34D399;
  --rb-error: #F97066;
  --rb-warning: #FDB022;
  --rb-info: #53B1FD;
  --rb-link-blue: #53B1FD;
  --rb-bubble-in-light: #1A2A42;
  --rb-bubble-system: #24344D;
  --rb-pressed-overlay: rgba(255, 255, 255, 0.08);
  --rb-glass-fallback: #111C2E;
  --rb-elev-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --rb-elev-2: 0 2px 4px rgba(0, 0, 0, 0.3);
  --rb-elev-3: 0 4px 6px rgba(0, 0, 0, 0.3);
  --rb-elev-4: 0 8px 12px rgba(0, 0, 0, 0.3);
  --rb-elev-glass-1: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.3);
  --rb-elev-glass-2: 0 4px 8px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
  --rb-elev-glass-3: 0 12px 16px rgba(0, 0, 0, 0.3), 0 2px 2px rgba(0, 0, 0, 0.3);
}

/* ---- Reduced motion (KEPT, first-class) ---- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --rb-motion-micro: 0ms;
    --rb-motion-fast: 100ms;
    --rb-motion-base: 100ms;
    --rb-motion-medium: 100ms;
    --rb-motion-slow: 100ms;
    --rb-motion-skeleton: 0ms;
    --rb-motion-typing: 0ms;
  }
}

/* prefers-reduced-transparency (where supported): glass collapses to the
   solid fallback — glass must never render invisible/transparent. */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --rb-glass-light: #FFFFFF;
    --rb-glass-dark: #111C2E;
  }
}
