/* ═══════════════════════════════════════════════════════════════════════════
   WYRR Design System — one institution, many departments.
   Served from wyrr.me/shared/wyrr-design-system.css

   Identity: calm · intelligent · ruthless · minimal · premium.
   A cold future corporation — NOT crypto, NOT cyberpunk.
   Near-black ground, hairline structure, mono for data. The WYRR spectrum
   (coral→pink→orange→purple) is a SIGNAL, never decoration. Gold is premium.
   No particle fields, no scanlines, no neon, no perpetual motion, no blur.
   Motion is a single 0.3s entrance fade. All classes prefixed `wyrr-`.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens: the institution (dark, primary) ────────────────────────────── */
:root {
  /* Ground & surfaces — near-black, flat, honest */
  --wyrr-bg-0: #0A0A0A;   /* page ground */
  --wyrr-bg-1: #141414;   /* card / surface */
  --wyrr-bg-2: #181818;   /* raised surface */
  --wyrr-bg-3: #1F1F1F;   /* input / inset */

  /* Structure — hairline borders, no glass, no blur */
  --wyrr-border:      rgba(255, 255, 255, 0.06);
  --wyrr-border-hi:   rgba(255, 255, 255, 0.10);
  --wyrr-border-hero: rgba(255, 255, 255, 0.14);

  /* Back-compat aliases (older components referenced glass tokens) */
  --wyrr-glass-bg:        var(--wyrr-bg-1);
  --wyrr-glass-bg-strong: var(--wyrr-bg-2);
  --wyrr-glass-border:    var(--wyrr-border);
  --wyrr-glass-highlight: rgba(255, 255, 255, 0.08);
  --wyrr-glass-blur:      none;
  --wyrr-glass-blur-lite: none;
  --wyrr-backdrop:        rgba(0, 0, 0, 0.72);

  /* Text hierarchy — cold near-white */
  --wyrr-text:       #F5F5F5;
  --wyrr-text-dim:   rgba(255, 255, 255, 0.56);
  --wyrr-text-faint: rgba(255, 255, 255, 0.34);
  --wyrr-text-on-signal: #FFFFFF;
  --wyrr-text-on-gold:   #17130A;

  /* WYRR spectrum — SIGNAL ONLY (active state, focus, brand mark, one CTA) */
  --wyrr-coral:  #FF6B4A;
  --wyrr-pink:   #FF3D8B;
  --wyrr-orange: #FF9D42;
  --wyrr-purple: #9B5DE5;
  --wyrr-signal: linear-gradient(120deg, #FF6B4A 0%, #FF3D8B 34%, #FF9D42 66%, #9B5DE5 100%);
  --wyrr-signal-soft: linear-gradient(120deg, rgba(255,107,74,0.16), rgba(255,61,139,0.16) 50%, rgba(155,93,229,0.16));

  /* Gold — premium tier only (Unlimited, verified issuer, prestige) */
  --wyrr-gold:        #D4AF37;
  --wyrr-gold-bright: #E9C765;
  --wyrr-gold-soft:   #E4C860;
  --wyrr-gold-deep:   #9C7E1E;
  --wyrr-gold-10:     rgba(212, 175, 55, 0.10);
  --wyrr-gold-18:     rgba(212, 175, 55, 0.18);
  --wyrr-gold-30:     rgba(212, 175, 55, 0.30);
  --wyrr-gold-50:     rgba(212, 175, 55, 0.50);

  /* Status — muted, functional, never neon */
  --wyrr-ok:     #3DD68C;
  --wyrr-warn:   #E7B04B;
  --wyrr-danger: #F0668A;
  --wyrr-info:   #6BB8E8;

  /* Radii — matched to iOS WYRRDesignSystem.Radius (xs6 sm10 md14 lg20 xl28) */
  --wyrr-r-xs:   6px;
  --wyrr-r-sm:   10px;
  --wyrr-r-md:   14px;   /* iOS cornerRadius = 14 */
  --wyrr-r-lg:   20px;
  --wyrr-r-xl:   28px;
  --wyrr-r-pill: 100px;  /* iOS Radius.full = 100 */

  /* Spacing — matched to iOS WYRRDesignSystem.Spacing */
  --wyrr-s-1: 4px;    /* iOS xs */
  --wyrr-s-2: 8px;    /* iOS sm */
  --wyrr-s-3: 12px;   /* iOS md */
  --wyrr-s-4: 16px;   /* iOS lg */
  --wyrr-s-5: 24px;   /* iOS xl */
  --wyrr-s-6: 32px;   /* iOS xxl */
  --wyrr-s-7: 48px;   /* iOS xxxl */
  --wyrr-s-8: 72px;
  --wyrr-card-pad:   20px;  /* iOS cardPadding / screenPadding */
  --wyrr-section:    28px;  /* iOS sectionSpacing */

  /* Shadows — restrained depth, no colored glow by default */
  --wyrr-shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.40);
  --wyrr-shadow-md:   0 4px 20px rgba(0, 0, 0, 0.45);
  --wyrr-shadow-lg:   0 12px 48px rgba(0, 0, 0, 0.55);
  --wyrr-inner-light: none;
  /* legacy glow aliases kept minimal so old refs don't glow */
  --wyrr-glow-gold:    none;
  --wyrr-glow-gold-lg: none;

  /* Typography — Inter/system UI, mono for data */
  --wyrr-font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  --wyrr-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --wyrr-fs-xs:      0.75rem;    /* 12 */
  --wyrr-fs-sm:      0.875rem;   /* 14 */
  --wyrr-fs-md:      1rem;       /* 16 — body */
  --wyrr-fs-lg:      1.25rem;    /* 20 */
  --wyrr-fs-xl:      clamp(1.6rem, 1.2rem + 1.4vw, 2rem);   /* 26–32 */
  --wyrr-fs-hero:    clamp(2.75rem, 1.8rem + 4vw, 4.5rem);  /* 44–72 headline */
  --wyrr-fs-display: clamp(3.25rem, 2rem + 5.5vw, 5.5rem);  /* 52–88 display */

  /* Motion — matched to iOS: 0.15s press, 0.3s entrance */
  --wyrr-dur-fast: 150ms;   /* iOS .easeInOut(duration: 0.15) press */
  --wyrr-dur-med:  200ms;
  --wyrr-dur-slow: 300ms;   /* 0.3s entrance */
  --wyrr-ease:     cubic-bezier(0.22, 1, 0.36, 1);
  --wyrr-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  /* legacy alias — spring collapses to the calm ease */
  --wyrr-ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Tokens: light institution (near-white, same signals) ───────────────── */
[data-wyrr-theme="light"],
[data-theme="light"] {
  --wyrr-bg-0: #FAFAFA;
  --wyrr-bg-1: #FFFFFF;
  --wyrr-bg-2: #F4F4F4;
  --wyrr-bg-3: #EEEEEE;
  --wyrr-border:    rgba(10, 10, 10, 0.08);
  --wyrr-border-hi: rgba(10, 10, 10, 0.14);
  --wyrr-border-hero: rgba(10, 10, 10, 0.20);
  --wyrr-glass-highlight: rgba(10, 10, 10, 0.04);
  --wyrr-backdrop:  rgba(20, 20, 20, 0.32);
  --wyrr-text:       #0A0A0A;
  --wyrr-text-dim:   rgba(10, 10, 10, 0.58);
  --wyrr-text-faint: rgba(10, 10, 10, 0.36);
  --wyrr-shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.08);
  --wyrr-shadow-md: 0 4px 20px rgba(20, 20, 20, 0.10);
  --wyrr-shadow-lg: 0 12px 48px rgba(20, 20, 20, 0.14);
}
@media (prefers-color-scheme: light) {
  :root:not([data-wyrr-theme]):not([data-theme]) {
    --wyrr-bg-0: #FAFAFA;
    --wyrr-bg-1: #FFFFFF;
    --wyrr-bg-2: #F4F4F4;
    --wyrr-bg-3: #EEEEEE;
    --wyrr-border:    rgba(10, 10, 10, 0.08);
    --wyrr-border-hi: rgba(10, 10, 10, 0.14);
    --wyrr-border-hero: rgba(10, 10, 10, 0.20);
    --wyrr-glass-highlight: rgba(10, 10, 10, 0.04);
    --wyrr-backdrop:  rgba(20, 20, 20, 0.32);
    --wyrr-text:       #0A0A0A;
    --wyrr-text-dim:   rgba(10, 10, 10, 0.58);
    --wyrr-text-faint: rgba(10, 10, 10, 0.36);
    --wyrr-shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.08);
    --wyrr-shadow-md: 0 4px 20px rgba(20, 20, 20, 0.10);
    --wyrr-shadow-lg: 0 12px 48px rgba(20, 20, 20, 0.14);
  }
}

