/* Spelling Bee: setup screen, letter boxes and the on-screen keyboard. Builds on style.css. */

.spell { --accent: #0891b2; --honey: #f5b301; --honey-soft: #fff6d6; --honey-edge: #ecc85c; }

.bee { max-width: 920px; margin: 0 auto; }

/* ---------- setup ---------- */

.bee-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 8px; }
.bee-badge {
  width: 112px; height: 112px; border-radius: 50%;
  display: grid; place-items: center; font-size: 66px; line-height: 1;
  background: var(--honey-soft); border: 3px solid #f6dc8c;
}
.bee-hero p { font-size: 19px; font-weight: 700; color: var(--muted); }
.bee-step { align-self: flex-start; font-size: 22px; font-weight: 900; letter-spacing: -0.01em; margin-top: 4px; }

.mode-picker { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mode-card, .level-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface); border: 3px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--edge);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.mode-card { padding: 18px 10px 16px; }
.mode-card:active, .level-card:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.mode-card[aria-pressed="true"], .level-card[aria-pressed="true"] {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, #fff);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 70%, #000);
}
.mode-icon { font-size: 42px; line-height: 1.1; }
.mode-name { font-size: 19px; font-weight: 900; }
.mode-blurb { font-size: 15px; font-weight: 700; color: var(--muted); }

