/* v7.css — Living Books v7 skin for Find Luna! on the Farm */

:root {
  --ink: #2C2418;
  --paper: #FFF8EC;
  --gold: #FFB300;
  --gold-deep: #D97A18;
  --teal: #2a9d8f;
  --rose: #FF6B8A;
  --sky: #BFE9FF;
  --leaf: #6aa84f;
  --shadow: 0 10px 30px rgba(60, 40, 10, .28);
  --stage-ar: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: "Trebuchet MS", "Segoe UI", "Avenir Next", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #1d2b3a;
  background-image:
    radial-gradient(circle at 18% 8%, rgba(255, 214, 130, .28), transparent 45%),
    radial-gradient(circle at 85% 88%, rgba(120, 220, 170, .22), transparent 45%),
    linear-gradient(160deg, #2f5d3a 0%, #24422c 58%, #16281d 100%);
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

.screen { display: none; }
.screen.active { display: flex; }

/* ─────────────────────────── title screen ─────────────────────────── */
#title-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 22px 16px 40px;
  text-align: center;
}

.cover-frame {
  position: relative;
  width: min(78vw, 420px);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 8px rgba(255, 255, 255, .82);
  background: #fff;
  animation: coverIn .7s cubic-bezier(.34, 1.56, .64, 1) both;
}
.cover-frame img { display: block; width: 100%; height: auto; }
.cover-frame::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(20, 12, 0, .45));
  pointer-events: none;
}
@keyframes coverIn { from { transform: scale(.82) translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.title-inner { width: min(94vw, 720px); }

.v7-title {
  margin: 6px 0 2px;
  font-size: clamp(1.9rem, 6.2vw, 3.4rem);
  line-height: 1.02;
  color: #fff;
  text-shadow: 0 3px 0 var(--gold-deep), 0 8px 20px rgba(0, 0, 0, .45);
  letter-spacing: .5px;
}
.v7-title span { display: block; font-size: .56em; color: #FFE7A8; margin-top: 4px; }
.v7-tagline {
  margin: 4px 0 18px;
  color: #CFE9F5;
  font-size: clamp(.9rem, 2.4vw, 1.1rem);
  font-weight: 700;
}

.mode-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.mode-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(1rem, 3.4vw, 1.35rem);
  color: #3A2A10;
  padding: 16px 26px;
  min-width: 210px;
  border-radius: 999px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .22), var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.mode-btn:hover { transform: translateY(-3px); filter: saturate(1.12); }
.mode-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(0, 0, 0, .22); }
#btn-read { background: linear-gradient(180deg, #FFD35C, var(--gold)); }
#btn-play { background: linear-gradient(180deg, #7BE0C4, #2FA8A0); color: #06342F; }

.lang-row { margin-top: 18px; display: flex; gap: 10px; justify-content: center; }
.lang-btn {
  appearance: none; cursor: pointer; font-family: inherit; font-weight: 800;
  font-size: .98rem; padding: 9px 18px; border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .14); color: #fff;
  transition: background .18s ease, transform .18s ease;
}
.lang-btn:hover { transform: translateY(-2px); }
.lang-btn.active { background: #fff; color: #23303d; border-color: #fff; }

.title-hint {
  margin-top: 16px; color: #A9C8D8; font-size: .92rem; font-weight: 600;
  max-width: 34ch; margin-left: auto; margin-right: auto;
}

/* ─────────────────────────── book screen ─────────────────────────── */
#book-screen {
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px 8px 0;
  gap: 6px;
}

#hud {
  width: min(100%, 1060px);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12, 22, 30, .55);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
  justify-content: center;
}
.hud-btn {
  appearance: none; cursor: pointer; font-family: inherit; font-weight: 800;
  border: 0; border-radius: 999px; padding: 8px 14px; font-size: .95rem;
  background: rgba(255, 255, 255, .16); color: #fff;
  transition: transform .15s ease, background .15s ease;
}
.hud-btn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .3); }
.hud-btn.main { background: var(--gold); color: #3A2A10; }

#scene-tabs { display: flex; gap: 6px; flex: 1 1 200px; min-width: 0; overflow-x: auto; }
.tab {
  appearance: none; cursor: pointer; font-family: inherit; font-weight: 700;
  border: 0; border-radius: 999px; padding: 7px 13px; font-size: .84rem; white-space: nowrap;
  background: rgba(255, 255, 255, .1); color: #E7F3FA;
}
.tab.active { background: #fff; color: #22323f; }

.mode-badge {
  font-weight: 900; font-size: .9rem; padding: 7px 15px; border-radius: 999px; color: #3A2A10;
  background: var(--gold); white-space: nowrap;
}
.mode-badge.play { background: #7BE0C4; color: #06342F; }

#stage-wrap { width: 100%; display: flex; justify-content: center; }

#stage {
  position: relative;
  width: 100%;
  max-width: max(300px, min(100%, calc((100vh - 300px) * var(--stage-ar))));
  max-width: max(300px, min(100%, calc((100dvh - 300px) * var(--stage-ar))));
  aspect-ratio: var(--stage-ar);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 5px rgba(255, 255, 255, .85);
  background: #cfe6f2;
  isolation: isolate;
}

#bg-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: fill; user-select: none; -webkit-user-drag: none;
}
#actor-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  overflow: visible;
}
#fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