/* ═══ Components ════════════════════════════════════════════════════════── */

/* Card — 1px border, 12px radius, flat surface, no blur */
.wyrr-glass-card,
.wyrr-card {
  position: relative;
  background: var(--wyrr-bg-1);
  border: 1px solid var(--wyrr-border);
  border-radius: var(--wyrr-r-md);
  box-shadow: none;
  color: var(--wyrr-text);
  padding: var(--wyrr-card-pad);
  font-family: var(--wyrr-font);
  transition: border-color var(--wyrr-dur-med) var(--wyrr-ease),
              background var(--wyrr-dur-med) var(--wyrr-ease);
}
.wyrr-glass-card:hover,
.wyrr-card:hover {
  border-color: var(--wyrr-border-hi);
}

/* Pill / tag surface */
.wyrr-glass-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--wyrr-s-2);
  background: var(--wyrr-bg-1);
  border: 1px solid var(--wyrr-border);
  border-radius: var(--wyrr-r-pill);
  padding: var(--wyrr-s-2) var(--wyrr-s-4);
  color: var(--wyrr-text-dim);
  font-family: var(--wyrr-font);
  font-size: var(--wyrr-fs-sm);
}

/* Buttons — primary=signal gradient, secondary=border, tertiary=text */
.wyrr-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wyrr-s-2);
  border: 1px solid transparent;
  border-radius: var(--wyrr-r-md);
  padding: 12px 20px;
  font-family: var(--wyrr-font);
  font-size: var(--wyrr-fs-md);
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  transition: opacity var(--wyrr-dur-fast) var(--wyrr-ease),
              border-color var(--wyrr-dur-fast) var(--wyrr-ease),
              background var(--wyrr-dur-fast) var(--wyrr-ease);
  background: var(--wyrr-signal);
  background-size: 140% 140%;
  color: var(--wyrr-text-on-signal);
  box-shadow: none;
}
.wyrr-btn:hover   { opacity: 0.92; }
.wyrr-btn:active  { opacity: 0.84; }
.wyrr-btn:focus-visible { outline: 2px solid var(--wyrr-pink); outline-offset: 2px; }
.wyrr-btn:disabled { opacity: 0.40; cursor: not-allowed; }

