/* Practice with Finn - interactive Elkonin sound-box app
   Brand system shared with the main site (cream / teal / Baloo 2 / Andika). */
:root {
  --teal-deep: #1D5F7A;
  --teal-mid: #3E8CA8;
  --blue-soft: #C9DEE8;
  --cream: #FBF6E9;
  --coral: #E8734A;
  --ink: #2B2B2B;
  --white: #ffffff;
  --green: #3F9D6C;

  --font-display: 'Baloo 2', 'Trebuchet MS', sans-serif;
  --font-body: 'Andika', 'Segoe UI', sans-serif;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow-sm: 0 2px 10px rgba(29, 95, 122, 0.10);
  --shadow-md: 0 12px 34px rgba(29, 95, 122, 0.16);
  --tap: 56px; /* min touch target */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: manipulation;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--teal-deep); margin: 0; font-weight: 700; line-height: 1.12; }
img { max-width: 100%; display: block; }
button { font-family: var(--font-display); cursor: pointer; }

/* ---------- App header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,246,233,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(29,95,122,.12);
}
.app-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; max-width: 1240px; margin: 0 auto; }
.app-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.app-brand img { width: 40px; height: auto; }
.app-brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--teal-deep); }
.app-nav-links { display: flex; gap: 18px; align-items: center; list-style: none; margin: 0; padding: 0; }
.app-nav-links a { font-family: var(--font-display); font-weight: 500; text-decoration: none; color: var(--teal-deep); font-size: 1rem; }
.app-nav-links a:hover { color: var(--coral); }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; }
.nav-toggle span { display: block; width: 26px; height: 3px; background: var(--teal-deep); border-radius: 3px; margin: 5px 0; }
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .app-nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--cream);
    border-bottom: 1px solid rgba(29,95,122,.15); padding: 8px 0;
  }
  .app-nav-links.open { display: flex; }
  .app-nav-links li { width: 100%; text-align: center; }
  .app-nav-links a { display: block; padding: 12px 0; }
}

.app-main { max-width: 1240px; margin: 0 auto; padding: 20px 18px 60px; }
.screen { animation: fade .3s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  min-height: var(--tap); padding: 12px 26px; border-radius: 999px;
  border: 2px solid transparent; text-decoration: none;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 6px 16px rgba(232,115,74,.34); }
.btn-secondary { background: var(--teal-deep); color: #fff; }
.btn-ghost { background: var(--white); color: var(--teal-deep); border-color: var(--blue-soft); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: #f2f8fb; }

/* ---------- Set picker ---------- */
.picker-head { text-align: center; margin: 8px 0 26px; }
.picker-head img { width: 120px; margin: 0 auto 10px; filter: drop-shadow(0 10px 18px rgba(29,95,122,.18)); animation: bob 6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.picker-head h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); }
.picker-head p { color: var(--teal-mid); font-size: 1.1rem; font-family: var(--font-display); font-weight: 500; margin-top: 4px; }

.picker-group-title {
  font-family: var(--font-display); font-weight: 700; color: var(--teal-mid);
  font-size: 1.05rem; letter-spacing: .05em; text-transform: uppercase;
  margin: 28px 0 14px;
}
.set-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.set-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  background: var(--blue-soft); border: 3px solid transparent; border-radius: var(--radius);
  padding: 20px 14px; min-height: 130px; justify-content: center;
  color: var(--teal-deep); text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.set-card:hover, .set-card:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--teal-mid); outline: none; }
.set-card:active { transform: scale(.97); }
.set-card .set-friend { width: 58px; height: 58px; object-fit: contain; }
.set-card .set-label { font-family: var(--font-display); font-weight: 700; font-size: 1.18rem; line-height: 1.1; }
.set-card .set-count { font-family: var(--font-body); font-size: .9rem; color: var(--teal-mid); }

/* ---------- Word screen ---------- */
.word-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0;
  color: var(--teal-deep); font-family: var(--font-display); font-weight: 500; font-size: 1rem;
  min-height: var(--tap); padding: 6px 8px;
}
.back-link:hover { color: var(--coral); }
.set-name-pill {
  font-family: var(--font-display); font-weight: 700; color: var(--teal-deep);
  background: var(--blue-soft); padding: 6px 16px; border-radius: 999px; font-size: 1rem;
}

/* progress dots */
.progress-dots { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 6px 0 18px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--blue-soft); transition: background .2s ease, transform .2s ease; }
.dot.done { background: var(--teal-mid); }
.dot.current { background: var(--coral); transform: scale(1.35); }

