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

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur-slow) var(--ease-out), color var(--dur-slow) var(--ease-out);
}

body > main {
  flex: 1 0 auto;
}

body:has([popover]:popover-open:not(#toast-region)) {
  overflow: hidden;
}

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

img,
svg {
  display: block;
  max-width: 100%;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 800;
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--action-text);
  text-underline-offset: 3px;
  transition: color var(--dur-fast) ease;
}

a:hover {
  color: var(--action-hover);
}

:root[data-theme="dark"] a:hover {
  color: var(--green-200);
}

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

button {
  cursor: pointer;
}

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

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

.section {
  padding-block: var(--space-12);
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--action-text);
}

.section-kicker::before {
  content: "";
  width: 1.5rem;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--brand);
}

.page-header {
  padding-block: calc(var(--nav-height) + var(--space-12)) var(--space-6);
}

.page-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-title {
  font-size: var(--fs-2xl);
}

.page-lead {
  max-width: 40rem;
  margin-top: var(--space-3);
  color: var(--text-muted);
  font-size: var(--fs-md);
}

/* ---------- Utilities ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hide {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

/* ---------- Scroll reveal (only when JS is available) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 80ms);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Cross-page transitions (progressive enhancement) ---------- */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.28s;
  animation-timing-function: var(--ease-out);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgb(0 170 19 / 0.5); }
  100% { box-shadow: 0 0 0 10px rgb(0 170 19 / 0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  to { background-position-x: -200%; }
}

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

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}
