/*
 * v2 design system — small custom CSS layered on top of Tailwind.
 *
 * Colours resolve to the CSS variables defined in theme-tokens.css (loaded
 * first in every v2 layout), so light/dark flips with the <html data-theme>
 * attribute. DARK values are byte-identical to the pre-theme hardcoded ones.
 *
 * Anything that's a Tailwind utility class lives in the markup.
 * Anything that needs a CSS feature Tailwind doesn't ship by default
 * (font tabular-nums, animated dot, custom hairline ring) lives here.
 */

/* color-scheme is set per-theme in theme-tokens.css */

html, body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: hsl(var(--c-bg));
  color: rgb(var(--z-100));
}

/* Tabular numerics for amounts — keeps columns aligned */
.num {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}

/* Hairline border that survives both dark/light bg via inset shadow */
.ring-line {
  box-shadow: inset 0 0 0 1px hsl(var(--c-line));
}

/* Pulsing earning indicator */
.pulse-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: rgb(var(--c-brand));
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 0 4px rgb(var(--c-brand) / 0.18);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/*
 * Brand button — used a lot, so a small CSS class keeps markup tidy.
 * Tailwind equivalent would need ~6 utility classes per button.
 */
.btn-brand {
  background: rgb(var(--c-brand));
  color: rgb(9 9 11);
  font-weight: 500;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  transition: background 150ms;
  white-space: nowrap;     /* prevent CTA text wrapping on narrow viewports */
}

/* :target highlight — applied to any element with .anchor-target whose
   id matches the URL hash. Gives the user visual feedback when they
   land on a deep-linked row (e.g. the "Review →" link from the
   withdrawal list page to the focused review queue). */
.anchor-target:target {
  background: rgb(var(--c-brand) / 0.06) !important;
  box-shadow: inset 0 0 0 2px rgb(var(--c-brand) / 0.4);
  animation: anchor-target-pulse 1.2s ease-out;
}
@keyframes anchor-target-pulse {
  0%   { background: rgb(var(--c-brand) / 0.18); }
  100% { background: rgb(var(--c-brand) / 0.06); }
}
.btn-brand:hover { background: rgb(var(--c-brand-dark)); }
.btn-brand:disabled { background: rgb(var(--z-700)); color: rgb(var(--z-400)); cursor: not-allowed; }

.btn-ghost {
  background: hsl(var(--c-card));
  box-shadow: inset 0 0 0 1px hsl(var(--c-line));
  color: rgb(var(--z-100));
  font-weight: 500;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  transition: box-shadow 150ms;
  white-space: nowrap;     /* same — keep ghost CTAs on a single line */
}
.btn-ghost:hover { box-shadow: inset 0 0 0 2px hsl(240 4% 30%); }

/* Form inputs — minimum-friction style for the redesign */
.input-v2 {
  background: hsl(var(--c-card));
  box-shadow: inset 0 0 0 1px hsl(var(--c-line));
  color: rgb(var(--z-100));
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  /* 16px on mobile to prevent iOS Safari from auto-zooming the page when
     a field is focused (any input < 16px triggers the zoom-and-don't-restore
     behavior). 14px above sm so desktop forms keep their compact look. */
  font-size: 16px;
  width: 100%;
  outline: none;
  transition: box-shadow 150ms;
}
@media (min-width: 640px) {
  .input-v2 { font-size: 0.875rem; }
}
.input-v2:focus {
  box-shadow: inset 0 0 0 2px rgb(var(--c-brand));
}
.input-v2::placeholder { color: rgb(var(--z-600)); }

/* <select> with .input-v2 — replace the native arrow (which sits flush
   against the right border in WebKit/Blink and looks broken inside our
   rounded inputs) with a custom chevron. The grey/brand chevrons read on
   both light and dark inputs. Extra right-padding gives the value room. */
select.input-v2 {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px 14px;
  padding-right: 2.25rem;
}
select.input-v2::-ms-expand { display: none; }
select.input-v2:focus {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378BE43' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* Status pill — small uppercase badge with color-tinted background.
   Tints work on both themes; the pastel TEXT colours are tuned for dark
   and get darker variants under [data-theme="light"] further down. */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.pill-brand   { background: rgb(var(--c-brand) / 0.15); color: rgb(167 215 119); }
.pill-amber   { background: rgba(245, 158, 11, 0.15); color: rgb(252 211 77); }
.pill-violet  { background: rgba(139, 92, 246, 0.15); color: rgb(196 181 253); }
.pill-zinc    { background: hsl(var(--c-line));       color: rgb(var(--z-300)); }
.pill-rose    { background: rgba(244, 63, 94, 0.15);  color: rgb(252 165 165); }

/* Alert banner — used for warnings (TOTP not enrolled, etc) */
.alert-v2 {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.8125rem;
}
.alert-v2.warn  { background: rgba(245, 158, 11, 0.08); box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.25); color: rgb(252 211 77); }
.alert-v2.error { background: rgba(244, 63, 94, 0.08);  box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.25);  color: rgb(252 165 165); }
.alert-v2.ok    { background: rgb(var(--c-brand) / 0.08); box-shadow: inset 0 0 0 1px rgb(var(--c-brand) / 0.25); color: rgb(167 215 119); }

