/* ════════════════════════════════════════════════════════════════════
   Login / auth screen — ticker tape, dot grid, helmet animation, login card
   The helmet stage's animation is driven by JS (see js/auth/helmet.js);
   this file is the static visual envelope only.
   ════════════════════════════════════════════════════════════════════ */

#login-screen {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--background); color: var(--foreground);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 1; transition: opacity .35s ease;
}
#login-screen.fading { opacity: 0; pointer-events: none; }

/* ── Ticker tape — sticky strip across the top ─────────────────────── */
.ticker-tape {
  position: sticky; top: 0; z-index: 5;
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.30);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  /* Reserve the populated height up-front so the tape doesn't reflow from
     20px → 38px when the JS bootstrap injects the track. Math: 12px font ×
     1.5 line-height + 10px top + 10px bottom padding = 38px. Using
     min-height (not height) so any future taller content still grows the
     tape correctly. */
  min-height: 38px;
  padding: 10px 0;
  box-sizing: border-box;
}
:root[data-theme="light"] .ticker-tape {
  background: rgba(255,255,255,.85);
  border-bottom-color: rgba(0,0,0,.08);
}
.ticker-track {
  display: flex; gap: 32px;
  white-space: nowrap;
  animation: ticker-scroll 38s linear infinite;
  width: max-content;
  padding-left: 24px;
}
.ticker-track:hover { animation-play-state: paused; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.t-item { display: inline-flex; align-items: center; gap: 12px; }
.t-sym  { color: var(--muted-foreground); }
.t-val  { color: var(--foreground); font-variant-numeric: tabular-nums; }
.t-delta { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; color: var(--muted-foreground); }
.t-delta.pos { color: var(--profit); }
.t-delta.neg { color: var(--loss); }
.t-delta .arr { font-size: 10px; }

/* ── Dot grid background ─────────────────────────────────────────────
   Geometry: the element uses a symmetric `inset: 100px`, so its centre
   coincides with the viewport centre at every viewport size.

   To make a dot land on that centre point we need TWO things:
   1. The dot must be at the geometric centre of its 35px tile —
      `circle at 50% 50%` (not `at 1px 1px`, which would shove the dot
      into the tile corner and leave it 16.5px off-centre).
   2. The repeating tile must be anchored to the element centre —
      `background-position: 50% 50%`. Without this, the pattern starts
      from the element's top-left and the alignment depends on viewport
      width happening to be a multiple of 35px.

   Together: a dot sits exactly on viewport centre, with concentric rings
   of dots radiating outward at 35px intervals. Resize the window and
   the dot stays centred. */
.auth-dot-grid {
  pointer-events: none;
  position: fixed;
  inset: 100px;
  z-index: 0;
  --dot-size: 1px;
  --grid-size: 35px;
  --dot-alpha: .08;
  background-size: var(--grid-size) var(--grid-size);
  background-position: 50% 50%;
  background-image: radial-gradient(
    circle at 50% 50%,
    rgba(248, 248, 248, var(--dot-alpha)) var(--dot-size),
    transparent var(--dot-size)
  );
}
:root[data-theme="light"] .auth-dot-grid {
  --dot-alpha: .30;
  background-image: radial-gradient(
    circle at 50% 50%,
    rgba(17, 17, 17, var(--dot-alpha)) var(--dot-size),
    transparent var(--dot-size)
  );
}

/* ── Floating Spartan helmet ───────────────────────────────────────────
   Carbon-copy of spartan-mnf-dashboard's auth-background.tsx structure.
   Two stages mounted (dark + light variants); CSS hides the inactive one
   per theme so the JS animation runs only what's visible. */
.auth-helmet-stage {
  pointer-events: none;
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 0;
}
:root[data-theme="dark"]  .helmet-only-light { display: none; }
:root[data-theme="light"] .helmet-only-dark  { display: none; }

.auth-helmet-mask {
  --helmet-mask-center-alpha: 0.88;
  position: relative;
  height: 100%; width: 100%;
  transform-style: preserve-3d;
  /* Mask gradient is centered on the helmet's anchor (top: 50%) so the
     alpha falloff is symmetric around the helmet rather than around the
     viewport — keeps the assembled silhouette evenly lit. */
  -webkit-mask-image: radial-gradient(
    circle at 50% 50%,
    rgba(0, 0, 0, var(--helmet-mask-center-alpha)) 0%,
    rgba(0, 0, 0, 0) 115%
  );
          mask-image: radial-gradient(
    circle at 50% 50%,
    rgba(0, 0, 0, var(--helmet-mask-center-alpha)) 0%,
    rgba(0, 0, 0, 0) 115%
  );
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
}

.auth-helmet-frag-wrap {
  /* Wrapper anchors at viewport center now that the SPARTAN text-shard
     animation is disabled — the helmet is the sole brand element and is
     visually centered. NOTE: must match HELMET_ANCHOR_Y_RATIO in
     js/auth/helmet.js. */
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
}

.auth-helmet-fragment {
  width: 100%;
  height: 100%;
  will-change: transform;
  transform-origin: center;
  transform-style: preserve-3d;
}
.auth-helmet-fragment svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ── Floating SPARTAN text — backdrop layer behind the helmet ───────────
   Mounted earlier in DOM than the helmet stages so it sits behind them at
   equal z-index. Each character is its own animated fragment driven by
   js/auth/text-shards.js. The visible color matches the active theme via
   --text-fragment-color. */
.auth-text-stage {
  pointer-events: none;
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 0;
}

.auth-text-mask {
  --text-mask-center-alpha: 0.6;
  position: relative;
  height: 100%; width: 100%;
  transform-style: preserve-3d;
  /* Mask gradient centered on the text anchor (top: 75%) — keeps the
     alpha falloff symmetric around SPARTAN, fading to 0 toward the top
     of the viewport where the helmet lives. */
  -webkit-mask-image: radial-gradient(
    circle at 50% 80%,
    rgba(0, 0, 0, var(--text-mask-center-alpha)) 0%,
    rgba(0, 0, 0, 0) 110%
  );
          mask-image: radial-gradient(
    circle at 50% 80%,
    rgba(0, 0, 0, var(--text-mask-center-alpha)) 0%,
    rgba(0, 0, 0, 0) 110%
  );
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
}

/* Wrapper sized in JS to the letter's slot; transformed to its center. */
.auth-text-frag-wrap {
  position: absolute;
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
  user-select: none;
}

.auth-text-fragment {
  width: 100%;
  height: 100%;
  will-change: transform, opacity;
  transform-origin: center;
  transform-style: preserve-3d;
}
.auth-text-fragment svg {
  display: block;
  width: 100%;
  height: 100%;
  /* Belt + braces: viewBox already crops, but explicit overflow:hidden
     guarantees adjacent letters never bleed into a shard's silhouette. */
  overflow: hidden;
}

/* ── Login card / access panel ─────────────────────────────────────────
   The auth panel is intentionally compact and contained — a single focal
   "console" object that sits politely under the helmet rather than two
   loose buttons. Backdrop blur + translucent surface keeps the helmet and
   text-shard animations visible THROUGH the panel so the brand artwork
   reads continuously across the whole viewport.

   Width is bounded so the Spartan button stays compact: the helmet
   coalesce animation reads #auth-spartan-btn's bounding rect (see
   js/auth/helmet.js) and uses max(width,height)*3 as its influence
   radius. A wider button would over-eagerly gather; a too-narrow one
   would feel under-responsive. ~256px is the sweet spot.
*/
.auth-main {
  position: relative; z-index: 2;
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 24px;
}
.auth-card {
  position: relative;
  display: flex; flex-direction: column; align-items: stretch;
  width: 100%;
  max-width: 320px;
  padding: 24px 24px 18px;
  /* Glass fill held at ~.55 on both themes so dark and light read as
     the same material. The default --surface-card token (.30 dark,
     1.0 light) was too far apart — dark looked like vapor, light
     looked solid. */
  background: rgba(20,20,20,.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  -webkit-backdrop-filter: blur(10px) saturate(120%);
          backdrop-filter: blur(10px) saturate(120%);
  /* Soft shadow + faint inner highlight gives the panel a tactile,
     "machined" feel without looking glossy. */
  box-shadow:
    0 1px 0 rgba(255,255,255,.03) inset,
    0 8px 32px rgba(0,0,0,.45);
}
:root[data-theme="light"] .auth-card {
  background: rgba(255,255,255,.55);
  box-shadow:
    0 1px 0 rgba(255,255,255,.6) inset,
    0 8px 24px rgba(17,17,17,.08);
}

/* ── Eyebrow: status dot + uppercase mono label ─────────────────────────
   The "RESTRICTED ACCESS" eyebrow names the surface. The pulsing dot is a
   ops/terminal-grade affordance: at a glance it signals the system is
   live and reachable, the way Bloomberg/trading-ops UIs do. */
.auth-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  color: var(--muted-foreground);
  margin-bottom: 14px;
}
.auth-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--status-live);
  box-shadow: 0 0 0 0 currentColor;
  animation: auth-status-pulse 2.4s ease-out infinite;
  color: var(--status-live);
  flex: 0 0 auto;
}
@keyframes auth-status-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(81,193,72,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(81,193,72,0);   }
  100% { box-shadow: 0 0 0 0   rgba(81,193,72,0);   }
}
:root[data-theme="light"] .auth-status-dot {
  animation-name: auth-status-pulse-light;
}
@keyframes auth-status-pulse-light {
  0%   { box-shadow: 0 0 0 0   rgba(22,163,74,.40); }
  70%  { box-shadow: 0 0 0 6px rgba(22,163,74,0);   }
  100% { box-shadow: 0 0 0 0   rgba(22,163,74,0);   }
}

