@font-face { font-family: 'Creepster'; src: url('assets/fonts/creepster-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('assets/fonts/fredoka-latin-var.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  /* Minuteman Press Caldwell: white page, green #006341, orange #F26522, gray #333333. */
  --green: #006341;
  --green-dark: #00402a;
  --green-tint: #eaf4ef;
  --orange: #f26522;
  --orange-dark: #d24f12;
  --orange-tint: #fff1e9;
  --ink: #333333;
  --ink-2: #555555;
  --sky: #ffffff; /* the child's sky colour after a scan, as a soft tint */
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: #fff;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- page backdrop: white, with a few bats in soft brand green ---------- */
.sky { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #fff; }
body[data-screen='result'] .sky {
  background: radial-gradient(75% 50% at 50% 50%, color-mix(in srgb, var(--sky) 20%, #fff), #fff 75%);
}
.bat { position: absolute; width: 64px; fill: var(--green); opacity: 0.14; }
.bat-1 { top: 16%; left: -80px; animation: fly 19s linear infinite; }
.bat-2 { top: 9%; left: -80px; width: 40px; animation: fly 27s linear 6s infinite; }

/* ---------- 3D stage ---------- */
#stage {
  position: fixed; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  touch-action: none; display: block;
}
body:not([data-screen='result']) #stage { visibility: hidden; }

/* ---------- layout ---------- */
main { position: relative; z-index: 2; min-height: 100dvh; display: flex; }
.screen {
  width: min(100%, 480px); margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center;
}

.brand { display: inline-flex; }
.brand img { display: block; width: min(64vw, 250px); height: auto; }

.hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero-ghost { transform-box: fill-box; animation: float 3.2s ease-in-out infinite; }
.hero-pumpkin { width: min(64vw, 262px); filter: drop-shadow(0 10px 16px rgba(242, 101, 34, 0.25)); animation: bob 2.6s ease-in-out infinite; }
.hp-face { animation: flicker 3s infinite; }
h1, h2 {
  font-family: 'Creepster', 'Fredoka', fantasy; font-weight: 400; margin: 0; line-height: 1.05;
  color: var(--orange); letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 64, 42, 0.22);
}
h1 { font-size: clamp(2.3rem, 10vw, 3.4rem); }
h2 { font-size: clamp(1.9rem, 8vw, 2.6rem); }
h1:focus, h2:focus, .status:focus, .hint:focus { outline: none; }
.lead { margin: 0; font-size: 1.15rem; color: var(--ink); }
.lead em { font-style: normal; color: var(--green); font-weight: 700; }

/* ---------- buttons ---------- */
/* Button text is 19px+ bold, so white on brand orange meets the large-text contrast bar. */
.actions { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: 100%; }
.row .btn { flex: 1 1 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 22px; border-radius: 999px;
  font: 700 1.2rem/1.1 'Fredoka', system-ui, sans-serif; color: var(--green);
  background: #fff; border: 2px solid var(--green);
  cursor: pointer; text-decoration: none; user-select: none; -webkit-user-select: none;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { background: var(--green-tint); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, input:focus-visible + .btn { outline: 3px solid var(--orange); outline-offset: 3px; }
.btn.primary {
  background: var(--orange); color: #fff; border-color: var(--orange);
  box-shadow: 0 6px 18px rgba(242, 101, 34, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.btn.primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn.big { min-height: 64px; font-size: 1.25rem; width: 100%; }
.btn.small { min-height: 42px; padding: 0 16px; font-size: 1rem; }
.btn svg { width: 26px; height: 26px; flex: none; }
.btn[aria-busy='true'] { opacity: 0.7; pointer-events: none; }
/* The shop's logo on its own, as the link to the shop's site. */
.shop-logo { display: block; padding: 6px 10px; border-radius: 14px; transition: transform 0.12s; }
.shop-logo img { display: block; width: min(190px, 52vw); height: auto; }
.shop-logo:active { transform: scale(0.96); }
.shop-logo:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }

/* ---------- loader + tips ---------- */
.loader { width: 100%; }
.bar { height: 8px; background: var(--green-tint); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), #ff9a5c); transition: width 0.25s; }
.loader[data-state='ready'] .bar { visibility: hidden; }
.loader[data-state='error'] #loader-text { color: #b3261e; }
#loader-text { margin: 8px 0 0; font-size: 0.95rem; color: var(--ink-2); }

.tips { list-style: none; margin: 0; padding: 0; width: 100%; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.tips li { position: relative; padding: 12px 14px 12px 44px; background: var(--green-tint); border-radius: 16px; font-size: 1.05rem; line-height: 1.35; color: var(--ink); }
.tips li::before { content: ''; position: absolute; left: 14px; top: 14px; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ff9a5c, var(--orange)); }
.tips.mini { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tips.mini li { padding: 6px 12px; font-size: 0.9rem; font-weight: 500; color: var(--green-dark); border-radius: 99px; }
.tips.mini li::before { display: none; }

.fine { margin: 0; font-size: 0.9rem; color: var(--ink-2); }
.fine a { color: var(--green); font-weight: 600; }
.credit { margin: 0; max-width: 34em; font-size: 0.85rem; line-height: 1.5; color: var(--ink-2); }
.credit a { color: var(--green); font-weight: 600; }

.banner { width: 100%; background: var(--orange-tint); color: var(--ink); border: 2px solid var(--orange); border-radius: 18px; padding: 14px 16px; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.banner p { margin: 0; }

/* ---------- working ---------- */
.scanframe { position: relative; width: min(74vw, 330px); aspect-ratio: 3 / 4; border-radius: 22px; overflow: hidden; background: #f4f4f4; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18), 0 0 0 3px var(--green); }
.scanframe img { width: 100%; height: 100%; object-fit: cover; }
.sweep { position: absolute; left: 0; right: 0; top: 0; height: 30%; background: linear-gradient(180deg, transparent, rgba(242, 101, 34, 0.45), transparent); animation: sweep 1.5s ease-in-out infinite alternate; }
.status { margin: 0; font-size: 1.3rem; font-weight: 700; min-height: 1.6em; color: var(--green); }

/* ---------- result ---------- */
#result { position: fixed; inset: 0; width: 100%; max-width: none; justify-content: flex-start; gap: 12px; pointer-events: none; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
body[data-screen='result'] main { pointer-events: none; } /* touches reach the 3D canvas */
#result .btn, #result .shop-logo { pointer-events: auto; }
.result-top { width: min(100%, 480px); display: flex; justify-content: space-between; }
.result-actions { margin-top: auto; width: min(100%, 480px); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.result-actions > .btn { width: 100%; }
.hint { margin: 0; padding: 8px 18px; border-radius: 99px; background: var(--green); color: #fff; font-weight: 600; animation: pulse 1.8s ease-in-out infinite; }
.boo {
  position: fixed; top: 20%; left: 50%; z-index: 3; pointer-events: none;
  font-family: 'Creepster', fantasy; font-size: clamp(3.5rem, 16vw, 6rem); color: var(--orange);
  text-shadow: 0 4px 0 var(--green-dark), 0 0 20px rgba(255, 255, 255, 0.9);
  opacity: 0; transform: translate(-50%, 0) scale(0.4);
}
.boo.pop { animation: boo 0.95s ease-out; }
.joke {
  position: fixed; top: 16%; left: 50%; z-index: 3; pointer-events: none;
  width: min(88vw, 420px); margin: 0; padding: 14px 18px; transform: translateX(-50%);
  background: #fff; border: 3px solid var(--green); border-radius: 22px;
  font-size: 1.15rem; line-height: 1.35; text-align: center; color: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.15); animation: joke-in 0.35s ease-out;
}
.joke strong { color: var(--green); }
.joke::after { content: ''; position: absolute; left: 50%; bottom: -14px; width: 24px; height: 24px; background: #fff; border: 3px solid var(--green); border-top: 0; border-left: 0; transform: translateX(-50%) rotate(45deg); }
@keyframes joke-in { from { opacity: 0; transform: translate(-50%, 10px); } }
.boo.long { font-size: clamp(2rem, 9vw, 3.2rem); white-space: nowrap; animation-duration: 1.6s; }

/* ---------- oops ---------- */
.oops-photo { max-width: 100%; max-height: 34vh; border-radius: 14px; border: 3px solid var(--green-tint); }

/* ---------- misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 10;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--green); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); transition: opacity 0.25s, transform 0.25s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.nojs { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; text-align: center; background: #fff; color: var(--ink); font-size: 1.2rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }
@keyframes float { 50% { transform: translateY(-7px) rotate(3deg); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: 0.85; } 50% { opacity: 1; } 72% { opacity: 0.9; } }
@keyframes fly { 0% { transform: translate(0, 0); } 25% { transform: translate(30vw, 3vh); } 50% { transform: translate(60vw, -2vh); } 75% { transform: translate(90vw, 4vh); } 100% { transform: translate(calc(100vw + 160px), 0); } }
@keyframes sweep { to { top: 70%; } }
@keyframes pulse { 50% { transform: scale(1.05); } }
@keyframes boo {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.4); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -40px) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .bat { display: none; }
  .boo.pop { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
