/* ============================================================
   base.css — reset, typography, shared components
   Loaded on every public page after tokens.css.
============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
}
/* faint fixed grain — breaks up flat colour fields so surfaces read
   as textured/crafted rather than a solid CSS gradient. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.035 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
html.dark body::before { opacity: 0.7; mix-blend-mode: soft-light; }
.page { position: relative; z-index: 1; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: var(--accent-2); color: #191919; }

/* `.serif` is a legacy utility name kept so markup doesn't need a
   find/replace — it now renders the bold display sans, matching
   Notion's headline treatment (there is no serif in this system). */
.serif { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.02em; }
.mono  { font-family: var(--f-mono); }

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--fg);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-family: var(--f-sans);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  z-index: 100;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- focus ---------- */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- layout shell ---------- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px clamp(20px, 4vw, 56px) 40px;
}
/* <header> sits outside <main id="main"> so the skip link actually
   skips the navigation. main takes the remaining height and keeps the
   flex column, so children that rely on flex:1 (e.g. the 404 block)
   still centre correctly. */
.page > main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.container { max-width: var(--container); width: 100%; margin: 0 auto; }
.prose { max-width: var(--measure); }

/* ---------- top nav ----------
   .top has three direct flex children: .brand, .nav, .theme-toggle.
   Desktop: brand sits left; nav gets margin-left:auto to push itself
   (and the toggle right after it) over to the right edge as a group.
   Mobile: order is rearranged so brand+toggle share row 1 and nav
   (full width) wraps cleanly to row 2 — see the mobile block below.
------------------------------------------------------------------- */
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 12px 28px;
  max-width: var(--container);
  margin: 0 auto;
  width: 100%;
}
.brand {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  order: 1;
}
.brand .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2);
  display: inline-block;
}
.nav { display: flex; gap: clamp(16px, 2.2vw, 26px); flex-wrap: wrap; order: 2; margin-left: auto; }
.nav a {
  color: var(--fg-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 6px 2px;
  transition: color var(--dur-fast) ease;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }

.theme-toggle {
  background: var(--chip);
  border: 1px solid transparent;
  color: var(--fg);
  opacity: 0.8;
  border-radius: 999px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  order: 3;
  transition: opacity var(--dur-fast) ease, background var(--dur-fast) ease;
}
.theme-toggle:hover { opacity: 1; background: var(--hover); }
.theme-toggle svg { width: 14px; height: 14px; }

/* ---------- footer ---------- */
.site-footer {
  max-width: var(--container);
  margin: var(--sp-8) auto 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: var(--sp-5);
  border-top: 1px solid var(--rule);
  color: var(--fg-mute);
  font-family: var(--f-sans);
  font-size: 13px;
}
.site-footer a { color: inherit; text-decoration: none; transition: color var(--dur-fast) ease; display: inline-flex; align-items: center; min-height: 24px; padding: 4px 2px; margin: -4px -2px; }
.site-footer a:hover { color: var(--fg); }
.site-footer .fsocial { display: flex; gap: 16px; }

/* ---------- common text ---------- */
.eyebrow {
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-mute);
  margin-bottom: var(--sp-2);
}
.section-label {
  font-family: var(--f-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-mute);
  margin: var(--sp-8) 0 var(--sp-3);
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }

/* ---------- chips / tags (Notion property-tag style) ---------- */
.chip {
  font-family: var(--f-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--fg-soft);
  display: inline-block;
}
.chip:nth-of-type(5n+1) { background: var(--tag-blue-bg);   color: var(--tag-blue-fg); }
.chip:nth-of-type(5n+2) { background: var(--tag-green-bg);  color: var(--tag-green-fg); }
.chip:nth-of-type(5n+3) { background: var(--tag-yellow-bg); color: var(--tag-yellow-fg); }
.chip:nth-of-type(5n+4) { background: var(--tag-pink-bg);   color: var(--tag-pink-fg); }
.chip:nth-of-type(5n+5) { background: var(--tag-purple-bg); color: var(--tag-purple-fg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- buttons / links ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: var(--fg);
  background: var(--chip);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 42px;
  transition: background var(--dur-fast) ease, transform var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.btn:hover { background: var(--hover); transform: translateY(-1px); }
.btn.primary { background: var(--fg); color: var(--bg); }
.btn.primary:hover { opacity: 0.85; background: var(--fg); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.accent:hover { opacity: 0.9; background: var(--accent); }

.link-arrow {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; color: var(--fg);
  font-weight: 500;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: border-color var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.link-arrow:hover { border-color: var(--fg-soft); }
.link-arrow svg { width: 12px; height: 12px; transition: transform var(--dur-fast) var(--ease); }
.link-arrow:hover svg { transform: translate(2px, -2px); }

/* round black icon-button, Notion feature-card arrow */
.arrow-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform var(--dur-fast) var(--ease);
}
.arrow-btn svg { width: 14px; height: 14px; }
a:hover > .arrow-btn, .card:hover .arrow-btn { transform: translate(2px, -2px); }

/* ---------- card ---------- */
.card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-l);
  padding: var(--sp-5);
  background: var(--bg-card);
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }

/* ---------- utility ---------- */
.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;
}
hr.rule { border: 0; border-top: 1px solid var(--rule); margin: var(--sp-7) 0; }

/* ---------- scroll reveal (progressive enhancement, see reveal.js) ---------- */
[data-reveal] { transition: opacity .6s var(--ease), transform .6s var(--ease); }
[data-reveal].pre-reveal { opacity: 0; transform: translateY(18px); }
[data-reveal-group] > [data-reveal]:nth-child(2)  { transition-delay: .06s; }
[data-reveal-group] > [data-reveal]:nth-child(3)  { transition-delay: .12s; }
[data-reveal-group] > [data-reveal]:nth-child(4)  { transition-delay: .18s; }
[data-reveal-group] > [data-reveal]:nth-child(5)  { transition-delay: .24s; }

/* ---------- mobile shell ---------- */
@media (max-width: 640px) {
  .page { padding: 20px 18px 32px; }
  .top { row-gap: 12px; column-gap: 12px; }
  .brand { font-size: 17px; }
  /* Row 1: brand + toggle (toggle pushed to the right edge).
     Row 2: nav, full width, wrapping its own links as needed. */
  .theme-toggle { order: 2; margin-left: auto; }
  .nav { order: 3; width: 100%; margin-left: 0; gap: 12px 18px; }
  .nav a { font-size: 14px; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: 10px; margin-top: var(--sp-7); }
}

/* ---------- print ---------- */
@media print {
  .theme-toggle, .site-footer .fsocial, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
  .card { border-color: #999; box-shadow: none; }
}
