/* ==========================================================================
   Base: reset, typography, accessibility helpers, motion preferences
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1.25rem);
  interpolate-size: allow-keywords;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

main { flex: 1 0 auto; outline: none; }

img, svg, video, picture { display: block; max-width: 100%; }
img { height: auto; }
picture { width: 100%; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.12;
  color: var(--text);
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 12 5 5;
  text-wrap: balance;
}

p { margin: 0 0 1em; text-wrap: pretty; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 10 4 4; }
p:last-child { margin-bottom: 0; }

:where(ul[role="list"], ol[role="list"]) { list-style: none; margin: 0; padding: 0; }

a { color: var(--link); text-decoration-thickness: .08em; text-underline-offset: .2em; }
a:hover { text-decoration-color: var(--accent); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

address { font-style: normal; }
dl, dd { margin: 0; }
figure { margin: 0; }
mark { background: var(--accent-soft); color: inherit; }
code { font-family: var(--font-mono); font-size: .92em; padding: .1em .35em; border-radius: var(--radius-xs); background: var(--surface-2); }

::selection { background: var(--lime-300); color: var(--navy-900); }

/* Focus: visible, high-contrast, never removed */
:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}
:focus:not(:focus-visible) { outline: none; }

/* Icons */
.icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  vertical-align: -.22em;
}

/* Helpers */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  top: .75rem; left: .75rem;
  z-index: 200;
  padding: .75rem 1.1rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus { transform: none; }

[hidden] { display: none !important; }

/* Scroll-reveal (only when JS runs; content is visible otherwise) */
.js [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition:
    opacity .75s var(--ease-out) calc(var(--i, 0) * 70ms),
    transform .9s var(--ease-out) calc(var(--i, 0) * 70ms);
}
.js [data-reveal].is-revealed { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
}

/* Crisp theme switches (JS adds this class for a single frame) */
.theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }
