/* QuantFin Exeter - visual system shared with quantfin.dev */

:root {
  --qf-bg: #060818;
  --qf-bg-2: #0a0f1f;
  --qf-bg-3: #0e1530;
  --qf-surface: rgba(255, 255, 255, 0.04);
  --qf-surface-2: rgba(255, 255, 255, 0.06);
  --qf-line: rgba(255, 255, 255, 0.08);
  --qf-line-2: rgba(255, 255, 255, 0.14);
  --qf-ink: #e9edf5;
  --qf-ink-soft: #aab3c5;
  --qf-muted: #7a8499;
  --qf-brand: #3282b8;
  --qf-brand-2: #5fd0ff;
  --qf-accent: #ff7a1a;
  --qf-pos: #4ade80;
  --qf-neg: #f87171;
  --qf-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --qf-mono: "JetBrains Mono", ui-monospace, monospace;
}

body.site-shell {
  min-height: 100dvh;
  position: relative;
  background:
    radial-gradient(120% 70% at 0% -20%, rgba(50, 130, 184, 0.08) 0%, transparent 55%),
    radial-gradient(120% 70% at 100% 0%, rgba(95, 208, 255, 0.06) 0%, transparent 50%),
    var(--qf-bg);
  color: var(--qf-ink);
}

body.site-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.35;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
}

h1,
h2,
h3,
h4 {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  letter-spacing: -0.01em;
}

/* Tabular figures for anything that reads like a quote board */
.bench-table td,
.bench-table th,
.metric-card,
.font-mono {
  font-variant-numeric: tabular-nums;
}

#main-content > :first-child {
  animation: page-enter 0.56s ease both;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Navbar ===== */
#main-nav {
  background: rgba(6, 8, 24, 0.55);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  transition: background 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

#main-nav .nav-link {
  color: rgba(233, 237, 245, 0.72);
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

#main-nav .nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

#main-nav .nav-active {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.12) !important;
}

#main-nav .nav-brand-text {
  color: #ffffff;
}

#main-nav #mobile-menu-btn {
  color: rgba(233, 237, 245, 0.85);
}

#main-nav.nav-scrolled,
.page-light #main-nav {
  background: rgba(6, 8, 24, 0.85);
  border-bottom-color: var(--qf-line);
}

.mobile-menu-panel {
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, max-height 0.18s ease;
}

.mobile-menu-panel.open {
  opacity: 1;
  transform: translateY(0);
  max-height: 420px;
}

.mobile-nav-link {
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ===== Hero ===== */
.hero-gradient {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--qf-bg) 0%, var(--qf-bg-2) 45%, var(--qf-bg-3) 100%);
}

.hero-gradient::before {
  content: "";
  position: absolute;
  inset: -30% -10% -15% -10%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 56% 38% at 20% 80%, rgba(95, 208, 255, 0.1) 0%, transparent 66%),
    radial-gradient(ellipse 50% 34% at 86% 24%, rgba(95, 208, 255, 0.14) 0%, transparent 68%);
  animation: hero-shift 9s ease-in-out infinite alternate;
}

.hero-gradient::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.16;
}

@keyframes hero-shift {
  from {
    transform: translate3d(-1.5%, -1%, 0) scale(1);
  }
  to {
    transform: translate3d(1.5%, 1%, 0) scale(1.05);
  }
}

/* ===== Fade-in on scroll ===== */
.fade-section {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.fade-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Cards ===== */
.approach-card {
  background: var(--qf-surface);
  border: 1px solid var(--qf-line);
  border-radius: 18px;
  padding: 1.75rem;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease, background 0.24s ease;
}

.approach-card:hover {
  transform: translateY(-5px);
  background: var(--qf-surface-2);
  box-shadow: var(--qf-shadow);
  border-color: rgba(95, 208, 255, 0.45);
}

.approach-card .card-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.05rem;
}

/* ===== Pipeline ===== */
.pipeline-step {
  position: relative;
  text-align: center;
  flex: 0 0 auto;
  width: 100%;
  max-width: 14rem;
  margin-inline: auto;
  min-width: 0;
}

