/* ==========================================================================
   Korjin — customer stories: a shoppable rail of videos, one editor block
   per story (sections/stories). Tokens only, per tokens.css.
   ========================================================================== */

/* With no stories there is nothing honest to show, so there is no section. */
.stories:not(:has(.story)) {
  display: none;
}

.stories {
  background: var(--ground-sunken);
}

.stories__head {
  max-width: 620px;
  margin-bottom: var(--sp-7);
}

.stories__head .title-xl {
  margin-block: var(--sp-3) var(--sp-4);
}

/* ---- the rail (filled state) --------------------------------------------- */

/* Stories per row, alignment and spacing come from the section's settings:
   --stories-cols and --stories-cols-phone are set on the section, the gap and
   alignment are classes. A column is a share of the width, so three stories
   at "3 per row" fill it and one story at "4 per row" takes a quarter. */
.stories {
  --stories-gap: var(--sp-5);
  --stories-n: var(--stories-cols, 4);
}

.stories--gap-tight { --stories-gap: var(--sp-3); }
.stories--gap-wide { --stories-gap: var(--sp-7); }

.stories__track {
  position: relative;
}

.stories__rail {
  list-style: none;
  padding: 0 0 var(--sp-3);
  margin: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - (var(--stories-n) - 1) * var(--stories-gap)) / var(--stories-n));
  gap: var(--stories-gap);
  justify-content: start;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.stories__rail::-webkit-scrollbar {
  display: none;
}

.stories--center .stories__rail {
  justify-content: center;
}

/* ---- arrows on the rail ------------------------------------------------ */

.stories__arrow {
  position: absolute;
  top: calc(50% - var(--sp-6));
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-strong);
  background: var(--ground-raised);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.stories__arrow--prev { left: calc(-1 * var(--sp-4)); }
.stories__arrow--next { right: calc(-1 * var(--sp-4)); }

.stories__arrow:hover {
  background: var(--ground-sunken);
}

.stories__arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.stories__arrow[hidden] {
  display: none;
}

.stories__more {
  margin: var(--sp-5) 0 0;
  text-align: center;
}

.stories__more[hidden],
.story[hidden] {
  display: none;
}

.story {
  scroll-snap-align: start;
}

.story__tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: var(--band-dark);
  border: 1px solid transparent;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.story__tile:hover,
.story__tile:focus-visible {
  border-color: var(--accent-surface);
}

.story__tile video,
.story__poster,
.story__poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story__poster--empty {
  padding: 20%;
  opacity: 0.35;
}

/* Tile shapes and arrangements, from the section's settings. */
.stories--tall .story__tile {
  aspect-ratio: 4 / 5;
}

.stories--square .story__tile {
  aspect-ratio: 1;
}

.stories--grid .stories__rail {
  grid-auto-flow: row;
  grid-template-columns: repeat(var(--stories-n), minmax(0, 1fr));
  overflow: visible;
  scroll-snap-type: none;
}

.stories--grid .stories__arrow {
  display: none;
}

/* "Gifted product", "Paid partnership": the FTC wants this on the story, not
   in a footnote, so it sits on the tile as well as beside the video. */
.story__disclosure {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  padding: 0.3125rem 0.625rem;
  background: color-mix(in srgb, var(--korjin-black) 72%, transparent);
  color: var(--korjin-cream);
  font-size: var(--label-xs);
  letter-spacing: 0.16em;
}

.story__player-src[hidden] {
  display: none;
}

/* Sample watermark — non-negotiable while the tiles are placeholders. */
.story__sample {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  padding: 0.3125rem 0.625rem;
  background: var(--korjin-black);
  color: var(--gold-line);
  font-size: var(--label-xs);
  letter-spacing: 0.2em;
}

.story__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.story__play::before {
  content: "▶";
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding-left: 3px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--korjin-black) 55%, transparent);
  color: var(--korjin-cream);
  font-size: 0.75rem;
  transition: transform var(--dur-fast) var(--ease-out);
}

.story__tile:hover .story__play::before {
  transform: scale(1.08);
}

.story__meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-6) var(--sp-4) var(--sp-4);
  text-align: left;
  color: var(--korjin-cream);
  background: linear-gradient(to top, rgb(0 0 0 / 72%), transparent);
}

.story__day {
  font-size: var(--label-xs);
  color: var(--gold-line);
}

.story__tag {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  font-size: var(--label-xs);
  color: var(--ink-muted);
}

.story__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-surface);
  flex: none;
}

.stories__note {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--rule);
  max-width: 60ch;
}

/* ---- fullscreen player --------------------------------------------------- */

.stories__player {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
}

.stories__scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}

.stories.is-playing .stories__scrim {
  opacity: 1;
}

.stories__stage {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(940px, 92vw);
  height: min(620px, 86vh);
  background: var(--ground-raised);
  border: 1px solid var(--rule);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}

.stories.is-playing .stories__stage {
  opacity: 1;
  transform: none;
}

/* The story's content is moved into this box; it lays out like the stage. */
.stories__stage-content {
  display: grid;
  grid-template-columns: auto 320px;
  min-height: 0;
  height: 100%;
}

.stories__x {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--ground-raised);
  border: 1px solid var(--rule);
  color: var(--ink);
}

.stories__x:hover {
  background: var(--ground-sunken);
}

.stories__video {
  position: relative;
  background: var(--band-dark);
  overflow: hidden;
}

.stories__video video,
.stories__still,
.stories__still img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The platform's video component sizes itself by aspect ratio; in the
   player it fills the column instead, and the video letterboxes inside. */
.stories__video theme-video-media,
.stories__video .theme-video-media {
  height: 100%;
  aspect-ratio: auto !important;
}

.stories__video .theme-video-media__poster img {
  object-fit: contain;
}

.story__quote {
  margin: 0;
}

.story__quote p {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: var(--leading-snug);
}

.story__quote cite {
  font-style: normal;
}

.story__disclosure-line {
  margin: 0;
}

.stories__sample-lg {
  top: var(--sp-4);
  left: var(--sp-4);
}

.stories__buy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-6);
  border-left: 1px solid var(--rule);
  overflow-y: auto;
}

.stories__buy img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: var(--ground-sunken);
  padding: 5px;
}

/* A long product name in a 320px column: body size, not display size. */
.stories__buy .title-sm {
  font-size: var(--step-1);
  line-height: var(--leading-snug);
}

.stories__price {
  font-family: var(--font-display);
  font-size: var(--step-3);
}

.stories__buy .btn--primary {
  width: 100%;
  margin-top: var(--sp-2);
}

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
  .stories {
    --stories-n: var(--stories-cols-phone, 1.2);
    --stories-gap: var(--sp-4);
  }

  /* Never centred on a phone: a centred rail cannot be scrolled to its start. */
  .stories--center .stories__rail {
    justify-content: start;
  }

  .stories--grid .stories__rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stories__arrow {
    display: none;
  }

  .stories__stage {
    height: min(88vh, 760px);
  }

  .stories__stage-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .stories__buy {
    border-left: 0;
    border-top: 1px solid var(--rule);
    padding: var(--sp-5);
  }

  .stories__buy img {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stories__scrim,
  .stories__stage,
  .story__play::before {
    transition: none;
  }
}