/* actor idle motion ---------------------------------------------------- */
.actor { cursor: pointer; outline: none; }
.actor:focus-visible .ac-holder { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 10px var(--gold)); }
.ac-hit { fill: transparent; }
.ac-inner { transform-box: fill-box; transform-origin: 50% 100%; }
.ac-breath { transform-box: fill-box; transform-origin: 50% 100%; animation: v7breathe 3.4s ease-in-out infinite; }
.ac-idle { transform-box: fill-box; transform-origin: 50% 100%; }
.ac-eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: v7blink 5.4s infinite; }
.actor[data-idle="float"] .ac-idle { animation: v7float 3.2s ease-in-out infinite; }
.actor[data-idle="hover"] .ac-idle { animation: v7float 2.4s ease-in-out infinite; }
.actor[data-idle="spin"] .ac-idle { animation: v7float 4s ease-in-out infinite; }
.actor[data-idle="swim"] .ac-idle { animation: v7float 2.8s ease-in-out infinite; }

/* the pulsing FIND-LUNA ring drawn over the dog painted into the artwork */
.find-marker { cursor: pointer; pointer-events: all; }
.find-marker .ac-hit { fill: transparent; }
.find-marker .ac-idle {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: v7find 2.8s ease-in-out infinite;
  filter: drop-shadow(0 0 5px rgba(255, 201, 60, .95)) drop-shadow(0 0 12px rgba(255, 201, 60, .55));
}
@keyframes v7find {
  0%, 100% { opacity: .78; transform: scale(.93); }
  50%      { opacity: 1;   transform: scale(1.09); }
}
.actor.gagging .ac-holder { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .3)); }

@keyframes v7breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50% { transform: scaleY(1.035) scaleX(.99); }
}
@keyframes v7blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 96% { transform: scaleY(.08); }
}
@keyframes v7float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-9px) rotate(3deg); }
}

/* ─────────────────────────── karaoke ─────────────────────────── */
#karaoke {
  width: min(100%, 1060px);
  margin: 2px auto 8px;
  background: rgba(12, 22, 30, .62);
  border-radius: 18px;
  padding: 10px 14px 12px;
  color: #EAF6FC;
  box-shadow: var(--shadow);
}
.karao-line {
  font-size: clamp(.98rem, 2.3vw, 1.18rem);
  line-height: 1.55;
  font-weight: 700;
  letter-spacing: .2px;
  opacity: .62;
  transition: opacity .3s ease;
}
.karao-line.active-lang { opacity: 1; }
.karao-line + .karao-line {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, .22);
  font-size: clamp(.92rem, 2.4vw, 1.12rem);
  color: #FFE9C2;
}
.kw {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .12s ease;
}
.kw:hover { background: rgba(255, 255, 255, .22); transform: translateY(-1px); }
.kw.on {
  background: var(--gold);
  color: #3A2A10;
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(255, 179, 0, .35);
}
.karao-line.active-lang .kw.done { background: rgba(255, 179, 0, .18); color: #FFE0A8; }

/* ─────────────────────────── bottom bar ─────────────────────────── */
#bottom-bar {
  width: min(100%, 1060px);
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 0 6px 10px;
  flex-wrap: wrap;
}
#find-target { color: #BFE0EE; font-weight: 800; font-size: .95rem; }
#find-count {
  background: rgba(255, 255, 255, .16); color: #fff; font-weight: 900;
  border-radius: 999px; padding: 5px 13px; font-size: .92rem;
}

