/* Overrides base.css in the same layer, so it must sort after it: stylesheets load alphabetically. */
@layer base {
  body {
    line-height: 1.375;
    grid-template-columns: 1fr min(90rem, 98%) 1fr;
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    interpolate-size: allow-keywords;
    max-inline-size: 100vw;
    scroll-behavior: auto;
    text-rendering: optimizeLegibility;

    >header {
      border-bottom: none;
      padding: 0;

      > :only-child {
        margin-block-start: 0;
      }
    }

    >footer {
      border-top: none;
    }
  }

  main {
    padding-top: 0;
  }

  h1 {
    text-align: center;
    margin-block: 0;
  }

  /* Navigation */
  .site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.5rem;
    padding-block: 0.25rem;
  }

  .site-search {
    flex: 0 1 20rem;
    align-self: center;

    & .input {
      font-size: 1rem;
      margin-block-end: 0;
    }
  }

  .nav__brand {
    display: inline-flex;
    align-items: center;
  }

  .nav__logo {
    display: block;
    height: 2.5rem;
    width: auto;
  }

  header nav,
  footer nav {
    font-size: 1.25rem;
    line-height: 2;
    padding: 0;

    :is(ul, ol) {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      gap: 0 0.25rem;
      list-style: none;
      margin: 0;
      padding: 0;
    }

    a {
      margin: 0 0.5rem;
      border: none;
      font-weight: 900;

      &:hover,
      &.current,
      &[aria-current="page"],
      &[aria-current="true"] {
        background: transparent;
      }
    }

    @media (width <=720px) {
      font-size: 0.9rem;
    }
  }

  @media (width <=720px) {
    .site-header {
      flex-direction: column;
      gap: 0.5rem;
    }

    .site-search {
      flex-basis: auto;
      align-self: stretch;
    }
  }

  /* Width containers */
  .w-small {
    max-width: 40rem;
    margin-inline: auto;
    width: 100%;
  }

  .w-medium {
    max-width: 65rem;
    margin-inline: auto;
    width: 100%;
  }

  .toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-block: 0.25rem;
  }

  /* Full-width form fields */
  form :is(textarea,
    select,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="url"],
    input[type="search"]),
  .input {
    width: 100%;
    font-size: 1.5rem;
  }

  p {
    margin: 1rem 0;
  }

  form li {
    margin-block: 0.25rem;
  }

  /* Field spacing */
  form label {
    margin-block-start: 1rem;
  }

  form label:first-child,
  form>label:first-of-type {
    margin-block-start: 0;
  }

  .for-screen-reader {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;

    &:focus {
      position: static;
      width: auto;
      height: auto;
      overflow: visible;
      clip-path: none;
      white-space: normal;
    }
  }

  /* Turbo */
  turbo-frame,
  turbo-cable-stream-source {
    display: contents;

    >* {
      pointer-events: auto;
    }
  }

  @media (width >=720px) {
    article {
      padding-inline: 3rem;
    }
  }

  html[data-theme="light"] {
    color-scheme: light;

    :is(img, video) {
      opacity: 1;
    }
  }

  html[data-theme="dark"] {
    color-scheme: dark;

    :is(img, video) {
      opacity: 0.8;
    }
  }

}