*,
::before,
::after {
  /* Prevent padding and border from affecting element width */
  /* https://github.com/jensimmons/cssremedy/issues/4 */
  box-sizing: border-box;

  /* Allow adding a border with just a border-width */
  /* https://github.com/tailwindlabs/tailwindcss/pull/116 */
  border-width: 0;
  border-style: solid;
}

html {
  /* Prevent overflow in code blocks */
  tab-size: 2;

  /* Prevent overflow caused by long words if all other methods fail */
  overflow-wrap: break-word;

  /* Prevent erroneous text scaling in iOS Safari */
  /* https://kilianvalkhof.com/2022/css-html/your-css-reset-needs-text-size-adjust-probably/ */
  -webkit-text-size-adjust: 100%;
}

body {
  /* Remove space around edges */
  margin: 0;
}

hr {
  /* Ensure visibility */
  border-top-width: 1px;
}

pre {
  /* Prevent overflow */
  white-space: pre-wrap;
}

u {
  /* Valid use cases are usually indicated by a wavy underline */
  /* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/u#usage_notes */
  text-decoration-style: wavy;
}

/* https://github.com/jensimmons/cssremedy/issues/14 */
img,
iframe,
embed,
object,
video,
audio,
svg,
canvas {
  /* Block display is usually what we want */
  display: block;

  /* Prevent overflow */
  max-width: 100%;

  /* Remove strange space-below when inline */
  vertical-align: middle;
}

/* https://github.com/jensimmons/cssremedy/issues/14 */
img,
video,
svg {
  /* Preserve aspect ratio when the height attribute is set */
  height: auto;
}

audio {
  /* Fill available space instead of using a fixed width */
  width: 100%;
}

/* https://github.com/jensimmons/cssremedy/issues/39 */
table {
  /* Prevent double borders */
  border-collapse: collapse;

  /* Use equal-width numerals */
  font-variant-numeric: tabular-nums;
}

textarea {
  /* Constrain resizing to the block direction */
  resize: vertical;
  resize: block;
}

[hidden]:not([hidden="until-found"]),
audio:not([controls]) {
  /* Prioritize default behavior over custom styles above */
  display: none;
}
