/* ─────────────────────────────────────────────
   Design Tokens — Arda Design System, Base theme
   Source of truth: https://claude.ai/artifact/QnSPSRx8WrFAbrhjnPEjiy

   Dark-first, quiet chrome, loud data. Orbit is dark-only: every page sits
   on pure black, and <html> always carries class="dark" data-theme="base"
   (see app/views/layouts/application.html.erb).

   Two layers of variables:
   1. Arda tokens (--bg, --glass, --info, --radius-md, ...), named exactly as
      in the design system so a token change there maps 1:1 here.
   2. Orbit's semantic --color-* tokens, which Tailwind CSS 4 registers via
      @theme inline in app/assets/tailwind/application.css. They point at
      the Arda tokens.

   Reading text (#1350, my-designer ME-DESIGN-002): pure white on pure black
   blooms for readers with astigmatism, so the app's text colour is the warm
   off-white --text-reading (#D6D4CC, 14.2:1 on --bg, 12.5:1 on glass) at weight 500 (one
   body rule in tailwind/application.css). Font size never changes. Pure white
   stays as --text-bright and --primary-bg for filled controls only.
   NOTE: this is a deliberate local deviation from the Arda DS artifact's
   --text (#FFFFFF); mirror it there before the next 1:1 token sync.

   Rules worth repeating:
   - The main action is white (bg-primary). Role colours never fill buttons;
     destructive is the only exception.
   - Role colours carry meaning only: info (links, focus, active), success,
     new, warning, error. Pair each with an icon or word.
   - Elevation is glass + blur, not shadows. Only floating layers cast one.
   - Motion (#1921) runs on --ease-spring with --duration-sheet (280ms),
     --duration-confirm (220ms) and --duration-select (160ms); exits use
     --duration-sheet-close (180ms) on --ease-in. Every motion rule is off
     under prefers-reduced-motion (see "Motion (#1921)" in application.css).
   ───────────────────────────────────────────── */