.level-picker { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.level-card { padding: 14px 6px 12px; }
.level-num {
  position: absolute; top: 8px; left: 8px;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px;
  display: grid; place-items: center;
  background: #f2efe8; color: var(--ink); font-size: 17px; font-weight: 900;
}
.level-card[aria-pressed="true"] .level-num { background: var(--accent); color: #fff; }
.level-icon { font-size: 38px; line-height: 1.2; margin-top: 10px; }
.level-title { font-size: 15px; font-weight: 800; line-height: 1.15; min-height: 2.3em; display: flex; align-items: center; }
.level-stars { display: flex; gap: 2px; }
.level-stars .icon { width: 18px; height: 18px; }
.level-card.mastered:not([aria-pressed="true"]) { background: #fffbeb; border-color: #f6dc8c; box-shadow: 0 5px 0 var(--honey-edge); }

.bee-start { width: 100%; max-width: 360px; font-size: 26px; padding: 18px 30px; margin-top: 6px; }

@media (hover: hover) {
  .mode-card:not([aria-pressed="true"]):hover, .level-card:not([aria-pressed="true"]):hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  }
}

/* ---------- question ---------- */

.spell-q { gap: 18px; }
.spell-q .eyebrow { margin-top: -6px; }

.spell-prompt { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; }
.spell-pic {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center; font-size: 50px; line-height: 1;
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}
.hear-btn, .sentence-btn {
  display: inline-flex; align-items: center; gap: 10px;
  border-radius: 999px; font-weight: 900;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.hear-btn {
  padding: 16px 30px; font-size: 26px;
  background: var(--accent); color: #fff; border: 0;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 65%, #000);
}
.hear-btn .icon { width: 32px; height: 32px; }
.hear-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 65%, #000); }
.hear-btn.pulse { animation: pulse 1.6s ease-in-out infinite; }
.sentence-btn {
  padding: 13px 22px; font-size: 19px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--edge);
}
.sentence-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 65%, #000), 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  50% { box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 65%, #000), 0 0 0 14px transparent; }
}

/* One box per letter; boxes shrink so long words still fit on a phone. */
.slots {
  --gap: 10px;
  display: flex; justify-content: center; gap: var(--gap);
  width: 100%; margin-top: 4px;
}
.slot {
  width: min(76px, calc((100vw - 40px - (var(--n) - 1) * var(--gap)) / var(--n)));
  aspect-ratio: 5 / 6;
  display: grid; place-items: center;
  font-size: clamp(30px, 7vw, 52px); font-weight: 900; line-height: 1;
  background: var(--surface); color: var(--ink);
  border: 3px dashed #c9c3b5; border-radius: 16px;
  transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.slot.filled { border-style: solid; border-color: var(--edge); box-shadow: 0 4px 0 var(--edge); animation: pop 0.18s; }
.slot.next { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, #fff); }
.slot.given { border: 3px solid transparent; background: #ece8df; color: #4b4f60; cursor: default; }
.slot.kept { border: 3px solid var(--good); background: var(--good-soft); color: var(--good-ink); cursor: default; }
.slot.drop { border-style: solid; border-color: var(--accent); transform: scale(1.08); background: color-mix(in srgb, var(--accent) 14%, #fff); }
.slot.right { border: 3px solid var(--good); background: var(--good-soft); color: var(--good-ink); box-shadow: 0 4px 0 var(--good); }
.slot.wrong { border: 3px solid var(--bad); background: var(--bad-soft); color: var(--bad-ink); box-shadow: 0 4px 0 var(--bad); animation: shake 0.4s; }
.slot.fix { border: 3px solid var(--bad); background: #fff; color: var(--bad); box-shadow: 0 4px 0 var(--bad); }
.spell-q .slot.right { animation: hop 0.45s both; }
.slot.right:nth-child(2) { animation-delay: 0.05s; }
.slot.right:nth-child(3) { animation-delay: 0.1s; }
.slot.right:nth-child(4) { animation-delay: 0.15s; }
.slot.right:nth-child(5) { animation-delay: 0.2s; }
.slot.right:nth-child(6) { animation-delay: 0.25s; }
.slot.right:nth-child(7) { animation-delay: 0.3s; }
.slots.nudge { animation: shake 0.3s; }

@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px); } }

.spell-hint { min-height: 28px; font-size: 21px; font-weight: 800; color: var(--bad-ink); }

/* ---------- keyboard dock ---------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #ebe7de; border-top: 1px solid var(--edge);
  padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
}
.dock-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }

.keyboard { display: flex; flex-direction: column; gap: 8px; }
.kb-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.kb-row:last-child { padding: 0 calc((100% - 6 * 8px) / 7 + 8px); grid-template-columns: repeat(5, 1fr); }

.key {
  height: 60px; border-radius: 14px;
  font-size: 32px; font-weight: 900; line-height: 1;
  background: var(--surface); color: var(--ink);
  border: 0; box-shadow: 0 4px 0 var(--edge);
  touch-action: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s;
}
.key.vowel { background: #fff3c4; box-shadow: 0 4px 0 var(--honey-edge); }
.key:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.key.vowel:active:not(:disabled) { box-shadow: 0 1px 0 var(--honey-edge); }
.key.lifted { opacity: 0.4; }
.key:disabled { opacity: 0.25; cursor: default; }

.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 6px 0; }
.key.tile { width: 72px; height: 72px; font-size: 38px; border-radius: 16px; }

.key-ghost {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  width: 72px; height: 76px; border-radius: 16px;
  display: grid; place-items: center;
  font-size: 40px; font-weight: 900; color: var(--ink);
  background: var(--surface); border: 3px solid var(--accent);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.35);
}

.kb-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.kb-erase, .kb-check {
  height: 60px; border-radius: 16px; border: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 22px; font-weight: 900;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s;
}
.kb-erase { background: var(--surface); box-shadow: 0 4px 0 var(--edge); }
.kb-erase:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.kb-check { background: var(--good); color: #fff; box-shadow: 0 4px 0 var(--good-ink); }
.kb-check .icon { stroke-width: 3.5; }
.kb-check:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--good-ink); }
.kb-check:disabled { opacity: 0.4; cursor: default; }
.kb-check.ready { animation: ready 1.2s ease-in-out infinite; }

@keyframes ready { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }

/* Feedback takes the keyboard's place in the dock. */
.feedback-dock { max-width: 760px; margin: 0 auto; padding: 10px 6px; animation: slide-up 0.22s ease-out; }
.feedback-dock.good { color: var(--good-ink); }
.feedback-dock.bad { color: var(--bad-ink); }
.dock:has(.feedback-dock.good) { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, #fff); }
.dock:has(.feedback-dock.bad) { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, #fff); }
.feedback-dock .fb-text span { letter-spacing: 0.06em; }
.feedback-dock .big-btn.next {
  min-width: 150px; background: var(--bad); border-color: var(--bad); color: #fff;
  box-shadow: 0 5px 0 var(--bad-ink);
}
.feedback-dock .big-btn.next:active { box-shadow: 0 1px 0 var(--bad-ink); }

/* ---------- done ---------- */

.practice { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.practice-title { font-size: 15px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.practice-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.practice-word {
  padding: 8px 16px; border-radius: 999px; font-size: 22px; font-weight: 900;
  background: var(--bad-soft); color: var(--bad-ink); border: 2px solid color-mix(in srgb, var(--bad) 30%, #fff);
}

/* ---------- smaller screens ---------- */

@media (max-width: 640px) {
  .bee-badge { width: 88px; height: 88px; font-size: 52px; }
  .bee-hero p { font-size: 16px; text-align: center; }
  .mode-picker { gap: 8px; }
  .mode-card { padding: 14px 4px 12px; }
  .mode-icon { font-size: 34px; }
  .mode-name { font-size: 15px; text-align: center; line-height: 1.15; }
  .mode-blurb { display: none; }
  .level-picker { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .level-card { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px; text-align: left; }
  .level-num { position: static; }
  .level-icon { margin: 0; font-size: 28px; }
  .level-title { flex: 1; min-height: 0; font-size: 14px; }
  .level-stars { position: absolute; right: 8px; bottom: 4px; }
  .level-stars .icon { width: 12px; height: 12px; }

  .spell-q { gap: 12px; }
  .spell-pic { width: 60px; height: 60px; font-size: 36px; }
  .hear-btn { padding: 12px 22px; font-size: 21px; }
  .hear-btn .icon { width: 26px; height: 26px; }
  .sentence-btn { padding: 10px 16px; font-size: 16px; }
  .slots { --gap: 6px; }
  .slot { border-radius: 12px; }

  .dock { padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); }
  .dock-inner, .keyboard { gap: 6px; }
  .kb-row { gap: 6px; }
  .kb-row:last-child { padding: 0 calc((100% - 6 * 6px) / 7 + 6px); }
  .key { height: 50px; font-size: 26px; border-radius: 10px; }
  .key.tile { width: 58px; height: 58px; font-size: 32px; }
  .kb-erase, .kb-check { height: 52px; font-size: 19px; }
}

@media (max-height: 700px) and (max-width: 640px) {
  .spell-pic { display: none; }
}
