/* ==========================================================================
   base.css — Reset, global typography, and shared primitives
   Owns: element normalization, body defaults, focus, a11y helpers.
   Does NOT own component styling (that's app.css / preview.css).
   ========================================================================== */

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

* {
  margin: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* App shell fills the viewport; internal panes handle their own scroll. */
  min-height: 100dvh;
  min-height: 100vh;
}

/* Media defaults */
img,
svg {
  display: block;
  max-width: 100%;
}

/* Form controls inherit typography instead of the UA defaults */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

textarea {
  resize: vertical;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Focus: visible only for keyboard users ---- */
:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

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

/* ==========================================================================
   Accessibility helpers
   ========================================================================== */

/* Visually hidden but available to assistive tech */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link: off-screen until focused */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-radius: var(--radius-md);
  transform: translateY(-150%);
  transition: transform var(--transition-fast);
}

.skip-link:focus {
  transform: translateY(0);
  text-decoration: none;
}

/* ==========================================================================
   Motion preferences — honor reduced-motion globally
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
