/* ==========================================================================
   AI Quant Signal Engine — Media Buy Landing Page
   Stripe / Apple clean light aesthetic · Mobile-first H5 · Zero dependencies
   ========================================================================== */

/* --------------------------------------------------------------------------
   1) Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --border-soft: #E2E8F0;

  /* Brand — Electric Tech Blue */
  --primary: #2563EB;
  --primary-strong: #1D4ED8;
  --primary-tint: rgba(37, 99, 235, 0.08);

  /* Bullish / positive — Emerald */
  --positive: #10B981;
  --positive-deep: #059669;
  --positive-tint: rgba(16, 185, 129, 0.12);

  /* Ink */
  --ink-title: #0F172A;
  --ink-body: #334155;
  --ink-muted: #64748B;
  --ink-faint: #94A3B8;

  /* Shape & depth */
  --radius-card: 16px;
  --radius-inner: 12px;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.05);

  /* Type */
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-stack);
  background: var(--bg-page);
  color: var(--ink-title);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;   /* iOS 14 fallback */
  min-height: 100dvh;  /* dynamic viewport lock (iOS 15.4+) */
}

svg {
  display: block;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   3) Page Shell — single column card flow, full-screen lock, safe-area
   -------------------------------------------------------------------------- */
.page {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 428px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 26px) 20px calc(env(safe-area-inset-bottom, 0px) + 30px);
  min-height: 100vh;
  min-height: 100dvh;
}

/* --------------------------------------------------------------------------
   4) Brand Header
   -------------------------------------------------------------------------- */
.brand-header {
  text-align: center;
  padding: 6px 0 26px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-bottom: 16px;
  border-radius: 13px;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--primary);
}

.headline {
  margin-top: 10px;
  font-size: 27px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-title);
}

.subline {
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   5) Cards & Step Transitions
   -------------------------------------------------------------------------- */
.card {
  width: 100%;
  padding: 22px 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.step {
  display: none;
}

.step.active {
  display: block;
  animation: step-in 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.step-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.step-pill.pill-green {
  border-color: rgba(16, 185, 129, 0.25);
  background: var(--positive-tint);
  color: var(--positive-deep);
}

.feed-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.feed-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  animation: dot-ping 1.8s ease-out infinite;
}

.lock-chip {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--positive-deep);
}

.card-title {
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink-title);
}

.card-title.center {
  text-align: center;
  margin-bottom: 18px;
}

/* --------------------------------------------------------------------------
   6) Step 1 — Field Labels & Selection Chips
   -------------------------------------------------------------------------- */
.field-label {
  margin: 18px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.chip-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chip {
  padding: 12px 4px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-inner);
  background: var(--bg-card);
  color: var(--ink-body);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.18s ease, background-color 0.18s ease,
    color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.chip:active {
  transform: scale(0.97);
}

.chip.selected {
  border-color: var(--primary);
  background: var(--primary-tint);
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px var(--primary);
}

/* --------------------------------------------------------------------------
   7) Primary CTA Buttons
   -------------------------------------------------------------------------- */
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 17px 16px;
  border-radius: 14px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.18s ease;
}

.btn-primary:active {
  transform: scale(0.985);
  background: var(--primary-strong);
}

.btn-pulse {
  animation: btn-pulse 1.9s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.chip:focus-visible,
.btn-primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.micro-note {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   8) Page Footer
   -------------------------------------------------------------------------- */
.page-footer {
  margin-top: 26px;
  padding: 0 4px;
  text-align: center;
  font-size: 11px;
  line-height: 1.65;
  color: var(--ink-muted);
}

.footer-fine {
  margin-top: 8px;
  font-size: 10px;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   9) Step 2 — Circular Radar Scanner
   -------------------------------------------------------------------------- */
.radar {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 4px auto 20px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: radial-gradient(circle at 50% 50%, #FFFFFF 0%, #F1F5F9 100%);
  overflow: hidden;
}

.radar-ring {
  position: absolute;
  border: 1px solid var(--border-soft);
  border-radius: 50%;
}

.radar-ring.r1 { inset: 17%; }
.radar-ring.r2 { inset: 35%; }

.radar-axis {
  position: absolute;
  background: var(--border-soft);
}

.radar-axis.h { left: 9%; right: 9%; top: 50%; height: 1px; }
.radar-axis.v { top: 9%; bottom: 9%; left: 50%; width: 1px; }

.radar-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(37, 99, 235, 0.30) 0deg,
    rgba(37, 99, 235, 0.04) 70deg,
    rgba(37, 99, 235, 0) 110deg);
  animation: radar-spin 2.2s linear infinite;
}

