/* ==========================================================================
 * WattWisely — reset and element defaults
 * ========================================================================== */

@layer base {

  /* -- Reset -------------------------------------------------------------- */

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

  * { margin: 0; }

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

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

  body {
    font-family: var(--ww-font-sans);
    font-size: var(--ww-step-0);
    line-height: var(--ww-leading-normal);
    color: var(--ww-body);
    background: var(--ww-white);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  img,
  picture,
  video,
  canvas,
  svg {
    display: block;
    max-width: 100%;
  }

  img,
  video { height: auto; }

  input,
  button,
  textarea,
  select { font: inherit; color: inherit; }

  p,
  h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

  /* -- Typography --------------------------------------------------------- */

  h1, h2, h3, h4, h5, h6 {
    color: var(--ww-ink);
    font-weight: var(--ww-weight-bold);
    line-height: var(--ww-leading-tight);
    letter-spacing: -0.02em;
    text-wrap: balance;
  }

  h1 { font-size: var(--ww-step-6); }
  h2 { font-size: var(--ww-step-4); }
  h3 { font-size: var(--ww-step-2); }
  h4 { font-size: var(--ww-step-1); font-weight: var(--ww-weight-semibold); }
  h5,
  h6 { font-size: var(--ww-step-0); font-weight: var(--ww-weight-semibold); }

  p { text-wrap: pretty; }

  p,
  ul,
  ol { max-width: var(--ww-measure); }

  /* A list used as a layout container is not running prose. Without this the
     measure caps the grid itself: the steps component is an <ol class="grid">,
     so on every page using it the row sat 241px narrower than the identical
     <div class="grid"> above it, left-aligned against a centred section. */
  :is(ul, ol):is(.grid, .cluster) { max-width: none; }

  strong { font-weight: var(--ww-weight-semibold); color: var(--ww-ink); }

  small { font-size: var(--ww-step--1); }

  code,
  kbd,
  samp,
  pre { font-family: var(--ww-font-mono); font-size: 0.9em; }

  /* -- Links -------------------------------------------------------------- */

  a {
    color: var(--ww-primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: color var(--ww-motion-fast) var(--ww-motion-ease);
  }

  a:hover { color: var(--ww-primary-hover); }

  /* -- Focus -------------------------------------------------------------- */
  /* 2px ring with a white offset so it reads on both light and dark surfaces. */

  :focus-visible {
    outline: 2px solid var(--ww-focus);
    outline-offset: 2px;
    border-radius: var(--ww-radius-sm);
  }

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

  /* -- Lists -------------------------------------------------------------- */

  ul,
  ol { padding-inline-start: 1.25em; }

  li + li { margin-top: var(--ww-space-2); }

  /* -- Tables ------------------------------------------------------------- */

  table {
    border-collapse: collapse;
    width: 100%;
  }

  th { text-align: left; color: var(--ww-ink); font-weight: var(--ww-weight-semibold); }

  th,
  td {
    padding: var(--ww-space-3) var(--ww-space-4);
    border-bottom: 1px solid var(--ww-border);
  }

  /* -- Anchors ------------------------------------------------------------ */
  /* The header is sticky, so an unadjusted #anchor jump parks the target
     underneath it. Applies to focus-driven scrolling too, not just clicks. */

  [id] { scroll-margin-top: calc(var(--ww-header-h, 4.5rem) + var(--ww-space-5)); }

  /* -- Misc --------------------------------------------------------------- */

  hr {
    border: 0;
    border-top: 1px solid var(--ww-border);
    margin-block: var(--ww-space-8);
  }

  ::selection {
    background: var(--ww-teal-200);
    color: var(--ww-ink);
  }

  /* Skip link — visible only when focused. */
  .skip-link {
    position: absolute;
    left: var(--ww-space-4);
    top: var(--ww-space-4);
    z-index: 200;
    padding: var(--ww-space-3) var(--ww-space-5);
    background: var(--ww-ink);
    color: var(--ww-white);
    border-radius: var(--ww-radius-sm);
    font-weight: var(--ww-weight-semibold);
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform var(--ww-motion-fast) var(--ww-motion-ease);
  }

  .skip-link:focus { transform: translateY(0); color: var(--ww-white); }

  /* Screen-reader-only text. */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}
