/* Shared avatar scene and desktop phone sizing. */
#avatar.photo-chapter {
  padding-block: clamp(52px, 7vw, 102px);
  background: #2a2225;
}
#avatar.photo-chapter .avatar-intro { margin-top: 0; }
#avatar.photo-chapter .figure__sticky {
  padding-top: clamp(10px, 2svh, 20px);
  padding-bottom: 16px;
  background: none;
}
#avatar.photo-chapter .figure.is-compact .figure__sticky {
  position: relative;
  top: auto;
}
#avatar .figure__controls:not([hidden]) {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  width: min(100%, 240px);
  margin-top: 10px;
}
#avatar .figure__controls button {
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid rgba(245, 222, 201, .28);
  border-radius: 999px;
  background: #4b3738;
  color: #fff4e8;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}
#avatar .figure__controls button:is(:hover, :focus-visible) {
  background: #674c48;
}
#avatar .figure__controls button span { font-size: 1.2rem; }
.avatar-stage-backdrop {
  position: absolute;
  z-index: -2;
  inset: 0;
  border: 1px solid rgba(235, 192, 157, .24);
  border-radius: clamp(20px, 3.2vw, 40px);
  background:
    radial-gradient(ellipse at 50% 73%, rgba(126, 86, 67, .19) 0%, transparent 67%),
    var(--avatar-photo, url("assets/photos/scene-avatar-20261114.webp")) center 72% / cover no-repeat,
    linear-gradient(155deg, #493639, #20191d 92%);
  box-shadow: inset 0 -16px 55px rgba(26, 18, 20, .27);
}

#moreImg[src^="assets/photos/"] {
  width: 100%;
  height: auto;
  max-height: min(42svh, 400px);
  margin: 0 0 6px;
  object-fit: contain;
  border-radius: var(--r-m);
}

@media (min-width: 1000px) and (min-height: 620px) {
  #story {
    --story-screen-width: min(380px, calc((100svh - var(--nav-height) - 48px) * 750 / 1629));
    --story-phone-height: calc(var(--story-screen-width) * 1629 / 750 + 10px);
  }
  #story .story__sticky { min-height: 0; }
  #story .phone--story {
    width: max-content;
    max-width: 100%;
  }
  #story .phone--story > .phone__screen {
    width: var(--story-screen-width);
    max-width: 100%;
  }
  #avatar.photo-chapter .figure__stage {
    height: min(70svh, calc(100svh - var(--nav-height) - 107px), 650px);
  }
}

/* Keep surrounding captions readable while the selected screen stays emphasized. */
#story .story__step:not(.is-active) { opacity: 1; filter: none; }
#story .story__step:not(.is-active) h2 { color: var(--ink-2); }

/* In the compact layout the decorative glow must not widen the viewport. */
#story.is-compact .story__glow { display: none; }

@media (max-width: 759px) {
  #story .story__glow { display: none; }
  .avatar-stage-backdrop {
    --avatar-photo: url("assets/photos/scene-avatar-mobile-20261114.webp");
  }
}

/* Keep chapter photos behind the full content, including expanded panels. */
:is(#health, #clinic, #nutrition) {
  overflow: clip;
}
:is(#health, #clinic, #nutrition) > .scene-photo {
  inset: 0;
  height: auto;
  overflow: clip;
}
:is(#health, #clinic, #nutrition) > .scene-photo::after {
  background:
    linear-gradient(180deg, rgba(17, 16, 13, .12), rgba(17, 16, 13, .12) 50%, rgba(17, 16, 13, .28)),
    var(--scene-wash);
}
@media (prefers-reduced-motion: no-preference) {
  :is(#health, #clinic, #nutrition) > .scene-photo img {
    position: sticky;
    top: 0;
    max-height: 100svh;
  }
}
@media (max-width: 759px) {
  :is(#health, #clinic, #nutrition) > .scene-photo {
    inset: 0 0 auto;
    height: min(100%, var(--scene-image-height));
  }
  :is(#health, #clinic, #nutrition) > .scene-photo img {
    position: static;
    transform: none;
  }
  :is(#health, #clinic, #nutrition) > .scene-photo::after {
    background: linear-gradient(180deg, rgba(17, 16, 13, .05) 28%, var(--scene-base));
  }
}