:root {
  color-scheme: dark;

  /* ── Arda · Base surfaces, text and actions ── */
  --bg: #000000;
  --raised: #02090A;
  --glass: rgba(30, 44, 49, 0.45);
  --glass-menu: rgba(36, 48, 52, 0.55);
  --border: #1E2C31;
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-strong: rgba(255, 255, 255, 0.12);
  --border-strong: #3F3F46;
  --fill-subtle: rgba(255, 255, 255, 0.07);
  --text-reading: #D6D4CC;
  --text-bright: #FFFFFF;
  --text: var(--text-reading);
  --text-secondary: #A1A1AA;
  --text-meta: #898991;
  --primary-bg: #FFFFFF;
  --primary-fg: #000000;
  --primary-hover: #E4E4E7;
  --primary-pressed: #D4D4D8;
  --disabled-bg: rgba(255, 255, 255, 0.12);

  /* ── Arda · Base role colours (Google palette; info yellow, new blue) ── */
  --info: #FBBC05;
  --success: #34A853;
  --new: #4285F4;
  --warning: #FA7B17;
  --error: #EA4335;
  --info-ring: rgba(251, 188, 5, 0.28);
  --error-tint: rgba(234, 67, 53, 0.10);
  --error-edge: rgba(234, 67, 53, 0.45);
  /* Glow is a Neon-only effect; Base draws none. */
  --glow: none;

  /* ── Health data / category colours (K1, #1896) ──
     A separate set from the role colours above. They name a health area
     (heart, sleep, ...) on its icon, metric title and chart series only.
     They never fill a button, never mark a state (use a role colour plus
     its glyph for that) and always sit beside the area's name or icon.
     Every value is at least 6:1 on --bg and on glass. Activity and
     nutrition share hues with warning and success: the context (an area
     label, no status glyph) is what tells them apart. */
  --cat-heart: #FF5C8A;
  --cat-activity: #FF8F40;
  --cat-sleep: #8C84FF;
  --cat-mental: #2DD4BF;
  --cat-nutrition: #6EDC8C;
  --cat-vitals: #56B6FF;
  --cat-body: #C27CFF;
  --cat-medications: #F062D9;
  --cat-labs: #B5E550;
  --cat-records: #94A3B8;

  /* ── Arda · Elevation ── */
  --shadow-menu: 0 8px 32px rgba(0, 0, 0, 0.35);
  --blur-glass: 20px;
  --blur-menu: 28px;

  /* ── Arda · Spacing (4px grid) ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── Orbit semantic tokens → Arda ── */

  /* Primary — the white main action */
  --color-primary: var(--primary-bg);
  --color-primary-foreground: var(--primary-fg);
  --color-primary-hover: var(--primary-hover);
  --color-primary-active: var(--primary-pressed);
  --color-primary-subtle: rgba(255, 255, 255, 0.10);

  /* Secondary — quiet neutral fill */
  --color-secondary: rgba(255, 255, 255, 0.10);
  --color-secondary-foreground: var(--text);
  --color-secondary-hover: rgba(255, 255, 255, 0.14);
  --color-secondary-active: rgba(255, 255, 255, 0.18);
  --color-secondary-subtle: var(--fill-subtle);

  /* Info — links, focus, active state, chart series 1 */
  --color-info: var(--info);
  --color-info-foreground: var(--primary-fg);
  --color-info-hover: #FCCB3C;
  --color-info-subtle: rgba(251, 188, 5, 0.12);

  /* Destructive — error role */
  --color-destructive: var(--error);
  --color-destructive-foreground: var(--primary-fg);
  --color-destructive-hover: #EF6A5E;
  --color-destructive-active: #D94336;
  --color-destructive-subtle: var(--error-tint);
  --color-destructive-edge: var(--error-edge);

  /* Warning */
  --color-warning: var(--warning);
  --color-warning-foreground: var(--primary-fg);
  --color-warning-hover: #FB9645;
  --color-warning-active: #D66510;
  --color-warning-subtle: rgba(250, 123, 23, 0.12);

  /* Success */
  --color-success: var(--success);
  --color-success-foreground: var(--primary-fg);
  --color-success-hover: #4FC06D;
  --color-success-active: #2B8C45;
  --color-success-subtle: rgba(52, 168, 83, 0.10);

  /* New — highlight, featured, chart series 3 */
  --color-new: var(--new);
  --color-new-foreground: var(--primary-fg);
  --color-new-subtle: rgba(66, 133, 244, 0.10);

  /* Muted */
  --color-muted: var(--fill-subtle);
  --color-muted-foreground: var(--text-secondary);
  --color-meta: var(--text-meta);

  /* Accent — Orbit's old cyan accent now reads as the info role */
  --color-accent: var(--info);
  --color-accent-foreground: var(--primary-fg);
  --color-accent-hover: #FCCB3C;
  --color-accent-active: #D9A204;
  --color-accent-subtle: rgba(251, 188, 5, 0.12);

  /* Surfaces */
  --color-background: var(--bg);
  --color-foreground: var(--text);
  --color-raised: var(--raised);
  --color-card: var(--glass);
  --color-card-foreground: var(--text);
  --color-popover: var(--glass-menu);
  --color-border: var(--border);
  --color-border-strong: var(--border-strong);
  --color-border-glass: var(--border-glass);
  --color-input: var(--border-strong);
  --color-ring: var(--info);

  /* Border radius — soft, Apple-like */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;
  /* Health tiles and inset grouped lists (K6, #1898): glass, 20px. */
  --radius-tile: var(--radius-xl);

  /* Inset grouped list (K6, #1898): rows on one glass panel, split by a
     hairline that starts at the row's text inset. */
  --grouped-bg: var(--glass);
  --grouped-border: var(--border-glass);
  --grouped-separator: rgba(255, 255, 255, 0.08);
  --grouped-inset: 16px;
  --grouped-row-min-height: 44px;

  /* Chart (#1899): grid, axis, ticks, reference lines and selection. The
     chart controller reads these; nothing in a chart is a raw hex. */
  --chart-grid: var(--border);
  --chart-axis: var(--border-strong);
  --chart-tick: var(--text-secondary);
  --chart-threshold: #71717A;
  --chart-band: rgba(255, 255, 255, 0.06);
  --chart-selection: var(--text-bright);

  /* Controls (#1900): visual heights. Every control keeps a 44px hit area;
     the sm size reaches it with an invisible extension (.hit-area-44). */
  --control-height-sm: 32px;
  --control-height-md: 40px;
  --control-height-lg: 44px;
  --hit-area-min: 44px;
  /* Arda focus ring: 2px black gap plus a 2px info ring. */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--info);

  /* Type scale (#1897). Hierarchy by size, not weight. Health figures
     (hero, value) use Geist with tabular numerals (K5); small dates, times
     and IDs stay in JetBrains Mono. Pair each size with its line height. */
  --text-large-title: 34px;
  --text-large-title--line-height: 41px;
  --text-title-1: 28px;
  --text-title-1--line-height: 34px;
  --text-title-2: 20px;
  --text-title-2--line-height: 25px;
  --text-hero: 44px;
  --text-hero--line-height: 48px;
  --text-value: 28px;
  --text-value--line-height: 32px;
  --text-unit: 15px;
  --text-unit--line-height: 20px;
  --text-body: 15px;
  --text-body--line-height: 22px;
  --text-caption: 13px;
  --text-caption--line-height: 18px;
  --text-footnote: 12px;
  --text-footnote--line-height: 16px;

  /* Shadows — elevation is glass, so resting layers cast none.
     shadow-lg / shadow-xl are floating layers (menus, dialogs, toasts). */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: var(--shadow-menu);
  --shadow-xl: var(--shadow-menu);

  /* Z-index scale */
  --z-dropdown: 50;
  --z-sticky: 100;
  --z-modal: 200;
  --z-popover: 300;
  --z-toast: 400;

  /* Typography — Geist for UI, JetBrains Mono for IDs, dates and numbers */
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  /* Animation — one Arda curve for every motion */
  --ease-arda: cubic-bezier(0.2, 0.8, 0.4, 1);
  --ease-in: var(--ease-arda);
  --ease-out: var(--ease-arda);
  --ease-in-out: var(--ease-arda);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Animation — durations: fast 120 (hover, press), normal 200 (menus),
     slow 320 (modals) */
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 320ms;
  --duration-slower: 500ms;

  /* Animation — motion durations (#1921), used with --ease-spring: sheet open
     280, logged confirmation and toast enter 220, selected-value swap 160;
     sheet and toast exit 180 on --ease-in (no overshoot). */
  --duration-sheet: 280ms;
  --duration-sheet-close: 180ms;
  --duration-confirm: 220ms;
  --duration-select: 160ms;
}

/* Native form controls on black. In @layer base (a native cascade layer
   that Tailwind's own base/utilities layers order after), so a utility
   such as text-primary-foreground on a submit button still wins. */
@layer base {
  :where(input, textarea, select, option) {
    color: var(--color-foreground);
  }

  :where(select, option) {
    background-color: var(--raised);
  }

  input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="time"]::-webkit-calendar-picker-indicator,
  input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
  }

  ::selection {
    background: var(--info-ring);
  }
}

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

/* ─────────────────────────────────────────────
   Keyframe animations
   ───────────────────────────────────────────── */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slide-in-up {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slide-in-down {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes scale-in {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  50% { opacity: 0.5; }
}
