/*
 * Creo design system: tokens, base, and shared page chrome.
 * Served at /assets/creo.css. Link it before any page-specific stylesheet.
 *
 * Fonts (self-hosted, SIL OFL 1.1, see /assets/fonts/LICENSES.md):
 *   --font-sans    Google Sans Flex, the same sans ampcode.com uses.
 *   --font-mono    JetBrains Mono. Open substitute for Berkeley Mono / TX-02, which are
 *                  commercial. Closest open match in width, x-height and terminal feel.
 *   --font-display Instrument Serif. Open substitute for Sagittaire Display, which is
 *                  commercial. A condensed, high-contrast display serif with a true italic.
 *
 * Type scale matches ampcode.com's live CSS (13px base):
 *   xxs .625  xs .6875  sm .75  base .8125  md .9375  lg 1  xl 1.25  2xl 1.5
 *   3xl 2  4xl 2.5  5xl 3  6xl 3.75  7xl 4.5  8xl 6   (rem)
 *
 * Themes: light and dark follow the OS by default. Set data-theme="light" or
 * data-theme="dark" on <html> to force one (creo.js does this from the toggle).
 */

@font-face {
  font-family: "Google Sans Flex";
  src: url("/assets/fonts/GoogleSansFlex-latin.woff2") format("woff2-variations");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/JetBrainsMono-latin.woff2") format("woff2-variations");
  font-weight: 400 650;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/InstrumentSerif-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("/assets/fonts/InstrumentSerif-italic-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* Families */
  --font-sans: "Google Sans Flex", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;

  /* Type scale (ampcode.com) */
  --text-xxs: 0.625rem;
  --text-xs: 0.6875rem;
  --text-sm: 0.75rem;
  --text-base: 0.8125rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  --text-7xl: 4.5rem;
  --text-8xl: 6rem;

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.55;
  --tracking-label: 0.08em;

  /* Spacing (4px grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Layout */
  --page-max: 76rem;
  --page-gutter: clamp(1rem, 4vw, 2.5rem);
  --header-height: 3.5rem;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;

  /* Color: light (default) */
  --bg: #f4f2eb;
  --bg-raised: #fbfaf6;
  --bg-sunken: #ebe8de;
  --bg-inverse: #0c0e0d;
  --fg: #0d100e;
  --fg-muted: #5a5e58;
  --fg-faint: #62655f;
  --fg-inverse: #f1f4ee;
  --border: rgb(13 16 14 / 0.12);
  --border-strong: rgb(13 16 14 / 0.22);
  --accent: #0f7a4a;
  --accent-fg: #ffffff;
  --positive: #0f7a4a;
  --negative: #c2462b;
  --neutral: #8a8d86;
  --focus: #2c6cf0;
  --code-bg: #0f1211;
  --code-fg: #dfe6dd;
  --code-muted: #7d877e;
  --code-key: #8fd3ad;
  --code-string: #e8c58c;
  --code-number: #9cc3ff;
  --shadow: 0 1px 0 rgb(13 16 14 / 0.04), 0 8px 24px -12px rgb(13 16 14 / 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d0c;
    --bg-raised: #121514;
    --bg-sunken: #070908;
    --bg-inverse: #f1f4ee;
    --fg: #eef2ec;
    --fg-muted: #9da59d;
    --fg-faint: #858c85;
    --fg-inverse: #0d100e;
    --border: rgb(238 242 236 / 0.1);
    --border-strong: rgb(238 242 236 / 0.2);
    --accent: #5fd896;
    --accent-fg: #06110b;
    --positive: #5fd896;
    --negative: #f07a5c;
    --neutral: #6b726b;
    --focus: #7aa7ff;
    --code-bg: #070908;
    --shadow: 0 1px 0 rgb(0 0 0 / 0.3), 0 12px 32px -16px rgb(0 0 0 / 0.7);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0d0c;
  --bg-raised: #121514;
  --bg-sunken: #070908;
  --bg-inverse: #f1f4ee;
  --fg: #eef2ec;
  --fg-muted: #9da59d;
  --fg-faint: #858c85;
  --fg-inverse: #0d100e;
  --border: rgb(238 242 236 / 0.1);
  --border-strong: rgb(238 242 236 / 0.2);
  --accent: #5fd896;
  --accent-fg: #06110b;
  --positive: #5fd896;
  --negative: #f07a5c;
  --neutral: #6b726b;
  --focus: #7aa7ff;
  --code-bg: #070908;
  --shadow: 0 1px 0 rgb(0 0 0 / 0.3), 0 12px 32px -16px rgb(0 0 0 / 0.7);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Data series: one color per holding in charts. */
:root {
  --series-1: #2f6f9f;
  --series-2: #c27c2c;
  --series-3: #4f8a3c;
  --series-4: #8a5aa8;
  --series-5: #b8484f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #6aa8d8;
    --series-2: #e3a258;
    --series-3: #86c06e;
    --series-4: #b792d6;
    --series-5: #e57d82;
  }
}

:root[data-theme="dark"] {
  --series-1: #6aa8d8;
  --series-2: #e3a258;
  --series-3: #86c06e;
  --series-4: #b792d6;
  --series-5: #e57d82;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
}

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

a {
  color: inherit;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

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

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 500;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.num {
  font-variant-numeric: tabular-nums;
}

::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}

.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;
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--page-gutter));
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.section {
  padding-block: clamp(var(--space-16), 7vw, var(--space-24));
  border-top: 1px solid var(--border);
}