.pipeline-step .step-circle {
  width: 66px;
  height: 66px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  position: relative;
  z-index: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.pipeline-connector {
  position: absolute;
  top: 33px;
  left: calc(50% + 33px);
  right: calc(-50% + 33px);
  height: 2px;
  background: linear-gradient(90deg, #5fd0ff 0%, #3282b8 100%);
  z-index: 0;
}

.pipeline-connector::after {
  content: "";
  position: absolute;
  right: -6px;
  top: -4px;
  width: 0;
  height: 0;
  border-left: 8px solid #3282b8;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* ===== Metric Cards ===== */
.metric-card {
  background: linear-gradient(145deg, var(--qf-bg-2) 0%, var(--qf-bg-3) 100%);
  border-radius: 18px;
  padding: 1.7rem;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--qf-line-2);
}

.metric-card::before {
  content: "";
  position: absolute;
  top: -26%;
  right: -18%;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: rgba(95, 208, 255, 0.1);
}

/* ===== Case Study ===== */
.step-card {
  background: var(--qf-surface);
  border: 1px solid var(--qf-line);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.step-number {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #5fd0ff, #3282b8);
  color: #051528;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 8px 16px rgba(50, 130, 184, 0.3);
}

.governance-box {
  position: relative;
  background: var(--qf-surface);
  border: 1px solid var(--qf-line);
  border-left: 4px solid var(--qf-brand-2);
  border-radius: 0 14px 14px 0;
  padding: 1.25rem 1.5rem;
  line-height: 1.75;
  color: var(--qf-ink-soft);
}

.governance-box::before {
  content: "\201C";
  position: absolute;
  top: 0.2rem;
  left: 0.55rem;
  font-size: 2rem;
  line-height: 1;
  color: rgba(95, 208, 255, 0.35);
}

/* ===== Run Page ===== */
.config-panel {
  background: var(--qf-surface);
  border: 1px solid var(--qf-line);
  border-radius: 18px;
  padding: 1.2rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.config-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--qf-muted);
  margin-bottom: 0.38rem;
}

.config-select,
.config-input {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--qf-line-2);
  border-radius: 10px;
  font-size: 0.92rem;
  background: var(--qf-bg-2);
  color: var(--qf-ink);
  color-scheme: dark;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.config-select:focus,
.config-input:focus {
  outline: none;
  border-color: var(--qf-brand-2);
  box-shadow: 0 0 0 3px rgba(95, 208, 255, 0.16);
}

.btn-primary {
  background: linear-gradient(135deg, var(--qf-brand-2), var(--qf-brand));
  color: #051528;
  font-weight: 700;
  padding: 0.72rem 1.45rem;
  border-radius: 12px;
  border: 1px solid rgba(95, 208, 255, 0.5);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(50, 130, 184, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 40px rgba(95, 208, 255, 0.45);
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--qf-ink);
  font-weight: 700;
  padding: 0.68rem 1.3rem;
  border-radius: 11px;
  border: 1px solid var(--qf-line-2);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  border-color: var(--qf-brand-2);
  color: var(--qf-brand-2);
  background: rgba(95, 208, 255, 0.06);
}

.result-panel {
  background: var(--qf-surface);
  border: 1px solid var(--qf-line);
  border-radius: 16px;
  padding: 1.15rem;
  min-height: 200px;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 180px;
  color: var(--qf-muted);
  text-align: center;
  padding: 0 0.4rem;
}

.chart-shell {
  height: 360px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--qf-bg-2);
}

.chart-shell.chart-tall {
  height: 400px;
}

.chart-shell.chart-short {
  height: 300px;
}

/* ===== HTMX loading indicator ===== */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-flex;
}

.htmx-request .btn-label {
  opacity: 0.6;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(5, 21, 40, 0.3);
  border-top-color: #051528;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Benchmark table ===== */
.bench-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.bench-table thead th {
  background: var(--qf-bg-3);
  padding: 0.74rem 0.95rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--qf-ink-soft);
  border-bottom: 2px solid var(--qf-line-2);
  white-space: nowrap;
}

.bench-table thead th:first-child {
  border-radius: 8px 0 0 0;
}

.bench-table thead th:last-child {
  border-radius: 0 8px 0 0;
}

.bench-table tbody td {
  padding: 0.72rem 0.95rem;
  border-bottom: 1px solid var(--qf-line);
  color: var(--qf-ink-soft);
  white-space: nowrap;
  font-family: var(--qf-mono);
  font-size: 0.84rem;
}

.bench-table tbody td:first-child {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.9rem;
}

.bench-table tbody tr:hover td {
  background: rgba(95, 208, 255, 0.05);
}

.bench-table tbody tr.rl-row td {
  background: rgba(95, 208, 255, 0.08);
  font-weight: 700;
  color: var(--qf-ink);
}

/* ===== Plotly overrides ===== */
.js-plotly-plot .plotly .modebar {
  right: 6px !important;
  top: 6px !important;
}

/* ===== User manual math overflow ===== */
#user-manual-main .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.28rem;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .config-panel.sticky {
    position: static;
    top: auto;
  }
}

@media (max-width: 768px) {
  .pipeline-connector {
    display: none;
  }

  .pipeline-step {
    max-width: 16rem;
  }

  .step-card {
    padding: 1.4rem;
    border-radius: 16px;
  }

  .approach-card {
    padding: 1.25rem;
  }

  .metric-card {
    padding: 1.3rem;
  }

  .result-panel {
    padding: 0.95rem;
    border-radius: 14px;
  }

  .chart-shell {
    height: 300px;
  }

  .chart-shell.chart-tall {
    height: 320px;
  }

  .chart-shell.chart-short {
    height: 240px;
  }

  .governance-box {
    padding: 1rem 1rem 1rem 1.2rem;
    line-height: 1.68;
  }

  .governance-box::before {
    left: 0.3rem;
  }

  .bench-table {
    font-size: 0.82rem;
  }

  .bench-table thead th,
  .bench-table tbody td {
    padding: 0.62rem 0.74rem;
  }
}

@media (min-width: 768px) {
  .pipeline-step {
    flex: 1;
    max-width: none;
    margin-inline: 0;
  }
}

@media (max-width: 480px) {
  .chart-shell {
    height: 280px;
  }

  .chart-shell.chart-tall {
    height: 300px;
  }

  .chart-shell.chart-short {
    height: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--qf-bg-2);
}

::-webkit-scrollbar-thumb {
  background: #2c3a63;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3d4f82;
}