/* ─────────────────────────── popup ─────────────────────────── */
#word-popup {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(10, 18, 24, .55);
  padding: 18px;
}
#word-popup.show { display: flex; }
.pop-card {
  position: relative;
  width: min(92vw, 440px);
  background: var(--paper);
  border-radius: 26px;
  padding: 26px 24px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45), 0 0 0 6px rgba(255, 255, 255, .5);
  animation: popIn .28s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes popIn { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.pop-close {
  position: absolute; top: 10px; right: 12px;
  border: 0; background: rgba(0, 0, 0, .08); color: var(--ink);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1rem; font-weight: 800;
}
.pop-word { font-size: clamp(1.9rem, 7vw, 2.6rem); font-weight: 900; color: #2C2418; line-height: 1.05; }
.pop-resp { font-family: "Courier New", monospace; color: var(--teal); font-weight: 700; font-size: 1.05rem; margin-top: 4px; }
.pop-resp.es { color: var(--rose); }
.pop-arrow { margin: 12px 0 2px; font-size: 1.1rem; }
.pop-trans { font-size: clamp(1.4rem, 5.6vw, 2rem); font-weight: 900; color: var(--gold-deep); }
.pop-syl { margin-top: 12px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pop-syl span {
  background: #fff; border: 2px solid var(--gold); border-radius: 10px;
  padding: 3px 10px; font-weight: 800; font-size: 1rem;
}
.pop-first { margin-top: 10px; font-weight: 700; color: #5A4A32; }
.pop-btns { margin-top: 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pop-btn {
  appearance: none; cursor: pointer; font-family: inherit; font-weight: 800;
  border: 0; border-radius: 999px; padding: 11px 18px; font-size: .98rem;
  background: linear-gradient(180deg, #FFD35C, var(--gold)); color: #3A2A10;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18);
}
.pop-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
.pop-hint { margin-top: 14px; font-size: .8rem; color: #8A7A62; }

/* ─────────────────────────── word chips ─────────────────────────── */
.word-chip {
  position: absolute; z-index: 5;
  transform: translate(-50%, 0);
  background: rgba(20, 12, 0, .82);
  color: #FFE7A8;
  font-weight: 800; font-size: clamp(.8rem, 2.4vw, 1rem);
  padding: 6px 12px; border-radius: 999px;
  white-space: nowrap; pointer-events: auto; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .4);
  max-width: 96%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─────────────────────────── ending ─────────────────────────── */
#ending-screen {
  position: fixed; inset: 0; z-index: 70;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(12, 26, 34, .92); color: #fff; text-align: center; gap: 14px; padding: 24px;
}
#ending-screen.active { display: flex; }
#ending-screen h2 { font-size: clamp(1.8rem, 7vw, 3rem); margin: 0; }
.end-btn {
  appearance: none; cursor: pointer; font-family: inherit; font-weight: 900;
  border: 0; border-radius: 999px; padding: 14px 26px; font-size: 1.05rem;
  background: linear-gradient(180deg, #FFD35C, var(--gold)); color: #3A2A10;
}

@media (min-width: 780px) {
  /* wide screens: the two languages read side by side */
  #karaoke { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
  .karao-line + .karao-line {
    margin-top: 0; padding-top: 0;
    border-top: 0;
    border-left: 1px dashed rgba(255, 255, 255, .22);
    padding-left: 20px;
  }
}

@media (max-width: 779px) {
  #karaoke { max-height: 42vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .karao-line { font-size: 1rem; line-height: 1.5; }
}

@media (max-width: 640px) {
  #hud { border-radius: 18px; padding: 6px; }
  .mode-btn { min-width: 160px; padding: 14px 18px; }
  #karaoke { padding: 8px 10px 10px; border-radius: 14px; }
  #scene-tabs { order: 3; width: 100%; }
  #stage { max-width: max(280px, min(100%, calc((100dvh - 430px) * var(--stage-ar)))); }
}

/* ─────────────────── TAP-TO-START / UNMUTE OVERLAY ─────────────────── */
.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 179, 0, .30), transparent 62%),
    linear-gradient(160deg, #10233a 0%, #0b1725 55%, #071019 100%);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  text-align: center;
  font-family: "Trebuchet MS", "Avenir Next", system-ui, -apple-system, sans-serif;
}
.start-overlay.show { display: flex; }
body.overlay-open { overflow: hidden; }

.start-card {
  width: min(92vw, 460px);
  padding: 34px 30px 30px;
  border-radius: 28px;
  background: linear-gradient(165deg, #fffdf6 0%, #fff4dc 100%);
  border: 4px solid #ffb300;
  box-shadow: 0 26px 60px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .9);
  animation: startPop .38s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes startPop {
  from { transform: scale(.84) translateY(14px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.start-emoji { font-size: 3.2rem; line-height: 1; animation: startTap 1.5s ease-in-out infinite; }
@keyframes startTap {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-12px) rotate(6deg); }
}
.start-title {
  margin: 10px 0 4px;
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: .5px;
  color: #14304f;
}
.start-sub { font-size: .95rem; font-weight: 700; color: #3d6a8f; margin-bottom: 10px; }
.start-note { font-size: .9rem; color: #6b5836; margin-bottom: 20px; line-height: 1.45; }
.start-btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  padding: 15px 34px;
  border-radius: 999px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #3b2400;
  background: linear-gradient(180deg, #ffd257 0%, #ffb300 100%);
  box-shadow: 0 8px 0 #c98200, 0 14px 26px rgba(0, 0, 0, .28);
  transition: transform .12s ease, box-shadow .12s ease;
}
.start-btn:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #c98200, 0 8px 16px rgba(0, 0, 0, .28);
}
.start-btn:focus-visible { outline: 4px solid #2f80ed; outline-offset: 3px; }

@media (max-width: 480px) {
  .start-card { padding: 26px 20px 24px; border-radius: 22px; }
  .start-title { font-size: 1.6rem; }
  .start-emoji { font-size: 2.5rem; }
  .start-btn { padding: 13px 26px; font-size: 1rem; }
}
