/* ============================================================================
   UNDER — STORY STOP STYLES (CLEANED)
   Source: user's current story.css, consolidated for the flip-card layout.

   QUICK CONTROLS — change the values below, not the layout rules.
   The original 3D environment, story content, and finale use other files.
   ============================================================================ */

:root {
  --story-white: #f2f0e6;
  --story-soft: #d0d5cc;
  --story-panel-color: #050b09ed;
}

#story-stop {
  /* Regular, single-sided story stops */
  --panel-width: 1120px;
  --panel-height: 92dvh;
  --panel-background: rgba(5, 11, 9, 0.94);
  --panel-padding: 24px;
  --panel-image-height: 52dvh;
  --panel-image-focus-x: 50%;
  --panel-image-focus-y: 50%;
  --panel-image-radius: 3px;
  --panel-content-gap: 22px;

  /* Flip card — YOUR current custom dimensions, preserved */
  --flip-width: min(90vw, 1500px);
  --flip-height: min(70dvh, 1800px);
  --flip-front-image-height: min(58dvh, 1060px);
  --flip-back-focus: center 35%;
  --carousel-counter-bottom: 16px;
  --carousel-arrow-inset: 12px;

  position: fixed;
  inset: 0;
  z-index: 8;
  color: var(--story-white);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

#story-stop.is-visible {
  opacity: 1;
  transition-duration: 0.65s;
}

/* Let the browser's hidden attribute win over layout display declarations. */
#story-stop [hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   1. STANDARD SINGLE-SIDED STORY STOPS
   Also used for narrative stops without rightSlide, including written theme.
   -------------------------------------------------------------------------- */

#story-stop .story-shell {
  position: absolute;
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(var(--panel-width), calc(100vw - 48px));
  height: min(var(--panel-height), 1000px);
  max-height: 96dvh;
  box-sizing: border-box;
  padding: var(--panel-padding);
  background: var(--panel-background);
  border: 1px solid rgba(235, 235, 220, 0.12);
  border-radius: 6px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  pointer-events: auto;
}

#story-stop .story-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c1c8b65c transparent;
  touch-action: pan-y;
  pointer-events: auto;
  outline-offset: 6px;
}

#story-stop .story-scroll:focus-visible {
  outline: 1px solid #e5ead4;
}

#story-stop .story-composition {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--panel-content-gap);
  width: 100%;
  padding: 0;
}

/* StoryStop.js wraps the original image and text in this article. */
#story-stop .story-left-slide {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: var(--panel-content-gap);
}

#story-stop .story-art {
  position: relative;
  order: 0;
  align-self: stretch;
  width: 100%;
  max-width: none;
  margin: 0;
  transform: none;
  border-radius: var(--panel-image-radius);
  overflow: hidden;
}

#story-stop .story-art img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: var(--panel-image-height);
  max-height: none;
  object-fit: cover;
  object-position: var(--panel-image-focus-x) var(--panel-image-focus-y);
  border: 0;
  border-radius: var(--panel-image-radius);
}

#story-stop .story-art figcaption {
  margin-top: 10px;
  font: 10px/1.7 Arial, sans-serif;
  letter-spacing: 0.1em;
  text-align: left;
  color: #e0e2d7;
  text-shadow: 0 1px 4px #000, 0 1px 12px #000;
}

#story-stop .story-copy {
  position: relative;
  order: 1;
  isolation: isolate;
  width: 100%;
  max-width: 100%;
  padding: 8px 4px 16px;
}

/* No old blurred/feathered rectangle behind the text. */
#story-stop .story-copy::before {
  content: none;
}

#story-stop .story-kicker {
  margin: 0 0 21px;
  color: var(--story-soft);
  font: 10px/1.6 Arial, sans-serif;
  letter-spacing: 0.21em;
}

#story-stop .story-title {
  max-width: 850px;
  margin: 0 0 18px;
  padding: 0;
  color: var(--story-white);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 3.4vw, 54px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.035em;
  white-space: pre-line;
  text-wrap: balance;
}

#story-stop .story-title:focus {
  outline: none;
}

#story-stop .story-body {
  max-width: 78ch;
  color: #e4e6dc;
  font: 15px/1.75 Arial, sans-serif;
  letter-spacing: 0.005em;
}

#story-stop .story-body p,
#story-stop .story-right-body p {
  margin: 0 0 14px;
}

#story-stop .story-body p:last-child,
#story-stop .story-right-body p:last-child {
  margin-bottom: 0;
}

