html.is-stories-open,
html.is-stories-open body {
  overflow: hidden;
}

.hs-popup {
  position: fixed;
  inset: 0;
  z-index: 3100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  visibility: hidden;
  pointer-events: none;
}

.hs-popup.active {
  visibility: visible;
  pointer-events: auto;
}

.hs-overlay {
  position: absolute;
  inset: 0;
  background: var(--search-overlay-bg);
  opacity: 0;
  transition: opacity var(--motion-base);
}

.hs-popup.active .hs-overlay {
  opacity: 1;
}

.hs-stage {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  opacity: 0;
  transform: scale(0.97);
  transition:
    opacity var(--motion-base),
    transform 0.32s var(--ease-out);
}

.hs-popup.active .hs-stage {
  opacity: 1;
  transform: none;
}

/* frame: site colours by default, white chrome over the photo slide */

.hs-frame {
  --hs-ink: var(--text-main);
  --hs-soft: var(--text-soft);
  --hs-track: var(--divider-strong);
  --hs-hover: var(--search-item-hover-bg);

  position: relative;
  width: min(var(--story-frame-w), calc((100dvh - 48px) * 9 / 16));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: var(--bg-page);
  border: 1px solid var(--divider-strong);
  border-radius: var(--story-frame-radius);
  box-shadow: var(--shadow-strong);
  color: var(--hs-ink);
  outline: none;
  isolation: isolate;
}

.hs-frame.is-photo {
  --hs-ink: var(--story-title);
  --hs-soft: var(--story-soft);
  --hs-track: var(--story-progress-bg);
  --hs-hover: rgba(255, 255, 255, 0.12);

  background: var(--story-bg);
}

.hs-frame.is-photo::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 120px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
  pointer-events: none;
}

/* progress */

.hs-progress {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  gap: 4px;
}

.hs-bar {
  flex: 1 1 0;
  height: 2px;
  overflow: hidden;
  border-radius: var(--radius-xs);
  background: var(--hs-track);
  transition: background var(--motion-base);
}

.hs-fill {
  width: 0;
  height: 100%;
  background: var(--hs-ink);
}

.hs-bar.is-done .hs-fill {
  width: 100%;
}

.hs-bar.is-current .hs-fill {
  animation: hs-progress var(--hs-duration, 6s) linear forwards;
}

.hs-popup.is-paused .hs-bar.is-current .hs-fill {
  animation-play-state: paused;
}

@keyframes hs-progress {
  from { width: 0; }
  to { width: 100%; }
}

/* header */

.hs-header {
  position: absolute;
  top: 24px;
  left: 12px;
  right: 8px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hs-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hs-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.hs-meta-text {
  min-width: 0;
}

.hs-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 600 14px/1.2 var(--font-main);
  letter-spacing: var(--letter-text);
}

.hs-hint {
  margin-top: 2px;
  color: var(--hs-soft);
  font: 500 11px/1.2 var(--font-mono);
}

.hs-actions {
  display: flex;
  gap: 2px;
}

.hs-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--hs-ink);
  cursor: pointer;
  transition: background var(--motion-fast);
}

.hs-icon-btn:hover {
  background: var(--hs-hover);
}

.hs-icon-btn svg {
  width: 20px;
  height: 20px;
}

.hs-icon-play,
.hs-popup.is-paused .hs-icon-pause {
  display: none;
}

.hs-popup.is-paused .hs-icon-play {
  display: block;
}

/* tap zone */

.hs-tap {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* slides */

.hs-slider {
  position: absolute;
  inset: 0;
}

.hs-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0s linear 0.3s;
}

.hs-slide.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease;
}

.hs-media {
  position: absolute;
  inset: 0;
}

.hs-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hs-slide--image::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 60%;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.82), transparent);
}

.hs-slide--image {
  color: var(--story-title);
}

/* Text slides sit on the site's rails: two side lines and a "+"-marked line above the copy. */
.hs-slide--text {
  --hs-rail: 20px;
  background: var(--bg-page);
}

