/* Edi as a photo-real teacher (static/js/player/edi/avatar.js). Layout and modes still come from edi.css (the host
   .edi is positioned and scaled there); this sheet styles the image stack inside the host: the portrait card in the
   corner, the floating cutout in big moments, layer crossfades, the "alive" motion and the talking ring. */
.edi.edi-photo { height: var(--edi-size); }
.edi.loading { opacity: 0 !important; }                              /* until the manifest and the base image are decoded */                        /* square portrait instead of the 1.2:1 drawing */
.edi.edi-photo svg { display: none; }
.edi-av { position: absolute; inset: 0; border-radius: 24%; overflow: hidden; isolation: isolate;
  background: radial-gradient(ellipse at 50% 30%, #FFF8EC 0%, #F6E9D2 60%, #EBD9BC 100%);
  box-shadow: 0 10px 28px -10px rgba(28, 26, 23, .45), 0 2px 6px rgba(28, 26, 23, .18); transition: border-radius .5s ease, box-shadow .5s ease, background-color .5s ease; }
.edi-av-card { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 0 2px rgba(255, 90, 31, .85), inset 0 0 0 4px rgba(255, 255, 255, .55); transition: box-shadow .35s ease, opacity .4s ease; }
/* The canvas is waist-up (space 1536; the 1024 chest-up art sits at offset 256,96): card modes zoom back to head-and-shoulders. */
.edi-av-frame { position: absolute; inset: 0; transform-origin: 50% 50%; transform: scale(1.95) translate(0, 17.08%); transition: transform .6s cubic-bezier(.3, .8, .3, 1); }
.edi-av-body { position: absolute; inset: 0; transform-origin: 50% 100%; animation: ediAvBreath 4.2s ease-in-out infinite, ediAvSway 8s ease-in-out infinite; will-change: transform; }
.edi-av img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.edi-av-base { z-index: 1; }
.edi-av-base.off { opacity: 0; }                                     /* a gesture is fully up: its cutout does not cover the resting arm */
.edi-av-gesture { z-index: 2; opacity: 0; transition: opacity .28s ease; }
.edi-av-gesture.on { opacity: 1; z-index: 3; }                       /* the incoming gesture fades in above the outgoing one */
.edi-av-gesture.held { opacity: 1; transition: none; }               /* outgoing gesture, opaque until the next one is in */
.edi-av-layer { opacity: 0; transition: opacity 80ms linear; }
.edi-av-face { z-index: 4; transition-duration: 160ms; }
.edi-av-eyes { z-index: 5; transition-duration: 45ms; }
.edi-av-mouth { z-index: 6; }
.edi-av-layer.on { opacity: 1; }
/* a gesture image carries its own face/hand: the whole-face layer and the mouth stay out of its way */
.edi-av[data-gesture="chin"] .edi-av-face, .edi-av[data-gesture="chin"] .edi-av-mouth { opacity: 0; }

/* ---------- talking: the ring pulses softly (a pre-rendered glow whose opacity animates: compositor only, no repaint) ---------- */
.edi-av-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0; will-change: opacity;
  box-shadow: inset 0 0 0 3px rgba(255, 90, 31, 1), inset 0 0 0 5px rgba(255, 255, 255, .7), 0 0 18px 3px rgba(255, 90, 31, .4); }
