/*
 * Cortex Reset
 * Modern CSS reset based on CSS Zero / Andy Bell's approach
 */

@layer reset {
  /*
    1. Use border-box for all elements
    2. Remove default margins and padding
    3. Reset borders
  */
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid;
  }

  /* Sensible defaults for root */
  html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    font-family: var(--font-sans);
    -webkit-tap-highlight-color: transparent;
  }

  body {
    line-height: inherit;
  }

  /* Headings reset */
  h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
  }

  /* Links reset */
  a {
    color: inherit;
    text-decoration: inherit;
  }

  /* Strong */
  b, strong {
    font-weight: bolder;
  }

  /* Code */
  code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 1em;
  }

  small {
    font-size: 80%;
  }

  /* Tables */
  table {
    text-indent: 0;
    border-color: inherit;
    border-collapse: collapse;
  }

  /* Lists */
  ol, ul, menu {
    list-style: none;
  }

  /* Media elements */
  img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    vertical-align: middle;
  }

  img, video {
    max-inline-size: 100%;
    block-size: auto;
  }

  /* Form elements */
  button, input, select, optgroup, textarea {
    font: inherit;
    font-feature-settings: inherit;
    font-variation-settings: inherit;
    letter-spacing: inherit;
    color: inherit;
    border-radius: 0;
    background-color: transparent;
  }

  ::placeholder {
    opacity: 1;
    color: var(--color-ink-faint);
  }

  textarea {
    resize: vertical;
  }

  /* Buttons */
  button,
  input:where([type='button'], [type='reset'], [type='submit']) {
    appearance: button;
  }

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

  /* Turbo frames */
  turbo-frame {
    display: contents;
  }

  /* Rails field errors */
  .field_with_errors {
    display: contents;
  }

  /* Modal scroll lock */
  body:has(dialog:modal) {
    overflow: hidden;
  }

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