/* Credit to https://cr0x.net/en/modern-css-reset-forms-media/ */

/* 1) Box sizing: make width/height math boring */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 2) Remove default margin where it’s harmful, keep where it’s useful.
   We choose to clear body margin; content margins are a separate layer. */
html, body {
  margin: 0;
  padding: 0;
}

/* 3) Sensible root defaults */
html {
  /* Keep text scaling on mobile sane; do not disable user scaling behaviors */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Improve readability without taking control away from components */
  line-height: 1.5;
  /* Respect user’s font settings; set a system-first fallback */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

/* 4) Body inherits root typography, but doesn’t force size.
   Apps can set font-size at the theme layer. */
body {
  font: inherit;
  color: CanvasText;
  background: Canvas;
}

/* 5) Media defaults: responsive by default, avoid overflow */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* 6) Avoid “mystery inline gap” with media inside text flows when needed.
   If you prefer inline images in rich text, override at the component level. */
img {
  vertical-align: middle;
}

/* 7) Forms: inherit fonts and avoid odd line-height defaults */
input, button, textarea, select {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

/* 8) Make buttons consistent without killing native behavior */
button, [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
}

/* 9) Textarea: prevent horizontal resize that breaks layouts */
textarea {
  resize: vertical;
}

/* 10) Make sure hidden attribute actually hides */
[hidden] {
  display: none !important;
}

/* 11) Improve focus without removing it.
   Use focus-visible when supported; fall back to focus. */
:focus-visible {
  outline: 2px solid Highlight;
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* 12) Reduce motion for users who ask for it */
@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;
  }
}
