/* styles.css — TradeBuddy design tokens + component styles.
 *
 * Source of truth: design-system/tradebuddy/MASTER.md (style "Modern Dark").
 * The generator emitted a LIGHT color table while simultaneously declaring the style
 * "Modern Dark", listing dark keywords (deep navy, indigo, glow, glassmorphism), and
 * forbidding "Light mode default". That is the generator's known light/dark bug — we
 * resolve it in favor of the explicitly-declared dark mode, keeping the generator's
 * hue choices (blue primary "#1E40AF/#3B82F6", amber accent "#D97706") but darkened
 * for a dark surface. Inter, the spacing/shadow scales, motion easing, and every
 * anti-pattern rule are carried over verbatim.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* --- Color (dark, resolved from MASTER.md hues) --- */
  --color-background: #0B1120;   /* deep indigo-navy; NOT pure #000 (OLED smear rule) */
  --color-surface:    #131C2E;   /* elevated card */
  --color-surface-2:  #18233A;   /* nested / hover surface */
  --color-muted:      #1B2437;
  --color-border:     #2A3550;
  --color-foreground: #E8EEF9;   /* ~13:1 on background */
  --color-muted-fg:   #94A3B8;   /* ~5.3:1 on background */

  --color-primary:        #3B82F6;   /* blue brand (brightened from #1E40AF for dark bg) */
  --color-primary-strong: #1E40AF;
  --color-secondary:      #60A5FA;
  --color-accent:         #F59E0B;   /* amber CTA/highlight (from #D97706, brightened) */
  --color-accent-strong:  #D97706;
  --color-on-accent:      #0B1120;

  /* Trading semantics (supplemented — MASTER gives only destructive) */
  --color-bull:  #22C55E;   /* support / long / bullish */
  --color-bear:  #EF4444;   /* resistance / short / stop (== destructive) */
  --color-destructive: #EF4444;

  --color-ring: #3B82F6;

  /* --- Spacing (MASTER density 6/10) --- */
  --space-xs: 0.25rem; --space-sm: 0.5rem; --space-md: 1rem;
  --space-lg: 1.5rem;  --space-xl: 2rem;   --space-2xl: 3rem; --space-3xl: 4rem;

  /* --- Shadows (darkened) --- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.40);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.45);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.55);
  --glow-primary: 0 0 40px rgba(59,130,246,0.35);
  --glow-accent:  0 0 40px rgba(245,158,11,0.30);

  /* Motion (MASTER: Expo.out cubic-bezier(0.16,1,0.3,1)) */
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 220ms;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;               /* anti-pattern: no horizontal scroll on mobile */
}