/* Secondary — hairline border, no fill */
.wyrr-btn--ghost,
.wyrr-btn--secondary {
  background: transparent;
  border-color: var(--wyrr-border-hi);
  color: var(--wyrr-text);
}
.wyrr-btn--ghost:hover,
.wyrr-btn--secondary:hover { border-color: var(--wyrr-border-hero); opacity: 1; background: var(--wyrr-bg-1); }

/* Tertiary — text only */
.wyrr-btn--text {
  background: transparent;
  border-color: transparent;
  color: var(--wyrr-text-dim);
  padding: 10px 8px;
}
.wyrr-btn--text:hover { color: var(--wyrr-text); opacity: 1; }

/* Premium — gold (reserve for paid / prestige) */
.wyrr-btn--gold {
  background: var(--wyrr-gold);
  color: var(--wyrr-text-on-gold);
  border-color: transparent;
}
.wyrr-btn--gold:hover { background: var(--wyrr-gold-bright); opacity: 1; }

.wyrr-btn--danger {
  background: transparent;
  border-color: rgba(240, 102, 138, 0.5);
  color: var(--wyrr-danger);
}
.wyrr-btn--danger:hover { background: rgba(240, 102, 138, 0.10); opacity: 1; }

/* Bottom sheet — flat surface, no blur */
.wyrr-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 2147482800;
  max-height: min(86vh, 86dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--wyrr-bg-1);
  border: 1px solid var(--wyrr-border);
  border-bottom: none;
  border-radius: var(--wyrr-r-xl) var(--wyrr-r-xl) 0 0;
  box-shadow: var(--wyrr-shadow-lg);
  color: var(--wyrr-text);
  font-family: var(--wyrr-font);
  padding: var(--wyrr-s-5);
  padding-bottom: calc(var(--wyrr-s-5) + env(safe-area-inset-bottom, 0px));
  transform: translateY(105%);
  transition: transform var(--wyrr-dur-slow) var(--wyrr-ease);
  will-change: transform;
}
.wyrr-sheet.is-open { transform: translateY(0); }
.wyrr-sheet::before {
  content: "";
  display: block;
  width: 40px; height: 4px;
  margin: 0 auto var(--wyrr-s-4);
  border-radius: var(--wyrr-r-pill);
  background: var(--wyrr-border-hero);
}
.wyrr-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147482799;
  background: var(--wyrr-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--wyrr-dur-med) var(--wyrr-ease);
}
.wyrr-sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* Toast */
.wyrr-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483001;
  transform: translate(-50%, 12px);
  opacity: 0;
  max-width: min(92vw, 420px);
  display: flex;
  align-items: center;
  gap: var(--wyrr-s-3);
  background: var(--wyrr-bg-2);
  border: 1px solid var(--wyrr-border-hi);
  border-radius: var(--wyrr-r-md);
  box-shadow: var(--wyrr-shadow-lg);
  color: var(--wyrr-text);
  font-family: var(--wyrr-font);
  font-size: var(--wyrr-fs-sm);
  padding: var(--wyrr-s-3) var(--wyrr-s-4);
  pointer-events: none;
  transition: transform var(--wyrr-dur-med) var(--wyrr-ease),
              opacity var(--wyrr-dur-med) var(--wyrr-ease);
}
.wyrr-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.wyrr-toast--success { border-color: rgba(61, 214, 140, 0.4); }
.wyrr-toast--error   { border-color: rgba(240, 102, 138, 0.45); }
.wyrr-toast--gold    { border-color: var(--wyrr-gold-50); }
.wyrr-toast__dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--wyrr-text-dim); }
.wyrr-toast--success .wyrr-toast__dot { background: var(--wyrr-ok); }
.wyrr-toast--error   .wyrr-toast__dot { background: var(--wyrr-danger); }

