/* ==========================================================================
   Base — reset, document defaults, and the shared animation vocabulary.
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  font-weight: 600;
}

main {
  display: flex;
  width: 100%;
  flex-direction: column;
}

::selection {
  background-color: color-mix(in oklab, var(--foreground) 85%, transparent);
  color: var(--background);
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
html {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--foreground) 20%, transparent) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 9999px;
  background-color: color-mix(in oklab, var(--foreground) 20%, transparent);
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in oklab, var(--foreground) 35%, transparent);
}

/* Icons are sized by font-size; width/height track it via `1em`, so every
   rule below only needs to set font-size. */
iconify-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 0;
}

/* ── Keyframes ──────────────────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ping {

  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.95);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes anim-pop {
  from {
    opacity: 0;
    transform: scale(.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes anim-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Entrance utilities ─────────────────────────────────────────────────── */
/* Hero elements animate on load; `--d` staggers them. */
.anim-pop {
  animation: anim-pop .5s ease both;
}

.anim-up {
  animation: anim-up .5s ease both;
  animation-delay: var(--d, 0s);
}

/* Everything below the fold animates when scrolled into view. `is-in` is
   added by the IntersectionObserver in js/main.js. */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .5s ease, transform .5s ease;
}

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

/* Children of a [data-stagger] container fade in one after another once their
   containing .reveal lands. `--i` is set per child by js/main.js.
   Opacity only — these elements own their own transforms (card hover lift,
   icon nudge) and a transform here would fight them. */
.stagger {
  opacity: 0;
  transition: opacity .45s ease;
}

.is-in .stagger {
  opacity: 1;
  transition-delay: calc(var(--i, 0) * 55ms);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .avatar-ring,
  .ping-wave {
    animation: none;
  }

  .anim-pop,
  .anim-up {
    animation: none;
    opacity: 1;
    transform: none;
  }

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

  .stagger {
    opacity: 1;
    transition: none;
  }

  .theme-toggle .is-switching {
    animation: none;
  }
}