/* --- Ambient light blobs (MASTER: "animated ambient light blobs") --- */
.ambient { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.ambient .blob {
  position: absolute; border-radius: 9999px; filter: blur(90px); opacity: 0.28;
  will-change: transform;
}
.ambient .blob-1 { width: 42vw; height: 42vw; left: -8vw; top: -6vw;
  background: radial-gradient(circle, var(--color-primary), transparent 70%);
  animation: drift1 22s var(--ease-expo) infinite alternate; }
.ambient .blob-2 { width: 36vw; height: 36vw; right: -6vw; top: 18vh;
  background: radial-gradient(circle, var(--color-accent), transparent 70%);
  animation: drift2 26s var(--ease-expo) infinite alternate; opacity: 0.2; }
.ambient .blob-3 { width: 30vw; height: 30vw; left: 30vw; bottom: -10vh;
  background: radial-gradient(circle, #8B5CF6, transparent 70%);
  animation: drift3 30s var(--ease-expo) infinite alternate; opacity: 0.16; }

@keyframes drift1 { to { transform: translate(6vw, 8vh) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-5vw, -6vh) scale(1.15); } }
@keyframes drift3 { to { transform: translate(4vw, -8vh) scale(1.08); } }

/* --- Glassmorphism surfaces (MASTER: "BlurView glassmorphism headers/nav") --- */
.glass {
  background: rgba(19, 28, 46, 0.6);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- Typography helpers --- */
.font-mono-nums { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.text-gradient {
  background: linear-gradient(120deg, var(--color-foreground) 20%, var(--color-secondary) 60%, var(--color-accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* --- Buttons (MASTER specs, dark-adapted; press scale 0.97 → 1.0) --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm);
  padding: 12px 24px; border-radius: 8px; font-weight: 600; cursor: pointer;
  border: none; font-size: 15px; transition: transform var(--dur) var(--ease-expo),
  box-shadow var(--dur) var(--ease-expo), background var(--dur) var(--ease-expo), opacity var(--dur); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.5); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--glow-accent); background: var(--color-accent-strong); }

.btn-secondary { background: transparent; color: var(--color-foreground); border: 1px solid var(--color-border); }
.btn-secondary:hover { transform: translateY(-2px); border-color: var(--color-primary); box-shadow: var(--glow-primary); }

.btn-ghost { background: transparent; color: var(--color-muted-fg); padding: 8px 12px; }
.btn-ghost:hover { color: var(--color-foreground); background: var(--color-surface-2); }

/* --- Cards --- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 12px; padding: var(--space-lg); box-shadow: var(--shadow-md);
  transition: transform var(--dur) var(--ease-expo), box-shadow var(--dur) var(--ease-expo), border-color var(--dur);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: rgba(59,130,246,0.4); }

/* --- Inputs --- */
.input {
  width: 100%; padding: 14px 16px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 10px; color: var(--color-foreground);
  font-size: 16px; font-family: inherit; transition: border-color var(--dur), box-shadow var(--dur);
}
.input::placeholder { color: var(--color-muted-fg); }
.input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }

/* --- Autocomplete + watchlist dropdowns --- */
.dropdown {
  position: absolute; z-index: 50; margin-top: 8px; width: 100%; max-height: 340px; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px;
  box-shadow: var(--shadow-xl); padding: 6px;
}
.dropdown[hidden] { display: none; }
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-sm); padding: 10px 12px; border-radius: 8px;
  cursor: pointer; transition: background var(--dur); color: var(--color-foreground);
}
.dropdown-item:hover, .dropdown-item.active { background: var(--color-surface-2); }
.dropdown-item .sym { font-weight: 700; letter-spacing: 0.02em; }
.dropdown-item .name { color: var(--color-muted-fg); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item .exch { margin-left: auto; font-size: 11px; color: var(--color-muted-fg);
  border: 1px solid var(--color-border); padding: 2px 6px; border-radius: 6px; flex-shrink: 0; }
.dropdown-empty { padding: 14px 12px; color: var(--color-muted-fg); font-size: 14px; text-align: center; }

.star { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 6px;
  color: var(--color-muted-fg); line-height: 0; transition: color var(--dur), transform var(--dur); flex-shrink: 0; }
.star:hover { color: var(--color-accent); transform: scale(1.15); }
.star[aria-pressed="true"] { color: var(--color-accent); }
.star:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(245,158,11,0.5); }

/* --- Chips / badges --- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--color-border); }
.badge-bull { color: var(--color-bull); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.badge-bear { color: var(--color-bear); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }
.badge-neutral { color: var(--color-secondary); border-color: rgba(96,165,250,0.4); background: rgba(96,165,250,0.08); }

/* --- Section rhythm --- */
.section { position: relative; z-index: 1; padding: var(--space-3xl) var(--space-lg); max-width: 1200px; margin: 0 auto; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; font-weight: 600; color: var(--color-accent); }

/* --- Demo chart (inline SVG) --- */
.demo-line { fill: none; stroke-width: 1.5; stroke-linecap: round; }
.demo-line--res { stroke: var(--color-bear); stroke-dasharray: 6 4; }
.demo-line--sup { stroke: var(--color-bull); stroke-dasharray: 6 4; }
.demo-line--entry { stroke: var(--color-accent); }
.demo-label { font-size: 11px; font-weight: 600; font-family: 'Inter', sans-serif; }

/* --- GSAP no-FOUC: hide reveal targets ONLY when motion is enabled & JS armed it --- */
.gsap-ready .reveal { opacity: 0; }

/* --- Reduced motion: the hard safety net (MASTER checklist) --- */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; }
  .ambient .blob { animation: none !important; }
  .btn:active { transform: none; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; }
}