.hs-slide--text::before {
  content: "";
  position: absolute;
  inset: 0 var(--hs-rail);
  border-left: 1px solid var(--rail-line);
  border-right: 1px solid var(--rail-line);
  pointer-events: none;
}

.hs-count {
  position: absolute;
  top: 80px;
  left: calc(var(--hs-rail, 0px) + 20px);
  color: var(--text-soft);
  font: 500 12px/1 var(--font-mono);
  letter-spacing: 0.02em;
}

.hs-body {
  position: relative;
  padding: 0 24px 28px;
}

.hs-slide--text .hs-body {
  margin: 0 var(--hs-rail);
  padding: 28px 20px;
  border-top: 1px solid var(--rail-line);
}

.hs-slide--text .hs-body::before {
  content: "";
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  height: 9px;
  color: var(--rail-cross);
  background:
    linear-gradient(currentColor, currentColor) left 4px top 0 / 1px 9px no-repeat,
    linear-gradient(currentColor, currentColor) left 0 top 4px / 9px 1px no-repeat,
    linear-gradient(currentColor, currentColor) right 4px top 0 / 1px 9px no-repeat,
    linear-gradient(currentColor, currentColor) right 0 top 4px / 9px 1px no-repeat;
  pointer-events: none;
}

.hs-eyebrow {
  margin-bottom: 14px;
  color: var(--story-soft);
  font: 500 12px/1 var(--font-mono);
  letter-spacing: 0.02em;
}

.hs-slide--text .hs-eyebrow {
  color: var(--green-text);
}

.hs-title {
  font: 600 var(--fs-story-title)/1.12 var(--font-main);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.hs-slide--text .hs-title {
  font-size: calc(var(--fs-story-title) * 1.35);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hs-text {
  margin: 12px 0 0;
  color: var(--story-muted);
  font: 400 var(--fs-story-desc)/1.5 var(--font-main);
}

.hs-slide--text .hs-text {
  color: var(--text-muted);
}

.hs-cta {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  margin-top: 24px;
  border: 1px solid var(--green-button-border);
  border-radius: var(--radius-md);
  background: var(--green-button-gradient);
  box-shadow: var(--green-button-shadow);
  color: var(--green-button-text);
  font: 500 15px/1 var(--font-main);
  letter-spacing: var(--letter-text);
  text-decoration: none;
  transition: background var(--motion-fast);
}

.hs-cta:hover {
  background: var(--green-button-gradient-hover);
}

/* side navigation */

.hs-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--divider-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: opacity .2s ease;
}

.hs-nav:hover {
  opacity: .65;
}

.hs-nav:disabled {
  opacity: 0.4;
  cursor: default;
}

.hs-nav:disabled:hover {
  opacity: .4;
}

.hs-nav svg {
  width: 20px;
  height: 20px;
}

.hs-icon-btn:focus-visible,
.hs-nav:focus-visible,
.hs-cta:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .hs-popup {
    padding: 0;
  }

  .hs-stage {
    width: 100%;
    height: 100%;
  }

  .hs-nav {
    display: none;
  }

  .hs-frame {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .hs-progress {
    top: max(10px, env(safe-area-inset-top));
  }

  .hs-header {
    top: calc(max(10px, env(safe-area-inset-top)) + 12px);
  }

  .hs-title {
    font-size: var(--fs-story-title-mobile);
  }

  .hs-slide--text {
    --hs-rail: 12px;
  }

  .hs-slide--text .hs-title {
    font-size: calc(var(--fs-story-title-mobile) * 1.3);
  }

  .hs-text {
    font-size: var(--fs-story-desc-mobile);
  }

  .hs-body {
    padding: 0 var(--site-gutter-mobile) max(24px, env(safe-area-inset-bottom));
  }

  .hs-slide--text .hs-body {
    padding: 24px 16px max(24px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .hs-overlay,
  .hs-stage,
  .hs-slide {
    transition: none;
  }

  /* The progress bar is the story timer, not decoration: keep its real duration. */
  .hs-popup .hs-bar.is-current .hs-fill {
    animation-duration: var(--hs-duration, 6s) !important;
  }
}
