/* ──────────────────────────────────────────────────────────────
   Modern Reset & Base – “Best reset.css ever seen”
   - Low specificity via :where(...)
   - Sensible defaults for typography, media, forms
   - Accessible focus styles & reduced-motion support
   - Dark-mode aware via color-scheme
   - Framework-friendly (doesn’t nuke everything)
   ---------------------------------------------------------------- */

/* 1) Universal box model + sane defaults */
:where(*, *::before, *::after) {
  box-sizing: border-box;
}

/* 2) Root & document */
:where(html) {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  line-height: 1.5;
  tab-size: 4;
  color-scheme: auto; 
}

:where(body) {
  margin: 0;
  min-height: 100dvh; 
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 3) Typography basics */
:where(p, h1, h2, h3, h4, h5, h6, figure, blockquote, dl, dd) {
  margin: 0;
}

:where(h1, h2, h3, h4, h5, h6) {
  text-wrap: balance;
}

:where(p) {
  text-wrap: pretty;
}

:where(b, strong) {
  font-weight: bolder;
}

:where(code, kbd, samp, pre) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  font-size: 1em;
}

/* 4) Links */
:where(a) {
  color: inherit;
  text-decoration: none;
}
:where(a:where(:hover)) {
  text-decoration: underline;
}

/* 5) Media elements */
:where(img, svg, video, canvas, audio, iframe, embed, object) {
  display: block;
  max-width: 100%;
}
:where(img, video) {
  height: auto;
}
:where(svg) {
  vertical-align: middle;
  overflow: visible; 
}

/* 6) Forms */
:where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
  margin: 0;
}
:where(button) {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
:where(textarea) {
  resize: vertical;
}
:where(label) {
  cursor: pointer;
}
:where(input[type="search"]) {
  -webkit-appearance: textfield;
  appearance: textfield;
  outline-offset: -2px;
}
:where(::placeholder) {
  opacity: 0.7;
}

/* 7) Tables & lists */
:where(table) {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}
:where(ul[role="list"], ol[role="list"]) {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 8) Structural elements */
:where(fieldset) {
  margin: 0;
  padding: 0;
  border: 0;
}
:where(hr) {
  height: 0;
  color: inherit;
  border: 0;
  border-top: 1px solid currentColor;
  opacity: 0.2;
}
:where([hidden]) {
  display: none !important;
}
:where(#root, #__next) {
  isolation: isolate; 
}

/* 9) Focus styles – accessible, minimal specificity */
:where(:focus-visible) {
  outline: max(2px, 0.12em) solid currentColor;
  outline-offset: 2px;
}
:where(:focus) {
  outline: none; 
}

/* 10) Text overflow & long words */
:where(*) {
  overflow-wrap: break-word;
}

/* 11) Motion reduction */
@media (prefers-reduced-motion: reduce) {
  :where(html:focus-within) {
    scroll-behavior: auto !important;
  }
  :where(*), :where(*::before), :where(*::after) {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 12) Print-friendly tweaks */
@media print {
  :where(img, svg) {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
  :where(a) {
    text-decoration: underline;
  }
  :where(pre, code) {
    white-space: pre-wrap;
  }
}

/* 13) Optional: reduce default form element rounding inconsistencies */
:where(button, input, select, textarea) {
  border-radius: 0.375rem; 
}

/* 14) Optional: ensure clickable areas aren’t tiny on touch */
@supports (touch-action: manipulation) {
  :where(button, [role="button"], input[type="button"], input[type="submit"]) {
    touch-action: manipulation;
  }
}