/* Chip */
.wyrr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--wyrr-border);
  border-radius: var(--wyrr-r-pill);
  background: transparent;
  color: var(--wyrr-text-dim);
  font-family: var(--wyrr-font);
  font-size: var(--wyrr-fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--wyrr-dur-fast) var(--wyrr-ease),
              border-color var(--wyrr-dur-fast) var(--wyrr-ease);
}
.wyrr-chip:hover { color: var(--wyrr-text); border-color: var(--wyrr-border-hi); }
.wyrr-chip.is-active,
.wyrr-chip[aria-pressed="true"] {
  color: var(--wyrr-text);
  border-color: transparent;
  background: var(--wyrr-signal);
  -webkit-background-clip: border-box;
  background-clip: border-box;
}

/* Input */
.wyrr-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  box-sizing: border-box;
  background: var(--wyrr-bg-3);
  border: 1px solid var(--wyrr-border);
  border-radius: var(--wyrr-r-sm);
  color: var(--wyrr-text);
  font-family: var(--wyrr-font);
  font-size: var(--wyrr-fs-md);
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--wyrr-dur-med) var(--wyrr-ease),
              box-shadow var(--wyrr-dur-med) var(--wyrr-ease);
}
.wyrr-input::placeholder { color: var(--wyrr-text-faint); }
.wyrr-input:focus {
  border-color: var(--wyrr-pink);
  box-shadow: 0 0 0 3px rgba(255, 61, 139, 0.14);
}