/* --- Custom scrollbar (fintech polish) --- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--color-background); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 6px; border: 2px solid var(--color-background); }
::-webkit-scrollbar-thumb:hover { background: var(--color-muted-fg); }

/* --- Disclaimer strip --- */
.disclaimer { border: 1px solid rgba(245,158,11,0.35); background: rgba(245,158,11,0.06);
  border-radius: 12px; padding: var(--space-md) var(--space-lg); color: #FCD9A0; font-size: 14px; }

/* --- Utility: hide only visually (a11y) --- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ===========================================================================
   Floating parameters dock (left edge): gear button + slide-out panel
   =========================================================================== */
.param-dock {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  z-index: 60; display: flex; align-items: center;
}

/* The gear tab that sits on the left edge */
.param-gear {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 52px; flex-shrink: 0; cursor: pointer;
  background: rgba(19, 28, 46, 0.72);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.08); border-left: none;
  border-radius: 0 14px 14px 0; color: var(--color-muted-fg);
  box-shadow: var(--shadow-lg);
  transition: color var(--dur) var(--ease-expo), background var(--dur), box-shadow var(--dur);
}
.param-gear:hover, .param-dock.open .param-gear { color: var(--color-accent); background: rgba(24, 35, 58, 0.9); box-shadow: var(--glow-accent); }
.param-gear:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(245,158,11,0.5); }
.param-gear svg { transition: transform var(--dur) var(--ease-expo); }
.param-dock.open .param-gear svg { transform: rotate(60deg); }

/* The panel slides out to the right of the gear. It is ABSOLUTELY positioned so the
   hidden panel does NOT occupy a flex slot in .param-dock — otherwise the dock's box
   (and its :hover region) would stretch the full panel width, opening the panel when
   the cursor is merely near the left edge, and the invisible slot would swallow clicks. */
.param-panel {
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%) translateX(-16px) scale(0.98);
  width: 300px; margin-left: 10px; padding: 18px;
  background: rgba(19, 28, 46, 0.86);
  backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; box-shadow: var(--shadow-xl);
  opacity: 0; transform-origin: left center;
  pointer-events: none; visibility: hidden;
  transition: opacity var(--dur) var(--ease-expo), transform var(--dur) var(--ease-expo), visibility var(--dur);
}
/* Invisible hover-bridge spanning the 10px gap between gear and panel, so sliding the
   cursor from the gear into the panel never leaves .param-dock's hit-area (no flicker).
   It inherits the panel's pointer-events, so it's inert (won't block clicks) while closed
   and only "catches" the cursor once the panel is open. */
.param-panel::before {
  content: ''; position: absolute; left: -14px; top: 0; width: 14px; height: 100%;
}

/* Reveal on keyboard focus within, or when toggled open (click/tap — the mobile path). */
.param-dock:focus-within .param-panel,
.param-dock.open .param-panel {
  opacity: 1; transform: translateY(-50%) translateX(0) scale(1); pointer-events: auto; visibility: visible;
}
/* Hover-to-open is DESKTOP-ONLY: gate it behind a fine pointer (mouse/trackpad) so touch
   devices open strictly on tap. With the panel out of flow, .param-dock now hugs the gear,
   so :hover fires only over the gear; hovering the revealed panel keeps it open (sliders stay
   usable) because the panel sits inside .param-dock. */
@media (hover: hover) and (pointer: fine) {
  .param-dock:hover .param-panel {
    opacity: 1; transform: translateY(-50%) translateX(0) scale(1); pointer-events: auto; visibility: visible;
  }
  .param-dock:hover .param-gear svg { transform: rotate(60deg); }
}

.param-panel-head { margin-bottom: 16px; }
.param-panel-head p { margin: 6px 0 0; font-size: 12px; color: var(--color-muted-fg); line-height: 1.5; }

.param-field { margin-bottom: 18px; }
.param-field:last-child { margin-bottom: 0; }
.param-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.param-label-row label { font-size: 13px; font-weight: 600; color: var(--color-foreground); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.param-val { font-variant-numeric: tabular-nums; color: var(--color-accent); font-weight: 700; font-size: 13px; }
.param-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 9999px; border: 1px solid currentColor; }
.param-tag[data-level="conservative"] { color: var(--color-bull); }
.param-tag[data-level="moderate"]     { color: var(--color-accent); }
.param-tag[data-level="aggressive"]   { color: var(--color-bear); }

.param-scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: var(--color-muted-fg); }

/* Trading-style options: 4 directly-selectable cards (a styled radio group). Each shows its
   label · interval/lookback · focus, so the options double as the explanation. */
