/* Silly Scan, on the web. The palette is the app's: cream, ink, coral, sunny, and blue kept
   for the scan line and the Go button only. */

:root {
  --cream: #fff7e8;
  --cream-deep: #ffeecd;
  --ink: #2a2a35;
  --blue: #1e90ff;
  --blue-deep: #0f6fd0;
  --coral: #ff6b5a;
  --sunny: #ffc53d;
  --white: #fffdf8;

  --radius-card: 32px;
  --radius-inner: 18px;
  --touch: 64px;
  --shell: 560px;

  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Segoe UI Variable Display",
    "Nunito", system-ui, -apple-system, "Helvetica Neue", sans-serif;

  --lift: 0 6px 0 rgba(42, 42, 53, 0.12), 0 14px 30px rgba(42, 42, 53, 0.14);
}

* { box-sizing: border-box; }

/* Author rules like `.overlay { display: flex }` outrank the browser's own rule for the
   hidden attribute, so say it once, loudly, and let every phase switch use `hidden`. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--blue);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 0 0 var(--radius-inner) 0;
  font-weight: 800;
  z-index: 40;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
}

/* ---------- hero ---------- */

.hero {
  padding: 22px 20px 14px;
  text-align: center;
  max-width: var(--shell);
  margin: 0 auto;
}

.wordmark {
  font-size: clamp(2.6rem, 13vw, 4.2rem);
  font-weight: 900;
  letter-spacing: -0.035em;
}
.wordmark-silly { color: var(--coral); display: inline-block; transform: rotate(-3deg); }
.wordmark-scan {
  color: var(--ink);
  display: inline-block;
  transform: rotate(2deg);
  position: relative;
}
.wordmark-scan::after {
  content: "";
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: 0.06em;
  height: 6px;
  border-radius: 6px;
  background: var(--blue);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85) inset;
}

.tagline {
  margin-top: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  color: rgba(42, 42, 53, 0.78);
  text-wrap: balance;
}

/* ---------- camera stage ---------- */

.stage-wrap {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 10px 16px 28px;
}

.stage {
  position: relative;
  width: 100%;
  /* Short enough that the picture, the Go button, and the Save buttons all fit on a phone
     screen at once. A kid should never have to scroll to find Go. */
  height: min(52svh, 480px);
  min-height: 320px;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--ink);
  box-shadow: var(--lift);
  isolation: isolate;
}

.stage video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(160deg, var(--cream-deep), var(--cream));
  color: var(--ink);
  z-index: 2;
}

.overlay-emoji { font-size: 3rem; line-height: 1; }
.overlay-title { font-size: 1.5rem; font-weight: 900; }
.overlay-note {
  font-size: 0.98rem;
  font-weight: 600;
  color: rgba(42, 42, 53, 0.72);
  max-width: 30ch;
}
.overlay-start .btn, .overlay-sad .btn { margin-top: 10px; }

.overlay-count {
  background: rgba(42, 42, 53, 0.42);
  backdrop-filter: blur(2px);
}

.count-number {
  font-size: clamp(7rem, 34vw, 11rem);
  font-weight: 900;
  color: var(--white);
  text-shadow: 0 10px 0 rgba(42, 42, 53, 0.25);
  animation: pop 0.75s cubic-bezier(0.22, 1.4, 0.4, 1);
}

@keyframes pop {
  0% { transform: scale(0.3); opacity: 0; }
  45% { transform: scale(1.18); opacity: 1; }
  70% { transform: scale(0.94); }
  100% { transform: scale(1); opacity: 1; }
}

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 3;
  background: rgba(42, 42, 53, 0.72);
  color: var(--white);
  font-weight: 800;
  font-size: 0.92rem;
  padding: 9px 16px;
  border-radius: 999px;
  white-space: nowrap;
}

.stage-cancel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 247, 232, 0.92);
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 900;
  font-family: var(--font);
  cursor: pointer;
}

/* ---------- controls ---------- */

.card {
  margin-top: 14px;
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: var(--lift);
}

.row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.row + .row { margin-top: 12px; }
.row-go { align-items: center; }
.row-actions { flex-wrap: wrap; align-items: stretch; }

.group {
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0;
}
.group legend {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(42, 42, 53, 0.5);
  padding: 0 0 6px 4px;
}

#directionGroup { flex: 2; }
#speedGroup { flex: 3; }

.segmented { display: flex; gap: 6px; }