/* ── Title + subtitle ─────────────────────────────────────────────────── */
.auth-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -.005em;
  color: var(--foreground);
  line-height: 1.3;
}
.auth-subtitle {
  margin: 4px 0 18px;
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

/* ── Buttons block — equal width, stacked, hairline divider above ─────── */
.auth-buttons {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Login button — overrides the generic .primary/.ghost padding so both
   buttons share the SAME footprint inside the panel (full width, identical
   height). Provider mark + label are laid out with flex so the icon stays
   pinned to the visual left while the label remains optically centered. */
.auth-login {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  transition: opacity .15s, background .15s, border-color .15s, transform .08s;
}
.auth-login:active { transform: translateY(1px); }
.auth-login:disabled { cursor: not-allowed; opacity: .55; }
/* Keyboard focus ring — visible only for keyboard users so the helmet
   coalesce-on-focus interaction feels intentional, not noisy. */
.auth-login:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--background), 0 0 0 3px var(--ring);
}

/* The Google mark is multi-color by brand requirement — keep it visually
   anchored to the start of the button without absolute positioning so the
   button width can flex without breaking centering. The colored G reads
   well directly on both filled (primary) and ghost button surfaces, so no
   inset plate is needed. */
.auth-provider-mark { flex: 0 0 auto; }
.auth-login-label { flex: 0 1 auto; display: inline-flex; align-items: center; }

