/* ═══════════════════════════════════════════════════════════════
   base.css — Niveshyantra universal shell styles
   Contains: CSS variables, resets, ambient layers, ticker,
   header/nav, mobile drawer, footer, floating chat, utilities.
   Page-specific styles live in pages/<name>.css
═══════════════════════════════════════════════════════════════ */

/* ── Tailwind CDN (for utility classes) ───────────────────────
   Include here so every page gets it automatically. In a real
   build this would be a compiled output. */
@import url("https://cdn.jsdelivr.net/npm/tailwindcss@3.4.4/base.min.css");

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:             #c0c1ff;
  --on-primary:          #1000a9;
  --secondary:           #ddb7ff;
  --on-secondary:        #3a0068;
  --tertiary:            #4cd7f6;
  --on-tertiary:         #003543;

  /* Surfaces */
  --background:          #070712;
  --surface:             #0e0e22;
  --surface-variant:     #1c1c38;
  --on-surface:          #e8e8ff;
  --on-surface-variant:  #a3a3c8;

  /* Feedback */
  --green-400:           #4ade80;
  --success-soft:        rgba(74,222,128,0.10);

  /* WhatsApp */
  --whatsapp:            #25D366;

  /* Shadows / glows */
  --shadow-glow-md:      0 0 24px rgba(192,193,255,0.25), 0 0 48px rgba(192,193,255,0.10);
  --shadow-glow-lg:      0 0 40px rgba(192,193,255,0.35), 0 0 80px rgba(192,193,255,0.15);
  --shadow-glow-terminal:0 0 60px rgba(192,193,255,0.12);
  --shadow-glow-secondary-sm: 0 0 16px rgba(221,183,255,0.30);
  --shadow-glow-secondary-lg: 0 0 40px rgba(221,183,255,0.45);

  /* Spacing */
  --margin-desktop: 64px;
  --max-site:       1280px;
  --min-h-hero:     88vh;
  --max-terminal:   520px;
}

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

html { scroll-behavior: smooth; font-size: 16px; color-scheme: dark; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--background);
  color: var(--on-surface);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Native <select> dropdowns (sitewide) ─────────────────────
   Every select on the site (.filter-select, .builder-input,
   .modal-input, .dash-select, .float-select — and any future
   one, styled or not) renders its CLOSED box fine: a translucent
   background over the dark page reads as a subtle dark control.
   The OPEN option list is a different story — it's a native OS/
   browser popup with no page behind it, so browsers paint that
   popup's own background (almost always white) while still
   applying our light --on-surface text color on top of it. That
   mismatch is why "user_login" etc. show up as barely-visible
   pale lavender text on a white square.
   color-scheme:dark (also set on <html> above, for the same
   reason as the existing date-input rule below) gets most
   browsers most of the way there automatically; the explicit
   option/optgroup colors pin every popup to the site's actual
   surface palette so it's correct even where a browser only
   partially honors color-scheme. Global element selectors on
   purpose, so this covers every dropdown at once, present and
   future, with nothing to remember to add per-component. */
select { color-scheme: dark; }
option, optgroup {
  background-color: var(--surface-variant);
  color: var(--on-surface);
}

/* ── Font helpers ──────────────────────────────────────────── */
.font-sora  { font-family: 'Sora', sans-serif; }
.font-inter { font-family: 'Inter', sans-serif; }
.font-mono  { font-family: 'JetBrains Mono', monospace; }

/* ── Colour helpers ────────────────────────────────────────── */
.text-primary          { color: var(--primary); }
.text-secondary        { color: var(--secondary); }
.text-tertiary         { color: var(--tertiary); }
.text-on-surface       { color: var(--on-surface); }
.text-on-surface-variant { color: var(--on-surface-variant); }
.text-on-primary       { color: var(--on-primary); }
.text-on-secondary     { color: var(--on-secondary); }
.text-whatsapp         { color: var(--whatsapp); }
.text-green-400        { color: var(--green-400); }

.bg-primary            { background-color: var(--primary); }
.bg-secondary          { background-color: var(--secondary); }
.bg-background         { background-color: var(--background); }
.bg-surface            { background-color: var(--surface); }
.bg-surface-variant    { background-color: var(--surface-variant); }
.bg-success-soft       { background-color: var(--success-soft); }

/* ── Opacity-modifier fallbacks ────────────────────────────────
   "on-surface-variant" and "background" aren't colors Tailwind's
   JIT knows about (they only exist as our own CSS variables), so
   its `text-on-surface-variant/50`-style slash-opacity classes
   silently generate no rule at all wherever they're used across
   the site. These fill in that exact gap so the classes already
   written everywhere start working, instead of quietly doing
   nothing. See PROFILE-PANEL-NOTES.md for the full writeup. */
