/* Quantsoft — design tokens */
:root {
  /* Palette */
  --ivory: #F6F4EE;
  --ivory-2: #EFECE3;
  --paper: #FBFAF6;
  --ink: #0B0F14;
  --ink-2: #1A1F28;
  --ink-3: #2A313C;
  --muted: #5A6270;
  --muted-2: #8B919C;
  --rule: #D9D4C7;
  --rule-2: #E7E3D6;

  --indigo: #1B2B6B;
  --indigo-2: #253684;
  --indigo-tint: #E8E9F1;

  --accent: #E8511C;      /* saffron-red, quant signal */
  --accent-tint: #FBE9DF;

  --green: #1F7A4D;       /* up */
  --green-tint: #E2F1EA;
  --red: #C0392B;         /* down */
  --red-tint: #F7E3E1;

  /* Type */
  --f-display: "Fraunces", "Tiempos Headline", "Source Serif Pro", Georgia, serif;
  --f-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing */
  --unit: 8px;
  --container: 1240px;
  --gutter: 24px;

  /* Radii */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --r-xl: 22px;

  /* Shadow */
  --shadow-sm: 0 1px 0 rgba(11,15,20,.04), 0 1px 2px rgba(11,15,20,.05);
  --shadow-md: 0 2px 4px rgba(11,15,20,.04), 0 12px 28px -12px rgba(11,15,20,.16);
  --shadow-lg: 0 4px 8px rgba(11,15,20,.05), 0 30px 60px -24px rgba(11,15,20,.22);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-sans);
  color: var(--ink);
  background: var(--ivory);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img, svg { display: block; max-width: 100%; }
hr { border: none; border-top: 1px solid var(--rule); margin: 0; }

/* Utility */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.mono { font-family: var(--f-mono); font-feature-settings: "ss01", "zero"; }
.display { font-family: var(--f-display); font-weight: 400; letter-spacing: -0.02em; line-height: 1.02; }
.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.rule { height: 1px; background: var(--rule); width: 100%; }

/* Nav */
.qs-nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--ivory) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.qs-nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.qs-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.qs-logo-mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--ink);
  color: var(--ivory);
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 12px; font-weight: 700;
}
.qs-nav-links {
  display: flex; align-items: center; gap: 28px;
  font-family: var(--f-mono); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2);
}
.qs-nav-links a { position: relative; padding: 6px 0; }
.qs-nav-links a.active::after,
.qs-nav-links a:hover::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; background: var(--accent);
}
.qs-nav-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--ink); color: var(--ivory);
  border-radius: 999px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.qs-nav-cta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 20px;
  border-radius: 999px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  transition: transform .2s ease, background .2s ease, color .2s ease;
}
.btn-primary { background: var(--ink); color: var(--ivory); }
.btn-primary:hover { background: var(--indigo); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn-ghost:hover { border-color: var(--ink); }
.btn .arr { display: inline-block; transition: transform .2s; }
.btn:hover .arr { transform: translateX(3px); }

/* Sections */
section { padding: 80px 0; position: relative; }
section.tight { padding: 56px 0; }
.section-head {
  display: grid; grid-template-columns: 200px 1fr; gap: 40px;
  align-items: baseline; margin-bottom: 40px;
}
.section-head .eyebrow { padding-top: 6px; border-top: 1px solid var(--ink); display: inline-block; }
.section-head h2 { margin: 0; font-family: var(--f-display); font-size: clamp(36px, 5vw, 64px); font-weight: 400; letter-spacing: -0.02em; line-height: 1.02; }

/* Footer */
.qs-foot {
  border-top: 1px solid var(--rule);
  padding: 64px 0 32px;
  background: var(--ivory-2);
}
.qs-foot-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px;
  align-items: start;
}
.qs-foot h4 {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 16px;
}
.qs-foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.qs-foot a:hover { color: var(--accent); }
.qs-foot-bottom {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--rule);
  font-family: var(--f-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
}

/* Ticker */
.ticker {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  overflow: hidden;
  height: 42px;
}
.ticker-track {
  display: flex; gap: 48px;
  white-space: nowrap;
  animation: ticker 60s linear infinite;
  height: 100%; align-items: center;
  font-family: var(--f-mono); font-size: 12px;
}
.ticker-item { display: inline-flex; align-items: center; gap: 10px; }
.ticker-item .sym { font-weight: 600; color: var(--ink); }
.ticker-item .pr { color: var(--ink-2); }
.ticker-item .ch.up { color: var(--green); }
.ticker-item .ch.dn { color: var(--red); }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Cards */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 28px;
  transition: transform .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.card:hover { border-color: var(--ink-3); box-shadow: var(--shadow-md); }

/* Reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s ease, transform .8s ease; }
.reveal.in { opacity: 1; transform: none; }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--ivory-2); border: 1px solid var(--rule);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.chip.green .dot { background: var(--green); }

/* Grid bg */
.grid-bg {
  background-image:
    linear-gradient(var(--rule-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-2) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Small helpers */
.kbd {
  font-family: var(--f-mono); font-size: 11px;
  padding: 2px 6px; border: 1px solid var(--rule); border-bottom-width: 2px;
  border-radius: 4px; background: var(--paper); color: var(--ink-2);
}

/* Hero spacing */
.qs-hero-inner { padding-top: 72px; padding-bottom: 96px; }
@media (max-width: 960px) {
  .qs-hero-inner { padding-top: 48px; padding-bottom: 56px; }

  /* Hero stats: 2-up on tablet to avoid cramping */
  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
    margin-top: 48px !important;
  }

  /* PRISM chat demo card: remove fixed minHeight + absolute input on mobile */
  .prism-demo-card { min-height: 0 !important; padding-bottom: 16px !important; }
  .prism-demo-input {
    position: static !important;
    margin-top: 16px !important;
    left: auto !important; right: auto !important; bottom: auto !important;
  }
}
@media (max-width: 640px) {
  .qs-hero-inner { padding-top: 36px; padding-bottom: 40px; }
  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
    margin-top: 36px !important;
  }
  .hero-stats-grid .mono { font-size: 18px !important; }
}