/* mode toggle */
.mode-toggle {
  display: inline-flex; background: var(--white); border: 2px solid var(--blue-soft);
  border-radius: 999px; padding: 4px; gap: 4px; box-shadow: var(--shadow-sm);
}
.mode-toggle-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.mode-btn {
  border: 0; background: transparent; color: var(--teal-deep);
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  padding: 10px 22px; min-height: 48px; border-radius: 999px; transition: background .15s ease, color .15s ease;
}
.mode-btn[aria-selected="true"] { background: var(--teal-deep); color: #fff; }

/* word card / play area */
.play-area { display: grid; grid-template-columns: 1fr; gap: 22px; align-items: start; }
.word-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md);
  border: 1px solid rgba(29,95,122,.08); padding: 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.word-pic { width: min(72%, 300px); aspect-ratio: 1/1; object-fit: contain; }
.speaker-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--teal-deep); color: #fff; border: 0; border-radius: 999px;
  min-height: var(--tap); padding: 12px 26px; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  box-shadow: 0 6px 16px rgba(29,95,122,.28); transition: transform .14s ease;
}
.speaker-btn:active { transform: scale(.95); }
.speaker-btn svg { flex: none; }

/* ---------- Sound boxes (match printed mats) ---------- */
.boxes { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.sound-box {
  position: relative;
  width: clamp(70px, 20vw, 104px); height: clamp(70px, 20vw, 104px);
  background: var(--white);
  border: 4px solid var(--teal-deep);
  border-radius: 12px;
  display: grid; place-items: center;
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
  touch-action: none;
}
/* TAP mode fill */
.sound-box.filled { background: var(--blue-soft); }
/* correct / wrong feedback (tiles) */
.sound-box.correct { border-color: var(--green); background: #e6f6ee; animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.14); } 100% { transform: scale(1); } }
.sound-box.drop-hover { border-color: var(--coral); background: #fdeee7; }
.sound-box .box-letter {
  font-family: var(--font-body); font-weight: 700; font-size: clamp(1.8rem, 6vw, 2.6rem);
  color: var(--teal-deep); line-height: 1; user-select: none;
}
/* placed tile letter (green) */
.sound-box.correct .box-letter { color: var(--green); }

/* WRITE mode: canvas inside box */
.sound-box.write { padding: 0; overflow: hidden; }
.sound-box canvas { width: 100%; height: 100%; display: block; border-radius: 8px; cursor: crosshair; }
.sound-box .ghost {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-body); font-weight: 700; font-size: clamp(1.8rem, 6vw, 2.6rem);
  color: rgba(43,43,43,.22);
}

/* action row under boxes */
.box-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* TILES tray */
.tile-tray { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; min-height: 76px; }
.g-tile {
  width: clamp(64px, 18vw, 88px); height: clamp(64px, 18vw, 88px);
  background: var(--coral); color: #fff; border: 0; border-radius: 14px;
  font-family: var(--font-body); font-weight: 700; font-size: clamp(1.6rem, 5vw, 2.2rem);
  display: grid; place-items: center; box-shadow: 0 6px 14px rgba(232,115,74,.32);
  touch-action: none; user-select: none; transition: transform .1s ease, opacity .2s ease;
}
.g-tile.dragging { opacity: .4; }
.g-tile.placed { display: none; }
.g-tile.shake { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
/* floating drag clone */
.drag-ghost {
  position: fixed; z-index: 999; pointer-events: none; opacity: .92;
  width: 80px; height: 80px; background: var(--coral); color: #fff; border-radius: 14px;
  font-family: var(--font-body); font-weight: 700; font-size: 2rem; display: grid; place-items: center;
  box-shadow: 0 10px 22px rgba(232,115,74,.4); transform: translate(-50%, -50%);
}

.hint { text-align: center; color: var(--teal-mid); font-family: var(--font-display); font-weight: 500; font-size: 1rem; margin: 4px 0 0; }

/* nav arrows + finish row */
.word-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 26px; }
.arrow-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid var(--blue-soft);
  background: var(--white); color: var(--teal-deep); display: grid; place-items: center;
  box-shadow: var(--shadow-sm); transition: transform .12s ease, background .14s ease;
}
.arrow-btn:hover:not(:disabled) { background: #f2f8fb; }
.arrow-btn:active:not(:disabled) { transform: scale(.92); }
.arrow-btn:disabled { opacity: .35; cursor: default; }
.word-counter { font-family: var(--font-display); font-weight: 700; color: var(--teal-deep); font-size: 1.05rem; min-width: 64px; text-align: center; }

/* Finn bounce (blend it) */
.finn-bounce { animation: bounce .6s ease; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-26px); } 55% { transform: translateY(0); } 72% { transform: translateY(-12px); } }

