/* Gaau-zai the dumpling: the side panel on wide screens, and the conversation partner on every screen.
   Illustration colours are fixed so Gaau-zai looks the same on both themes. Moods are set on any ancestor:
   [data-mood=listening|thinking|happy|confused|sad|cold] and .talking (while Gong speaks). */

/* ---------- side panel: phrase of the day ---------- */
.say-bubble{position:relative; align-self:stretch; display:flex; flex-direction:column; gap:var(--s-1); padding:var(--s-4); border-radius:var(--r-box); background:var(--surface); box-shadow:var(--raise); animation:rise var(--t) var(--ease) both}
.say-bubble::after{content:""; position:absolute; bottom:-8px; left:50%; width:16px; height:16px; background:var(--surface); box-shadow:1px 1px 0 var(--line); transform:translateX(-50%) rotate(45deg)}
.mascot-jp{font-size:var(--fs-xl); line-height:1.35}
.mascot-en{color:var(--ink-2)}
.mascot-actions{display:flex; align-items:center; gap:var(--s-4); margin-top:var(--s-2)}
.mascot-name{font-weight:600}
/* only when you're not in the middle of something (a lesson, a conversation, the level check) */
:root.in-task .mascot .say-bubble{display:none}
.dumpling-btn{margin-top:var(--s-3); padding:0; border:0; background:none; border-radius:var(--r-box); cursor:pointer}
.dumpling-svg{display:block; width:230px; height:auto; overflow:visible}