.radar-blip {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  opacity: 0;
  animation: blip-fade 2.4s ease-out infinite;
}

.radar-blip.b1 { top: 26%; left: 62%; animation-delay: 0.2s; }
.radar-blip.b2 { top: 58%; left: 30%; animation-delay: 1.1s; }
.radar-blip.b3 {
  top: 40%;
  left: 44%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.8);
  animation-delay: 1.7s;
}

.radar-core {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 255, 255, 0.94) 0%,
    rgba(255, 255, 255, 0.42) 72%);
  font-variant-numeric: tabular-nums;
}

.radar-core strong {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-title);
}

.radar-core em {
  margin-top: 14px;
  font-style: normal;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   10) Step 2 — Progress Bar & Terminal Log
   -------------------------------------------------------------------------- */
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.15s linear;
}

.progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--ink-muted);
}

#scan-status {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#progress-pct-alt {
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.terminal {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 9px;
  height: 150px;
  margin-top: 16px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-inner);
  background: var(--bg-page);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-body);
}

.term-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  animation: term-in 0.28s ease both;
}

.t-prefix {
  flex-shrink: 0;
  color: var(--ink-muted);
}

.t-text {
  flex: 1;
  min-width: 0;
}

.t-status {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--positive-deep);
}

.t-status.t-lock {
  color: var(--primary);
}

.term-boot {
  color: var(--ink-muted);
}

.term-boot .t-status {
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   11) Step 3 — Signal Report Card
   -------------------------------------------------------------------------- */
.result-head {
  text-align: center;
}

.badge-bullish {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: var(--positive-tint);
  color: var(--positive-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  animation: badge-glow 2.4s ease-in-out infinite;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
  animation: dot-ping 1.8s ease-out infinite;
}

.result-head .card-title {
  margin-top: 16px;
}

.result-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.metric {
  padding: 14px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-inner);
  background: var(--bg-page);
  text-align: center;
}

.metric-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.metric-value {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-title);
  font-variant-numeric: tabular-nums;
}

.metric-value .metric-unit {
  margin-left: 1px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
}

.metric-foot {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--ink-muted);
}

.signal-rows {
  margin-top: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-inner);
  overflow: hidden;
}

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
}

.signal-row + .signal-row {
  border-top: 1px solid var(--border-soft);
}

.signal-row span {
  color: var(--ink-muted);
}

.signal-row strong {
  color: var(--ink-body);
  font-weight: 600;
  text-align: right;
}

.signal-row strong.up {
  color: var(--positive-deep);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   12) Keyframes
   -------------------------------------------------------------------------- */
@keyframes radar-spin {
  to { transform: rotate(360deg); }
}

@keyframes blip-fade {
  0% { opacity: 0; transform: scale(0.4); }
  12% { opacity: 1; transform: scale(1); }
  45% { opacity: 0.9; }
  100% { opacity: 0; transform: scale(1.15); }
}

@keyframes term-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes step-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes btn-pulse {
  0% { box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25), 0 0 0 0 rgba(37, 99, 235, 0.45); }
  70% { box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25), 0 0 0 16px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25), 0 0 0 0 rgba(37, 99, 235, 0); }
}

@keyframes badge-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.35); }
  50% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); }
}

@keyframes dot-ping {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  80% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --------------------------------------------------------------------------
   13) Accessibility & Responsive
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .radar-sweep,
  .radar-blip,
  .btn-pulse,
  .badge-bullish,
  .badge-dot,
  .feed-dot {
    animation: none;
  }

  .step.active {
    animation: none;
  }

  .progress-bar {
    transition: none;
  }
}

@media (min-width: 480px) {
  .page {
    padding-top: calc(env(safe-area-inset-top, 0px) + 44px);
  }

  .headline {
    font-size: 30px;
  }
}