/* ---------- Celebration overlay ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(29,95,122,.55); backdrop-filter: blur(3px); padding: 24px;
  animation: fade .3s ease;
}
.celebrate-card {
  background: var(--cream); border-radius: 28px; padding: 34px 30px; text-align: center;
  max-width: 440px; width: 100%; box-shadow: var(--shadow-md);
}
.celebrate-card img.friend-big { width: 180px; margin: 0 auto 12px; animation: splash .7s ease; }
@keyframes splash { 0% { transform: scale(.4) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.12) rotate(3deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.celebrate-card h2 { font-size: 2rem; margin-bottom: 6px; }
.celebrate-card p { color: #3f4a4f; margin: 0 0 20px; }
.celebrate-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* stars burst */
.stars { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }
.star { position: absolute; font-size: 1.6rem; animation: rise 1.1s ease-out forwards; }
@keyframes rise { 0% { transform: translateY(0) scale(.4) rotate(0); opacity: 1; } 100% { transform: translateY(-160px) scale(1.2) rotate(180deg); opacity: 0; } }

/* mini Finn splash (word complete in tiles) */
.splash-finn { position: fixed; left: 50%; top: 42%; transform: translate(-50%,-50%); z-index: 98; width: 120px; pointer-events: none; animation: splash .7s ease forwards; }

/* ---------- Responsive: iPad landscape & desktop - two-column play area ---------- */
@media (min-width: 900px) {
  .play-area {
    grid-template-columns: 1fr 1fr; gap: 34px; align-items: center;
    max-width: 980px; margin: 0 auto;
  }
  .word-card { position: sticky; top: 90px; }
}
@media (min-width: 700px) {
  .set-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
@media (min-width: 1000px) {
  .set-grid { grid-template-columns: repeat(4, 1fr); }
}

/* very small phones: keep boxes from wrapping awkwardly */
@media (max-width: 380px) {
  .sound-box { width: 62px; height: 62px; border-width: 3px; }
  .g-tile { width: 58px; height: 58px; }
}

/* ---- Footer email signup (matches main site style.css) ---- */
.footer-signup { background: #1D5F7A; padding: 40px 20px 28px; }
.footer-signup .wrap { max-width: 720px; margin: 0 auto; }
.footer-signup .signup {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px; padding: 26px 26px 24px;
}
.footer-signup .signup h3 { font-family: 'Baloo 2', sans-serif; color: #fff; font-size: 1.4rem; margin: 0 0 8px; }
.footer-signup .signup p { color: #C9DEE8; font-size: .96rem; margin: 0 0 16px; }
.signup-form { display: flex; gap: 10px; flex-wrap: wrap; }
.signup-form input[type="email"] {
  flex: 1 1 220px; min-width: 0; padding: 13px 16px; border-radius: 999px;
  border: 2px solid transparent; font: inherit; font-size: 1rem; background: #fff; color: #2B2B2B;
}
.signup-form input[type="email"]:focus { outline: none; border-color: #E8734A; }
.signup-form .btn { flex: none; }
.signup-honey { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* P3: write-mode instruction - much larger, teal-deep, bold */
.hint.hint-write {
  font-size: 1.35rem;
  color: var(--teal-deep);
  font-weight: 700;
  margin-top: 8px;
}

/* ============================================================
   COACH ARROW - guided pointer for the first word of a set
   ============================================================ */
.coach-arrow {
  position: fixed;
  z-index: 60;
  width: 40px;
  height: 44px;
  pointer-events: none; /* never intercept taps - always adjacent, never covering */
  color: var(--coral);
  filter: drop-shadow(0 3px 5px rgba(43, 43, 43, .28));
  will-change: transform;
  transition: opacity .18s ease;
}
.coach-arrow svg { display: block; }
/* filled coral disc behind the white glyph so it reads on any background */
.coach-arrow::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 50% / 46% 46% 54% 54%;
  background: var(--coral);
  z-index: -1;
}
/* SVG glyph is drawn pointing DOWN; this is the "point-down" default */
.coach-arrow.point-down { transform: rotate(0deg); animation: coach-bob-down 1s ease-in-out infinite; }
.coach-arrow.point-up   { transform: rotate(180deg); animation: coach-bob-up 1s ease-in-out infinite; }
.coach-arrow.hidden { display: none; }

@keyframes coach-bob-down {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50%      { transform: rotate(0deg) translateY(6px); }
}
@keyframes coach-bob-up {
  0%, 100% { transform: rotate(180deg) translateY(0); }
  50%      { transform: rotate(180deg) translateY(6px); }
}
@media (prefers-reduced-motion: reduce) {
  .coach-arrow.point-down, .coach-arrow.point-up { animation: none; }
}