/* Existing image treatments are deliberately neutralized: no vignette. */
#story-stop .story-art img,
#story-stop .story-right-art img {
  mask-image: none !important;
  -webkit-mask-image: none !important;
  filter: none !important;
  opacity: 1 !important;
}

/* --------------------------------------------------------------------------
   2. BACK / CONTINUE NAVIGATION AND OTHER EXISTING UI
   -------------------------------------------------------------------------- */

#story-stop .story-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex: 0 0 auto;
  width: 100%;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: auto;
}

#story-stop .story-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  white-space: nowrap;
  color: var(--story-white);
  border: 0;
  background: transparent;
  font: 11px/1.4 Arial, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

#story-stop .story-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
}

#story-stop .story-actions button span {
  vertical-align: -1px;
}

#story-stop .story-continue [data-icon] {
  margin-left: 25px;
}

#story-stop .story-back [data-icon] {
  margin-right: 20px;
}

#story-stop .story-cue {
  margin: 0;
  color: #eceddf;
  font: italic 11px/1.6 Georgia, serif;
  text-shadow: 0 1px 3px #000, 0 1px 10px #000;
}

.story-sr {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.story-holding #hud {
  display: none;
}

#controls {
  z-index: 10;
  opacity: 0.85;
  background: #050b09b8;
  padding: 3px 10px;
  margin: -3px -10px;
}

#controls button {
  min-height: 44px;
  color: #eeeee1;
}

header {
  z-index: 9;
}

#motion-toggle {
  display: block;
  margin: 20px auto 0;
  padding: 10px;
  border: 0;
  background: transparent;
  color: #d8e1ce;
  font: 10px/1.5 Arial, sans-serif;
  letter-spacing: 0.09em;
}

/* --------------------------------------------------------------------------
   3. WRITTEN / GRAPHITE STORY STOP
   Keeps handwritten text, delayed reveal and pencil-etched shell outline.
   -------------------------------------------------------------------------- */

#story-stop[data-theme="written"] {
  --written-panel-opacity: 0.42;
  --written-image-height: 42dvh;
  --written-image-x: 50%;
  --written-image-y: 50%;
  --written-content-gap: 22px;
  --written-animation-speed: 1.3s;
  --pencil-color: 225, 215, 195;
  --pencil-strength: 0.65;
  --pencil-echo: 0.22;
}

#story-stop[data-theme="written"] .story-shell {
  position: absolute;
  background: rgba(20, 19, 17, var(--written-panel-opacity));
  border: 1px solid transparent;
  border-radius: 3px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#story-stop[data-theme="written"] .story-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#story-stop[data-theme="written"] .story-composition {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  min-height: 100%;
  gap: var(--written-content-gap);
  padding: 0;
}

#story-stop[data-theme="written"] .story-left-slide {
  flex: 1 0 auto;
  gap: var(--written-content-gap);
}

#story-stop[data-theme="written"] .story-art {
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  transform: none;
}

#story-stop[data-theme="written"] .story-art img {
  width: 100%;
  height: var(--written-image-height);
  max-height: none;
  object-fit: cover;
  object-position: var(--written-image-x) var(--written-image-y);
  border-radius: 2px;
}

#story-stop[data-theme="written"] .story-art figcaption {
  margin-top: 10px;
  font-size: 10px;
  opacity: 0.75;
}

#story-stop[data-theme="written"] .story-copy {
  width: 100%;
  max-width: 100%;
  padding: 10px 4px 20px;
  margin-top: auto;
  transform: none;
}

#story-stop[data-theme="written"] .story-title,
#story-stop[data-theme="written"] .story-body,
#story-stop[data-theme="written"] .story-kicker,
#story-stop[data-theme="written"] .story-actions button {
  font-family: "Segoe Print", "Bradley Hand", cursive;
  font-weight: 400;
}

#story-stop[data-theme="written"] .story-title {
  margin-bottom: 20px;
  color: #f2e9dc;
  font-size: clamp(34px, 3.5vw, 54px);
  line-height: 1.15;
  letter-spacing: 0.01em;
}

#story-stop[data-theme="written"] .story-body {
  max-width: 68ch;
  color: #eee5d8;
  font-size: clamp(16px, 1.3vw, 20px);
  line-height: 1.7;
}

#story-stop[data-theme="written"] .story-kicker {
  color: #d9cfc0;
}

#story-stop[data-theme="written"] .story-actions {
  position: relative;
  border-top: 0;
  padding-top: 18px;
}

