/* Reframe the unchanged opening image; no new raster, portrait or prop is created. */
.stage[data-background=needle] .stage-background{object-position:62% 50%;transform:none}
.stage[data-background=needle] .stage-light{background:linear-gradient(90deg,#07180fd9,transparent 52%),linear-gradient(0deg,#07180f88,transparent 28%)}
body[data-framing=illustration] .reading-space{width:min(38vw,480px);margin:0}
body[data-framing=illustration] .reading-panel{padding:24px 26px 14px;background:#091b11e8}
.stage[data-background=deck] .stage-background,.stage[data-background=sails] .stage-background{filter:brightness(.68) saturate(.8)}
.stage[data-background=gaspar]{clip-path:inset(0 0 28svh 0);mask-image:linear-gradient(#000 0,#000 65svh,transparent 72svh)}
.stage[data-background=gaspar] .stage-background{object-position:62% 0%;transform:scale(1.85);transform-origin:85% 0%}
.stage[data-framing=companions] .actor-patrick{left:30%}
.stage[data-framing=companions] .actor-elliana{left:71%}
.stage[data-framing=elliana] .actor-elliana{left:54%;width:min(43vw,590px)}
@media(max-width:1100px){
  body[data-framing=illustration] .reading-space{width:min(1120px,100%);margin:0 auto}
  body[data-framing=illustration] .reader{padding-top:52svh}
  .stage[data-background=needle] .stage-background{height:53svh;min-height:0;object-position:80% 0%}
  .stage[data-background=needle] .stage-light{background:linear-gradient(0deg,#07180f 0%,#07180f 43%,#07180f44 51%,transparent 64%)}
}
@media(max-width:960px) and (min-width:641px){.stage[data-framing=elliana] .actor-elliana{width:60vw}}
@media(max-width:640px){
  body[data-framing=illustration] .reader{padding-top:50svh}
  body[data-framing=illustration] .reading-panel{padding:16px 20px 10px}
  .stage[data-background=needle] .stage-background{height:50svh;object-position:80% 0%}
  .stage[data-background=needle] .stage-light{background:linear-gradient(0deg,#07180f 0%,#07180f 47%,#07180f44 55%,transparent 66%)}
  .stage[data-background=gaspar] .stage-background{height:50svh;min-height:0;object-position:90% 0%;transform:scale(1.5);transform-origin:85% 0%}
  .stage[data-background=gaspar]{clip-path:inset(0 0 55svh 0);mask-image:linear-gradient(#000 0,#000 38svh,transparent 45svh)}
  .stage[data-framing=companions] .actor-patrick{top:6svh;bottom:auto;left:24%;width:72vw}
  .stage[data-framing=companions] .actor-elliana{top:5svh;bottom:auto;left:75%;width:78vw}
  .stage[data-framing=elliana] .actor-elliana{top:1svh;bottom:auto;left:54%;width:106vw}
}
@media(max-height:620px) and (min-width:1101px){body[data-framing=illustration] .reader{padding-top:24px}}
/* staging.js keeps the complete old image until the next image is decoded.
   Only the outgoing bitmap fades; the incoming one stays fully opaque. */
body:not(.reduce-motion) .stage-background{animation:none}
.scene-transition-frame{position:fixed;z-index:3;pointer-events:none;overflow:hidden;will-change:opacity}
.scene-transition-image{pointer-events:none}
.scene-transition-light{position:absolute;inset:0;pointer-events:none}
/* Small glows stay registered to visible flames/lanterns, never the whole scene. */
.scene-atmosphere{position:absolute;z-index:0;pointer-events:none;overflow:hidden}
.scene-light-source{position:absolute;display:block;pointer-events:none;opacity:0;mix-blend-mode:screen;background:radial-gradient(ellipse at center,#fff0cceb 0%,#ffc27ba6 24%,#eaaa6440 55%,#eaaa6400 100%)}
.scene-light-soft{mix-blend-mode:normal;background:none}
.scene-sea-surface{position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none;opacity:0}
@media(prefers-reduced-motion:no-preference){
  body:not(.reduce-motion) .stage .scene-light-source{animation:scene-lantern-flicker var(--light-period,4.6s) ease-in-out infinite}
  body:not(.reduce-motion) .stage .scene-light-soft{animation-name:scene-soft-light-flicker}
  body:not(.reduce-motion) .stage .scene-sea-surface{opacity:1}
  body:not(.reduce-motion) .stage .scene-water-motion{animation:scene-water-drift 5.8s cubic-bezier(.45,0,.55,1) infinite}
  body:not(.reduce-motion) .stage .scene-sail-motion{animation:scene-sail-drift 7.2s cubic-bezier(.45,0,.55,1) infinite}
}
.stage[data-motion-paused=true] .scene-atmosphere *,body:has(dialog[open]) .scene-atmosphere *{animation-play-state:paused!important}
@keyframes scene-lantern-flicker{
  0%,100%{opacity:.06}
  18%{opacity:.92}
  34%{opacity:.22}
  53%{opacity:.68}
  72%{opacity:.1}
  87%{opacity:.8}
}
@keyframes scene-soft-light-flicker{
  0%,100%{opacity:.1}
  18%{opacity:.64}
  34%{opacity:.22}
  53%{opacity:.48}
  72%{opacity:.16}
  87%{opacity:.54}
}
@keyframes scene-water-drift{
  0%,100%{opacity:.75;transform:translate(-9px,2px) scaleX(.992)}
  50%{opacity:1;transform:translate(11px,-2px) scaleX(1.008)}
}
@keyframes scene-sail-drift{
  0%,100%{transform:translate(-9px,2px) rotate(-.24deg)}
  50%{transform:translate(11px,-4px) rotate(.28deg)}
}

/* The new illustrated scenes keep their whole wide composition above the text. */
body:is([data-framing=cinematic],[data-framing=collage],[data-framing=silent]){
  --scene-height:max(240px,calc(100svh - var(--reading-panel-height,220px) - 48px));
}
.stage:is([data-framing=cinematic],[data-framing=collage],[data-framing=silent]){position:absolute;bottom:auto;height:var(--scene-height)}
.stage:is([data-framing=cinematic],[data-framing=collage],[data-framing=silent]) .stage-background{
  height:var(--scene-height);min-height:0;object-fit:contain;object-position:50% 50%;transform:none;filter:none;
}
.stage:is([data-framing=cinematic],[data-framing=collage],[data-framing=silent]) .stage-light{background:none}
body:is([data-framing=cinematic],[data-framing=collage],[data-framing=silent]) .reader{padding-top:calc(var(--scene-height) + 12px)}
.montage-collage{position:absolute;top:0;left:50%;transform:translateX(-50%);display:grid;grid-template-columns:1fr 1fr 1fr;grid-template-rows:1fr 1fr;gap:6px;width:min(1320px,100%);height:var(--scene-height);padding:12px 0}
.montage-panel{min-width:0;min-height:0;overflow:hidden;background:#06120c}
.montage-panel:first-child{grid-row:span 2}
.montage-panel img{display:block;width:100%;height:100%;object-fit:cover;object-position:50% 50%}
@media(min-width:801px){.montage-panel:first-child img{object-position:70% 50%}}
body[data-presentation=silent] .reading-panel{background:none;border-color:transparent;box-shadow:none}
body[data-presentation=silent] .panel-top{display:none}
body[data-presentation=silent] .passage{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
body[data-presentation=silent] .reading-bottom{margin-top:0}
@media(max-width:800px){
  body:is([data-framing=cinematic],[data-framing=silent]){--scene-height:56.25vw}
  body[data-framing=silent]{--scene-height:max(240px,calc(100svh - var(--reading-panel-height,84px) - 48px))}
  body[data-framing=collage]{--scene-height:calc(112.5vw + 12px)}
  body:is([data-framing=cinematic],[data-framing=collage],[data-framing=silent]) .reader{justify-content:flex-start;padding:calc(var(--scene-height) + 16px) 12px 20px}
  body:is([data-framing=cinematic],[data-framing=collage]) .reading-panel{padding:16px 20px 10px}
  .montage-collage{grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr 2fr;gap:4px;padding:0;width:100%}
  .montage-panel:first-child{grid-row:auto}
  .montage-panel:last-child{grid-column:span 2}
  .montage-panel img{object-fit:contain}
  body[data-presentation=silent] .reader{min-height:100svh;justify-content:flex-end}
}
@media(prefers-reduced-motion:no-preference){
  body:not(.reduce-motion) .stage[data-framing=collage].shot-enter .montage-panel{animation:collage-arrive .22s ease-out backwards}
  body:not(.reduce-motion) .stage[data-framing=collage].shot-enter .montage-panel:nth-child(2){animation-delay:.06s}
  body:not(.reduce-motion) .stage[data-framing=collage].shot-enter .montage-panel:nth-child(3){animation-delay:.12s}
  body:not(.reduce-motion) .stage[data-framing=collage].shot-enter .montage-panel:nth-child(4){animation-delay:.18s}
  body:not(.reduce-motion) .stage[data-framing=collage].shot-enter .montage-panel:nth-child(5){animation-delay:.24s}
}
@keyframes collage-arrive{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:none}}

/* Ambient menu layers use the existing image; the character is never transformed. */
.menu-atmosphere{position:absolute;pointer-events:none;overflow:hidden}
.menu-ship-drift{transform-origin:1218px 682px}
.menu-lantern-flicker,.menu-needle-glint{opacity:0}
@media(prefers-reduced-motion:no-preference){
  body:not(.reduce-motion) .stage[data-background=menu] .menu-ship-drift{animation:menu-ship-drift 6.8s ease-in-out infinite}
  body:not(.reduce-motion) .stage[data-background=menu] .menu-lantern-flicker{animation:menu-lantern-flicker 3.8s ease-in-out infinite}
  body:not(.reduce-motion) .stage[data-background=menu] .menu-needle-glint{animation:menu-needle-glint 4.6s ease-in-out infinite}
}
.stage[data-motion-paused=true] .menu-atmosphere *,body:has(dialog[open]) .menu-atmosphere *{animation-play-state:paused!important}
@keyframes menu-ship-drift{
  0%,100%{transform:translate(0,0) rotate(0deg)}
  28%{transform:translate(24px,-8px) rotate(.18deg)}
  72%{transform:translate(-24px,8px) rotate(-.18deg)}
}
@keyframes menu-lantern-flicker{
  0%,100%{opacity:.06}
  17%{opacity:1}
  31%{opacity:.24}
  44%{opacity:.78}
  62%{opacity:.08}
  76%{opacity:.94}
  89%{opacity:.3}
}
@keyframes menu-needle-glint{
  0%,8%,40%,100%{opacity:0;transform:translateY(8px)}
  22%{opacity:.95;transform:translateY(0)}
  34%{opacity:.25;transform:translateY(-8px)}
}