/* Inline SPARTAN wordmark inside the primary button — replaces the literal
   "Spartan" text with the same SVG used in the brand lockup so the button
   reads as a true brand-anchored CTA. Implemented as a CSS mask painted
   with currentColor so the wordmark inherits the button's text color and
   flips correctly across themes. SVG aspect is 232:35 ≈ 6.63:1; at 11px
   tall the width works out to ~73px. */
.auth-spartan-text {
  display: inline-block;
  width: 73px;
  height: 11px;
  background-color: currentColor;
  -webkit-mask: url('/spartan_text_dark.svg') no-repeat center / contain;
          mask: url('/spartan_text_dark.svg') no-repeat center / contain;
  vertical-align: -1px;
  margin-right: 8px;
}

/* Error line lives between the buttons block and the meta footer. */
.auth-error-line {
  margin: 12px 0 0;
  color: var(--destructive-foreground);
  font-size: 12px;
  text-align: center;
}

/* ── Panel meta footer — subtle, mono, tracked ──────────────────────────
   Names the firm + the auth method. Restraint is the point: no decoration,
   no marketing copy. Reads as a system identifier. */
.auth-meta {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  color: var(--muted-foreground);
  text-transform: uppercase;
}
.auth-meta-sep {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}

/* Disclaimer footer — docked at the bottom, two lines. */
.auth-footer {
  position: relative; z-index: 2;
  padding: 16px 24px;
  text-align: center;
  font-size: 11px; color: var(--muted-foreground);
  line-height: 1.6;
  display: flex; flex-direction: column; gap: 2px;
}

/* Helmet sizing is fully responsive in JS — wrappers are resized on
   `resize` events and the dispersed cloud's half-extent is derived from
   the live viewport every frame, so no CSS scaling rule is needed. */

