/**
 * Modern CSS Reset — Composite
 * Sources:
 *   - Josh W. Comeau (https://www.joshwcomeau.com/css/custom-css-reset/) — March 2025 edition
 *   - Andy Bell (https://bell.bz/a-modern-css-reset/)
 *   - Selected additions from @acab/reset.css
 * License: MIT / public domain (all sources)
 *
 * Philosophy:
 *   - Remove browser inconsistencies
 *   - Preserve useful defaults (list markers, etc.)
 *   - Enable modern CSS features (interpolate-size, text-wrap)
 *   - Respect user accessibility preferences
 */

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

/* ─── Remove default margin ───────────────────────────────────── */
/* Josh's approach: remove margin from all except dialog */
*:not(dialog) {
  margin: 0;
}

/* Andy's approach for headings + typographic elements specifically */
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
  margin-block-end: 0;
}

/* ─── Enable CSS keyword animations (height: auto, etc.) ───────── */
@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

/* ─── Root / scroll ───────────────────────────────────────────── */
html {
  /* Prevent text size adjustment on orientation change (iOS) */
  -webkit-text-size-adjust: 100%;
  /* Smoother scrolling when JS triggers anchor jumps */
  scroll-behavior: smooth;
}

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

/* ─── Body defaults ───────────────────────────────────────────── */
body {
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport units for mobile */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeSpeed;
}

/* ─── Media elements ──────────────────────────────────────────── */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* ─── Form elements ───────────────────────────────────────────── */
input,
button,
textarea,
select {
  font: inherit;
}

/* ─── Text wrapping ───────────────────────────────────────────── */
p {
  text-wrap: pretty;  /* prevents orphans */
}

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance; /* distributes heading lines evenly */
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word; /* prevents text overflow on long words/URLs */
}

/* ─── Links ───────────────────────────────────────────────────── */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* ─── Lists ───────────────────────────────────────────────────── */
/* Only remove list styles when a role or class is applied */
ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

/* ─── Tables ──────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ─── Stacking context isolation ──────────────────────────────── */
/* Prevents z-index leakage from React/Next.js root elements */
#root,
#__next {
  isolation: isolate;
}

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

/* ─── Hidden attribute ─────────────────────────────────────────── */
[hidden] {
  display: none !important;
}

/* ─── Focus visible ────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}
