/* =========================================================================
   base.css — shared layout and components for every page.
   Load after theme.css.
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.55;
  transition: background-color .2s, color .2s;
}
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 20px 72px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---- top bar: back link + theme toggle ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  margin-bottom: 18px;
}
.back {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cyan);
  text-decoration: none;
}
.back:hover { text-decoration: underline; }
.theme-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 600 13px/1 var(--display);
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px 8px 10px;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* ---- type ---- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  font-weight: 600;
  font-size: clamp(34px, 5.6vw, 60px);
  line-height: 1.02;
  margin: 10px 0 14px;
  text-wrap: balance;
}
h1 .y { color: var(--accent-text); }
h2 { text-wrap: balance; }
.lede { color: var(--fg-soft); max-width: 60ch; margin: 0; }
code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 2px 6px;
  border-radius: 5px;
  overflow-wrap: anywhere;
}

/* ---- shared pieces ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
footer {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

/* ---- accessibility ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