/* ── Auth error / access denied pages ──────────────────────────────── */
.auth-error-shell {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--background); color: var(--foreground);
  padding: 24px;
}
.auth-error-card {
  max-width: 480px; width: 100%;
  background: var(--card, rgba(255,255,255,.04));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
}
.auth-error-card h1 { margin: 0 0 12px; font-size: 18px; letter-spacing: .04em; }
.auth-error-card p { margin: 8px 0; font-size: 13px; line-height: 1.6; }
.auth-error-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--primary, #2563eb);
  color: #fff;
  border: 0; border-radius: 6px;
  font: inherit; cursor: pointer; text-decoration: none;
}

/* ── LP role: hide write-only affordances ─────────────────────────────
   Server-side RLS is the real enforcement; this is purely cosmetic so LPs
   don't see buttons that 403 on click. */
:root[data-role="lp"] #btn-add-deal,
:root[data-role="lp"] #btn-calculate,
:root[data-role="lp"] .deal-delete,
:root[data-role="lp"] .deal-card .ticker-input,
:root[data-role="lp"] .deal-card input:not([readonly]),
:root[data-role="lp"] .deal-card select,
:root[data-role="lp"] .deal-card textarea,
:root[data-role="lp"] #settings-credentials-form {
  pointer-events: none;
  opacity: .55;
}
:root[data-role="lp"] #btn-add-deal,
:root[data-role="lp"] .deal-delete {
  display: none !important;
}

/* ── Role-conditional inline copy ──────────────────────────────────────
   .spartan-only-inline / .lp-only-inline let copy in tab subtitles +
   card headers swap based on the active role without JS. Same idea as
   the existing .spartan-only sidebar gate, but inline-friendly. */
.spartan-only-inline { display: inline; }
.lp-only-inline      { display: none; }
:root[data-role="lp"] .spartan-only-inline { display: none; }
:root[data-role="lp"] .lp-only-inline      { display: inline; }

/* ── LP capability gating ─────────────────────────────────────────────
   data-lp-perms is space-separated (e.g. "view_portfolio reports"), so
   `[data-lp-perms~="run_calc"]` matches only when run_calc is granted.
   Spartans always have the full set so these :not() rules never fire. */
:root[data-role="lp"]:not([data-lp-perms~="view_funds"]) [data-tab="funds"] {
  display: none !important;
}
:root[data-role="lp"]:not([data-lp-perms~="run_calc"]) [data-tab="backtest"] {
  display: none !important;
}
:root[data-role="lp"]:not([data-lp-perms~="reports"]) [data-tab="report"] {
  display: none !important;
}
:root[data-role="lp"]:not([data-lp-perms~="token_dd"]) [data-tab="tokendd"] {
  display: none !important;
}
:root[data-role="lp"]:not([data-lp-perms~="funding_scan"]) [data-tab="fundingscan"] {
  display: none !important;
}
/* Live Arb reuses the scanners' funding_scan scope (same gate as the
   /api/research/live-arb routes). */
:root[data-role="lp"]:not([data-lp-perms~="funding_scan"]) [data-tab="livearb"] {
  display: none !important;
}
:root[data-role="lp"]:not([data-lp-perms~="live_positions"]) [data-tab="cex"] {
  display: none !important;
}

/* Hide section headers when an LP has no access to any item in that
   section. Workspace items (Overview, Portfolio group) are not
   perm-gated today, but the rule is here for symmetry — it only fires
   if every workspace-tied perm is missing. Research collapses when an
   LP has none of run_calc / token_dd / funding_scan. Reports lives in
   Administration / Fund Management now, so it no longer keeps Research
   alive. Admin always retains Settings, so it never empties. */
:root[data-role="lp"]:not([data-lp-perms~="view_portfolio"]) [data-section="workspace"] {
  display: none !important;
}
:root[data-role="lp"]:not([data-lp-perms~="run_calc"]):not([data-lp-perms~="token_dd"]):not([data-lp-perms~="funding_scan"]) [data-section="research"] {
  display: none !important;
}

/* ── Trading terminal: only the two named operators (email-gated) ──────────
   Hides the sidebar section + tab for everyone else, INCLUDING other Spartans.
   data-user-email is stamped on <html> by app/legacy/AppShell.tsx. The real gate is
   server-side (lib/trading/access.ts + app/legacy/trading/page.tsx); this is cosmetic
   so non-operators never see an entry point. */
:root:not([data-user-email="alex.laidlaw@spartangroup.io"]):not([data-user-email="aditya.saraf@spartangroup.io"]) [data-tab="trading"],
:root:not([data-user-email="alex.laidlaw@spartangroup.io"]):not([data-user-email="aditya.saraf@spartangroup.io"]) [data-section="trading"] {
  display: none !important;
}
