/* ═══════════════════════════════════════════════════════════════
   /learn/toddlers/ — shared styles (shelf + book)
   Light only, on purpose: bright palette from /learn/symbols/index.html.
   Do NOT add /light-theme.js to these pages.
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
    --sky:    #fff8e7;
    --warm:   #fff3d0;
    --gold:   #f59e0b;
    --dgold:  #d97706;
    --teal:   #0d9488;
    --purple: #7c3aed;
    --pink:   #db2777;
    --blue:   #2563eb;
    --green:  #16a34a;
    --text:   #1c1a12;
    --soft:   #78716c;
    --paper:  #fffdf6;
    --band-h: 64px;
    --shadow: 0 10px 30px rgba(120, 80, 0, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Nunito', system-ui, sans-serif;
    background: var(--sky);
    color: var(--text);
    min-height: 100dvh;
    touch-action: manipulation;
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}
button { font-family: inherit; cursor: pointer; border: none; }

/* Judean text — always this, never italic */
.jud { font-family: 'Manakahthey', serif; direction: rtl; font-style: normal; }

/* ── Top band ── */
.band {
    height: var(--band-h);
    padding: 0 14px;
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    position: relative; z-index: 60;
    box-shadow: 0 2px 12px rgba(120, 80, 0, 0.18);
}
.band::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(circle at 80% 50%, rgba(255, 255, 255, 0.18), transparent 60%);
}
.band > * { position: relative; }
.band-title { flex: 1; font-size: 1.25rem; font-weight: 900; color: #1c1a12; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.band-title .jud { font-size: 1.5rem; font-weight: 400; color: #3b2300; }
.band-title span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Hold-to-exit button (grown-ups): a quick tap only shows a hint */
.exit-btn {
    position: relative; width: 46px; height: 46px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.55); color: #1c1a12;
    font-size: 1.3rem; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    touch-action: none; flex-shrink: 0;
}
.exit-btn svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.exit-btn .ring { fill: none; stroke: #1c1a12; stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; }
.exit-btn.holding .ring { stroke-dashoffset: 0; transition: stroke-dashoffset 0.9s linear; }
.hold-hint {
    position: fixed; top: calc(var(--band-h) + 10px); left: 12px; z-index: 80;
    background: #1c1a12; color: #fff; font-size: 0.85rem; font-weight: 700;
    padding: 8px 14px; border-radius: 14px; max-width: 70vw;
    opacity: 0; transform: translateY(-6px); transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
.hold-hint.show { opacity: 1; transform: none; }

.sound-btn {
    width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
    background: rgba(255, 255, 255, 0.55); font-size: 1.3rem;
    display: flex; align-items: center; justify-content: center;
}

/* ═══════════ SHELF ═══════════ */
.hub { max-width: 860px; margin: 0 auto; padding: 22px 16px 60px; }
.hub-hint { text-align: center; color: var(--soft); font-weight: 700; margin-bottom: 22px; font-size: 1rem; }
.shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 30px 20px; justify-items: center; }
.shelf-slot { position: relative; width: 100%; max-width: 190px; padding-bottom: 16px; }
.shelf-slot::after { /* the plank the book stands on */
    content: ''; position: absolute; left: -8%; right: -8%; bottom: 0; height: 14px; border-radius: 6px;
    background: linear-gradient(#d9a066, #b9793d); box-shadow: 0 6px 12px rgba(120, 80, 0, 0.2);
}
.shelf-book {
    --c: #f59e0b; --tint: #fde68a;
    position: relative; display: block; width: 100%; aspect-ratio: 3 / 4;
    border-radius: 6px 18px 18px 6px;
    background: linear-gradient(160deg, var(--tint), var(--c));
    box-shadow: var(--shadow), inset 14px 0 0 rgba(0, 0, 0, 0.13);
    text-decoration: none; color: #1c1a12; text-align: center;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px 10px 14px 24px;
    transition: transform 0.2s;
}
.shelf-book:active { transform: scale(0.96); }
.shelf-book:hover { transform: translateY(-4px) rotate(-1deg); }
.shelf-book .icon { font-size: 3.4rem; line-height: 1; }
.shelf-book .icon.jud { font-size: 2.6rem; letter-spacing: 4px; direction: rtl; }
.shelf-book .title { font-weight: 900; font-size: 1.1rem; line-height: 1.15; }
.shelf-book .title-jud { font-size: 1.5rem; }
.shelf-book.soon { filter: grayscale(0.55); opacity: 0.6; cursor: default; pointer-events: none; }
.shelf-book .ribbon {
    position: absolute; top: 12px; right: -6px; background: #1c1a12; color: #fff;
    font-size: 0.7rem; font-weight: 800; padding: 4px 10px; border-radius: 6px 0 0 6px; letter-spacing: 0.5px;
}
.hub-msg { text-align: center; color: var(--soft); padding: 40px 10px; font-weight: 700; }

/* ═══════════ BOOK ═══════════ */
body.book-page { overflow: hidden; height: 100vh; height: 100dvh; position: fixed; left: 0; right: 0; width: 100%; overscroll-behavior: none; }
.stage {
    position: relative; height: calc(100vh - var(--band-h)); height: calc(100dvh - var(--band-h));
    display: flex; align-items: center; justify-content: center;
    -webkit-perspective: 2200px; perspective: 2200px; padding-bottom: 92px;
    touch-action: pan-y; overscroll-behavior: none;
    background: radial-gradient(ellipse at 50% 40%, #fffdf6 0%, var(--warm) 70%, #ffe8a3 100%);
}
.stage-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; font-weight: 800; color: var(--soft); font-size: 1.1rem; }
.stage-msg .big { font-size: 3rem; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(245, 158, 11, 0.25); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bobber.closed { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.book {
    position: relative; height: var(--ph); width: calc(var(--pw) * 2);
    -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
    transition: transform 0.9s cubic-bezier(0.4, 0.1, 0.2, 1);
}
.book.single { width: var(--pw); }
.book.spread.closed { transform: translateX(calc(var(--pw) * -0.5)); }

.leaf {
    position: absolute; top: 0; left: var(--pw); width: var(--pw); height: 100%;
    -webkit-transform-origin: left center; transform-origin: left center;
    -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
    transform: translateZ(0px) rotateY(0deg);
    -webkit-transition: -webkit-transform 0.85s cubic-bezier(0.45, 0.05, 0.25, 1);
    transition: transform 0.85s cubic-bezier(0.45, 0.05, 0.25, 1);
}
.book.single .leaf { left: 0; }
.book.quick .leaf { -webkit-transition-duration: 0.45s; transition-duration: 0.45s; }

.face {
    position: absolute; inset: 0; overflow: hidden;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    background: var(--paper);
    border: 1px solid rgba(120, 80, 0, 0.14);
}
.face.front { border-radius: 4px 20px 20px 4px; }
.face.back  { border-radius: 20px 4px 4px 20px; -webkit-transform: rotateY(180deg); transform: rotateY(180deg); }
.face.back.paper { background: linear-gradient(270deg, #f3e3b3, #fff6d6 40%, #fff3cf); }
.face.front::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 22px; pointer-events: none; background: linear-gradient(90deg, rgba(0, 0, 0, 0.13), transparent); }
.face.back::after  { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 22px; pointer-events: none; background: linear-gradient(270deg, rgba(0, 0, 0, 0.13), transparent); }
.face.endpaper { background: repeating-linear-gradient(45deg, #fff6d6, #fff6d6 10px, #ffefbd 10px, #ffefbd 20px); }

/* Cover */
.face.cover {
    --c: #f59e0b; --tint: #fde68a;
    background: linear-gradient(150deg, var(--tint), var(--c));
    border-radius: 6px 22px 22px 6px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    text-align: center; padding: 0 12% 0 16%; color: #1c1a12;
    box-shadow: 0 8px 18px rgba(120, 80, 0, 0.25), inset 18px 0 0 rgba(0, 0, 0, 0.14);
}
.cover .c-icon { font-size: calc(var(--pw) * 0.34); line-height: 1; }
.cover .c-icon.jud { font-size: calc(var(--pw) * 0.26); letter-spacing: 4px; }
.cover .c-jud { font-size: calc(var(--pw) * 0.2); line-height: 1.1; }
.cover .c-en { font-size: calc(var(--pw) * 0.095); font-weight: 900; }
.cover .c-tap {
    margin-top: 6px; background: rgba(255, 255, 255, 0.7); border-radius: 30px;
    padding: 8px 18px; font-weight: 800; font-size: calc(var(--pw) * 0.065); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* Page content */
.page {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: center;
    gap: calc(var(--pw) * 0.04); padding: calc(var(--pw) * 0.07) calc(var(--pw) * 0.07) calc(var(--pw) * 0.07) calc(var(--pw) * 0.1);
}
.face.back .page { padding: calc(var(--pw) * 0.07) calc(var(--pw) * 0.1) calc(var(--pw) * 0.07) calc(var(--pw) * 0.07); }

.pic {
    --accent: #f59e0b; --tile: #fde68a;
    position: relative; flex: 1; min-height: 0; border-radius: 22px; background: #fff;
    border: 6px solid var(--accent); overflow: hidden; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.pic img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.pic .art { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--tile); color: #1c1a12; font-size: calc(var(--pw) * 0.5); line-height: 1; }
.pic.boing { animation: boing 0.6s ease; }
@keyframes boing { 0% { transform: scale(1); } 30% { transform: scale(1.07) rotate(-1.5deg); } 60% { transform: scale(0.97) rotate(1deg); } 100% { transform: scale(1); } }

.wp { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: calc(var(--pw) * 0.03); }
.book.single .wp { flex: 0 0 auto; }
.wp .w-jud { font-weight: 900; line-height: 1.1; cursor: pointer; color: #1c1a12; max-width: 100%; word-break: keep-all; }
.wp .w-jud.boing { animation: boing 0.6s ease; }
.wp .w-sub { font-size: calc(var(--pw) * 0.1); color: #5a5248; font-weight: 400; }
.wp .w-en {
    display: inline-flex; align-items: center; gap: 8px; font-weight: 900; color: #5a5248;
    font-size: calc(var(--pw) * 0.085); background: #fff3d0; border-radius: 30px; padding: calc(var(--pw) * 0.015) calc(var(--pw) * 0.045); cursor: pointer;
}
.wp .w-en::before { content: '🔈'; font-size: 0.9em; }

/* End page */
.endpage { position: absolute; inset: 0; border-radius: 4px 20px 20px 4px; background: linear-gradient(160deg, #fff3d0, #fde68a); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--pw) * 0.05); text-align: center; padding: 0 8% 0 12%; border: 1px solid rgba(120, 80, 0, 0.14); }
.endpage .star { font-size: calc(var(--pw) * 0.3); line-height: 1; }
.endpage .the-end { font-size: calc(var(--pw) * 0.12); font-weight: 900; }
.endpage button { width: 100%; max-width: 280px; padding: calc(var(--pw) * 0.04); border-radius: 40px; font-weight: 900; font-size: calc(var(--pw) * 0.075); background: #fff; color: var(--dgold); box-shadow: 0 4px 0 rgba(120, 80, 0, 0.25); }
.endpage button.close { background: var(--dgold); color: #fff; }
.end-left { display: flex; align-items: center; justify-content: center; font-size: calc(var(--pw) * 0.45); background: linear-gradient(160deg, #fde68a, #fff3d0); }
.right-base { position: absolute; top: 0; left: var(--pw); width: var(--pw); height: 100%; }
.book.single .right-base { left: 0; }

/* Pager */
.pager {
    position: fixed; left: 0; right: 0; bottom: 12px; z-index: 50;
    display: flex; justify-content: center; align-items: center; gap: 22px;
    transition: opacity 0.3s;
}
.pager.hidden { opacity: 0; pointer-events: none; }
.pager button {
    width: 72px; height: 72px; border-radius: 50%; background: #fff; color: var(--dgold);
    font-size: 2rem; font-weight: 900; box-shadow: 0 5px 0 rgba(120, 80, 0, 0.22), var(--shadow);
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.pager button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(120, 80, 0, 0.22); }
.pager button:disabled { opacity: 0.35; }
.pager .count { min-width: 84px; text-align: center; font-weight: 900; color: var(--dgold); font-size: 1.15rem; }

@media (max-height: 520px) {
    :root { --band-h: 52px; }
    .stage { padding-bottom: 76px; }
    .pager button { width: 58px; height: 58px; font-size: 1.6rem; }
    .exit-btn, .sound-btn { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    .leaf, .book { transition-duration: 0.01s !important; }
    .bobber.closed, .cover .c-tap, .pic.boing, .w-jud.boing { animation: none !important; }
}

/* Symbols: picture on the right page, the Judean name on top of it */
.book .wp.letter { flex: 1; min-height: 0; justify-content: stretch; }
.w-frame { position: relative; width: 100%; flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; border-radius: 22px; border: 6px solid #0d9488; background: #fff8e7; overflow: hidden; cursor: pointer; }
.w-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.w-frame .w-jud { position: relative; width: 100%; text-align: center; padding: calc(var(--pw) * 0.015) 0 calc(var(--pw) * 0.06); background: linear-gradient(rgba(255,255,255,0.92) 55%, rgba(255,255,255,0)); text-shadow: 0 0 6px #fff; transform-origin: 50% 0; }
.w-jud.pending { opacity: 0; transform: scale(0.4); }
.w-jud.in { animation: wordIn 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
@keyframes wordIn { 0% { opacity: 0; transform: scale(0.4); } 55% { opacity: 1; transform: scale(1.18); } 100% { opacity: 1; transform: scale(1); } }

/* First-page finger demo */
.finger { position: fixed; z-index: 90; font-size: 64px; line-height: 1; pointer-events: none; opacity: 0; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); }
.finger.on { opacity: 1; }
.finger.tap { transform: scale(0.82) translateY(6px); }
.hint { animation: hintpulse 0.7s ease-in-out infinite; box-shadow: 0 0 0 6px rgba(219, 39, 119, 0.55); }
@keyframes hintpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ═══════════ GAMES ═══════════ */
.game-stage { position: relative; height: calc(100vh - var(--band-h)); height: calc(100dvh - var(--band-h)); overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, #fffdf6 0%, var(--warm) 70%, #ffe8a3 100%); }
.spark { position: absolute; width: 14px; height: 14px; border-radius: 50%; pointer-events: none; z-index: 40;
    animation: spark 0.7s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }

/* Sound game */
.snd-wrap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh; padding: 12px; }
.snd-ear { width: 110px; height: 110px; border-radius: 50%; background: #fff; font-size: 3.4rem; color: var(--dgold);
    box-shadow: 0 6px 0 rgba(120, 80, 0, 0.22), var(--shadow); display: flex; align-items: center; justify-content: center; }
.snd-ear:active { transform: translateY(4px); }
.snd-ear.pulse { animation: pulse 1.2s ease-in-out infinite; }
.snd-choices { display: flex; gap: 5vw; justify-content: center; align-items: center; flex-wrap: wrap; }
.snd-tile { --s: min(40vw, 40vh); width: var(--s); height: var(--s); border-radius: 28px; border: 8px solid var(--a, #f59e0b);
    background: var(--t, #fde68a); color: #1c1a12; font-size: calc(var(--s) * 0.62); line-height: 1;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.snd-tile.in { animation: tileIn 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
.snd-tile.right { animation: boing 0.6s ease; }
.snd-tile.wrong { animation: wobble 0.45s ease; }
.snd-tile.away { animation: away 0.5s ease forwards; }
@keyframes tileIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes away { to { transform: scale(0.3); opacity: 0; } }

/* Bubble game */
.bub { position: absolute; bottom: -200px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95) 0 8%, var(--b1) 9%, var(--b2) 100%);
    border: 4px solid rgba(255, 255, 255, 0.85); box-shadow: inset -10px -14px 24px rgba(0, 0, 0, 0.12), 0 8px 18px rgba(120, 80, 0, 0.2);
    color: #1c1a12; line-height: 1; animation: bubUp var(--dur) linear forwards; touch-action: manipulation; cursor: pointer; }
.bub span { transform: translateY(-4%); }
.bub.pop { animation: bubPop 0.25s ease-out forwards !important; }
@keyframes bubUp { from { transform: translateY(0) translateX(0); } 25% { transform: translateY(-28vh) translateX(14px); } 50% { transform: translateY(-58vh) translateX(-14px); } 75% { transform: translateY(-88vh) translateX(14px); } to { transform: translateY(-125vh) translateX(0); } }
@keyframes bubPop { to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .bub { animation-duration: 40s !important; } }


/* iPhone / portrait: a folded page corner you can tap to turn the page */
.face .blank { position: absolute; inset: 0; }
.curl { position: absolute; right: 0; bottom: 0; width: calc(var(--pw) * 0.2); height: calc(var(--pw) * 0.2); z-index: 2000; cursor: pointer; display: none;
    -webkit-transform: translateZ(60px); transform: translateZ(60px); }
.book.single .curl { display: block; }
.book.single.closed .curl, .book.single.atend .curl { display: none; }
.curl::before { content: ''; position: absolute; right: 0; bottom: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(0,0,0,0) 0 50%, rgba(120,80,0,.28) 50%, #fff6d6 54%, #ffe9a8 100%);
    border-top-left-radius: 90% 100%; box-shadow: -4px -4px 10px rgba(120,80,0,.25);
    animation: curlWiggle 2.6s ease-in-out infinite; transform-origin: bottom right; }
@keyframes curlWiggle { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.18); } 90% { transform: scale(1.05); } }


/* page turn: the page darkens as it swings, like paper turning away from the light */
.face.front::before, .face.back::before { content: ''; position: absolute; inset: 0; z-index: 6; pointer-events: none; opacity: 0;
    background: linear-gradient(90deg, rgba(40,20,0,.55), rgba(40,20,0,.1) 75%, rgba(40,20,0,0));
    -webkit-transition: opacity 0.85s linear; transition: opacity 0.85s linear; }
.face.back::before { opacity: 1; background: linear-gradient(270deg, rgba(40,20,0,.55), rgba(40,20,0,.1) 75%, rgba(40,20,0,0)); }
.leaf.flipped .face.front::before { opacity: 1; }
.leaf.flipped .face.back::before { opacity: 0; }
.book.quick .face::before { -webkit-transition-duration: 0.45s; transition-duration: 0.45s; }
.cover.face::before { display: none; }
.stage.single { -webkit-perspective: 1000px; perspective: 1000px; }