.edi[data-talking="1"] .edi-av-card::after { animation: ediAvRing 1.6s ease-in-out infinite; }
@keyframes ediAvRing { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

/* ---------- big moments (greeting, chapter card): the cutout floats over the stage, no card ---------- */
/* The figure is complete except for one clean horizontal cut: the canvas bottom sits on (just below) the stage floor, which clips it; the 4% overshoot absorbs sway and bounce. */
.edi[data-mode="big"], .stage-wrap.immersive .edi[data-mode="big"] { bottom: 0; }
.edi[data-mode="big"] .edi-av { overflow: visible; border-radius: 0; background: transparent; box-shadow: none; }
.edi[data-mode="big"] .edi-av-card { opacity: 0; }
.edi[data-mode="big"] .edi-av-frame { transform-origin: 50% 100%; transform: translate(9%, 4%) scale(1.42); }
.edi[data-side="left"][data-mode="big"] .edi-av-frame { transform: translate(-9%, 4%) scale(1.42); }
.edi[data-mode="big"] .edi-av-body { filter: drop-shadow(0 6px 10px rgba(28, 26, 23, .35)); }
/* pop (feedback) and peek (interactive scenes): tighter portrait */
.edi[data-mode="pop"] .edi-av-frame { transform: scale(1.65) translate(0, 13.08%); }   /* keeps a chest-level thumbs-up in frame */
.edi[data-mode="peek"] .edi-av-frame { transform: scale(2.04) translate(0, 17.75%); }
/* end of session: the celebration card takes the middle of the stage; the square portrait cheers as a card below it */
.edi.edi-photo[data-mode="cheer"] { transform: translate(var(--edi-cheer-x, -2%), 0) scale(1.18); }
.edi.edi-photo[data-side="left"][data-mode="cheer"] { transform: translate(calc(-1 * var(--edi-cheer-x, -2%)), 0) scale(1.18); }
.edi[data-mode="cheer"] .edi-av-frame { transform: scale(1.65) translate(0, 13.08%); }
/* the square figure is wider than the former drawing: text keeps clear of it in big mode. Range syntax: the stage
   width is often fractional (16:9 of the available height), and "min-width: 701px / max-width: 700px" both miss e.g. 700.4 px */
@container stage (width > 700px) {
  .stage-wrap.edi-on[data-edi-mode="big"] .subtitles { left: 30%; max-width: 46%; }
  .stage-wrap.edi-on[data-edi-mode="big"][data-edi-side="left"] .subtitles { left: 70%; }
  .stage-wrap.edi-on[data-edi-mode="big"] .slide { padding-right: 34%; }   /* same as edi.css, but this block also matches fractional widths */
  .stage-wrap.edi-on[data-edi-mode="big"][data-edi-side="left"] .slide { padding-right: 7%; padding-left: 34%; }
}
/* large stages have room to spare: keep the bullets clear of the raised hand */
@container stage (width > 960px) {
  .stage-wrap.edi-on[data-edi-mode="big"] .slide { padding-right: 38%; }
  .stage-wrap.edi-on[data-edi-mode="big"][data-edi-side="left"] .slide { padding-right: 7%; padding-left: 38%; }
}
/* immersive (landscape phones): the subtitles stay clear of the waist-up figure and its raised arm */
.stage-wrap.immersive.edi-on[data-edi-mode="big"] .subtitles { left: 29%; max-width: 46%; }
.stage-wrap.immersive.edi-on[data-edi-mode="big"][data-edi-side="left"] .subtitles { left: 71%; }
/* mid-size stages (laptops): a slightly smaller title while the figure takes a third of the width, so long titles keep two lines */
@container stage (700px < width <= 960px) {
  .stage-wrap.edi-on[data-edi-mode="big"] .slide h2 { font-size: clamp(18px, 3.7cqw, 28px); }
}
@container stage (width <= 700px) {
  .stage-wrap.edi-on[data-edi-mode="big"] .slide { padding-right: 44%; }
  .stage-wrap.edi-on[data-edi-mode="big"][data-edi-side="left"] .slide { padding-right: 7%; padding-left: 44%; }
  .stage-wrap:not(.immersive).edi-on[data-edi-mode="big"] .subtitles { left: 28%; max-width: 46%; }
  .stage-wrap:not(.immersive).edi-on[data-edi-mode="big"][data-edi-side="left"] .subtitles { left: 72%; }
}

/* ---------- alive: breathing, slow sway, phrase nods, sleeping droop ---------- */
@keyframes ediAvBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012) translateY(-.4%); } }
@keyframes ediAvSway { 0%, 100% { rotate: 0deg; } 30% { rotate: 1.4deg; } 70% { rotate: -1.1deg; } }
.edi-av-body.nod { animation: ediAvBreath 4.2s ease-in-out infinite, ediAvSway 8s ease-in-out infinite, ediAvNod .42s ease-in-out 1; }
@keyframes ediAvNod { 0%, 100% { translate: 0 0; } 45% { translate: 0 1.6%; } }
.edi[data-pose="sleeping"] .edi-av-body { animation: ediAvBreath 6s ease-in-out infinite; rotate: 5deg; translate: 0 2%; transition: rotate 1.2s ease, translate 1.2s ease; }
.edi[data-pose="listening"] .edi-av-body { rotate: -3deg; transition: rotate .5s ease; }
.edi[data-pose="happy"] .edi-av-body { animation: ediAvBreath 4.2s ease-in-out infinite, ediAvCheer .7s ease-in-out 2; }
@keyframes ediAvCheer { 0%, 100% { translate: 0 0; } 50% { translate: 0 -2%; } }
.edi[data-pose="oops"] .edi-av-body { animation: ediAvBreath 4.2s ease-in-out infinite, ediAvShake .55s ease-in-out 1; }
@keyframes ediAvShake { 0%, 100% { rotate: 0deg; } 25% { rotate: -2.5deg; } 75% { rotate: 2.5deg; } }
.edi.edi-photo[data-pose="sleeping"] .edi-av { filter: saturate(.8) brightness(.96); }
.edi.edi-photo.swapping .edi-av { transition: opacity .25s ease; opacity: 0; }

