/* ====================================================
   restapi.wtf — shared base styles.

   Owns: color/font tokens, body atmosphere, brand mark,
   header chrome (brand + mode-toggle + theme-toggle),
   footer with wordmark, SSR intro, copy buttons, utilities.

   Loaded BEFORE components.css and before per-site styles.css.

   Aesthetic: editorial trade press. Warm-dark / cream-light
   palette, rescue orange accent, Instrument Serif italic display,
   Instrument Sans body, JetBrains Mono for the <wtf/> mark + code.
   Each site must load Google Fonts in its <head>:

     <link rel="preconnect" href="https://fonts.googleapis.com">
     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?\
       family=Instrument+Sans:ital,wght@0,400;0,500;0,600;1,400&\
       family=Instrument+Serif:ital@0;1&\
       family=JetBrains+Mono:wght@400;500;600&display=swap">

   See individual site index.html files for the exact form.
   ==================================================== */

:root {
  color-scheme: dark light;

  /* dark (default) — warm near-black */
  --bg:           #0c0a09;
  --bg-elev:      #131110;
  --bg-elev-2:    #1a1612;
  --surface:      #1a1612;
  --fg:           #f5efe6;
  --fg-soft:      #c8bdaf;
  --fg-muted:     #857a6e;
  --fg-subtle:    #4f4a45;
  --border:       rgba(245, 239, 230, 0.08);
  --border-hi:    rgba(245, 239, 230, 0.18);
  --border-strong: rgba(245, 239, 230, 0.32);
  --accent:       #ff5400;
  --accent-deep:  #c43c00;
  --accent-soft:  rgba(255, 84, 0, 0.15);
  --accent-fg:    #1a0d00;
  --warn:         #ffd97d;
  --warn-bg:      rgba(255, 217, 125, 0.08);
  --warn-border:  rgba(255, 217, 125, 0.4);

  /* fonts */
  --serif: "Instrument Serif", "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --sans:  "Instrument Sans", -apple-system, "Helvetica Neue", Helvetica, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* geometry */
  --r:        0px;        /* default to sharp; small UI uses --r-sm */
  --r-sm:     3px;
  --r-pill:   999px;
  --maxw:     1240px;
  --maxw-prose: 720px;

  /* atmospheres (used by ::before / ::after on body) */
  --glow-1: rgba(255, 84, 0, 0.08);
  --glow-2: rgba(255, 84, 0, 0.04);
}

/* explicit light theme */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:           #f5efe6;
  --bg-elev:      #ede5d8;
  --bg-elev-2:    #e6dccb;
  --surface:      #e6dccb;
  --fg:           #0c0a09;
  --fg-soft:      #3a342e;
  --fg-muted:     #6e6557;
  --fg-subtle:    #a89f8f;
  --border:       rgba(12, 10, 9, 0.08);
  --border-hi:    rgba(12, 10, 9, 0.18);
  --border-strong: rgba(12, 10, 9, 0.32);
  --warn:         #b76e00;
  --warn-bg:      rgba(255, 217, 125, 0.4);
  --warn-border:  rgba(183, 110, 0, 0.4);
  --glow-1: rgba(255, 84, 0, 0.07);
  --glow-2: rgba(255, 84, 0, 0.03);
}
/* system-preference light (when no explicit data-theme set) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg:           #f5efe6;
    --bg-elev:      #ede5d8;
    --bg-elev-2:    #e6dccb;
    --surface:      #e6dccb;
    --fg:           #0c0a09;
    --fg-soft:      #3a342e;
    --fg-muted:     #6e6557;
    --fg-subtle:    #a89f8f;
    --border:       rgba(12, 10, 9, 0.08);
    --border-hi:    rgba(12, 10, 9, 0.18);
    --border-strong: rgba(12, 10, 9, 0.32);
    --warn:         #b76e00;
    --warn-bg:      rgba(255, 217, 125, 0.4);
    --warn-border:  rgba(183, 110, 0, 0.4);
    --glow-1: rgba(255, 84, 0, 0.07);
    --glow-2: rgba(255, 84, 0, 0.03);
  }
}

/* ---------- Resets / base typography ---------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scrollbar-gutter: stable; scrollbar-color: var(--fg-subtle) var(--bg); }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* atmospheric layer — radial accent wash, behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 90% -8%, var(--glow-1), transparent 60%),
    radial-gradient(ellipse 60% 80% at -10% 110%, var(--glow-2), transparent 60%);
}
/* grain overlay — subtle, breaks up flat backgrounds */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.8 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
/* in light mode, soften the grain further */
:root[data-theme="light"] body::after,
:root:not([data-theme="dark"]) body::after { opacity: 0.025; mix-blend-mode: multiply; }

::selection { background: var(--accent); color: var(--accent-fg); }

a { color: var(--fg); text-decoration: none; transition: color 180ms; }
a:hover { color: var(--accent); }

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}
.mono { font-family: var(--mono); }
.serif { font-family: var(--serif); }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.italic { font-style: italic; }

/* uppercase-mono label, used in eyebrows and section markers */
.label-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.label-eyebrow .accent { color: var(--accent); }

/* ---------- Header (brand + mode-toggle + theme-toggle) ---------- */

header.app-header {
  position: relative;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 40px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--fg);
  transition: color 180ms;
}
.brand .b-br   { color: var(--fg-muted); transition: color 200ms; }
.brand .b-tag  { color: var(--fg); }
.brand .b-attr { color: var(--fg-muted); }
.brand .b-eq   { color: var(--fg-muted); }
.brand .b-str  { color: var(--accent); }
.brand:hover { color: var(--fg); text-decoration: none; }
.brand:hover .b-br { color: var(--accent); }

/* mode-toggle is the family signature: mono small-caps with an accent
   underline under the active tab. */
