/* Stories rail + full-screen viewer (see stories.js). Uses site tokens with fallbacks. */

/* ---------- rail ---------- */
.story-rail { max-width: 100%; overflow: hidden; }
.story-list {
  display: flex; gap: 14px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  padding: 6px 2px 10px; margin: 0;
  scrollbar-width: none;
}
.story-list::-webkit-scrollbar { display: none; }
.story-item { flex: 0 0 auto; scroll-snap-align: start; }

.story-bubble {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 88px; padding: 0; margin: 0;
  background: none; border: 0; cursor: pointer;
  font: 500 .8rem/1.2 var(--sans, system-ui, sans-serif);
  color: var(--ink, #23201D);
  -webkit-tap-highlight-color: transparent;
}
.story-ring {
  display: block; width: 76px; height: 76px; padding: 3px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--terra, #C1121F), #E3672B, var(--green, #006233), var(--terra, #C1121F));
  transition: transform .18s ease;
}
.story-ring img {
  display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  border: 3px solid var(--cream, #FBF5EC); background: var(--sand, #E9D6BD);
}
.story-bubble.is-seen .story-ring { background: #C9C0B4; }
.story-bubble.is-seen .story-name { color: var(--muted, #5E554C); }
.story-name { max-width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-bubble:hover .story-ring { transform: scale(1.04); }
.story-bubble:active .story-ring { transform: scale(.96); }
.story-bubble:focus-visible { outline: none; }
.story-bubble:focus-visible .story-ring { outline: 3px solid var(--ink, #23201D); outline-offset: 3px; }

/* ---------- viewer ---------- */
html.sv-lock { overflow: hidden; }

.story-viewer {
  position: fixed; inset: 0;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #0d0b0a; color: #fff;
  overflow: hidden;
}
.story-viewer::backdrop { background: rgba(10, 8, 7, .92); }
.story-viewer[open] { display: flex; align-items: center; justify-content: center; }

.sv-frame {
  position: relative;
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
@media (min-width: 600px) {
  .story-viewer { background: rgba(10, 8, 7, .94); }
  .sv-frame {
    width: min(480px, calc((100vh - 48px) * 9 / 16));
    height: min(calc(100vh - 48px), 853px);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  }
}

.sv-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.sv-media { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
img.sv-media { -webkit-user-drag: none; }

/* top gradient so the bars and title read on bright photos */
.sv-frame::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 110px; z-index: 2; pointer-events: none;
  background: linear-gradient(rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
}

.sv-bars { position: absolute; z-index: 4; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; }
.sv-seg { flex: 1 1 0; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.sv-fill { display: block; height: 100%; width: 100%; background: #fff; transform: scaleX(0); transform-origin: left center; }

.sv-head {
  position: absolute; z-index: 5; top: 22px; left: 12px; right: 6px;
  display: flex; align-items: center; gap: 8px;
}
.sv-title {
  margin: 0; flex: 0 1 auto; min-width: 0;
  font: 600 1rem/1.2 var(--serif, Georgia, serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.sv-count { flex: 1 1 auto; font: 500 .8rem/1 var(--sans, system-ui, sans-serif); opacity: .8; }

.sv-btn {
  flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35); color: #fff;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px;
  font: 600 .85rem/1 var(--sans, system-ui, sans-serif); cursor: pointer;
}
.sv-btn[hidden] { display: none; }
.sv-close { padding: 0; width: 44px; border-color: transparent; background: transparent; }
.sv-btn:hover { background: rgba(0, 0, 0, .55); }
.sv-btn:focus-visible, .sv-nav:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* tap layer: below header, above media */
.sv-tap { position: absolute; z-index: 3; left: 0; right: 0; top: 72px; bottom: 0; cursor: pointer; }

/* prev/next buttons: shown on wide screens and for reduced motion; keyboard arrows always work */
.sv-nav {
  position: absolute; z-index: 5; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(251, 245, 236, .9); color: var(--ink, #23201D);
  border: 0; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
.sv-prev { left: 10px; }
.sv-next { right: 10px; }
@media (min-width: 600px) and (hover: hover) { .sv-nav { display: inline-flex; } }
.story-viewer.is-reduced .sv-nav { display: inline-flex; }
/* reduced motion: native video controls need the bottom of the frame */
.story-viewer.is-reduced .sv-tap { bottom: 64px; }

.story-viewer.is-paused .sv-bars, .story-viewer.is-paused .sv-head { opacity: .55; transition: opacity .2s; }

@media (prefers-reduced-motion: reduce) {
  .story-ring, .sv-head, .sv-bars { transition: none; }
}