/* ---------- a mention: the corner teacher leans toward the stage (AVA-03) ----------
   The narration names something on the stage and it lights up: pose "pointing" (edi/core.js, POINT_MS) turns the
   portrait about the card's bottom edge and slides it a little toward the stage (left of the card; right when the
   learner dragged it to the left), easing in and back with the frame's own transition. The base framing (scale +
   translate) repeats the corner and peek rules above. Not with reduced motion: the stage's highlight is enough. */
@media (prefers-reduced-motion: no-preference) {
  .edi:not(.still)[data-mode="corner"][data-pose="pointing"] .edi-av-frame { transform: translate(-4%, 50%) rotate(-3.5deg) translate(0, -50%) scale(1.95) translate(0, 17.08%); }
  .edi:not(.still)[data-side="left"][data-mode="corner"][data-pose="pointing"] .edi-av-frame { transform: translate(4%, 50%) rotate(3.5deg) translate(0, -50%) scale(1.95) translate(0, 17.08%); }
  .edi:not(.still)[data-mode="peek"][data-pose="pointing"] .edi-av-frame { transform: translate(-4%, 50%) rotate(-3.5deg) translate(0, -50%) scale(2.04) translate(0, 17.75%); }
  .edi:not(.still)[data-side="left"][data-mode="peek"][data-pose="pointing"] .edi-av-frame { transform: translate(4%, 50%) rotate(3.5deg) translate(0, -50%) scale(2.04) translate(0, 17.75%); }
}

/* ---------- reduced motion: no sway/breath/nod, instant layer swaps; blinking stays ---------- */
.edi.still .edi-av-body, .edi.still .edi-av-card::after { animation: none !important; }
.edi.still .edi-av-layer, .edi.still .edi-av-gesture, .edi.still .edi-av-frame, .edi.still .edi-av { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .edi-av-body, .edi-av-card::after { animation: none !important; }
  .edi-av-layer, .edi-av-gesture { transition: none !important; }
}

/* ---------- corner size: 110–140 px on desktop, ~80 px on phones ---------- */
.stage, .stage-box > .subtitles { --edi-size: clamp(80px, 12.5cqw, 140px); }
@container stage (width <= 480px) { .stage, .stage-box > .subtitles { --edi-size: 80px; } }
/* narrow stages: the subtitles give way to the card on its side only (instead of shrinking on both sides) */
@container stage (width <= 600px) {
  .stage-wrap.edi-on[data-edi-mode="corner"] .subtitles, .stage-wrap.edi-on[data-edi-mode="pop"] .subtitles {
    max-width: calc(100% - var(--edi-size) - 30px); left: calc(50% - (var(--edi-size) + 14px) / 2); }
  .stage-wrap.edi-on[data-edi-mode="corner"][data-edi-side="left"] .subtitles, .stage-wrap.edi-on[data-edi-mode="pop"][data-edi-side="left"] .subtitles {
    left: calc(50% + (var(--edi-size) + 14px) / 2); }
}

/* ---------- tutor header: the same face, small ---------- */
.edi-av-mini { position: relative; inset: auto; width: 100%; height: 100%; border-radius: 12px; box-shadow: none; }
.edi-av-mini .edi-av-card { box-shadow: inset 0 0 0 1.5px rgba(255, 90, 31, .8); }
.edi-av-mini .edi-av-body { animation: none; }
.tutor-head .avatar.edi-avatar.edi-mini-photo { background: #F6E9D2; padding: 0; }
