/* @layer reset — modern cascade reset */

@layer reset {

  /* ─────────────────────────────────────────────
     BOX MODEL
     Inherit from :root so components can override locally
     without breaking the cascade.
     ───────────────────────────────────────────── */

  *,
  *::before,
  *::after {
    box-sizing: inherit;
  }

  :root {
    box-sizing: border-box;
  }

  /* ─────────────────────────────────────────────
     DOCUMENT BASE
     Set from tokens — no bare values.
     ───────────────────────────────────────────── */

  html {
    /* Fluid text rendering */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-synthesis: none;

    /* Smooth scroll only when user has not requested reduced motion */
    scroll-behavior: auto;

    /* Tab-size for code blocks, if ever used */
    tab-size: 4;
  }

  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  body {
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    /* Prevent horizontal overflow from rogue elements */
    overflow-x: hidden;
  }

  /* ─────────────────────────────────────────────
     TYPOGRAPHY RESET
     Remove UA margins that fight the layout system.
     ───────────────────────────────────────────── */

  h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: var(--leading-tight);
    overflow-wrap: break-word;
  }

  p, blockquote, figure {
    margin: 0;
    overflow-wrap: break-word;
  }

  /* ─────────────────────────────────────────────
     LISTS
     WAI pattern: preserve semantics when list-style is removed.
     role="list" must be added in HTML when list-style is none.
     ───────────────────────────────────────────── */

  ul, ol {
    margin: 0;
    padding: 0;
  }

  /* WAI pattern: scope list-style removal to elements where role="list" is
     declared in HTML. VoiceOver on Safari strips list semantics when
     list-style: none is applied without the role attribute. */
  ul[role="list"],
  ol[role="list"] {
    list-style: none;
  }

  /* ─────────────────────────────────────────────
     MEDIA
     Prevent overflow; preserve aspect ratio.
     ───────────────────────────────────────────── */

  img,
  video,
  svg,
  canvas,
  iframe {
    display: block;
    max-inline-size: 100%;
  }

  img {
    /* Prevent bottom gap from inline baseline */
    vertical-align: middle;
  }

  /* ─────────────────────────────────────────────
     FORMS
     Normalize across UA stylesheets.
     ───────────────────────────────────────────── */

  button,
  input,
  select,
  textarea {
    /* Inherit font — UA never does this by default */
    font: inherit;
    color: inherit;
    margin: 0;
  }

  button {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
  }

  /* Remove default appearance for number/search inputs */
  input[type="number"] {
    -moz-appearance: textfield;
  }

  input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
  }

  textarea {
    resize: vertical;
  }

  fieldset {
    border: none;
    margin: 0;
    padding: 0;
  }

  legend {
    padding: 0;
  }

  /* ─────────────────────────────────────────────
     ANCHORS
     Remove UA styling; components apply their own.
     ───────────────────────────────────────────── */

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

  /* ─────────────────────────────────────────────
     TABLES
     ───────────────────────────────────────────── */

  table {
    border-collapse: collapse;
    border-spacing: 0;
  }

  /* ─────────────────────────────────────────────
     DIALOG
     Remove UA default styles for native dialog.
     ───────────────────────────────────────────── */

  dialog {
    padding: 0;
    border: none;
    background: none;
    max-inline-size: 100%;
    max-block-size: 100%;
  }

  /* ─────────────────────────────────────────────
     REDUCED MOTION
     System-level override. Placed in reset so it
     wins against any layer below utilities.
     ───────────────────────────────────────────── */

  @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;
    }
  }

  /* ─────────────────────────────────────────────
     FOCUS VISIBLE
     Global ring: accent color, never invisible.
     :focus:not(:focus-visible) suppresses mouse
     focus rings without hiding keyboard rings.
     ───────────────────────────────────────────── */

  :focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
  }

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

  /* ─────────────────────────────────────────────
     SELECTION
     Brand-consistent text selection color.
     ───────────────────────────────────────────── */

  ::selection {
    background-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
    color: var(--color-text-primary);
  }

} /* @layer reset */