/* Skeleton — quiet shimmer */
.wyrr-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--wyrr-bg-2);
  border-radius: var(--wyrr-r-sm);
  min-height: 1em;
  color: transparent !important;
}
.wyrr-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--wyrr-glass-highlight), transparent);
  animation: wyrr-shimmer 1.6s var(--wyrr-ease) infinite;
}
@keyframes wyrr-shimmer { 100% { transform: translateX(100%); } }

/* Badge — neutral by default; signal / gold as opt-in */
.wyrr-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--wyrr-r-pill);
  padding: 3px 10px;
  font-family: var(--wyrr-font);
  font-size: var(--wyrr-fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--wyrr-border-hi);
  color: var(--wyrr-text-dim);
}
.wyrr-badge--signal { border-color: transparent; background: var(--wyrr-signal); color: #fff; }
.wyrr-badge--gold   { background: var(--wyrr-gold-10); border-color: var(--wyrr-gold-30); color: var(--wyrr-gold-bright); }
.wyrr-badge--ok     { background: rgba(61, 214, 140, 0.10); border-color: rgba(61, 214, 140, 0.35); color: var(--wyrr-ok); }
.wyrr-badge--danger { background: rgba(240, 102, 138, 0.10); border-color: rgba(240, 102, 138, 0.38); color: var(--wyrr-danger); }
.wyrr-badge--info   { background: rgba(107, 184, 232, 0.10); border-color: rgba(107, 184, 232, 0.35); color: var(--wyrr-info); }

/* Divider — hairline */
.wyrr-divider {
  border: none;
  height: 1px;
  margin: var(--wyrr-s-5) 0;
  background: var(--wyrr-border);
}

/* Signal helpers — the ONLY place the spectrum belongs by default */
.wyrr-signal-text {
  background: var(--wyrr-signal);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.wyrr-signal-bar {
  height: 2px;
  border-radius: 2px;
  background: var(--wyrr-signal);
}

/* Headline / display scale */
.wyrr-hero { font-family: var(--wyrr-font); font-size: var(--wyrr-fs-hero); font-weight: 700; line-height: 1.02; letter-spacing: -0.02em; color: var(--wyrr-text); }
.wyrr-display { font-family: var(--wyrr-font); font-size: var(--wyrr-fs-display); font-weight: 800; line-height: 0.98; letter-spacing: -0.03em; color: var(--wyrr-text); }
.wyrr-mono { font-family: var(--wyrr-font-mono); font-variant-numeric: tabular-nums; }

/* Scroll reveal (pairs with WYRR_DS.revealInit) — entrance fade only */
.wyrr-reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--wyrr-dur-slow) var(--wyrr-ease),
              transform var(--wyrr-dur-slow) var(--wyrr-ease);
  will-change: opacity, transform;
}
.wyrr-reveal.is-visible { opacity: 1; transform: none; }

/* Amount — mono, tabular, restrained */
.wyrr-amount {
  font-family: var(--wyrr-font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--wyrr-text);
  text-shadow: none;
}

/* Press feedback */
[data-wyrr-press] {
  transition: opacity var(--wyrr-dur-fast) var(--wyrr-ease);
  -webkit-tap-highlight-color: transparent;
}
[data-wyrr-press].wyrr-pressed { opacity: 0.82; }

/* Safe-area helpers */
.wyrr-safe-bottom { padding-bottom: calc(var(--wyrr-s-4) + env(safe-area-inset-bottom, 0px)); }
.wyrr-safe-top    { padding-top: calc(var(--wyrr-s-4) + env(safe-area-inset-top, 0px)); }
.wyrr-safe-x {
  padding-left: calc(var(--wyrr-s-4) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--wyrr-s-4) + env(safe-area-inset-right, 0px));
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wyrr-glass-card, .wyrr-card, .wyrr-btn, .wyrr-sheet, .wyrr-sheet-backdrop, .wyrr-toast,
  .wyrr-chip, .wyrr-input, .wyrr-reveal, [data-wyrr-press] {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
  .wyrr-reveal { opacity: 1; transform: none; }
  .wyrr-skeleton::after { animation: none; }
}
