/* ==========================================================================
   Base — reset, typography, global states
   ========================================================================== */
@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color-scheme: light;
    scrollbar-gutter: stable;
    scroll-padding-top: calc(var(--header-h) + var(--nav-h) + var(--space-4));
    hanging-punctuation: first last;
  }

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

  /* Overlays (drawers, modals, search) lock page scroll without JS */
  html:has(dialog[open]:modal) {
    overflow: hidden;
  }

  body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    font-weight: var(--fw-regular);
    line-height: var(--lh-body);
    font-kerning: normal;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
  }

  main {
    flex: 1 0 auto;
    display: block;
  }

  /* ---- Media ---- */
  img,
  picture,
  video,
  canvas {
    display: block;
    max-width: 100%;
    height: auto;
  }

  img {
    font-style: italic; /* alt text styling while loading */
    background-color: var(--surface-3);
  }

  svg {
    flex-shrink: 0;
  }

  /* ---- Headings: editorial serif, sentence case, never uppercase ---- */
  h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
    letter-spacing: var(--tracking-display);
    color: var(--heading);
    text-wrap: balance;
    overflow-wrap: break-word;
  }

  h1 { font-size: var(--fs-3xl); line-height: var(--lh-tight); font-weight: var(--fw-light); }
  h2 { font-size: var(--fs-2xl); line-height: 1.12; font-weight: var(--fw-light); }
  h3 { font-size: var(--fs-xl); }
  h4 { font-size: var(--fs-lg); }
  h5 { font-size: var(--fs-md); font-family: var(--font-sans); font-weight: var(--fw-medium); letter-spacing: 0; }
  h6 { font-size: var(--fs-base); font-family: var(--font-sans); font-weight: var(--fw-semibold); letter-spacing: 0; }

  p,
  ul,
  ol,
  dl,
  figure,
  blockquote {
    margin: 0;
  }

  p {
    text-wrap: pretty;
  }

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

  strong, b { font-weight: var(--fw-semibold); }

  small { font-size: var(--fs-xs); }

  /* ---- Links ---- */
  a {
    color: var(--link);
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
    transition: color var(--dur-fast) var(--ease-out), text-decoration-color var(--dur-fast) var(--ease-out);
  }

  a:hover {
    color: var(--link-hover);
    text-decoration-color: currentColor;
  }

  /* ---- Focus ---- */
  :focus {
    outline: none;
  }

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

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

  /* ---- Form controls inherit type ---- */
  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
  }

  button {
    cursor: pointer;
  }

  button:disabled {
    cursor: not-allowed;
  }

  textarea {
    resize: vertical;
  }

  ::placeholder {
    color: var(--text-muted);
    opacity: 1;
  }

  /* ---- Tables ---- */
  table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
  }

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

  th {
    font-weight: var(--fw-medium);
    color: var(--text-soft);
  }

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

  address {
    font-style: normal;
  }

  kbd {
    font-family: var(--font-sans);
    font-size: 0.8em;
    padding: 0.05em 0.45em;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
  }

  dialog {
    color: inherit;
  }

  [hidden] {
    display: none !important;
  }

  /* ---- Accessibility helpers (WooCommerce uses .screen-reader-text) ---- */
  .sr-only,
  .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: fixed;
    inset-block-start: var(--space-3);
    inset-inline-start: var(--space-3);
    z-index: calc(var(--z-toast) + 1);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-pill);
    background: var(--ink);
    color: var(--paper);
    font-weight: var(--fw-medium);
    text-decoration: none;
    translate: 0 -200%;
    transition: translate var(--dur) var(--ease-out);
  }

  .skip-link:focus-visible {
    translate: 0 0;
    color: var(--paper);
  }

  /* ---- Reduced motion ---- */
  @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;
    }
  }
}