.section-head {
  display: grid;
  gap: var(--space-4);
  max-width: 44rem;
  margin-bottom: clamp(var(--space-10), 5vw, var(--space-16));
}

/* ---------- Type ---------- */

.eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-muted);
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.02;
}

.display em {
  font-style: italic;
}

.h1 {
  font-size: clamp(var(--text-4xl), 3.2vw + 1.4rem, var(--text-7xl));
}

.h2 {
  font-size: clamp(var(--text-3xl), 2.2vw + 1.2rem, var(--text-5xl));
}

.h3 {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-snug);
  letter-spacing: -0.005em;
}

.lead {
  font-size: clamp(var(--text-md), 0.4vw + 0.85rem, var(--text-xl));
  line-height: 1.5;
  color: var(--fg-muted);
  max-width: 38rem;
}

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

.fine-print {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 2.5rem;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button.small {
  height: 2rem;
  padding: 0 var(--space-3);
  font-size: var(--text-base);
}

.button.primary {
  background: var(--fg);
  color: var(--bg);
}

.button.primary:hover {
  background: color-mix(in srgb, var(--fg) 84%, var(--bg));
}

.button.secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--fg);
}

.button.secondary:hover {
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

/* A live secondary action that must not read as disabled, such as "Get notified". */
.button.notify {
  background: var(--bg);
  border-color: var(--fg);
  color: var(--fg);
  font-weight: 600;
}

.button.notify:hover {
  background: var(--fg);
  color: var(--bg);
}

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.button .arrow {
  font-family: var(--font-mono);
  transition: transform 120ms ease;
}

.button:hover .arrow {
  transform: translateX(2px);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.text-link {
  display: inline-flex;
  gap: var(--space-1);
  font-weight: 500;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: var(--header-height);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.wordmark svg {
  width: 18px;
  height: 18px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-right: auto;
}

.nav-links a {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  text-decoration: none;
}

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

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-actions .nav-signin {
  color: var(--fg-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
}

.nav-actions .nav-signin:hover {
  color: var(--fg);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--fg-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--border);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.theme-toggle .icon-sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (max-width: 760px) {
  .site-header .container {
    gap: var(--space-3);
  }
  .nav-links {
    display: none;
  }
  .nav-actions {
    margin-left: auto;
  }
  .nav-actions .nav-signin {
    display: none;
  }
}

/* Home for a connected browser: hidden while creo.js confirms and redirects to /portfolio. */
:root[data-home-redirect] main,
:root[data-home-redirect] #factor-tape,
:root[data-home-redirect] .site-footer {
  visibility: hidden;
}

/* Signed-in header (creo.js): "Connected brokerages" replaces the primary CTA. While the
   localStorage hint says connected, the CTA hides before first paint and the button's
   width is reserved, so nothing swaps or shifts when the script adds it. */
:root[data-session="connected"] .nav-actions > .button.primary {
  display: none;
}

:root[data-session="connected"] .nav-actions::after {
  content: "";
  width: var(--brokerages-width);
  height: 2rem;
}

:root[data-session="connected"] .nav-actions:has(.brokerages-button)::after {
  display: none;
}

:root {
  --brokerages-width: 13.25rem;
}

.brokerages-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--brokerages-width);
  height: 2rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.brokerages-button:hover {
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.brokerages-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.brokerages-dot,
.bs-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 20%, transparent);
}

.brokerages-button .bk-short {
  display: none;
}

.brokerages-button .bk-count {
  margin-left: calc(var(--space-1) * -1);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  :root {
    --brokerages-width: 8.75rem;
  }
  .brokerages-button .bk-long {
    display: none;
  }
  .brokerages-button .bk-short {
    display: inline;
  }
}

/* The settings sheet: a right-side panel on desktop, a bottom sheet on phones. */
.brokerages-sheet {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(26rem, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: var(--space-6);
  overflow-y: auto;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.brokerages-sheet[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: sheet-in-right 0.2s ease;
}

.brokerages-sheet::backdrop {
  background: rgb(8 10 9 / 0.45);
}

@keyframes sheet-in-right {
  from { transform: translateX(1.5rem); opacity: 0; }
}

@keyframes sheet-in-up {
  from { transform: translateY(1.5rem); opacity: 0; }
}

.bs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.bs-head h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.bs-close {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--fg-muted);
  cursor: pointer;
}

.bs-close:hover {
  color: var(--fg);
  border-color: var(--border);
}

.bs-close svg {
  width: 14px;
  height: 14px;
}

.bs-lede,
.bs-muted,
.bs-sync,
.bs-foot p {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.bs-rows {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.bs-row,
.bs-empty,
.bs-note {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.bs-empty,
.bs-note {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.bs-row {
  display: grid;
  gap: var(--space-3);
}

.bs-main {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
}

.bs-main h3 {
  font-size: var(--text-md);
  font-weight: 600;
}

.bs-accounts {
  margin-top: var(--space-1);
  font-size: var(--text-base);
  font-variant-numeric: tabular-nums;
}

.bs-sync {
  margin-top: 2px;
}

.bs-error {
  color: var(--negative);
}

.bs-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding-left: calc(7px + var(--space-3));
}

.bs-ask {
  margin-right: auto;
  font-size: var(--text-sm);
  font-weight: 500;
}

.button.bs-danger {
  background: transparent;
  border-color: transparent;
  color: var(--negative);
}

.button.bs-danger:hover {
  border-color: color-mix(in srgb, var(--negative) 40%, transparent);
}

.button.bs-danger.solid {
  background: var(--negative);
  color: #fff;
}

.bs-add {
  align-self: start;
}

.bs-foot {
  display: grid;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.bs-billing {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .brokerages-sheet {
    inset: auto 0 0 0;
    width: 100vw;
    height: auto;
    max-height: 85dvh;
    padding: var(--space-5) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .brokerages-sheet[open] {
    animation-name: sheet-in-up;
  }
  .bs-add {
    align-self: stretch;
  }
  .bs-foot {
    margin-top: var(--space-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .brokerages-sheet[open] {
    animation: none;
  }
}

/* Factor tape slot: content owned by /tape.js and /tape.css. The slot reserves the
   strip's exact height (2.5rem, matching .ctape) before the script runs, so mounting,
   loading and an empty feed never move the page. */
#factor-tape {
  height: 2.5rem;
  overflow: hidden;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Home: the analyzer's own filing strip replaces the global tape while results show
   (creo:analyzed / creo:cleared, see landing.js). */
#factor-tape {
  transition:
    height 0.24s ease,
    border-width 0.24s ease;
}

#factor-tape.is-collapsed {
  height: 0;
  border-block-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  #factor-tape {
    transition: none;
  }
}

/* Edge fades wide enough to read as a fade, not a clip, at every width. Overrides the
   shorter mask in tape.css. */
#factor-tape .ctape__viewport {
  --tape-fade-in: var(--space-8);
  --tape-fade-out: clamp(3.5rem, 8vw, 7rem);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--tape-fade-in), #000 calc(100% - var(--tape-fade-out)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--tape-fade-in), #000 calc(100% - var(--tape-fade-out)), transparent);
}

/* Empty feed: one quiet, truncated line rather than a scrolling message. */
#factor-tape.is-empty .ctape__track {
  width: 100%;
}

#factor-tape .ctape__empty {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 2.5rem;
  color: var(--fg-faint);
  font-size: var(--text-xs);
}

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

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-12) var(--space-10);
  color: var(--fg-muted);
  font-size: var(--text-base);
}

.site-footer .container {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: var(--space-8);
}

.site-footer .wordmark {
  color: var(--fg);
}

.footer-brand p {
  margin-top: var(--space-3);
  max-width: 22rem;
}

.footer-col h2 {
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-faint);
}