.text-on-surface-variant\/30 { color: color-mix(in srgb, var(--on-surface-variant) 30%, transparent); }
.text-on-surface-variant\/40 { color: color-mix(in srgb, var(--on-surface-variant) 40%, transparent); }
.text-on-surface-variant\/50 { color: color-mix(in srgb, var(--on-surface-variant) 50%, transparent); }
.text-on-surface-variant\/60 { color: color-mix(in srgb, var(--on-surface-variant) 60%, transparent); }
.text-on-surface-variant\/70 { color: color-mix(in srgb, var(--on-surface-variant) 70%, transparent); }
.bg-background\/40           { background-color: color-mix(in srgb, var(--background) 40%, transparent); }

/* ── Gradient text ─────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--tertiary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Drop shadows ──────────────────────────────────────────── */
.drop-shadow-primary  { filter: drop-shadow(0 0 12px rgba(192,193,255,0.5)); }
.drop-shadow-secondary{ filter: drop-shadow(0 0 12px rgba(221,183,255,0.5)); }
.drop-shadow-tertiary { filter: drop-shadow(0 0 12px rgba(76,215,246,0.5)); }

/* ── Glass card ────────────────────────────────────────────── */
.glass-card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.06);
}

/* .glass — same treatment as .glass-card. Used in 25 places across
   backtest.html, builder.html, docs.html, live.html, and strategies.html
   (segmented toggle bars, docs panels) but was never actually defined —
   every one of those elements was rendering with no background, no blur,
   no border at all. .glass-hover (docs.css) already assumed this existed. */
.glass {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ── Glow button ───────────────────────────────────────────── */
.glow-button {
  position: relative;
  transition: box-shadow 0.25s, transform 0.2s;
  cursor: pointer;
}
.glow-button:hover {
  box-shadow: var(--shadow-glow-md);
  transform: translateY(-1px);
}

/* ── Shadow glow utilities ─────────────────────────────────── */
.shadow-glow-md  { box-shadow: var(--shadow-glow-md); }
.shadow-glow-lg  { box-shadow: var(--shadow-glow-lg); }
.shadow-glow-secondary-sm { box-shadow: var(--shadow-glow-secondary-sm); }
.shadow-glow-secondary-lg { box-shadow: var(--shadow-glow-secondary-lg); }
.shadow-glow-terminal     { box-shadow: var(--shadow-glow-terminal); }

/* ── Data-pulse border animation ───────────────────────────── */
@keyframes data-pulse {
  0%,100% { border-color: rgba(192,193,255,0.06); }
  50%      { border-color: rgba(192,193,255,0.18); }
}
.data-pulse { animation: data-pulse 3s ease-in-out infinite; }

/* ── Reveal on scroll ──────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.visible {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ── Logo flicker ──────────────────────────────────────────── */
@keyframes logo-flicker {
  0%,100% { opacity: 1; }
  92%     { opacity: 1; }
  93%     { opacity: 0.6; }
  94%     { opacity: 1; }
  96%     { opacity: 0.8; }
  97%     { opacity: 1; }
}
.logo-flicker { animation: logo-flicker 6s infinite; }

/* ── Active nav link ────────────────────────────────────────── */
.nav-link-active {
  color: var(--primary) !important;
  position: relative;
}
.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

/* ── Spin slow (ethos globe) ────────────────────────────────── */
@keyframes spin-slow     { to { transform: rotate(360deg); } }
@keyframes spin-slow-rev { to { transform: rotate(-360deg); } }
.spin-slow     { animation: spin-slow     12s linear infinite; }
.spin-slow-rev { animation: spin-slow-rev 18s linear infinite; }

/* ── Terminal cursor blink ──────────────────────────────────── */
@keyframes blink { 0%,49%{ opacity:1; } 50%,100%{ opacity:0; } }
.terminal-cursor {
  display: inline-block;
  width: 7px; height: 13px;
  background: var(--primary);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: middle;
}

/* ── Energy trails ──────────────────────────────────────────── */
@keyframes energy-trail {
  0%   { transform: translateX(-100%); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateX(200%); opacity: 0; }
}
.energy-trail {
  position: absolute;
  left: 0;
  height: 1px;
  width: 80px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: energy-trail 3s ease-in-out infinite;
}

/* ── Ticker band ───────────────────────────────────────────── */
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-track {
  display: flex;
  gap: 32px;
  width: max-content;
  animation: ticker-scroll 28s linear infinite;
  white-space: nowrap;
}
.ticker-track:hover { animation-play-state: paused; }

/* ─────────────────────────────────────────────────────────────
   AMBIENT LAYERS
───────────────────────────────────────────────────────────── */
#starfield, #lightning-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}
#starfield        { z-index: 0; }
#lightning-overlay{ z-index: 1; opacity: 0.3; }

#mouse-glow {
  position: fixed;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(192,193,255,0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  transition: transform 0.08s linear;
  top: 0; left: 0;
}

/* ─────────────────────────────────────────────────────────────
   CONTENT LAYER
───────────────────────────────────────────────────────────── */
.content-layer {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-layer main { flex: 1; }

/* ─────────────────────────────────────────────────────────────
   HEADER / NAV
───────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ─────────────────────────────────────────────────────────────
   MOBILE DRAWER
───────────────────────────────────────────────────────────── */
#drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 60;
  backdrop-filter: blur(4px);
}
#drawer-overlay.open { display: block; }

#mobile-drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(320px, 90vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid rgba(255,255,255,0.08);
  z-index: 70;
  padding: 24px;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
}
#mobile-drawer.open { transform: translateX(0); }