.style-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.style-option:hover { border-color: var(--color-primary); background: var(--color-surface-2); }
.style-option.is-active { border-color: var(--color-accent); background: rgba(245,158,11,0.06); box-shadow: var(--glow-accent); }
.style-option:focus-within { outline: none; box-shadow: 0 0 0 3px rgba(245,158,11,0.4); }

/* Money field */
.param-money { position: relative; }
.param-money-sign { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-muted-fg); font-weight: 600; pointer-events: none; }
.param-money-input { padding: 10px 12px 10px 26px !important; font-size: 15px !important; }
/* strip number spinners for a cleaner look */
.param-money-input::-webkit-outer-spin-button, .param-money-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.param-money-input { -moz-appearance: textfield; }

/* ---- Custom range sliders ---- */
.slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 9999px;
  background: var(--color-muted); outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--color-foreground); border: 3px solid var(--color-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5); cursor: pointer; transition: transform var(--dur) var(--ease-expo), border-color var(--dur);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--color-foreground);
  border: 3px solid var(--color-primary); box-shadow: 0 2px 6px rgba(0,0,0,0.5); cursor: pointer;
}
.slider:focus-visible { box-shadow: 0 0 0 3px rgba(59,130,246,0.4); }
/* Risk slider: color-coded track (green → amber → red) so higher risk reads as "hotter" */
.slider-risk { background: linear-gradient(90deg, var(--color-bull) 0%, var(--color-accent) 45%, var(--color-bear) 100%); }
.slider-risk::-webkit-slider-thumb { border-color: var(--color-on-accent); }
.slider-risk::-moz-range-thumb { border-color: var(--color-on-accent); }

/* ---- Info tooltip (hover/focus the ⓘ next to each label) ---- */
.info-tip { position: relative; display: inline-flex; color: var(--color-muted-fg); cursor: help; line-height: 0; flex-shrink: 0; }
.info-tip:hover, .info-tip:focus-visible { color: var(--color-secondary); outline: none; }
.info-bubble {
  position: absolute; right: 0; top: calc(100% + 8px); width: 240px; z-index: 70;
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--color-foreground);
  box-shadow: var(--shadow-xl); text-transform: none; letter-spacing: normal;
  opacity: 0; transform: translateY(-4px); pointer-events: none; visibility: hidden;
  transition: opacity var(--dur), transform var(--dur), visibility var(--dur);
}
.info-tip:hover .info-bubble, .info-tip:focus-visible .info-bubble, .info-tip:focus .info-bubble {
  opacity: 1; transform: translateY(0); visibility: visible;
}

/* Card variant: tips embedded in setup rows anchor to the LEFT of the icon and widen,
   so a mid-row tip can't overflow the card's left edge like the right-anchored dock tips. */
.info-tip--card .info-bubble { right: auto; left: 0; width: max(240px, 100%); }
.info-tip--card { color: var(--color-muted-fg); }

/* Reference-level variant: cells sit in a grid whose end columns touch either page edge
   (body is overflow-x:hidden), so a one-directional bubble would clip. Center it on the icon
   instead — symmetric overflow is visually balanced and never runs off one side. */
.info-tip--ref { color: var(--color-muted-fg); }
.info-tip--ref .info-bubble { right: auto; left: 50%; transform: translate(-50%, -4px); width: 230px; }
.info-tip--ref:hover .info-bubble, .info-tip--ref:focus-visible .info-bubble, .info-tip--ref:focus .info-bubble {
  transform: translate(-50%, 0);
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .section { padding: var(--space-2xl) var(--space-md); }
  .param-dock { top: auto; bottom: 16px; transform: none; }
  /* Gear sits at the bottom on mobile, so the panel opens UPWARD (bottom-anchored to the
     gear) instead of centered on it — centering a tall panel here would run off-screen. */
  .param-panel {
    width: min(76vw, 300px);
    top: auto; bottom: 0;
    transform: translateY(0) translateX(-16px) scale(0.98);
  }
  .param-dock:focus-within .param-panel,
  .param-dock.open .param-panel,
  .param-dock:hover .param-panel {
    transform: translateY(0) translateX(0) scale(1);
  }
}

/* Reduced motion: dock/panel/tooltips still work, just no easing (net above zeroes durations) */
@media (prefers-reduced-motion: reduce) {
  .param-gear svg { transform: none !important; }
}
