/* ============================================================
   VOLDECK design system — "volatility as light"
   ============================================================ */

/* ── Custom properties ── */
:root {
  --ink:      #0A0E14;
  --panel:    #121722;
  --panel2:   #0E131C;
  --line:     #222A38;
  --calm:     #34D3FF;
  --accent:   #7C5CFF;
  --rich:     #FF8A3D;
  --text:     #E6EDF3;
  --muted:    #8B98A9;
  --pos:      #3DD68C;
  --neg:      #FF5C7C;
  --rail-w:   200px;
  --topbar-h: 52px;
  --tape-h:   72px;
  --radius:   7px;
}

/* ── Reset / base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--ink);
  background-image: radial-gradient(
    ellipse 90% 45% at 55% 0%,
    rgba(124, 92, 255, 0.07) 0%,
    transparent 100%
  );
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
}

/* Mono helper */
.mono {
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-feature-settings: "tnum" 1;
}

/* ── Focus-visible ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Left rail ── */
.rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--rail-w);
  background: var(--panel2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

.rail-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.rail-brand-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--text);
  text-transform: uppercase;
}

.rail-nav {
  list-style: none;
  padding: 0.75rem 0;
  flex: 1;
  overflow-y: auto;
}

.rail-nav li {
  display: block;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s;
}

.rail-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.rail-link.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
}

.rail-glyph {
  font-size: 0.9375rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── Main column ── */
.main-col {
  margin-left: var(--rail-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
  gap: 1rem;
}

.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-date {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Vol tape ── */
.voltape-bar {
  height: var(--tape-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.voltape-bar::-webkit-scrollbar { height: 4px; }
.voltape-bar::-webkit-scrollbar-track { background: transparent; }
.voltape-bar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* Tape cells */
.tape-cell {
  --rank-color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s;
  background: color-mix(in srgb, var(--rank-color) 6%, var(--panel2));
  box-shadow:
    0 0 14px color-mix(in srgb, var(--rank-color) 28%, transparent),
    0 0  5px color-mix(in srgb, var(--rank-color) 14%, transparent);
  border-color: color-mix(in srgb, var(--rank-color) 32%, var(--line));
}

.tape-cell:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--rank-color) 55%, var(--line));
}

/* Regime colour fallbacks (CSS only, overridden by deck.js with exact gradient) */
.tape-calm { --rank-color: var(--calm); }
.tape-mid  { --rank-color: var(--accent); }
.tape-rich { --rank-color: var(--rich); }

/* Dim cell (missing analytics) */
.tape-dim {
  --rank-color: var(--muted);
  opacity: 0.45;
  box-shadow: none;
}

.tape-ticker {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.tape-rank {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.tape-iv {
  font-size: 0.625rem;
  color: var(--muted);
}

/* Sparkline inside tape cells */
.sparkline {
  width: 52px;
  height: 18px;
  flex-shrink: 0;
  color: color-mix(in srgb, var(--rank-color) 80%, transparent);
  display: block;
}

.sparkline-empty {
  display: inline-block;
  width: 52px;
  height: 18px;
}

/* ── Tape reveal animation (motion-safe only) ── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes tape-rise {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .tape-reveal {
    animation: tape-rise 0.4s ease-out forwards;
    opacity: 0;
  }
}

/* ── Scrollable main content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ============================================================
   Panel / card components
   ============================================================ */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

/* Big stats */
.stat {
  font-family: 'IBM Plex Mono', monospace;
  font-feature-settings: "tnum" 1;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
  display: block;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: block;
  margin-top: 0.2rem;
}

/* ── Table ── */
.deck-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.deck-table th {
  font-family: 'Inter', sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: left;
  padding: 0.4rem 0.75rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.deck-table th.num,
.deck-table td.num {
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
  font-feature-settings: "tnum" 1;
}

.deck-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(34, 42, 56, 0.6);
  color: var(--text);
  vertical-align: middle;
}

.deck-table td.mono {
  font-family: 'IBM Plex Mono', monospace;
  font-feature-settings: "tnum" 1;
}

.deck-table tr:last-child td {
  border-bottom: none;
}

.deck-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.chip-pos  { color: var(--pos);  border-color: rgba(61, 214, 140, 0.3);  background: rgba(61, 214, 140, 0.08); }
.chip-neg  { color: var(--neg);  border-color: rgba(255, 92, 124, 0.3);  background: rgba(255, 92, 124, 0.08); }
.chip-rich { color: var(--rich); border-color: rgba(255, 138, 61, 0.3);  background: rgba(255, 138, 61, 0.08); }
.chip-calm { color: var(--calm); border-color: rgba(52, 211, 255, 0.3);  background: rgba(52, 211, 255, 0.08); }
.chip-mid  { color: var(--accent); border-color: rgba(124, 92, 255, 0.3); background: rgba(124, 92, 255, 0.08); }

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.875rem;
  border-radius: 5px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Gauge shell ── */
.gauge {
  width: 100%;
  aspect-ratio: 1.6;
  max-width: 200px;
}

/* ── Bar / progress ── */
.bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ── Toast ── */
.deck-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  z-index: 9999;
  pointer-events: none;
  font-family: 'Inter', sans-serif;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .deck-toast { animation: toast-in 0.2s ease-out; }
}

.deck-toast-ok  { background: var(--pos); color: var(--ink); }
.deck-toast-err { background: var(--neg); color: #fff; }

/* ── Payoff SVG ── */
.payoff-svg {
  width: 100%;
  max-width: 320px;
  border-radius: 4px;
}

/* ── Mobile — rail collapses to horizontal top row ── */
@media (max-width: 820px) {
  html, body { overflow: auto; }

  body { flex-direction: column; }

  .rail {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .rail-brand {
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 0.75rem 1rem;
    white-space: nowrap;
  }

  .rail-nav {
    display: flex;
    flex-direction: row;
    padding: 0;
    overflow: visible;
  }

  .rail-link {
    padding: 0.75rem 0.875rem;
    border-left: none;
    border-bottom: 2px solid transparent;
    flex-direction: column;
    gap: 0.125rem;
    font-size: 0.6875rem;
    align-items: center;
  }

  .rail-link.active {
    border-bottom-color: var(--accent);
    border-left-color: transparent;
    background: transparent;
  }

  .rail-glyph { font-size: 1rem; width: auto; }

  .main-col {
    margin-left: 0;
    height: auto;
    min-height: calc(100vh - 52px);
  }

  .main-content { overflow-y: visible; }

  .panel { margin-bottom: 1rem; }
}
