/* StoriesPage — ring list + full-screen viewer overlay. Layout only; every
   colour/spacing/radius value comes from argentum-ui.css tokens so a theme
   swap (dark/light, accent) reskins this page for free. The viewer itself
   stays visually dark regardless of the active theme — same as the old
   MudBlazor page — since a story is meant to be viewed the same way a photo
   viewer is, not recoloured by the app chrome around it. */

.ag-stories {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--ag-space-4) var(--ag-space-6) var(--ag-space-8);
}

.ag-stories__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ag-space-3);
}

/* ---- ring list ---- */

.ag-story-ring-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ag-space-5);
  padding: var(--ag-space-2) var(--ag-space-1) var(--ag-space-4);
}

.ag-story-ring__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ag-space-2);
  width: 4.75rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.ag-story-ring__item:focus-visible {
  outline: none;
  box-shadow: var(--ag-shadow-focus);
  border-radius: var(--ag-radius-md);
}

/* The "has an active story" ring — a gradient border around the avatar,
   layered onto whichever `avatar-color-N` gradient fills it. */
.ag-story-ring__avatar {
  box-shadow:
    0 0 0 3px var(--ag-bg),
    0 0 0 5px var(--ag-accent-500);
  background-clip: padding-box;
}

.ag-story-ring__name {
  font-size: var(--ag-text-xs);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Deterministic per-peer palette — shared by the ring avatar and the
   viewer header avatar so the same peer reads with the same colour in
   both places. */
.avatar-color-0 { background: linear-gradient(135deg, #ff6b6b, #ee5a6f); }
.avatar-color-1 { background: linear-gradient(135deg, #f7b733, #fc4a1a); }
.avatar-color-2 { background: linear-gradient(135deg, #667eea, #764ba2); }
.avatar-color-3 { background: linear-gradient(135deg, #43cea2, #185a9d); }
.avatar-color-4 { background: linear-gradient(135deg, #11998e, #38ef7d); }
.avatar-color-5 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.avatar-color-6 { background: linear-gradient(135deg, #fa709a, #fee140); }
.avatar-color-7 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }

/* ---- viewer overlay ----
   `-root` is the fixed full-viewport layer; `-backdrop` is its first,
   absolutely-positioned child (click-to-close target); `-viewer` is the
   second child, flex-centred by `-root` on top of the backdrop — two
   siblings, not nested, so a click inside the panel never needs to stop
   propagation to avoid closing itself. */
.ag-story-viewer-root {
  position: fixed;
  inset: 0;
  z-index: var(--ag-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ag-story-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: var(--ag-overlay);
}

.ag-story-viewer {
  position: relative;
  width: min(26rem, 92vw);
  height: min(47.5rem, 88vh);
  background: var(--ag-neutral-1000);
  border-radius: var(--ag-radius-lg);
  box-shadow: var(--ag-shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--ag-neutral-0);
}

.ag-story-viewer__progress {
  display: flex;
  gap: var(--ag-space-1);
  padding: var(--ag-space-2) var(--ag-space-3) 0;
  position: relative;
  z-index: 2;
}

.ag-story-viewer__progress-seg {
  flex: 1;
  height: 3px;
  border-radius: var(--ag-radius-full);
  background: color-mix(in srgb, var(--ag-neutral-0) 28%, transparent);
  overflow: hidden;
}

.ag-story-viewer__progress-seg[data-state=seen],
.ag-story-viewer__progress-seg[data-state=active] {
  background: var(--ag-neutral-0);
}

.ag-story-viewer__progress-seg[data-state=upcoming] {
  background: color-mix(in srgb, var(--ag-neutral-0) 28%, transparent);
}

.ag-story-viewer__header {
  display: flex;
  align-items: center;
  gap: var(--ag-space-3);
  padding: var(--ag-space-2) var(--ag-space-3);
  position: relative;
  z-index: 2;
}

.ag-story-viewer__avatar {
  box-shadow: none;
  flex: none;
}

.ag-story-viewer__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ag-story-viewer__name {
  font-size: var(--ag-text-sm);
  font-weight: var(--ag-weight-semibold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ag-story-viewer__position {
  font-size: var(--ag-text-xs);
  color: color-mix(in srgb, var(--ag-neutral-0) 70%, transparent);
}

.ag-story-viewer__media {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.ag-story-viewer__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ag-story-viewer__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ag-space-2);
  color: color-mix(in srgb, var(--ag-neutral-0) 70%, transparent);
  font-size: var(--ag-text-sm);
  text-align: center;
  padding: 0 var(--ag-space-4);
}

.ag-story-viewer__spinner {
  width: 2rem;
  height: 2rem;
  border-radius: var(--ag-radius-full);
  border: 3px solid color-mix(in srgb, var(--ag-neutral-0) 25%, transparent);
  border-top-color: var(--ag-neutral-0);
  animation: ag-story-viewer-spin 0.7s linear infinite;
}

@keyframes ag-story-viewer-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ag-story-viewer__spinner {
    animation-duration: 1.6s;
  }
}

.ag-story-viewer__tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.ag-story-viewer__tap--prev {
  left: 0;
}

.ag-story-viewer__tap--next {
  right: 0;
}

.ag-story-viewer__footer {
  padding: var(--ag-space-2) var(--ag-space-4) var(--ag-space-4);
  position: relative;
  z-index: 2;
}

.ag-story-viewer__badges {
  display: flex;
  align-items: center;
  gap: var(--ag-space-2);
  margin-bottom: var(--ag-space-2);
}

.ag-story-viewer__caption {
  font-size: var(--ag-text-sm);
  line-height: var(--ag-leading-snug);
}

.ag-story-viewer__error {
  margin-top: var(--ag-space-2);
}

.ag-story-viewer__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  color: var(--ag-neutral-0);
  background: color-mix(in srgb, var(--ag-neutral-1000) 35%, transparent);
}

.ag-story-viewer__nav--prev {
  left: var(--ag-space-2);
}

.ag-story-viewer__nav--next {
  right: var(--ag-space-2);
}
