/*
 * The public site's only stylesheet. No JavaScript, no web fonts.
 *
 * The --app-* tokens keep their pre-F0 names but mirror the app's palette in
 * apps/web/src/styles/tokens.css value for value — each resolves through the
 * app's legacy alias (`--color-surface` → `--background`, etc.), so the site
 * and the app look like one product. test/site.test.mjs fails when they drift:
 * change a token there, then here.
 */
:root {
  --app-surface: #F8F8F8;
  --app-panel: #FFFFFF;
  --app-line: #E4E4E4;
  --app-content: #171717;
  --app-muted: #626262;
  --app-accent: #623FF5;

  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --page-width: 72rem;
  --prose-width: 68ch;
  --gutter: 1.5rem;
  --radius: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --app-surface: #0E0E12;
    --app-panel: #16161C;
    --app-line: #2A2A33;
    --app-content: #F2F2F5;
    --app-muted: #A1A1AE;
    --app-accent: #B7A8FF;
  }
}

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

html {
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app-surface);
  color: var(--app-content);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

a {
  color: var(--app-accent);
  text-underline-offset: 0.2em;
}

a:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: var(--gutter);
  top: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--app-panel);
  border: 1px solid var(--app-line);
  border-radius: 0.5rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border: 1px solid var(--app-accent);
  border-radius: 0.5rem;
  background: var(--app-accent);
  color: var(--app-panel);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  opacity: 0.9;
}

.button-quiet {
  background: transparent;
  border-color: var(--app-line);
  color: var(--app-content);
}

.button-quiet:hover {
  opacity: 1;
  border-color: var(--app-muted);
}

.button-small {
  min-height: 2.25rem;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--app-panel);
  /* A shadow rather than a border, so the line does not add to the 64 px. */
  box-shadow: 0 1px 0 var(--app-line);
}

.bar {
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: var(--page-width);
  height: 64px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--app-content);
  font-weight: 650;
  font-size: 1.0625rem;
  text-decoration: none;
  white-space: nowrap;
}

.mark {
  flex: none;
  border-radius: 0.5rem;
}

.nav {
  display: flex;
  gap: 1.5rem;
}

.nav a {
  color: var(--app-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover {
  color: var(--app-content);
}

.nav a[aria-current='page'] {
  color: var(--app-content);
  border-bottom-color: var(--app-accent);
}

.tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.lang {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 0.625rem;
  border: 1px solid var(--app-line);
  border-radius: 0.5rem;
  color: var(--app-content);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.lang:hover {
  border-color: var(--app-muted);
}

/* ── Main ────────────────────────────────────────────────────────────────── */

main {
  flex: 1;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 3rem var(--gutter) 5rem;
}

.page-head {
  max-width: var(--prose-width);
  margin-bottom: 2.5rem;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.crumb {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
}

.crumb a {
  color: var(--app-muted);
  text-decoration: none;
}

.crumb a::before {
  content: '← ';
}

.crumb a:hover {
  color: var(--app-content);
}

.lead {
  margin: 1rem 0 0;
  color: var(--app-muted);
  font-size: 1.1875rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.hero {
  padding: 3rem 0 3.5rem;
  margin-bottom: 1rem;
}

.hero h1 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(2.375rem, 6vw, 3.75rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.hero .lead {
  max-width: 54ch;
  margin-top: 1.5rem;
  font-size: clamp(1.125rem, 2vw, 1.3125rem);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0 0;
}

/* ── Prose ───────────────────────────────────────────────────────────────── */

.prose {
  max-width: var(--prose-width);
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  margin: 2.75rem 0 0.75rem;
  font-size: 1.375rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 2rem 0 0.5rem;
  font-size: 1.125rem;
  line-height: 1.35;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.375rem;
}

.prose li + li {
  margin-top: 0.375rem;
}

.prose li::marker {
  color: var(--app-muted);
}

.prose strong {
  font-weight: 650;
}

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 0.3rem;
  background: var(--app-panel);
  border: 1px solid var(--app-line);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--app-line);
  margin: 2.5rem 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: var(--app-panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--app-line);
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0 0 3rem;
  padding: 0;
  list-style: none;
}

.prose + .cards {
  margin-top: 1.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  height: 100%;
  padding: 1.25rem 1.375rem;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: var(--app-panel);
  color: var(--app-content);
  text-decoration: none;
  transition: border-color 120ms ease;
}

.card:hover {
  border-color: var(--app-accent);
}

.card-title {
  font-weight: 650;
  font-size: 1.0625rem;
}

.card-title::after {
  content: ' →';
  color: var(--app-accent);
}

.card-text {
  color: var(--app-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* ── Legal ───────────────────────────────────────────────────────────────── */

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 1rem 0 0;
  color: var(--app-muted);
  font-size: 0.9375rem;
}

.legal-meta strong {
  color: var(--app-content);
  font-weight: 600;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--app-line);
  background: var(--app-panel);
  color: var(--app-muted);
  font-size: 0.875rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 3rem;
}

.site-footer h2 {
  margin: 0 0 0.75rem;
  color: var(--app-content);
  font-size: 0.875rem;
  font-weight: 600;
}

.site-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer li + li {
  margin-top: 0.375rem;
}

.site-footer p {
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

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

.site-footer a:hover {
  color: var(--app-content);
  text-decoration: underline;
}

/* ── Narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  :root {
    --gutter: 1.125rem;
  }

  .bar {
    flex-wrap: wrap;
    height: auto;
    row-gap: 0;
    padding-top: 0.75rem;
  }

  .tools {
    order: 2;
  }

  .nav {
    order: 3;
    width: 100%;
    gap: 1.25rem;
    overflow-x: auto;
    padding: 0.625rem 0 0.5rem;
  }

  main {
    padding-top: 2rem;
    padding-bottom: 3.5rem;
  }

  .hero {
    padding: 1.5rem 0 2rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}
