/* ==========================================================================
   Apex AI — public static site (home + legal pages)
   Self-contained: no build step, no framework. Dark "F1 HUD" brand palette,
   Rajdhani headings + Barlow body to echo the app. All colours are tokens.
   British English throughout.
   ========================================================================== */

:root {
  --bg: #0a0e0c;
  --surface: #121815;
  --surface-2: #161d18;
  --border: rgba(255, 255, 255, 0.10);
  --border-gold: rgba(230, 184, 79, 0.30);
  --text: #e9ece9;
  --muted: #99a39d;
  --gold: #e6b84f;
  --gold-strong: #f1cd70;
  --green-dark: #06120c;
  --maxw: 50rem;
  --radius: 0.25rem;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 120ms ease, color 120ms ease;
}

a:hover {
  opacity: 0.82;
}

a:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 3.5rem;
  padding: 0 1.25rem;
  background: rgba(10, 14, 12, 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}

.brand-name {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  opacity: 1;
}

/* ---------- Layout ---------- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ---------- Home / hero ---------- */
.hero {
  text-align: center;
  padding: 3.5rem 1.25rem 1rem;
}

.hero .mark-lg {
  display: inline-block;
  width: 3.25rem;
  height: 3.25rem;
  object-fit: contain;
  margin-bottom: 1rem;
}

.hero h1 {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0.25rem 0 0.4rem;
}

.hero .eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0;
}

.hero p.lead {
  color: var(--muted);
  max-width: 38rem;
  margin: 1.25rem auto 2rem;
  font-size: 1.05rem;
}

.btn {
  display: inline-block;
  background: var(--gold);
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: none;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius);
  transition: background 120ms ease;
}

.btn:hover {
  background: var(--gold-strong);
  opacity: 1;
}

.home-links {
  margin-top: 2.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

/* ---------- Legal prose ---------- */
.prose h1 {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.prose .updated {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0 0 2rem;
}

.prose h2 {
  font-family: "Rajdhani", sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.3;
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin: 0 0 0.5rem;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose code {
  font-family: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  padding: 0.05rem 0.35rem;
}

.callout {
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

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

/* ---------- Exported legal documents (/privacy, /terms) ----------
   Those two pages are EXPORTED from apex-frontend's (legal) route group by
   scripts/export-legal.py — never hand-edited. The export drops the app's
   Tailwind utilities and keeps four structural class names the app defines
   itself (help-anchor, legal-toc, legal-plain-list, sr-only), so everything
   below styles the article by element and by those four names, scoped to
   main.legal-doc so the marketing pages can never pick it up. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Anchor jumps land below the sticky 3.5rem header, not under it. */
.legal-doc [id] {
  scroll-margin-top: 4.75rem;
}

/* The article's own "Version N · Effective …" line, straight under the title.
   Matched by its shape (a paragraph that is only an <em>), so a page whose first
   paragraph is ordinary text — /support — keeps body styling. */
.legal-doc article > h1 + p:has(> em:only-child) {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 2rem;
}

.legal-doc ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

/* "At a glance" summary box and the "On this page" contents box. */
.legal-doc aside,
.legal-doc .legal-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.legal-doc aside {
  border-color: var(--border-gold);
  border-left: 3px solid var(--gold);
}

.legal-doc aside > div:first-child,
.legal-doc .legal-toc > div:first-child {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.6rem;
}

.legal-doc aside > div:last-child:not(:first-child) {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 0.85rem;
}

.legal-doc .legal-plain-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.legal-doc .legal-plain-list li {
  margin: 0 0 0.4rem;
}

.legal-doc .legal-plain-list li:last-child {
  margin-bottom: 0;
}

.legal-doc aside .legal-plain-list li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.legal-doc aside .legal-plain-list li > span[aria-hidden] {
  flex: none;
  color: var(--muted);
}

.legal-doc .legal-toc ol {
  display: grid;
  gap: 0.35rem 1.5rem;
}

.legal-doc .legal-toc li {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.legal-doc .legal-toc a {
  color: var(--text);
  text-decoration: none;
}

.legal-doc .legal-toc a:hover {
  color: var(--gold);
  opacity: 1;
}

.legal-doc .legal-toc a > span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.4rem;
}

@media (min-width: 640px) {
  .legal-doc .legal-toc ol {
    grid-template-columns: 1fr 1fr;
  }
}

/* Heading permalinks: an empty <a> that shows "#" on hover or focus. */
.legal-doc .help-anchor {
  margin-left: 0.4rem;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
}

.legal-doc .help-anchor::after {
  content: "#";
}

.legal-doc h2:hover .help-anchor,
.legal-doc .help-anchor:focus-visible {
  opacity: 1;
}

/* Tables scroll inside themselves on a narrow screen, never the page. */
.legal-doc table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.legal-doc th,
.legal-doc td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

.legal-doc thead th {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--gold);
  background: var(--surface);
  white-space: nowrap;
}

.legal-doc tbody tr:nth-child(even) td {
  background: var(--surface);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer nav {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.site-footer nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer nav a:hover {
  color: var(--text);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .brand-sub { display: none; }
  .wrap { padding-top: 1.75rem; }
  .legal-doc table { font-size: 0.84rem; }
  .legal-doc th,
  .legal-doc td { padding: 0.45rem 0.55rem; }
}