/* ---------- the drawing: ink and seal (ui/dumpling.js) ---------- */
.dumpling-svg .paper{fill:#F6F0E2}
.dumpling-svg .dough{fill:#FFFDF8}
.dumpling-svg .shade{fill:#2A2522; opacity:.045}
.dumpling-svg .brush{fill:#2A2522}
.dumpling-svg .blush{stop-color:#F29A96}
.dumpling-svg .pleats{opacity:.6}
.dumpling-svg .basket-wash{fill:#E7D7B6; opacity:.55}
.dumpling-svg .slats{opacity:.55}
.dumpling-svg .seal rect{fill:#C23B2E}
.dumpling-svg .seal text{fill:#FBEFE0}
.dumpling-svg .steam path{stroke:#8C857C; opacity:.5}
/* Motion is brief: steam rises a few times when Gaau-zai appears, then rests (no endless loops: they keep the
   computer busy for as long as the page is open). gz-idle.js adds an occasional peek, squeeze, glance or hop. */
.dumpling-svg.live .steam path{animation:steam 3s ease-in-out 2}
.dumpling-svg .steam path:nth-child(2){animation-delay:-1s}
.dumpling-svg .steam path:nth-child(3){animation-delay:-2s}
.dumpling-svg.hatted .steam{display:none}
.dumpling-svg .brows{stroke:#2A2522; opacity:0; transition:opacity var(--t-fast)}
.dumpling-svg .bags{stroke:#B89A86; opacity:0}
.dumpling-svg.tired .bags{opacity:1}
.dumpling-svg .cheeks{opacity:.75; transition:opacity var(--t)}
.dumpling-svg :is(.eye, .eye-smile){fill:#2A2522}
.dumpling-svg :is(.eye-sad, .eye-cold, .mouth-smile, .mouth-flat, .mouth-wavy, .mouth-sad){stroke:#2A2522}
.dumpling-svg .glint{fill:#FFFFFF}
.dumpling-svg .mouth-in{fill:#7E2722; stroke:#2A2522}
.dumpling-svg .tongue{fill:#EC8A84}
.dumpling-svg .tear{fill:#7FB3E0}
/* faces: one set of eyes and one mouth showing at a time */
.dumpling-svg :is(.eye-smile, .eye-open, .eye-sad, .eye-cold, .tear, .mouth, .mouth-open, .mouth-smile, .mouth-flat, .mouth-wavy, .mouth-sad){opacity:0; transition:opacity 90ms}
.dumpling-svg :is(.eye-smile, .mouth){opacity:1}
/* mood extras, hidden until a mood shows them */
.dumpling-svg .thought circle{fill:#8C857C}
.dumpling-svg .waves path{stroke:var(--accent)}
.dumpling-svg .question{fill:var(--accent); font:700 44px/1 var(--font)}
.dumpling-svg .sparkles path{fill:#F2C14E}
.dumpling-svg :is(.thought, .waves, .question, .sparkles){opacity:0; transition:opacity var(--t-fast)}

/* ---------- motion ---------- */
.dumpling-svg :is(.dumpling, .body, .eyes, .eye-smile, .eye-open, .eye-ball, .glints, .mouth, .mouth-open, .cheeks, .brow-l, .brow-r, .tear){transform-box:fill-box; transform-origin:50% 100%; transition:transform var(--t) var(--ease)}
.dumpling-svg :is(.eyes, .eye-smile, .eye-open, .eye-ball, .glints, .cheeks, .brow-l, .brow-r){transform-origin:center}
.dumpling-svg .mouth-open{transform-origin:50% 0}
.dumpling-svg.live .dumpling{animation:bob 3.4s ease-in-out}
.dumpling-btn:hover .dumpling-svg .dumpling, .gz-btn:hover .dumpling-svg .dumpling{animation:bob 1.2s ease-in-out infinite}

[data-mood="listening"] .dumpling-svg .waves{opacity:1; animation:waves 1.1s ease-in-out infinite}
[data-mood="listening"] .dumpling-svg .body{transform:rotate(-4deg)}
[data-mood="listening"] .dumpling-svg .eye-open{opacity:1; transform:scale(1.1)}
[data-mood="listening"] .dumpling-svg .eye-ball{animation:gz-blink 4.2s ease-in-out 1.6s infinite}
[data-mood="thinking"] .dumpling-svg .thought{opacity:1}
[data-mood="thinking"] .dumpling-svg .thought circle{animation:think 1.2s ease-in-out infinite}
[data-mood="thinking"] .dumpling-svg .thought circle:nth-child(2){animation-delay:.2s}
[data-mood="thinking"] .dumpling-svg .thought circle:nth-child(3){animation-delay:.4s}
[data-mood="thinking"] .dumpling-svg .eye-open{opacity:1}
[data-mood="thinking"] .dumpling-svg :is(.eye-ball, .glints){transform:translate(4px, -4px)}
[data-mood="thinking"] .dumpling-svg .brows, [data-mood="confused"] .dumpling-svg .brows{opacity:1}
[data-mood="happy"] .dumpling-svg .eye-smile{transform:scale(1.08, .82)}
[data-mood="happy"] .dumpling-svg .mouth{transform:scale(1.18)}
[data-mood="happy"] .dumpling-svg .cheeks{opacity:.85; transform:translateY(-2px)}
[data-mood="happy"] .dumpling-svg .sparkles{opacity:1; animation:twinkle .9s ease-in-out infinite alternate}
[data-mood="happy"] .dumpling-svg .body{animation:hop .55s var(--ease) 2}
[data-mood="confused"] .dumpling-svg .question{opacity:1}
[data-mood="confused"] .dumpling-svg .body{transform:rotate(6deg)}
[data-mood="confused"] .dumpling-svg .eye-open{opacity:1}
[data-mood="confused"] .dumpling-svg .brow-l{transform:translateY(-4px) rotate(-10deg)}
[data-mood="confused"] .dumpling-svg .mouth-wavy{opacity:1}
/* sad: someone was unkind. Droopy eyes, worried brows, a tear that runs down, a frown, and Gaau-zai sinks a little */
[data-mood="sad"] .dumpling-svg .eye-sad{opacity:1}
[data-mood="sad"] .dumpling-svg .brows{opacity:1}
[data-mood="sad"] .dumpling-svg .brow-l{transform:rotate(-18deg) translateY(2px)}
[data-mood="sad"] .dumpling-svg .brow-r{transform:rotate(18deg) translateY(2px)}
[data-mood="sad"] .dumpling-svg .tear{opacity:1; animation:gz-tear 1.8s ease-in 3}
[data-mood="sad"] .dumpling-svg .mouth-sad{opacity:1}
[data-mood="sad"] .dumpling-svg .cheeks{opacity:.25}
[data-mood="sad"] .dumpling-svg .body{transform:translateY(3px) scale(1.02, .97)}
[data-mood="sad"] .dumpling-svg .steam{opacity:0}
/* the moods that don't smile hide the usual eyes and mouth */
[data-mood="listening"] .dumpling-svg .eye-smile, [data-mood="thinking"] .dumpling-svg .eye-smile, [data-mood="confused"] .dumpling-svg .eye-smile, [data-mood="sad"] .dumpling-svg .eye-smile{opacity:0}
[data-mood="listening"] .dumpling-svg .mouth, [data-mood="thinking"] .dumpling-svg .mouth, [data-mood="confused"] .dumpling-svg .mouth, [data-mood="sad"] .dumpling-svg .mouth{opacity:0}
[data-mood="listening"] .dumpling-svg .mouth-smile, [data-mood="thinking"] .dumpling-svg .mouth-flat{opacity:1}
.poked .dumpling-svg .body{animation:squish .4s var(--ease)}

/* talking: the open mouth takes over from any other and the smiling eyes move with the words. The body stays still:
   moving it would redraw its brush texture (an SVG filter) every frame, which costs phones far more than the face. */
.talking .dumpling-svg.ink :is(.mouth, .mouth-smile, .mouth-flat, .mouth-wavy, .mouth-sad){opacity:0}
.talking .dumpling-svg.ink .mouth-open{opacity:1; animation:talk .9s linear infinite}
.talking .dumpling-svg .eye-smile{animation:talk-eyes .9s ease-in-out infinite}

@keyframes bob{50%{transform:translateY(-5px) scale(1.01, .985)}}
/* the mouth opens by different amounts, the way syllables do, instead of flapping evenly */
@keyframes talk{0%{transform:scale(1.02, .3)} 14%{transform:scale(.96, 1)} 26%{transform:scale(1.04, .45)} 40%{transform:scale(.94, .85)} 52%{transform:scale(1.03, .25)} 66%{transform:scale(.97, 1.08)} 80%{transform:scale(1.02, .55)} 100%{transform:scale(1.02, .3)}}
@keyframes talk-eyes{0%, 100%{transform:none} 30%{transform:translateY(-1px) scale(1.04, .9)} 60%{transform:translateY(.5px)}}
@keyframes steam{0%{transform:translateY(4px); opacity:0} 40%{opacity:.6} 100%{transform:translateY(-8px); opacity:0}}
@keyframes waves{50%{opacity:.35}}
@keyframes think{50%{transform:translateY(-3px); opacity:.5}}
@keyframes twinkle{to{opacity:.4}}
@keyframes hop{40%{transform:translateY(-14px) scale(.97, 1.04)} 70%{transform:translateY(0) scale(1.04, .96)}}
@keyframes squish{30%{transform:scale(1.08, .88)} 60%{transform:scale(.96, 1.05)}}
@keyframes gz-tear{0%{transform:translateY(-4px) scale(.6); opacity:0} 20%{opacity:1; transform:none} 85%{opacity:1} 100%{transform:translateY(16px) scale(.8); opacity:0}}

/* ---------- conversation: Gaau-zai is your partner ---------- */
/* Phones and tablets: a band under the scene title, always in view while the chat scrolls. */
.gz-stage{display:grid; grid-template-columns:auto 1fr; align-items:center; gap:var(--s-3)}
.gz-btn{padding:0; border:0; background:none; border-radius:var(--r-ctl); cursor:pointer}
.gz-btn .dumpling-svg{width:92px}
.gz-text{min-width:0; display:flex; flex-direction:column; gap:2px}
.gz-role{font-size:var(--fs-sm); color:var(--ink-3)}
.gz-role b{color:var(--ink); font-weight:600}
.gz-caption{font-weight:600; color:var(--ink)}
.gz-stage[data-mood="listening"] .gz-caption, .gz-stage[data-mood="confused"] .gz-caption{color:var(--accent)}
.gz-bubble{display:none}

/* Wide screens: the right-hand panel becomes Gaau-zai's stage, with the line being said above. */
@media (min-width:1240px){
  body:has(.convo) .mascot{display:none}
  .gz-stage{position:fixed; top:0; right:0; bottom:0; width:360px; grid-template-columns:1fr; justify-items:center; align-content:center; gap:var(--s-3);
    padding:var(--s-6) var(--s-5); background:var(--bg); box-shadow:-1px 0 0 var(--line); text-align:center; overflow:auto}
  .gz-btn .dumpling-svg{width:240px}
  .gz-text{align-items:center}
  .gz-bubble{position:relative; display:flex; flex-direction:column; gap:var(--s-1); justify-self:stretch; padding:var(--s-4); border-radius:var(--r-box); background:var(--surface); box-shadow:var(--raise); text-align:left}
  .gz-bubble[hidden]{display:none}
  .gz-bubble::after{content:""; position:absolute; bottom:-8px; left:50%; width:16px; height:16px; background:var(--surface); box-shadow:1px 1px 0 var(--line); transform:translateX(-50%) rotate(45deg)}
  .gz-bubble .say-jp{font-size:var(--fs-lg)}
}

/* ---------- mouth follows the voice (audio/tts.js sets --mouth, 0 to 1.35, from the voice's loudness) ----------
   The mouth opens with each syllable and narrows a little as it opens; louder moments lift the cheeks, squeeze the
   smiling eyes, so the whole face speaks, not just the mouth. */
:root.lipsync .talking .dumpling-svg .mouth-open{animation:none; transform:scale(calc(1.04 - var(--mouth, .6) * .08), calc(.22 + var(--mouth, .6) * .7)); transition:transform 60ms linear}
:root.lipsync .talking .dumpling-svg .eye-smile{animation:none; transform:translateY(calc(var(--mouth, 0) * -1.2px)) scale(1, calc(1 - var(--mouth, 0) * .12)); transition:transform 80ms linear}
:root.lipsync .talking .dumpling-svg .cheeks{transform:translateY(calc(var(--mouth, 0) * -2px)); transition:transform 80ms linear}
:root.mouth-accent .talking .dumpling-svg .mouth-open{animation:none; transform:scale(.94, 1.15)}

/* ---------- idle moments (ui/gz-idle.js): the eyes do most of it ----------
   peek: the eyes open, look left and right, and close back into a smile · wink-open: they open and blink twice
   squeeze: a happy squeeze of the smiling eyes · yawn · hop · giggle: a wiggle with squeezed eyes */
.dumpling-svg:is(.idle-peek, .idle-blinks) .eye-smile{opacity:0}
.dumpling-svg:is(.idle-peek, .idle-blinks) .eye-open{opacity:1}
.dumpling-svg:is(.idle-peek, .idle-blinks) .mouth{opacity:0}
.dumpling-svg:is(.idle-peek, .idle-blinks) .mouth-smile{opacity:1}
.dumpling-svg.idle-peek :is(.eye-ball, .glints){animation:gz-look 2.2s ease-in-out}
.dumpling-svg.idle-blinks .eye-ball{animation:gz-blink2 1.3s ease-in-out}
.dumpling-svg.idle-squeeze .eye-smile{animation:gz-squeeze .5s ease-in-out}
.dumpling-svg.idle-yawn .mouth{opacity:0}
.dumpling-svg.idle-yawn .mouth-open{opacity:1; animation:gz-yawn 2.4s ease-in-out}
.dumpling-svg.idle-yawn .eye-smile{animation:gz-squint 2.4s ease-in-out}
.dumpling-svg.idle-hop .body{animation:hop .9s var(--ease)}
.dumpling-svg.idle-giggle .body{animation:gz-giggle .9s ease-in-out}
.dumpling-svg.idle-giggle .eye-smile{animation:gz-squeeze .45s ease-in-out 2}
@keyframes gz-look{15%{transform:none} 35%{transform:translateX(-5px)} 65%{transform:translateX(5px)} 85%, 100%{transform:none}}
@keyframes gz-yawn{0%{transform:scaleY(.2)} 40%, 62%{transform:scaleY(1.6)} 100%{transform:scaleY(.2)}}
@keyframes gz-squint{30%, 70%{transform:scale(1.05, .55)}}
@keyframes gz-squeeze{50%{transform:scale(1.08, .6) translateY(1px)}}
@keyframes gz-giggle{20%{transform:rotate(-3deg)} 40%{transform:rotate(3deg)} 60%{transform:rotate(-2deg)} 80%{transform:rotate(1.5deg)}}
@keyframes gz-blink{0%, 92%, 100%{transform:none} 96%{transform:scaleY(.1)}}
@keyframes gz-blink2{0%, 25%, 45%, 75%, 100%{transform:none} 35%, 85%{transform:scaleY(.1)}}

/* ---------- festival props ---------- */
.dumpling-svg .glow{opacity:.5}
.dumpling-svg.live .glow{animation:gz-glow 2s ease-in-out 6 alternate}
@keyframes gz-glow{from{opacity:.25} to{opacity:.7}}

/* Gaau-zai as a girl or a boy (ui/dumpling.js LOOK) */
.dumpling-svg.girl .cheek{fill:#F27A9A; opacity:.62}
.dumpling-svg .lashes{transition:opacity var(--t-fast)}
[data-mood="sad"] .dumpling-svg .lashes, [data-mood="cold"] .dumpling-svg .lashes{opacity:0}

/* Why Gaau-zai is blue: a snowflake at the top right of Gaau-zai, tap it to see why (ui/gz-cold.js) */
.gz-domain{position:relative; display:inline-block}
.cold-wrap{position:absolute; top:4%; right:2%; z-index:4}
.cold-badge{display:grid; place-items:center; width:32px; height:32px; padding:0; border:0; border-radius:50%; background:#E6F0FA; color:#3E7CB1; box-shadow:0 0 0 2px var(--bg), 0 2px 6px rgba(0,0,0,.12); cursor:pointer}
.cold-badge:hover, .cold-badge[aria-expanded="true"]{background:#3E7CB1; color:#FFFFFF}
.cold-tip{position:absolute; top:calc(100% + 8px); right:0; width:max-content; max-width:min(240px, 70vw); padding:8px 12px; border-radius:var(--r-ctl); background:var(--inv); color:var(--on-inv); font-size:var(--fs-sm); line-height:1.4; text-align:left; box-shadow:0 6px 20px rgba(0,0,0,.18)}
.cold-tip[hidden]{display:none}
.home-gz .cold-badge{width:28px; height:28px}