.chip {
  flex: 1;
  min-width: 0;
  min-height: var(--touch);
  /* The arrow sits above its word rather than beside it, so a narrow phone never has to
     squeeze "Normal" and "Fast" into the same space. */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.15;
  border: 3px solid transparent;
  border-radius: var(--radius-inner);
  background: rgba(42, 42, 53, 0.07);
  color: rgba(42, 42, 53, 0.55);
  font-family: var(--font);
  font-size: clamp(0.82rem, 3.4vw, 0.95rem);
  font-weight: 800;
  cursor: pointer;
  padding: 6px 2px;
  overflow: hidden;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.chip:active { transform: scale(0.96); }
.chip.is-on {
  background: var(--sunny);
  color: var(--ink);
  border-color: rgba(42, 42, 53, 0.85);
}

.btn {
  min-height: var(--touch);
  border: 0;
  border-radius: var(--radius-inner);
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  padding: 14px 22px;
  color: var(--ink);
  background: var(--cream-deep);
  transition: transform 0.12s ease, filter 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.5; cursor: default; }

.btn-icon {
  width: var(--touch);
  min-width: var(--touch);
  padding: 0;
  font-size: 1.5rem;
  background: rgba(42, 42, 53, 0.07);
}

.btn-go {
  flex: 1;
  background: var(--blue);
  color: var(--white);
  min-height: 76px;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  box-shadow: 0 5px 0 var(--blue-deep);
}
.btn-go:active { box-shadow: 0 2px 0 var(--blue-deep); }

.btn-sunny { flex: 1; background: var(--sunny); min-width: 140px; box-shadow: 0 5px 0 #d99f19; }
.btn-sunny:active { box-shadow: 0 2px 0 #d99f19; }
.btn-sunny.is-saved { background: #8fd694; box-shadow: 0 5px 0 #5da962; }

.btn-secondary { background: var(--coral); color: var(--white); box-shadow: 0 5px 0 #d8503f; }

.btn-wide { width: 100%; max-width: 320px; flex: none; }

.result-title {
  font-size: 1.3rem;
  font-weight: 900;
  text-align: center;
  padding-bottom: 12px;
}
.result-note {
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  color: rgba(42, 42, 53, 0.6);
}

/* ---------- page bands ---------- */

.band {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 34px 20px;
}
.band h2 {
  font-size: 1.7rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 18px;
  text-wrap: balance;
}
.band > p {
  font-size: 1.02rem;
  font-weight: 600;
  color: rgba(42, 42, 53, 0.8);
  text-align: center;
  margin-bottom: 14px;
  text-wrap: pretty;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}
.steps li {
  position: relative;
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 20px 20px 20px 74px;
  box-shadow: 0 4px 0 rgba(42, 42, 53, 0.08);
}
.step-number {
  position: absolute;
  left: 18px;
  top: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--white);
  font-size: 1.4rem;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.steps h3 { font-size: 1.15rem; font-weight: 900; margin-bottom: 4px; }
.steps p { font-size: 0.98rem; font-weight: 600; color: rgba(42, 42, 53, 0.75); }

.dad-card {
  background: var(--sunny);
  border-radius: var(--radius-card);
  padding: 26px 22px;
  box-shadow: var(--lift);
}
.dad-card h2 { text-align: left; margin-bottom: 12px; }
.dad-card p { font-weight: 700; font-size: 1rem; }

.promise {
  list-style: none;
  margin: 16px 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.promise li {
  background: rgba(255, 253, 248, 0.75);
  border-radius: var(--radius-inner);
  padding: 12px 14px;
  font-weight: 800;
  font-size: 0.98rem;
}
.dad-signoff { font-style: italic; }

.band-app { text-align: center; }
.btn-app { width: 100%; max-width: 340px; }
.app-note {
  margin-top: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(42, 42, 53, 0.6);
}

.band-privacy p { max-width: 62ch; margin-inline: auto; }

.text-link {
  color: var(--blue-deep);
  font-weight: 800;
  text-underline-offset: 3px;
}

.footer {
  text-align: center;
  padding: 26px 20px 40px;
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(42, 42, 53, 0.6);
  border-top: 3px dashed rgba(42, 42, 53, 0.12);
  margin-top: 10px;
}
.footer p + p { margin-top: 8px; }

/* ---------- wider screens ---------- */

@media (min-width: 760px) {
  :root { --shell: 720px; }
  .hero { padding-top: 48px; }
  .stage { height: 520px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .steps li { padding: 20px; padding-top: 74px; }
  .step-number { top: 20px; left: 20px; }
  .band { padding: 48px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .count-number { animation: none; }
  .btn, .chip { transition: none; }
  .btn:active, .chip:active { transform: none; }
}

/* ---------- privacy policy ---------- */

.legal { text-align: left; }
.legal h2 {
  text-align: left;
  font-size: 1.25rem;
  margin: 26px 0 8px;
}
.legal p, .legal li {
  font-weight: 600;
  font-size: 1rem;
  color: rgba(42, 42, 53, 0.82);
  text-align: left;
  margin-bottom: 10px;
  max-width: 68ch;
}
.legal ul { padding-left: 22px; margin: 0 0 10px; }
.legal-date {
  background: var(--white);
  border-radius: var(--radius-inner);
  padding: 14px 16px;
  font-weight: 700;
}
.legal-back { margin-top: 30px; font-weight: 800; }