#story-stop[data-theme="written"] .story-actions button {
  color: #f1e7d8;
  background: transparent;
}

@keyframes underWritingReveal {
  from {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    transform: translateY(0);
  }
}

/* Extra vertical clip margin avoids cropping descenders such as "g". */
@keyframes underSafeWritingReveal {
  from {
    opacity: 0;
    clip-path: inset(-20% 100% -30% 0);
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    clip-path: inset(-20% 0 -30% 0);
    transform: translateY(0);
  }
}

#story-stop[data-theme="written"].is-visible .story-kicker {
  animation: underWritingReveal 0.65s ease 0.15s both;
}

#story-stop[data-theme="written"].is-visible .story-title {
  animation: underSafeWritingReveal var(--written-animation-speed) ease-out 0.4s both;
}

#story-stop[data-theme="written"].is-visible .story-body p {
  animation: underWritingReveal 1s ease-out both;
}

#story-stop[data-theme="written"].is-visible .story-body p:nth-child(1) { animation-delay: 1.15s; }
#story-stop[data-theme="written"].is-visible .story-body p:nth-child(2) { animation-delay: 1.85s; }
#story-stop[data-theme="written"].is-visible .story-body p:nth-child(3) { animation-delay: 2.55s; }

/* Pencil line on the shell — two subtly imperfect passes. */
#story-stop[data-theme="written"] .story-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  opacity: var(--pencil-strength);
  background:
    repeating-linear-gradient(90deg, rgba(225,215,195,.8) 0px, rgba(225,215,195,.3) 11px, rgba(225,215,195,.9) 24px, rgba(225,215,195,.4) 37px, rgba(225,215,195,.7) 49px) top / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, rgba(225,215,195,.4) 0px, rgba(225,215,195,.9) 19px, rgba(225,215,195,.3) 32px, rgba(225,215,195,.7) 50px) bottom / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, rgba(225,215,195,.8) 0px, rgba(225,215,195,.3) 15px, rgba(225,215,195,.9) 31px, rgba(225,215,195,.5) 47px) left / 1px 100% no-repeat,
    repeating-linear-gradient(180deg, rgba(225,215,195,.4) 0px, rgba(225,215,195,.8) 20px, rgba(225,215,195,.3) 39px, rgba(225,215,195,.7) 55px) right / 1px 100% no-repeat;
}

#story-stop[data-theme="written"] .story-shell::after {
  content: "";
  position: absolute;
  inset: 2px 1px 1px 2px;
  z-index: 2;
  pointer-events: none;
  border: 1px solid rgba(225, 215, 195, 0.5);
  border-radius: 2px;
  opacity: var(--pencil-echo);
  transform: rotate(-0.06deg);
}

#story-stop[data-theme="written"] .story-actions::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(225,215,195,.75) 0px, rgba(225,215,195,.25) 17px, rgba(225,215,195,.8) 34px, rgba(225,215,195,.3) 48px);
  opacity: var(--pencil-strength);
  transform: rotate(-0.08deg);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   4. SINGLE CENTERED FLIP CARD
   Replaces the old two-wide, slightly canted panels entirely.
   -------------------------------------------------------------------------- */

#story-stop.has-flip-card .story-shell {
  width: var(--flip-width);
  height: auto;
  max-height: none;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#story-stop.has-flip-card .story-shell::before,
#story-stop.has-flip-card .story-shell::after {
  content: none;
}

#story-stop.has-flip-card .story-scroll {
  flex: 0 0 auto;
  padding: 8px;
  overflow: visible;
  touch-action: pan-y !important;
}

#story-stop.has-flip-card .story-composition {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
}

#story-stop.has-flip-card .story-flip-stage {
  width: 100%;
  height: var(--flip-height);
  perspective: 1400px;
}

#story-stop.has-flip-card .story-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.2, 0.75, 0.2, 1);
}

#story-stop.has-flip-card .story-flip-inner.is-flipped {
  transform: rotateY(180deg);
}

#story-stop.has-flip-card .story-left-slide,
#story-stop.has-flip-card .story-right-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  min-width: 0;
  padding: clamp(14px, 2vw, 24px);
  border: 1px solid rgba(235, 235, 220, 0.25);
  border-radius: 8px;
  background: rgba(7, 12, 10, 0.94);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.55);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

#story-stop.has-flip-card .story-right-slide {
  transform: rotateY(180deg);
  overflow: hidden;
  justify-content: flex-end;
}