.footer-col ul {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-col a {
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--fg);
}

.footer-legal {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--fg-faint);
}

@media (max-width: 760px) {
  .site-footer .container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* ---------- Surfaces ---------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 1.375rem;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  white-space: nowrap;
}

.chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
}

/* ---------- Code ---------- */

.code-block,
pre.code {
  margin: 0;
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.65;
  tab-size: 2;
}

.code-block .k,
pre.code .k {
  color: var(--code-key);
}

.code-block .s,
pre.code .s {
  color: var(--code-string);
}

.code-block .n,
pre.code .n {
  color: var(--code-number);
}

.code-block .c,
pre.code .c {
  color: var(--code-muted);
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-size: 0.9em;
}

.code-wrap {
  position: relative;
}

.code-copy {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  height: 1.75rem;
  padding: 0 var(--space-2);
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.06);
  color: var(--code-fg);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.code-copy:hover {
  background: rgb(255 255 255 / 0.12);
}

/* ---------- Forms ---------- */

input,
select,
textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-md);
}

textarea {
  min-height: 8rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: transparent;
}

label {
  display: grid;
  gap: var(--space-1);
  font-weight: 500;
}

/* ---------- Inner pages ---------- */

.page-hero {
  padding-block: clamp(var(--space-12), 7vw, var(--space-20)) clamp(var(--space-8), 4vw, var(--space-12));
}

.page-hero .container {
  display: grid;
  gap: var(--space-4);
}

.page-hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(var(--text-4xl), 2.6vw + 1.4rem, var(--text-6xl));
  line-height: 1.04;
  letter-spacing: -0.01em;
  max-width: 48rem;
}

.page-hero .lead {
  max-width: 42rem;
}

.page-body {
  padding-bottom: clamp(var(--space-16), 8vw, var(--space-24));
}

.prose {
  max-width: 44rem;
  font-size: var(--text-md);
  line-height: 1.65;
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2 {
  margin-top: var(--space-12);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--leading-snug);
}

.prose h3 {
  margin-top: var(--space-8);
  font-size: var(--text-lg);
  font-weight: 600;
}

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

.prose li + li {
  margin-top: var(--space-2);
}

.prose .code-block,
.prose .code-wrap {
  font-size: var(--text-sm);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

table.data th,
table.data td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table.data th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-muted);
  background: var(--bg-sunken);
}

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

.notice {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--positive);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.notice.error {
  border-left-color: var(--negative);
}

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

[hidden] {
  display: none !important;
}