.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.mode-toggle button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 10px 16px;
  cursor: pointer;
  position: relative;
  transition: color 180ms;
}
.mode-toggle button + button { border-left: 1px solid var(--border); }
.mode-toggle button:hover { color: var(--fg); }
.mode-toggle button[aria-pressed="true"] {
  color: var(--fg);
  background: var(--bg);
}
.mode-toggle button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

/* theme-toggle is the same shape as mode-toggle but smaller */
.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.theme-toggle button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 12px;
  cursor: pointer;
  transition: color 180ms;
}
.theme-toggle button + button { border-left: 1px solid var(--border); }
.theme-toggle button:hover { color: var(--fg); }
.theme-toggle button[aria-pressed="true"] {
  color: var(--fg);
  background: var(--bg);
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.header-spacer { flex: 1; }

.icon-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 180ms, border-color 180ms;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Main canvas ---------- */

main {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* ---------- Footer with editorial wordmark ---------- */

footer.app-footer {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 80px 40px 88px;
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 56px;
  align-items: end;
  border-top: 1px solid var(--border);
  margin-top: 64px;
}
/* the giant italic wordmark — each site's index.html opts in by adding
   <p class="foot-mark"><em>wtf</em>/SITE</p> as the first child of the footer */
.foot-mark {
  font-family: var(--serif);
  font-size: clamp(72px, 12vw, 188px);
  font-style: italic;
  font-weight: 400;
  line-height: 0.85;
  letter-spacing: -0.04em;
  color: var(--fg);
  margin: 0;
}
.foot-mark em { color: var(--accent); font-style: italic; }
.foot-mark sub {
  font-size: 0.16em;
  vertical-align: 0.6em;
  color: var(--fg-muted);
  font-style: normal;
  font-family: var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-left: 12px;
  display: inline-block;
  white-space: nowrap;
}

.foot-meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.foot-meta strong { color: var(--fg); font-weight: 500; }
.foot-meta p { margin: 0; }

/* The existing sibling-sites <p> remains supported but is restyled. */
.sibling-sites {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.sibling-sites a {
  color: var(--fg-muted);
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color 180ms, border-color 180ms;
}
.sibling-sites a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }
.sibling-sites a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.foot-tagline { color: var(--fg-muted); font-size: 12px; letter-spacing: 0.04em; text-transform: none; }
.foot-tagline strong { color: var(--fg); }

/* ---------- SSR intro (visible to crawlers + JS-off users; matches editorial) ---------- */

.ssr-intro { max-width: 70ch; padding: 16px 0 8px; }
.ssr-intro h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.0;
  letter-spacing: -0.022em;
  margin: 0 0 28px;
  color: var(--fg);
}
.ssr-intro h1 em { font-style: italic; color: var(--accent); }
.ssr-intro h2 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 40px 0 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ssr-intro h2::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--accent);
}
.ssr-intro p {
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 16px;
  color: var(--fg-soft);
  max-width: 65ch;
}
.ssr-intro p strong { color: var(--fg); font-weight: 600; }
.ssr-intro ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}
.ssr-intro li {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.55;
  color: var(--fg-soft);
}
.ssr-intro li strong { color: var(--fg); font-weight: 600; }
.ssr-intro code {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: var(--mono);
  color: var(--fg);
}
.ssr-intro noscript p {
  margin-top: 20px;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--fg);
}
.ssr-intro pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 20px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--fg-soft);
}
.ssr-intro pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ---------- Section heading pattern (used by detail pages) ---------- */

.detail-section { margin: 28px 0; }
.detail-section h2 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.detail-section h2::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--accent);
}
.detail-summary {
  font-family: var(--serif);
  font-size: clamp(22px, 2.6vw, 30px);
  font-style: italic;
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 0 0 28px;
  color: var(--fg);
  max-width: 60ch;
}

/* ---------- Syntax-highlight tokens (used by <pre><code> blocks) ----------

   Bash and JSON code blocks wrap segments in <span class="tok-*"> to get
   color. Used by the SSR intros and by the dynamic code-block renderer in
   mock-docs/src/highlight.js.

   Generic <pre>/<code> styling lives in per-site CSS (mock-docs/styles.css
   for the .codeblock wrapper, shared styles-base for .ssr-intro pre). The
   token classes themselves are scoped here so any page that uses them
   inherits the palette.
   --------------------------------------------------------------------- */

.tok-cmt { color: var(--fg-muted); font-style: italic; }   /* comments */
.tok-str { color: var(--warn); }                            /* strings */
.tok-key { color: var(--accent); }                          /* JSON keys, CLI flags */
.tok-fn  { color: var(--fg); }                              /* function / command names */
.tok-num { color: var(--warn); }                            /* numbers, booleans, null */
.tok-tpl { color: var(--accent); font-weight: 500; }        /* ${expr} templates */

/* ---------- Copy button ---------- */

.copy-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--fg-soft);
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 180ms, border-color 180ms;
  line-height: 1.2;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* ---------- Skeleton state ---------- */

.skeleton {
  color: var(--fg-subtle);
  font-family: var(--mono);
  font-size: 14px;
}

/* ---------- Responsive: header + footer collapse on small screens ---------- */

@media (max-width: 920px) {
  .header-inner { padding: 18px 24px; }
  main { padding: 32px 24px 64px; }
  footer.app-footer {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 56px 24px 64px;
  }
}
@media (max-width: 540px) {
  .header-inner { padding: 14px 20px; gap: 12px; }
  main { padding: 24px 20px 56px; }
  footer.app-footer { padding: 48px 20px 56px; }
  .brand { font-size: 13px; }
  .mode-toggle button { padding: 9px 12px; font-size: 10.5px; }
  .theme-toggle button { padding: 7px 10px; font-size: 10px; }
}
