/* =============================================================================
   zz_feed_stories.css — the story strip under the Home header and its viewer.
   Markup: pages/feed/story_strip.py. Behaviour: assets/feed_stories.js. Doc: docs/design/story_strip.md.
   ============================================================================= */

/* The strip replaces the intro heading and paragraph; the intro stays in the layout (hide, don't delete). */
.sp-stories-wrap + div .feed-intro {
  display: none;
}

/* ---- the strip ---- */
#main-feed-shell .sp-stories-wrap .mantine-Container-root {
  max-width: min(var(--feed-main-column-width, 540px), 100%) !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.sp-stories {
  padding: 12px 0 4px;
}

.sp-stories__row {
  display: flex;
  gap: 18px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.sp-stories__row::-webkit-scrollbar {
  display: none;
}

.sp-story {
  flex: none;
  width: 68px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--sp-text-2);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sp-story:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.sp-story__ring {
  display: block;
  width: 68px;
  height: 68px;
  margin-bottom: 5px;
  padding: 3px;
  border: 2px solid var(--sp-accent);
  border-radius: 50%;
  transition: border-color 0.2s ease;
}

.sp-story.is-seen .sp-story__ring {
  border-color: var(--sp-border-strong);
}

.sp-story__disc {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--sp-chip);
  color: var(--sp-text);
}

.sp-story__disc--logo {
  background: var(--sp-accent);
  color: var(--sp-bg);
}

/* the brand's B in the disc's own text colour */
.sp-story__disc--logo::before {
  content: "";
  width: 34%;
  height: 50%;
  background: currentColor;
  -webkit-mask: url("/assets/brand/ballproof-b.svg") center / contain no-repeat;
  mask: url("/assets/brand/ballproof-b.svg") center / contain no-repeat;
}

.sp-story__label {
  display: block;
}

/* ---- the viewer: a native <dialog>, so focus, Escape and the top layer come from the browser ---- */
.sp-story-viewer {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sp-text);
  overflow: hidden;
}

.sp-story-viewer[open] {
  display: grid;
  place-items: center;
}

.sp-story-viewer::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.sp-story-viewer__panel {
  --sp-story-top: calc(76px + env(safe-area-inset-top, 0px));
  --sp-story-bottom: 150px;
  position: relative;
  width: 100%;
  height: 100%;
  background: #0A0B0E;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
}

.sp-story-viewer__stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  touch-action: none;
}

/* The picture sits between the header and the buttons, scaled to fit and centred. */
.sp-story-viewer__img {
  position: absolute;
  top: var(--sp-story-top);
  left: 0;
  width: 100%;
  height: calc(100% - var(--sp-story-top) - var(--sp-story-bottom));
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

.sp-story-viewer__img.is-active {
  opacity: 1;
}

.sp-story-viewer__bars {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.sp-story-viewer__bars i {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--sp-border-strong);
  overflow: hidden;
}

.sp-story-viewer__bars b {
  display: block;
  width: 0;
  height: 100%;
  background: var(--sp-text);
}

.sp-story-viewer__bars i.is-done b,
.sp-story-viewer__bars i.is-static b {
  width: 100%;
}

.sp-story-viewer__bars i.is-timed b {
  animation: sp-story-fill var(--sp-story-ms, 6000ms) linear forwards;
}

.sp-story-viewer__panel.is-paused .sp-story-viewer__bars i.is-timed b {
  animation-play-state: paused;
}

@keyframes sp-story-fill {
  from { width: 0; }
  to { width: 100%; }
}

.sp-story-viewer__head {
  position: absolute;
  top: calc(26px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.sp-story-viewer__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sp-accent);
  color: var(--sp-bg);
  font: 800 12px var(--sp-font-ui, inherit);
}

.sp-story-viewer__who {
  display: grid;
  line-height: 1.2;
}

.sp-story-viewer__name {
  font-size: 14px;
  font-weight: 700;
}

.sp-story-viewer__count {
  color: var(--sp-text-2);
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-size: 11px;
}

.sp-story-viewer__close {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--sp-text);
  cursor: pointer;
  pointer-events: auto;
}

.sp-story-viewer__foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 0 16px max(24px, env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.sp-story-viewer__foot-item {
  display: none;
  gap: 10px;
  justify-items: stretch;
}

.sp-story-viewer__foot-item.is-active {
  display: grid;
}

.sp-story-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1.5px solid var(--sp-accent);
  border-radius: 999px;
  background: var(--sp-accent);
  color: var(--sp-bg);
  font: 700 16px var(--sp-font-ui, inherit);
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
}

.sp-story-action--secondary {
  border-color: var(--sp-border-strong);
  background: transparent;
  color: var(--sp-text);
}

.sp-story-hint {
  text-align: center;
  color: var(--sp-text-3);
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-size: 12px;
}

/* Previous / next buttons: for keyboard and mouse users; on a phone you tap the picture. */
.sp-story-viewer__nav {
  display: none;
}

@media (min-width: 768px) {
  .sp-story-viewer__panel {
    width: min(calc(92vh * 9 / 16), 92vw);
    width: min(calc(92dvh * 9 / 16), 92vw);
    height: auto;
    aspect-ratio: 9 / 16;
    max-height: 92dvh;
    border-radius: 18px;
  }

  .sp-story-viewer__nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    padding: 0;
    border: 1px solid var(--sp-border-strong);
    border-radius: 50%;
    background: var(--sp-surface);
    color: var(--sp-text);
    cursor: pointer;
  }

  .sp-story-viewer__nav--prev { left: -64px; }
  .sp-story-viewer__nav--next { right: -64px; }
}

@media (prefers-reduced-motion: reduce) {
  .sp-story__ring { transition: none; }
}