#story-stop.has-flip-card .story-copy {
  width: 100%;
  margin: 0;
  padding: 0;
}

#story-stop.has-flip-card .story-title,
#story-stop.has-flip-card .story-right-title {
  margin: 0 0 12px;
  color: var(--story-white);
  font: 400 clamp(27px, 3vw, 38px)/1.15 Georgia, serif;
}

#story-stop.has-flip-card .story-body,
#story-stop.has-flip-card .story-right-body {
  max-width: none;
  color: #e4e6dc;
  font-size: 14px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   5. FRONT CAROUSEL — IMAGE SIZE AND CONTROLS ARE INDEPENDENT
   The image determines the height of grid row 1. Arrows share that row.
   -------------------------------------------------------------------------- */

#story-stop.has-flip-card .story-art {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: none;
  margin: 0;
  transform: none;
}

#story-stop.has-flip-card .story-art > img:not(.story-extra-image) {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: var(--flip-front-image-height);
  max-height: none;
  object-fit: cover;
}

/* The carousel displays only one image. The old additional img stays hidden. */
#story-stop .story-extra-image[hidden] {
  display: none !important;
}

#story-stop.has-flip-card .story-art > figcaption {
  grid-column: 1;
  grid-row: 2;
}

#story-stop.has-flip-card .story-art > .story-image-controls {
  position: relative;
  inset: auto;
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  width: 100%;
  height: auto; /* DO NOT set the image height here */
  padding: 0 var(--carousel-arrow-inset);
  z-index: 2;
  pointer-events: none;
}

#story-stop.has-flip-card .story-image-controls button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: var(--story-white);
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  pointer-events: auto;
}

#story-stop.has-flip-card .story-image-controls svg {
  width: 20px;
  height: 20px;
}

#story-stop.has-flip-card .story-image-count {
  position: absolute;
  bottom: var(--carousel-counter-bottom);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 3px;
  color: var(--story-white);
  background: rgba(0, 0, 0, 0.65);
  font: 11px Arial, sans-serif;
  pointer-events: none;
}

#story-stop.has-flip-card .story-left-slide .story-art { order: 0; }
#story-stop.has-flip-card .story-left-slide .story-copy { order: 1; }
#story-stop.has-flip-card .story-left-slide .story-flip-button { order: 2; margin-top: auto; }

/* --------------------------------------------------------------------------
   6. BACK OF THE CARD — FULL-BLEED PORTRAIT
   -------------------------------------------------------------------------- */

#story-stop.has-flip-card .story-right-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

#story-stop.has-flip-card .story-right-art img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: var(--flip-back-focus);
  border-radius: 0;
}

#story-stop.has-flip-card .story-right-slide::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    transparent 20%,
    rgba(0, 0, 0, 0.15) 40%,
    rgba(0, 0, 0, 0.82) 75%,
    rgba(0, 0, 0, 0.96) 100%
  );
  pointer-events: none;
}

#story-stop.has-flip-card .story-right-copy {
  position: relative;
  z-index: 2;
  width: 100%;
  margin-top: auto;
  padding: 0 4px 8px;
}

#story-stop.has-flip-card .story-right-title {
  letter-spacing: normal;
}

#story-stop.has-flip-card .story-right-art figcaption {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  margin: 0;
}

/* --------------------------------------------------------------------------
   7. FLIP BUTTONS AND FLOATING BACK / CONTINUE NAVIGATION
   -------------------------------------------------------------------------- */

#story-stop.has-flip-card .story-flip-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-end;
  min-height: 44px;
  margin-top: auto;
  padding: 12px;
  border: 0;
  color: var(--story-white);
  background: transparent;
  font: 11px Arial, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#story-stop.has-flip-card .story-flip-button svg {
  width: 22px;
  height: 22px;
}

#story-stop.has-flip-card .story-flip-button:hover {
  color: #fff;
}

#story-stop.has-flip-card .story-right-slide .story-flip-button {
  position: relative;
  z-index: 2;
  order: 2;
  margin-top: 8px;
}

#story-stop.has-flip-card .story-actions {
  flex: 0 0 auto;
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

/* --------------------------------------------------------------------------
   8. MOBILE AND SHORT VIEWPORTS
   -------------------------------------------------------------------------- */

