/*
 * Chart Algo AI — public site (marketing, legal, admin sign-in).
 *
 * The palette below is the SAME design system as the iOS app
 * (constants/theme.ts in the chart-algo-ai Expo repo). Keep the two in sync:
 * the website is the first thing an App Store reviewer sees after the
 * screenshots, and a colour mismatch reads as a different product.
 *
 * Admin-only styles live in admin.css and are loaded on top of this file by
 * layouts/admin.html.erb. Plain CSS, no build step — propshaft serves it as-is.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  --bg: #0B1220;
  --surface: #131C2E;
  --surface-alt: #1A2438;
  --primary: #4F8DFD;
  --bull: #22C55E;
  --bear: #EF4444;
  --accent: #F5B84D;
  --text: #E8EDF5;
  --muted: #8B94A7;
  --border: #223047;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --maxw: 1080px;
  --maxw-prose: 760px;
  --header-h: 64px;
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* Anchor targets must clear the sticky header. */
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.02em;
  font-weight: 700;
}

h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

code, pre { font-family: var(--font-mono); }

img, svg { max-width: 100%; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.muted { color: var(--muted); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(19, 28, 46, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-row {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand:hover { text-decoration: none; color: #fff; }

.brand-mark {
  display: block;
  flex: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.nav-links a { color: var(--muted); }
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text); text-decoration: none; }

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--primary);
  color: #06101f;
  font-weight: 700;
  font-size: 0.9rem;
}

.nav-cta:hover { text-decoration: none; filter: brightness(1.08); }

.nav-admin {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-form { display: inline; }

.inline-form button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.inline-form button:hover { color: var(--text); border-color: var(--primary); }

/* ----------------------------------------------------------------- flash */

.flash {
  max-width: var(--maxw);
  margin: 16px auto 0;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 0.95rem;
}

.flash--notice { border-color: rgba(34, 197, 94, 0.5); color: #b9f2cd; }
.flash--alert  { border-color: rgba(239, 68, 68, 0.5); color: #ffc9c9; }

/* --------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #06101f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover { text-decoration: none; filter: brightness(1.08); }
.button.lg { padding: 15px 30px; font-size: 1.02rem; }

.button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.button.ghost:hover { border-color: var(--primary); filter: none; }

/* App Store badge placeholder — swapped for the official artwork at launch. */
.appstore-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 11px 22px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #05090f;
  color: var(--text);
}

.appstore-badge:hover { text-decoration: none; border-color: var(--primary); }
.appstore-badge .small { display: block; font-size: 0.66rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.appstore-badge .big { display: block; font-size: 1.05rem; font-weight: 700; line-height: 1.15; }

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  padding: 84px 0 72px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -40% 30% auto -10%;
  height: 620px;
  background: radial-gradient(closest-side, rgba(79, 141, 253, 0.20), transparent);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 56px;
  align-items: center;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 18px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero h1 { margin-bottom: 18px; }
.hero h1 .accent { color: var(--primary); }

.hero-sub {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 52ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 30px;
}

.hero-note {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-art {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.hero-art figcaption {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* --------------------------------------------------------------- section */

.section { padding: 72px 0; }
.section.alt { background: var(--surface); border-block: 1px solid var(--border); }

.section-head {
  max-width: 62ch;
  margin: 0 auto 44px;
  text-align: center;
}

.section-head p { color: var(--muted); margin-bottom: 0; }

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

.card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}

.section.alt .card { background: var(--surface-alt); }

.card h3 { margin-bottom: 8px; }
.card p { color: var(--muted); margin-bottom: 0; font-size: 0.97rem; }

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border-radius: 11px;
  background: rgba(79, 141, 253, 0.12);
  color: var(--primary);
}

.card-icon.bull { background: rgba(34, 197, 94, 0.12); color: var(--bull); }
.card-icon.bear { background: rgba(239, 68, 68, 0.12); color: var(--bear); }
.card-icon.accent { background: rgba(245, 184, 77, 0.12); color: var(--accent); }

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 16px;
  border-radius: 50%;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
}

.cta-band {
  text-align: center;
  padding: 72px 0 84px;
}

.cta-band .actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 26px;
}

.disclaimer {
  max-width: var(--maxw-prose);
  margin: 0 auto;
  padding: 18px 22px;
  border: 1px solid rgba(245, 184, 77, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(245, 184, 77, 0.07);
  color: #f3dcb2;
  font-size: 0.92rem;
}

.disclaimer p:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------------- prose */

.prose {
  max-width: var(--maxw-prose);
  margin: 0 auto;
  padding: 56px 24px 88px;
}

.prose h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin-bottom: 8px; }
.prose h2 { font-size: 1.35rem; margin-top: 42px; }
.prose h3 { font-size: 1.05rem; margin-top: 28px; }
.prose p, .prose li { color: #cfd7e4; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1em; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--text); }

.prose .updated {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 34px;
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 40px;
}

.toc h2 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin-bottom: 4px; }

.faq {
  border-top: 1px solid var(--border);
  padding-top: 22px;
  margin-top: 22px;
}

.faq h3 { margin-top: 0; }
.faq p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 48px 0 34px;
  font-size: 0.93rem;
}

.foot-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.foot-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 36px;
}

.foot-lead p { color: var(--muted); margin-top: 12px; max-width: 40ch; }

.foot-col { display: flex; flex-direction: column; gap: 9px; }

.foot-col .h {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.foot-col a { color: #cfd7e4; }
.foot-col a:hover { color: var(--primary); }

.foot-bottom {
  margin-top: 38px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}

/* ------------------------------------------------------- admin sign-in */

.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-sub { color: var(--muted); font-size: 0.93rem; margin-bottom: 24px; }

.auth-form .field { margin-bottom: 18px; }

.auth-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  font-size: 0.98rem;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.auth-remember input { accent-color: var(--primary); }

.auth-submit { width: 100%; }

.auth-error {
  margin-bottom: 20px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
  color: #ffc9c9;
  font-size: 0.9rem;
}

.auth-back {
  display: block;
  margin-top: 22px;
  text-align: center;
  font-size: 0.87rem;
  color: var(--muted);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .grid-3 { grid-template-columns: 1fr; }
  .foot-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .hero { padding: 56px 0 48px; }
  .section { padding: 52px 0; }
  .nav-links { gap: 14px; font-size: 0.88rem; }
  .brand { font-size: 0.76rem; letter-spacing: 0.12em; }
  .foot-row { grid-template-columns: 1fr; gap: 28px; }
  .hero-actions { gap: 12px; }
  .button.lg { padding: 13px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
