/* Guided story experience — immersive player.
   Scoped entirely to #app[data-route="experience"] so the rest of the site,
   including the collection page it is launched from, is never affected. */

#app[data-route="experience"] {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  display: flex;
  background: radial-gradient(120% 120% at 20% 0%, #3c5a6d 0%, #23384a 55%, #182631 100%);
  color: #f7f3eb;
}
html:has(#app[data-route="experience"]) { overflow: hidden; }

.experience-player {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  width: 100%;
  position: relative;
}

.experience-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(18px, 5vw, 56px);
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.experience-exit {
  background: rgba(247, 243, 235, 0.1);
  border: 1px solid rgba(247, 243, 235, 0.28);
  color: #f7f3eb;
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 40px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.experience-exit:hover { background: rgba(247, 243, 235, 0.18); }

.experience-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 180px;
  flex: 1;
  max-width: 360px;
}

.experience-counter {
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #d3dde3;
}

.experience-bar-el {
  width: 100%;
  height: 6px;
  appearance: none;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(247, 243, 235, 0.18);
}
.experience-bar-el::-webkit-progress-bar { background: rgba(247, 243, 235, 0.18); border-radius: 999px; }
.experience-bar-el::-webkit-progress-value { background: #c08a3e; border-radius: 999px; transition: width .35s ease; }
.experience-bar-el::-moz-progress-bar { background: #c08a3e; border-radius: 999px; }

.experience-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  text-align: center;
  gap: clamp(10px, 1.35dvh, 15px);
  padding: clamp(12px, 1.8dvh, 18px) clamp(20px, 6vw, 80px) clamp(14px, 1.8dvh, 22px);
  width: 100%;
  max-width: none; /* The full central area, including the blue sides, accepts scrolling. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 auto;
}
/* Reading and keyboard navigation still scroll; only the scrollbar is hidden. */
#app[data-route="experience"] .experience-stage::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.experience-reading-cue {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  min-width: 0;
}
.experience-scroll-hint {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(247,243,235,.18);
  background: rgba(24,43,57,.72);
  color: #e3e9e8;
  font: 500 12px/1.3 "DM Sans",sans-serif;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}
.experience-scroll-hint[hidden] { display: none; }

.experience-type {
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #c08a3e;
  font-weight: 700;
}

.experience-title {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.15;
  margin: 0;
  max-width: 760px;
  color: #fffdf8;
}

.experience-media { width: 100%; max-width: 900px; margin: 4px auto; }
/* Videos share the existing YouTube player's desktop width; photographs
   are allowed more of the stage without being cropped. */
#app[data-route="experience"] .experience-media:has(video.media-preview),
#app[data-route="experience"] .experience-media:has(.youtube-embed),
#app[data-route="experience"] .experience-media:has(.youtube-load) {
  max-width: 640px;
}
.experience-media .photo-strip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
/* The browse-card carousel wrapper forces a fixed aspect ratio and its own
   rounding/background; here the image should keep its natural shape up to
   68dvh (styled by the .experience-media img rule below), so only reset the
   wrapper's own box styling and let that rule do the rest. */
.experience-media .photo-carousel {
  display: flex;align-items: center;justify-content: center;
  width: min(100%, calc(68dvh * var(--experience-photo-ratio, 1.5)));
  max-width: 900px;
  aspect-ratio: var(--experience-photo-ratio, 1.5);
  max-height: 68dvh;
  border: 0;
  border-radius: 16px;
  background: transparent;
  margin: 4px auto;
  overflow: hidden;
  touch-action: pan-y;
}
/* object-fit:cover would crop whatever doesn't match the box's own aspect
   ratio — wrong here, since this is the one place a contributor's actual
   submitted photo or video is shown full-screen as the point of the page.
   width/height:auto with only max-width/max-height as caps scales the
   whole image down to fit without ever cropping it. The single-photo case
   is wrapped in .photo-strip, which (for the browse-card context it was
   designed for) sets its own aspect-ratio and object-fit:cover on the img
   directly — same specificity as this rule, so those two properties must
   be explicitly reset here or they survive regardless of load order. */
.experience-media img,
.experience-media .media-preview {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(68dvh, 720px);
  aspect-ratio: auto;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .35);
}
.experience-media audio.media-preview { max-height: none; width: 100%; }
/* Native video gets the same usable width as YouTube; object-fit retains
   every frame even for portrait recordings. */
