/* Reset + primitives shared by every screen. */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  /* Stop iOS from resizing text when the tablet is rotated. */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  overscroll-behavior: none;          /* no pull-to-refresh under small fingers */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;          /* kills the 300ms double-tap zoom delay */
}

/* Kid surfaces must never scroll or let a stray swipe leave the activity. */
body[data-surface="kid"] {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

body[data-surface="parent"] {
  overflow-y: auto;
}

.app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

h1, h2, h3, p { margin: 0; }

.noscript {
  padding: var(--s-5);
  font-size: var(--t-lg);
  text-align: center;
}

/* Overlays that never take pointer events. */
.pet-layer, .fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}
.fx-layer { z-index: 60; overflow: hidden; }

/* --- Shared primitives ------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--bg-raised);
  border: 2px solid var(--border);
  font-weight: 600;
  transition: transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(2px) scale(0.98); }

.btn--primary {
  background: var(--c-sun);
  border-color: var(--c-sun-deep);
  color: var(--c-ink);
  box-shadow: var(--edge);
}
.btn--primary:active { box-shadow: 0 2px 0 rgba(0,0,0,0.14); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-soft); }

.btn--big {
  min-height: var(--tap-min);
  font-size: var(--t-lg);
  padding: var(--s-4) var(--s-7);
}

.stack   { display: flex; flex-direction: column; gap: var(--s-4); }
.row     { display: flex; align-items: center; gap: var(--s-3); }
.spacer  { flex: 1; }
.center  { display: grid; place-items: center; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Focus is for keyboard users on the parent page; kids use touch only. */
:focus-visible {
  outline: 3px solid var(--c-sky);
  outline-offset: 3px;
}

/* --- Motion preference -------------------------------------------------
   We do not blanket-kill animation, because the pet's reactions carry
   meaning. pet.css handles that case specifically; here we only flatten
   decorative movement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
