/* ==========================================================================
   BASE — reset, typography, layout utilities
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-height) + 1rem);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  /* prevent content wider than viewport on tiny screens */
  overflow-x: clip;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
body.theme-ready { visibility: visible; }

img, video, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; }
ul, ol { list-style: none; }

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

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

/* ── Headings ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.025em;
  color: var(--text);
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

p { max-width: 68ch; color: var(--text-muted); }

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

/* ── Layout ── */
.container {
  width: min(100% - 2 * var(--gutter), var(--max-width));
  margin-inline: auto;
}

/* ── Utility ── */
.text-accent     { color: var(--accent); }
.text-muted      { color: var(--text-muted); }
.text-mono       { font-family: var(--font-mono); font-size: .8em; letter-spacing: .04em; }
.sr-only, .visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* Bootstrap compat classes used in the HTML */
.d-none    { display: none !important; }
.d-flex    { display: flex !important; }
.gap-3     { gap: .75rem !important; }
.gap-4     { gap: 1rem !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.align-items-center  { align-items: center !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between{ justify-content: space-between !important; }
.justify-content-end    { justify-content: flex-end !important; }
.text-center  { text-align: center !important; }
.text-xl-start{ text-align: start !important; }
.w-100        { width: 100% !important; }

@media (min-width: 768px) {
  .d-lg-inline-flex { display: inline-flex !important; }
}

/* ── Noise grain ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ── Scroll progress bar ── */
#scroll-progress {
  position: fixed; top: 0; left: 0;
  height: 2px; width: 0%;
  background: var(--accent); z-index: 9999;
  transition: width .1s linear;
  box-shadow: 0 0 8px var(--accent);
}

/* ── Skip link ── */
.skip-link {
  position: absolute; top: -100%; left: 1rem;
  padding: .5rem 1rem;
  background: var(--accent); color: #fff;
  border-radius: var(--radius-sm);
  z-index: 10000; font-weight: 600;
  transition: top .2s;
}
.skip-link:focus { top: 1rem; }