#app[data-route="experience"] .experience-media video.media-preview {
  width: auto;
  max-width: 100%;
  max-height: min(60dvh, 540px);
  object-fit: contain;
}
#app[data-route="experience"] .experience-media .youtube-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(60dvh, 540px);
  margin: 4px auto;
}
#app[data-route="experience"] .experience-media .youtube-note {
  color: #e3e9e8;
  max-width: 640px;
  margin-inline: auto;
}
/* The guided player displays a single image directly, not in browse's cream letterbox. */
#app[data-route="experience"] .experience-media .photo-strip.single-photo-frame {
  display: block;width: fit-content;max-width: 100%;height: auto;min-height: 0;
  aspect-ratio: auto;margin: 4px auto;border: 0;background: transparent;
  border-radius: 0;overflow: visible;
}
#app[data-route="experience"] .experience-media .photo-strip.single-photo-frame img {
  display: block;width: auto;height: auto;max-width: 100%;
  max-height: min(68dvh, 720px);aspect-ratio: auto;object-fit: contain;border-radius: 16px;
}
#app[data-route="experience"] .experience-media .photo-carousel-img {
  display: block;flex: 0 0 auto;width: 100%;height: 100%;
  max-width: 100%;max-height: 100%;aspect-ratio: auto;object-fit: contain;
  margin: 0;border-radius: 0;box-shadow: none;
}
#app[data-route="experience"] .experience-media .photo-carousel-nav {
  width: 44px;height: 44px;background: rgba(15, 30, 42, .73);
  border: 1px solid rgba(255, 255, 255, .5);
}
#app[data-route="experience"] .experience-media .photo-carousel-nav:focus-visible {
  outline: 2px solid #fffdf8;outline-offset: 2px;
}
.experience-stage:focus-visible { outline: 2px solid #e4ad58;outline-offset: -4px; }

.experience-text {
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(19px, 2.6vw, 23px);
  line-height: 1.6;
  color: #f1ede2;
  white-space: pre-wrap;
  max-width: 760px;
  margin: 0;
}

.experience-context {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-size: 16px;
  color: #c7d2da;
  max-width: 760px;
  margin: 0;
}

.experience-by {
  font-size: 14px;
  color: #aebdc7;
  margin-top: 4px;
}

.experience-nav {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
  flex: 0 0 auto;
  gap: 14px;
  padding: 14px clamp(18px, 5vw, 56px) clamp(18px, 2.5vh, 26px);
  background: linear-gradient(0deg, rgba(15, 31, 43, .18), transparent);
}
.experience-nav .btn { width:100%; max-width:220px; }
.experience-nav .btn[data-experience-prev] { justify-self:start; }
.experience-nav .btn[data-experience-next] { justify-self:end; }
.experience-nav .btn[disabled] { opacity: .35; cursor: default; }
.experience-nav .btn-primary { background: var(--fjord); box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.experience-nav .btn-primary:hover { background: #30495a; }
.experience-nav .btn-secondary {
  background: rgba(247, 243, 235, 0.1);
  color: #fffdf8;
  border: 1px solid rgba(247, 243, 235, 0.28);
}
.experience-nav .btn-secondary:hover { background: rgba(247, 243, 235, 0.18); }
/* The completion view is not counted as an additional memory. */
.experience-closing { gap: 22px; }
.experience-closing-mark {
  display: grid;place-items: center;width: 58px;height: 58px;
  border: 1px solid rgba(226, 183, 107, .8);border-radius: 50%;
  color: #e2b76b;font: 500 39px/1 "Newsreader", Georgia, serif;margin-bottom: 8px;
}
.experience-closing .experience-title { max-width: 660px;font-size: clamp(36px, 5.2vw, 58px); }
.experience-closing .experience-text { max-width: 530px;font-size: clamp(20px, 2.7vw, 24px); }
.experience-browse {
  display: inline-flex;align-items: center;justify-content: center;gap: 12px;
  margin-top: 16px;padding: 14px 24px;min-height: 48px;border-radius: 999px;
  background: #f7f3eb;color: #23384a;font: 700 16px/1.25 "DM Sans", sans-serif;text-decoration: none;
}
.experience-browse:hover,.experience-browse:focus-visible {
  background: #fffdf8;outline: 2px solid #e2b76b;outline-offset: 3px;
}
.experience-restart {
  color: #e0e8e9;background: transparent;border: 0;padding: 10px 12px;
  cursor: pointer;font: 500 15px/1.35 "DM Sans", sans-serif;
  text-decoration: underline;text-underline-offset: 4px;
}
.experience-restart:focus-visible { outline: 2px solid #e2b76b;outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .experience-stage { animation: experience-fade .35s ease; }
}
@keyframes experience-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .experience-nav { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px 12px; }
  .experience-reading-cue { grid-column:1 / -1; grid-row:1; }
  .experience-nav .btn[data-experience-prev] { grid-column:1; grid-row:2; }
  .experience-nav .btn[data-experience-next] { grid-column:2; grid-row:2; }
}
@media (max-width: 600px) {
  .experience-bar { padding: 16px 18px; }
  .experience-progress { align-items: stretch; max-width: none; }
  .experience-nav { padding: 8px 18px 16px; }
  .experience-nav .btn { max-width: none; }
}
