/* ═══════════════════════════════════════════════════════════════
   RESET — Who's That Fact? V2
   ═══════════════════════════════════════════════════════════════
   Modern CSS reset + accessibility defaults + iOS fixes.
   ═══════════════════════════════════════════════════════════════ */

/* Box model */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Root */
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Body */
body {
  min-height: 100vh;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* Safe area for notched iPhones (iPhone X+)
     Designer's Intent: Content never hides behind the notch or
     home indicator bar. */
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

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

/* Beach ball canvas — Three.js controls its own sizing via renderer.setSize();
   the reset's max-width can squish the canvas when it disagrees with the
   inline dimensions Three.js applies, producing a flattened ball. */
#beachBallBg,
#beachBallFg {
  max-width: none;
}

/* Form reset */
input, button, textarea, select {
  font: inherit;
  color: inherit;
}

/* Remove default button styling */
button {
  background: none;
  border: none;
  cursor: pointer;
}

/* Eliminate 300ms tap delay on touch devices
   Designer's Intent: iOS Safari adds a 300ms delay on taps to
   detect double-taps. This made V1 buttons feel sluggish on
   phones. touch-action: manipulation disables it. */
a, button, input, select, textarea,
[role="tab"], [role="button"], [role="listitem"] {
  touch-action: manipulation;
}

/* Minimum touch target size — WCAG 2.5.8 / iOS HIG
   Designer's Intent: The critique found .btn-sm at ~28px height,
   well below the 44px iOS minimum. This ensures all interactive
   elements meet the target regardless of font size or padding. */
button, [role="button"], [role="tab"] {
  min-height: 44px;
  min-width: 44px;
}

/* ─── Focus Ring ───
   Designer's Intent: Only shows on keyboard navigation (:focus-visible),
   not on mouse clicks. Gold ring matches the brand. 2px offset
   prevents the ring from overlapping button content. */
:focus-visible {
  outline: 2px solid var(--color-gold-500);
  outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Reduced Motion ───
   Designer's Intent: Accessibility isn't optional. Users who enable
   prefers-reduced-motion get a fully functional game with no animation.
   Clippy stays static, wheel shows instant result, confetti is a card.
   The blanket disable handles most cases; individual components add
   specific overrides where needed. */
@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;
  }
}

/* ─── Screen Reader Only ─── */
.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 ─── */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--color-gold-500);
  color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-base);
  z-index: var(--z-skip-link);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: var(--space-4);
}