/* ============ RESPONSIVE ============ */

/* Mobile menu toggle (hidden on desktop) */
.qs-menu-btn {
  display: none;
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: transparent;
  align-items: center; justify-content: center;
  color: var(--ink);
}
.qs-menu-btn svg { width: 18px; height: 18px; }

.qs-mobile-panel {
  display: none;
  position: fixed; top: 64px; right: 0;
  width: min(360px, 86vw); max-width: 100vw;
  height: calc(100vh - 64px); height: calc(100dvh - 64px);
  z-index: 60;
  background: var(--ivory);
  padding: 24px;
  flex-direction: column;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  box-shadow: -12px 0 40px -12px rgba(11,15,20,0.18);
  overflow-y: auto;
}
.qs-mobile-backdrop {
  display: none;
  position: fixed; top: 64px; left: 0; right: 0; bottom: 0;
  z-index: 59;
  background: rgba(11,15,20,0.32);
  backdrop-filter: blur(2px);
}
.qs-mobile-backdrop.open { display: block; }
.qs-mobile-panel.open { display: flex; }
.qs-mobile-panel a {
  font-family: var(--f-mono); font-size: 14px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink);
  padding: 16px 4px; border-bottom: 1px solid var(--rule);
}
.qs-mobile-panel a.active { color: var(--accent); }
.qs-mobile-panel .qs-nav-cta { margin-top: 28px; align-self: flex-start; }

/* Tablet & below */
@media (max-width: 960px) {
  :root { --gutter: 20px; }
  section { padding: 56px 0; }
  section.tight { padding: 40px 0; }

  /* Hide desktop nav links, show menu button */
  .qs-nav-links { display: none; }
  .qs-nav-cta { display: none; }
  .qs-menu-btn { display: inline-flex; }

  /* Section head: stack eyebrow over heading */
  .section-head {
    grid-template-columns: 1fr !important;
    gap: 14px;
    margin-bottom: 36px;
  }
  .section-head h2 { font-size: clamp(28px, 7vw, 44px) !important; }

  /* Footer: 2-up on tablet */
  .qs-foot-grid { grid-template-columns: 1fr 1fr !important; gap: 32px !important; }
  .qs-foot-bottom { flex-direction: column; gap: 8px; align-items: flex-start; text-align: left; }

  /* Generic two-column hero/section pattern: stack to single column */
  .qs-stack-md { grid-template-columns: 1fr !important; gap: 24px !important; }

  /* Buttons a touch smaller */
  .btn { padding: 12px 18px; font-size: 11px; }
}

/* Phone */
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  section { padding: 44px 0; }
  body { font-size: 15px; }

  .qs-foot-grid { grid-template-columns: 1fr !important; gap: 28px !important; }

  /* Stack ANY explicit grid columns we don't control */
  .qs-stack-sm { grid-template-columns: 1fr !important; gap: 20px !important; }

  /* Generic 2-col / 3-col / 4-col grids stack */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }

  /* Smaller buttons */
  .btn { padding: 11px 16px; }

  /* Ticker bumps font down */
  .ticker-track { font-size: 11px; gap: 28px; }
}

/* ===== Targeted resets for inline grid templates we know about =====
   These selectors match the inline styles used across pages so we
   don't have to refactor every component. */

@media (max-width: 960px) {
  /* Any direct grid that uses 200px sidebar + flex content */
  [style*="grid-template-columns: 200px 1fr"],
  [style*="gridTemplateColumns: 200px 1fr"],
  [style*="grid-template-columns:200px 1fr"],
  [style*="gridTemplateColumns:200px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  /* 360px sidebar (focus areas) */
  [style*="360px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  /* 180px / 200px multi-col layouts */
  [style*="180px 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }
  /* Two-col content+visual */
  [style*="1fr 1.1fr"],
  [style*="1fr 1.3fr"],
  [style*="1.1fr 1fr"],
  [style*="1.4fr 1fr"],
  [style*="1.6fr 1fr 1fr 1fr"],
  [style*="1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* repeat(N, 1fr) */
  [style*="repeat(3, 1fr)"],
  [style*="repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* The article 3-col layout (sidebar / body / share) */
  [style*="1fr 720px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  /* Borders that depended on multi-col layout look broken when stacked */
  [style*="border-right"][style*="1px solid var(--rule)"] {
    border-right: none !important;
  }
}

@media (max-width: 640px) {
  [style*="repeat(3, 1fr)"],
  [style*="repeat(4, 1fr)"],
  [style*="repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  /* Newsroom right panel etc. */
  [style*="1.4fr 1fr"],
  [style*="1.1fr 1fr"],
  [style*="1.6fr 1fr 1fr 1fr"],
  [style*="1.6fr 1fr 1fr"],
  [style*="120px 1fr"],
  [style*="160px 1fr"],
  [style*="70px 1fr 90px"] {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }
  /* Big hero typography */
  h1.display { font-size: clamp(40px, 10vw, 56px) !important; }
}