/* Inline tooltip — CSS-only, accessible via :hover and :focus-visible.
   Pattern:
     <span class="tip" tabindex="0">
       Term
       <svg class="tip-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
         <circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>
       </svg>
       <span class="tip-content">Definition that explains the term in one sentence.</span>
     </span>
   No JS, no positioning library. */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: help;
  outline: none;
  border-bottom: 1px dotted rgb(var(--c-brand) / 0.4);
}
.tip-icon {
  width: 0.875rem;
  height: 0.875rem;
  color: rgb(var(--z-400));
  flex: none;
}
.tip:hover .tip-icon,
.tip:focus-visible .tip-icon { color: rgb(var(--c-brand)); }
/* Tooltip body stays DARK in both themes — a dark tooltip reads fine on a
   light page, and white-on-white would not. Intentionally not tokenized. */
.tip-content {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 50;
  width: max-content;
  max-width: 280px;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  background: rgb(24 24 27);
  box-shadow: inset 0 0 0 1px rgb(39 39 42), 0 8px 16px rgb(0 0 0 / 0.4);
  font-size: 0.75rem;
  line-height: 1.45;
  color: rgb(228 228 231);
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease-out, transform 120ms ease-out;
}
.tip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgb(39 39 42);
}
.tip:hover .tip-content,
.tip:focus-visible .tip-content {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* ============================================================
   THEME TOGGLE ICON — sun shown in dark mode, moon in light mode.
   ============================================================ */
.theme-ico-sun, .theme-ico-moon { display: none; }
[data-theme="dark"]  .theme-ico-sun  { display: block; }
[data-theme="light"] .theme-ico-moon { display: block; }

/* ============================================================
   LIGHT THEME — targeted overrides
   The token system + variable-backed Tailwind handle structural colours
   automatically. These fix the cases a single flippable token can't:
   ============================================================ */

/* (1) White overlays (subtle contrast on DARK surfaces) are invisible on a
   light page — flip to black-alpha. Selectors match the compiled utilities
   exactly. Solid .bg-white (QR codes) and .bg-white/95 (logo tiles) are
   deliberately left white. */
[data-theme="light"] .bg-white\/5            { background-color: rgb(0 0 0 / 0.05); }
[data-theme="light"] .bg-white\/\[0\.01\]    { background-color: rgb(0 0 0 / 0.02); }
[data-theme="light"] .bg-white\/\[0\.02\]    { background-color: rgb(0 0 0 / 0.03); }
[data-theme="light"] .bg-white\/\[0\.06\]    { background-color: rgb(0 0 0 / 0.06); }
[data-theme="light"] .ring-white\/10         { --tw-ring-color: rgb(0 0 0 / 0.12); }
[data-theme="light"] .hover\:bg-white\/5:hover          { background-color: rgb(0 0 0 / 0.05); }
[data-theme="light"] .hover\:bg-white\/\[0\.015\]:hover { background-color: rgb(0 0 0 / 0.03); }
[data-theme="light"] .hover\:bg-white\/\[0\.02\]:hover  { background-color: rgb(0 0 0 / 0.03); }
[data-theme="light"] .hover\:bg-white\/\[0\.025\]:hover { background-color: rgb(0 0 0 / 0.035); }
[data-theme="light"] .hover\:bg-white\/\[0\.03\]:hover  { background-color: rgb(0 0 0 / 0.04); }

/* (2) Status TEXT: the -300/-400 shades are too light on white. Darken to
   ~-600/700 for contrast. Translucent bg/ring tints read fine as-is. */
[data-theme="light"] .text-emerald-400,
[data-theme="light"] .text-emerald-300 { color: #047857; }
[data-theme="light"] .text-rose-400,
[data-theme="light"] .text-rose-300    { color: #e11d48; }
[data-theme="light"] .text-amber-400,
[data-theme="light"] .text-amber-300,
[data-theme="light"] .text-amber-200   { color: #b45309; }
[data-theme="light"] .text-violet-400  { color: #7c3aed; }
[data-theme="light"] .text-sky-400     { color: #0284c7; }

/* (3) Brand green text is low-contrast on white — darken the TEXT only.
   bg-brand fills stay bright (driven by the --c-brand token). */
[data-theme="light"] .text-brand { color: #4e8a2f; }

/* (4) Pills & alerts: pastel text tuned for dark → darker on light. */
[data-theme="light"] .pill-brand     { color: #3f7320; }
[data-theme="light"] .pill-amber     { color: #b45309; }
[data-theme="light"] .pill-violet    { color: #6d28d9; }
[data-theme="light"] .pill-rose      { color: #be123c; }
[data-theme="light"] .alert-v2.warn  { color: #b45309; }
[data-theme="light"] .alert-v2.error { color: #be123c; }
[data-theme="light"] .alert-v2.ok    { color: #3f7320; }

/* (5) Sections sitting on a FIXED dark background (the homepage hero video +
   black overlay) must keep LIGHT text in BOTH themes — their zinc text
   classes must not flip with the theme. Add class="on-dark" to such a
   wrapper. Values match the dark-theme zinc ramp, so dark mode is unchanged. */
.on-dark .text-zinc-100 { color: rgb(244 244 245); }
.on-dark .text-zinc-200 { color: rgb(228 228 231); }
.on-dark .text-zinc-300 { color: rgb(212 212 216); }
.on-dark .text-zinc-400 { color: rgb(161 161 170); }
.on-dark .text-mute     { color: rgb(161 161 170); }

/* (6) Auth wordmark logo is white text on a black field — on the LIGHT auth
   card, round it into a deliberate dark plate so it reads as a brand lockup
   rather than a hard black rectangle. Left untouched in dark mode, where it
   sits seamlessly on the dark card. Only the wordmark (auth pages) matches;
   the topbar uses logo.png. */
[data-theme="light"] img[src*="logo-wordmark"] {
  border-radius: 0.625rem;
  padding: 0.5rem 0.75rem;
  box-sizing: content-box;
  background: #0b0b0f;
}
