/*
 * Shared stylesheet for every page of the portal (hub + one folder per app).
 * No external fonts, frameworks or build step: system font stacks keep the site fast
 * and avoid sending visitor data to font CDNs.
 *
 * To theme a future app, override only the --accent* tokens on <body data-app="...">.
 */

:root {
  color-scheme: light dark;

  /* Palette (light). True white background on purpose. */
  --bg: #ffffff;
  --surface: #f5f7fa;
  --ink: #172033;
  --muted: #526071;
  --line: #e2e7ee;
  --accent: #0d6b5e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ef;
  --code-bg: #10192b;
  --code-ink: #e6edf7;
  --code-muted: #8fa3bf;
  --focus: #2563eb;

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;

  /* Layout */
  --wrap: 72rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --surface: #151d2c;
    --ink: #e8edf4;
    --muted: #a3b0c2;
    --line: #263247;
    --accent: #4cc2ad;
    --accent-ink: #062520;
    --accent-soft: #12302b;
    --code-bg: #0a101b;
    --focus: #7aa7ff;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--font-sans);
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Skip link: hidden until focused by keyboard. */
.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  z-index: 10;
}

.skip:focus {
  top: 1rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  color: var(--muted);
  font-weight: 500;
}

.nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.25rem 0;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
}

.nav a[aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- Buttons ---------- */

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.875rem;
  padding: 0 1.25rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: 600 0.9375rem/1 var(--font-sans);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--ink));
}

.btn-secondary {
  border-color: var(--line);
  color: var(--ink);
  background: var(--bg);
}

.btn-secondary:hover {
  border-color: var(--muted);
}

/* ---------- Hero ---------- */

.hero {
  padding: clamp(3rem, 8vw, 6rem) 0 clamp(3rem, 7vw, 5rem);
}

.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 {
  font-size: clamp(2.125rem, 4.6vw, 3.25rem);
  font-weight: 700;
  max-width: 16ch;
}

.lede {
  font-size: clamp(1.0625rem, 1.6vw, 1.1875rem);
  color: var(--muted);
  max-width: 36rem;
  margin: 1.25rem 0 0;
}

/* ---------- Output specimen (signature element) ---------- */

.specimen-figure {
  margin: 0;
  min-width: 0;
}

.specimen {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px -24px rgb(16 25 43 / 45%);
  overflow: hidden;
}

.specimen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgb(255 255 255 / 8%);
  flex-wrap: wrap;
}

.specimen-title {
  font: 500 0.8125rem/1.4 var(--font-sans);
  color: var(--code-muted);
  margin: 0;
}

.tabs {
  display: flex;
  gap: 0.25rem;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--code-muted);
  font: 600 0.8125rem/1 var(--font-sans);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.tab:hover {
  color: var(--code-ink);
}

.tab[aria-selected="true"] {
  background: rgb(255 255 255 / 10%);
  color: #ffffff;
}

.specimen pre {
  margin: 0;
  padding: 1.25rem 1.25rem 1.5rem;
  font: 400 0.875rem/1.7 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 15.5rem;
}

.specimen pre[hidden] {
  display: none;
}

.specimen .k {
  color: #7fe0cc;
}

.specimen .d {
  color: var(--code-muted);
}

.specimen-note {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Sections ---------- */

.section {
  padding: clamp(3rem, 7vw, 5rem) 0;
  border-top: 1px solid var(--line);
}

.section-tint {
  background: var(--surface);
  border-top: 0;
}

.section h2 {
  font-size: clamp(1.625rem, 3vw, 2.125rem);
  font-weight: 700;
  max-width: 24ch;
}

.section-intro {
  color: var(--muted);
  max-width: 40rem;
  margin: 0.75rem 0 0;
}

/* Numbered steps: a horizontal rail, not cards. */
.steps {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  border-top: 2px solid var(--accent);
  padding-top: 1.25rem;
}

.steps li::before {
  content: counter(step);
  display: block;
  font: 700 0.875rem/1 var(--font-mono);
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.steps h3 {
  font-size: 1.125rem;
  font-weight: 650;
}

.steps p {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

/* Fact list: two-column definition list. */
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 3rem;
  margin: 2.5rem 0 0;
}

.facts div {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.facts dt {
  font-weight: 650;
}

.facts dd {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.plain-list {
  margin: 0;
  padding-left: 1.25rem;
}

.plain-list li + li {
  margin-top: 0.75rem;
}

.plain-list li::marker {
  color: var(--accent);
}

/* ---------- Hub ---------- */

.app-list {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.app-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem 2rem;
  align-items: center;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--line);
}

.app-list h2 {
  font-size: 1.375rem;
}

.app-list p {
  margin: 0.375rem 0 0;
  color: var(--muted);
  max-width: 42rem;
}

/* ---------- Document pages (privacy, terms, support) ---------- */

.doc {
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(3rem, 7vw, 5rem);
}

.doc .wrap {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.doc-head {
  grid-column: 1 / -1;
  max-width: 46rem;
}

.doc-head h1 {
  max-width: none;
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.meta {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.toc {
  position: sticky;
  top: 5.5rem;
  font-size: 0.875rem;
}

.toc h2 {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0;
  margin-bottom: 0.75rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--ink);
}

.prose {
  max-width: 44rem;
}

.prose h2 {
  font-size: 1.375rem;
  font-weight: 650;
  margin: 2.75rem 0 0.75rem;
  padding-top: 0.25rem;
}

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

.prose h3 {
  font-size: 1.0625rem;
  font-weight: 650;
  margin: 1.75rem 0 0.5rem;
}

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

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

.prose code,
.facts code,
.plain-list code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

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

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

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.65rem 0.75rem 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.prose th {
  font-weight: 650;
}

.table-scroll {
  overflow-x: auto;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem 0 3rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer .wrap {
  display: grid;
  gap: 1rem;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}

.footer-row ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer a {
  color: var(--muted);
}

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

.site-footer p {
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 56rem) {
  .hero .wrap,
  .split {
    grid-template-columns: 1fr;
  }

  .doc .wrap {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }
}

@media (max-width: 44rem) {
  .steps,
  .facts {
    grid-template-columns: 1fr;
  }

  .steps {
    gap: 1.75rem;
  }

  .app-list li {
    grid-template-columns: 1fr;
  }

  .site-header .wrap {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .tab,
  .nav a {
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
}

/* Single-column hero (hub and 404 pages). */
.hero .wrap.hero-single {
  display: block;
}

@media (max-width: 30rem) {
  .specimen pre {
    font-size: 0.8125rem;
    padding: 1rem;
    min-height: 0;
  }
}