@media (max-width: 700px) {
  #story-stop {
    --panel-width: 100%;
    --panel-height: 94dvh;
    --panel-padding: 14px;
    --panel-image-height: 35dvh;
    --panel-content-gap: 16px;
    --flip-front-image-height: 24dvh;
  }

  #story-stop .story-shell {
    width: calc(100vw - 20px);
    height: var(--panel-height);
  }

  #story-stop .story-title {
    font-size: clamp(30px, 8vw, 44px);
  }

  #story-stop .story-body {
    font-size: 14px;
  }

  #story-stop .story-actions {
    margin-top: 8px;
    padding-top: 12px;
    gap: 12px;
  }

  #story-stop .story-actions button {
    padding: 10px 8px;
    font-size: 10px;
  }

  #story-stop .story-cue {
    display: none;
  }

  #story-stop .story-continue [data-icon] { margin-left: 15px; }
  #story-stop .story-back [data-icon] { margin-right: 12px; }

  #controls {
    right: 24px;
    gap: 16px;
  }

  .wordmark {
    font-size: 14px;
    letter-spacing: 0.24em;
  }

  #story-stop[data-theme="written"] {
    --written-image-height: 28dvh;
    --written-content-gap: 16px;
  }

  #story-stop[data-theme="written"] .story-title { font-size: 32px; }
  #story-stop[data-theme="written"] .story-body { font-size: 15px; }
  #story-stop[data-theme="written"] .story-copy { margin-top: 0; }

  #story-stop.has-flip-card .story-shell {
    width: calc(100vw - 24px);
  }

  #story-stop.has-flip-card .story-flip-stage {
    height: 72dvh;
  }
}

@media (max-height: 650px) and (min-width: 701px) {
  #story-stop {
    --panel-image-height: 42dvh;
    --panel-padding: 16px;
  }

  #story-stop:not(.has-flip-card) .story-shell {
    height: 95dvh;
  }
}

/* --------------------------------------------------------------------------
   9. REDUCED MOTION
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  #story-stop.has-flip-card .story-flip-inner {
    transition: none;
  }

  #story-stop[data-theme="written"] * {
    animation: none !important;
  }
}

body.reduced-motion #story-stop.has-flip-card .story-flip-inner {
  transition: none;
}

body.reduced-motion #story-stop[data-theme="written"] * {
  animation: none !important;
}

body.reduced-motion *,
body.reduced-motion *::before {
  animation: none !important;
  transition: none !important;
}


/* ==========================================
   UNDER — FULLSCREEN IMAGE VIEWER
========================================== */

/* Clickable story images */

#story-stop .story-art img:not(.story-extra-image),
#story-stop .story-right-art img {
  cursor: zoom-in;
}

/* Full viewport overlay */

dialog.under-image-viewer {
  position: fixed;
  inset: 0;

  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100dvh;

  max-width: none;
  max-height: none;

  margin: 0;
  padding: 0;
  border: none;

  background: rgba(3, 5, 4, 0.97);
  color: #f2f0e6;

  box-sizing: border-box;
  overflow: hidden;
}

dialog.under-image-viewer::backdrop {
  background: rgba(0, 0, 0, 0.95);
}

/* Center image inside viewport */

.under-image-viewer-content {
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  box-sizing: border-box;

  padding:
    max(60px, env(safe-area-inset-top))
    20px
    max(24px, env(safe-area-inset-bottom));

  gap: 14px;
}

/* Show the ENTIRE image, not a crop */

.under-image-viewer-image {
  display: block;

  width: 100%;
  height: 100%;

  min-height: 0;
  max-width: 100%;
  max-height: 100%;

  object-fit: contain;
  flex: 1 1 auto;
}

/* Optional caption */

.under-image-viewer-caption {
  flex: 0 0 auto;
  margin: 0;

  font: 11px/1.6 Arial, sans-serif;
  letter-spacing: 0.12em;

  text-align: center;
  color: #d0d5cc;
}

.under-image-viewer-caption[hidden] {
  display: none;
}

/* X close control */

.under-image-viewer-close {
  position: absolute;

  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));

  width: 44px;
  height: 44px;

  display: grid;
  place-items: center;

  background: rgba(15, 20, 17, 0.85);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;

  color: #f2f0e6;
  cursor: pointer;
  z-index: 2;
}

.under-image-viewer-close svg {
  width: 22px;
  height: 22px;
}

.under-image-viewer-close:hover {
  background: rgba(60, 68, 60, 0.95);
}

/* Mobile spacing */

@media (max-width: 700px) {
  .under-image-viewer-content {
    padding-left: 10px;
    padding-right: 10px;
  }
}