/* ─────────────────────────────────────────────────────────────
   FOOTER
───────────────────────────────────────────────────────── */
footer { flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────────
   FLOATING CHAT WIDGET
───────────────────────────────────────────────────────────── */
#float-chat {
  position: fixed;
  bottom: 28px; right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

#float-toggle {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-glow-md);
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
#float-toggle:hover { transform: scale(1.08); box-shadow: var(--shadow-glow-lg); }

@keyframes pulse-ring { 0%{transform:scale(1);opacity:0.5} 100%{transform:scale(1.9);opacity:0} }
#float-pulse-ring {
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: pulse-ring 2s ease-out infinite;
}

#float-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
}
#float-chat.is-open #float-actions {
  max-height: 300px;
  pointer-events: auto;
}

.float-action-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.float-action-btn:hover { opacity: 0.88; transform: translateX(-2px); }

.float-action-wa      { background: #25D366; color: #fff; }
.float-action-primary { background: var(--primary); color: var(--on-primary); }
.float-action-ghost   { background: var(--surface-variant); color: var(--on-surface); border: 1px solid rgba(255,255,255,0.1); }

/* Float card */
#float-card {
  display: none;
  flex-direction: column;
  width: min(360px, calc(100vw - 48px));
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), var(--shadow-glow-md);
}

#float-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  background: var(--primary);
  flex-shrink: 0;
}
#float-card-header-left { display: flex; align-items: center; gap: 10px; }
#float-card-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#float-card-title   { font-family:'Sora',sans-serif; font-size:14px; font-weight:700; color:var(--on-primary); }
#float-card-subtitle{ font-size:11px; color:rgba(16,0,169,0.7); display:flex; align-items:center; gap:5px; margin-top:2px; }
#float-status-dot   { width:6px;height:6px;border-radius:50%;background:#1de468;flex-shrink:0; }

#float-card-close {
  background:none; border:none; cursor:pointer;
  color: var(--on-primary); opacity:0.7;
}
#float-card-close:hover { opacity:1; }

#float-card-body {
  overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  flex: 1;
}

.float-field-wrap { display:flex; flex-direction:column; gap:4px; }
.float-label      { font-size:11px; font-weight:600; color:var(--on-surface-variant); font-family:'JetBrains Mono',monospace; letter-spacing:0.04em; }
.float-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  color: var(--on-surface);
  font-family: 'Inter',sans-serif;
  font-size: 13px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.float-input:focus { border-color: var(--primary); }
.float-textarea { resize: none; }
.float-select { appearance:none; cursor:pointer; padding-right:32px; }
#float-select-wrap { position:relative; }
#float-select-arrow { position:absolute; right:8px; top:50%; transform:translateY(-50%); font-size:16px; color:var(--on-surface-variant); pointer-events:none; }
#float-phone-wrap   { display:flex; align-items:center; gap:6px; }
#float-phone-prefix { font-family:'JetBrains Mono',monospace; font-size:13px; color:var(--on-surface-variant); flex-shrink:0; }
.float-hint { font-size:10px; color:var(--on-surface-variant); opacity:0.6; margin-top:2px; }

#float-slots { display:flex; gap:6px; flex-wrap:wrap; margin-top:4px; }
.float-slot {
  font-family:'JetBrains Mono',monospace; font-size:11px;
  padding: 5px 10px; border-radius:8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  color: var(--on-surface-variant);
  cursor:pointer; transition: all 0.15s;
}
.float-slot:hover, .float-slot.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

#float-submit {
  width:100%; padding:11px;
  background:var(--primary); color:var(--on-primary);
  border:none; border-radius:12px;
  font-family:'Sora',sans-serif; font-weight:700; font-size:13px;
  cursor:pointer;
  margin-top:4px;
  transition: opacity 0.2s;
}
#float-submit:hover { opacity:0.88; }
#float-privacy { font-size:10px; color:var(--on-surface-variant); text-align:center; opacity:0.5; }

