/* Reset, page chrome and the primitives every section relies on:
   the .wrap gutter, focus/skip-link affordances, the reveal animation
   and the floating back-to-top button. */

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

/* Smooth scroll only when motion is OK */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* clip, not hidden: hidden turns <body> into a scroll container, which stops
     position: sticky working for the top bar. */
  overflow-x: clip;
}
/* Only cross-fade once the page is up, so the initial theme paint is instant. */
html.theme-ready body { transition: background-color .4s ease, color .4s ease; }
a { color: inherit; text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--accent); }
::selection { background: var(--accent); color: var(--paper); }

/* Focus styles for keyboard users */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Announced to screen readers, invisible on screen */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 999;
  padding: .75rem 1.25rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .25; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  position: relative;
  z-index: 1;
}


/* ---------- Reveal anim ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}


/* ---------- Scroll-to-top ----------
   Same round hairline shape as the bar buttons in the header, so the floating
   control reads as part of the same set. It sits over the text rather than in a
   bar of its own, so it takes a tinted, blurred pane and stops just short of
   full opacity while idle; hover settles it to solid. */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  width: 44px; height: 44px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, background .25s var(--ease-settle),
              border-color .25s var(--ease-settle), color .25s var(--ease-settle),
              transform .25s var(--ease-settle);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .back-to-top {
    background: color-mix(in srgb, var(--paper) 55%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    backdrop-filter: blur(14px) saturate(1.4);
  }
}
.back-to-top.visible {
  opacity: .82;
  pointer-events: auto;
}
.back-to-top.visible:hover,
.back-to-top.visible:focus-visible {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-3px);
}
@media (prefers-reduced-motion: reduce) {
  .back-to-top.visible:hover,
  .back-to-top.visible:focus-visible { transform: none; }
}
.back-to-top svg { width: 16px; height: 16px; }