#float-card-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-shrink: 0;
}
#float-footer-or { font-size:11px; color:var(--on-surface-variant); opacity:0.5; }
#float-wa-link   { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:600; color:#25D366; text-decoration:none; }
#float-wa-link:hover { text-decoration:underline; }

#float-success { display:flex; flex-direction:column; align-items:center; text-align:center; gap:10px; padding:16px 0; }
#float-success-icon { /* just icon */ }
#float-success-title { font-family:'Sora',sans-serif; font-weight:700; font-size:15px; color:var(--on-surface); }
#float-success-body  { font-size:13px; color:var(--on-surface-variant); line-height:1.5; max-width:260px; }

/* ─────────────────────────────────────────────────────────────
   UTILITY CLASSES (spacing, sizing, etc.)
   We include a minimal subset here since we're not running a
   build pipeline — full Tailwind-style utilities for the most
   common patterns used in the pages.
───────────────────────────────────────────────────────────── */

/* Layout */
.max-w-site   { max-width: var(--max-site); }
.max-w-terminal { max-width: var(--max-terminal); }

/* Tracking */
.tracking-label    { letter-spacing: 0.12em; }
.tracking-label-lg { letter-spacing: 0.18em; }
.tracking-tight    { letter-spacing: -0.02em; }
.tracking-wider    { letter-spacing: 0.08em; }
.tracking-widest   { letter-spacing: 0.16em; }

/* Leading */
.leading-hero   { line-height: 1.08; }
.leading-tight  { line-height: 1.2; }
.leading-relaxed{ line-height: 1.65; }

/* Sizing helpers */
.min-h-hero     { min-height: var(--min-h-hero); }
.w-480          { width: 480px; }
.h-480          { height: 480px; }
.rounded-huge   { border-radius: 32px; }
.scale-2x       { transform: scale(2); }

/* Width percentage helpers for progress bars */
.w-pct-24  { width: 24%; }
.w-pct-87  { width: 87%; }

/* Blur helpers */
.blur-xl-custom  { filter: blur(80px); }
.blur-lg-custom  { filter: blur(48px); }
.blur-md-custom  { filter: blur(32px); }
.blur-3xl        { filter: blur(64px); }

/* Dot colours for terminal titlebar */
.bg-dot-red    { background-color: #ff5f57; }
.bg-dot-yellow { background-color: #ffbd2e; }
.bg-dot-green  { background-color: #28c840; }

/* px-margin-desktop */
.px-margin-desktop { padding-left: var(--margin-desktop); padding-right: var(--margin-desktop); }

/* Logo items (broker strip) */
.logo-item { opacity: 0.45; transition: opacity 0.25s; }
.logo-item:hover { opacity: 0.85; }

/* Tilt card */
.tilt-card { transition: transform 0.2s ease; will-change: transform; }

/* Shimmer (progress bar shimmer) */
@keyframes shimmer { from{background-position:-200%} to{background-position:200%} }
.shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(192,193,255,0.3) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2.5s ease-in-out infinite;
}

/* Animate-spin (used in submit spinner) */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 0.8s linear infinite; }

/* Animate-pulse (hero badge, etc.) */
@keyframes animate-pulse { 0%,100%{opacity:1} 50%{opacity:0.45} }
.animate-pulse { animation: animate-pulse 2s ease-in-out infinite; }

/* ── Tailwind-like utilities we need that CDN base doesn't have ── */
/* (border-white/5 etc. are opacity variants we handle inline) */

/* ── Resend-cooldown disabled state ──────────────────────────────────────
   Used on "Forgot password?" / "Resend verification email" links+buttons
   while they're locked out (see static/js/base.js: window.QM.resendCooldown).
   Applied to both real <button disabled> elements (as a visual reinforcement
   of the native :disabled state) and plain <a> links, which have no native
   disabled state of their own — pointer-events:none is what actually stops
   clicks on those.
*/
.qm-cd-disabled {
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Required-field indicator ─────────────────────────────────────────────
   Single shared marker for every required field across the site (loaded on
   all 28 pages via base.css). Pairs with the native `required` attribute on
   the underlying input/select/textarea, which we add alongside this for
   real screen-reader semantics — the asterisk alone is decorative only.
   Uses #f87171, the same red already used for field-level error states
   (see base.js's inline validation borderColor), so a required marker and
   a validation error read as the same "attention" color instead of two
   competing reds.
*/
.required-asterisk {
  color: #f87171;
  margin-left: 3px;
  font-weight: 600;
}
