/* ==========================================================================
 * Global Stories Bar  — mirrors the home-page hp-stories card design.
 * Loaded on every page via _head_common.html.
 * On the home page the .hp-stories section renders server-side instead,
 * so the JS guard skips initialisation there.
 * ========================================================================== */

/* ---- Container ---- */
.gs-stories {
  padding: 6px 0 0;
}
.gs-stories__card {
  background: var(--ag-color-bg-surface, #fff);
  border: 1px solid var(--ag-color-brand-primary-softer, rgba(46,116,184,.12));
  border-radius: var(--ag-radius-xl, 12px);
  padding: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* ---- Scrollable row ---- */
.gs-stories__scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.gs-stories__scroll::-webkit-scrollbar { display: none; }

/* ---- Individual item ---- */
.gs-stories__item {
  flex-shrink: 0;
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, opacity .12s ease;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
}
.gs-stories__item:hover { opacity: .85; }
.gs-stories__item:active { transform: scale(.95); opacity: .8; }

/* ---- Ring (SVG gradient stroke) ---- */
.gs-ring {
  position: relative;
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gs-ring__svg {
  position: absolute;
  inset: 0;
  width: 62px;
  height: 62px;
}
.gs-ring__svg circle {
  fill: none;
  stroke-width: 3;
  stroke: url(#gs-ring-grad);
}
/* Seen → grey */
.gs-ring--seen .gs-ring__svg circle {
  stroke: #94a3b8;
}
/* Unseen → glow pulse */
.gs-ring--unseen {
  animation: gs-ring-glow 2s ease-in-out infinite;
}
@keyframes gs-ring-glow {
  0%, 100% {
    filter: drop-shadow(0 0 2px rgba(46,116,184,.25))
            drop-shadow(0 0 6px rgba(241,201,174,.3));
  }
  50% {
    filter: drop-shadow(0 0 4px rgba(46,116,184,.5))
            drop-shadow(0 0 12px rgba(241,201,174,.55));
  }
}
/* Dashed ring for "add" */
.gs-ring--dashed .gs-ring__svg circle {
  stroke: var(--ag-color-border, #D9E1EE);
  stroke-dasharray: 6 4;
}

/* Avatar inside ring */
.gs-ring__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  display: block;
}

/* "+" badge */
.gs-ring__add {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ag-color-brand-primary, #2E74B8);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  line-height: 1;
  font-size: 0;
  transition: transform .12s ease;
}
.gs-ring__add:hover { transform: scale(1.1); }
.gs-ring__add svg {
  width: 12px;
  height: 12px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
}

/* Username label */
.gs-stories__name {
  font-size: 11px;
  font-weight: 500;
  color: var(--ag-color-text-muted, #6B7491);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 76px;
  line-height: 1.2;
}
.gs-stories__item--unseen .gs-stories__name {
  color: var(--ag-color-text-heading, #1E284A);
  font-weight: 600;
}

/* ---- Empty state (no stories) ---- */
.gs-stories__empty {
  font-size: 13px;
  color: var(--ag-color-text-muted, #6B7491);
  padding: 4px 12px;
}

/* ---- Story viewer modal ---- */
.gs-viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: var(--ag-z-modal, 200);
  display: none;
  align-items: center;
  justify-content: center;
}
.gs-viewer-backdrop.active {
  display: flex;
}
.gs-viewer {
  position: relative;
  width: min(420px, 92vw);
  height: min(750px, 90vh);
  border-radius: 16px;
  overflow: hidden;
  background: #111;
}

/* Progress bar row */
.gs-viewer__progress {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.gs-viewer__seg {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,.35);
  border-radius: 2px;
  overflow: hidden;
}
.gs-viewer__seg--done {
  background: #fff;
}
.gs-viewer__fill {
  height: 100%;
  background: #fff;
  width: 0;
}
.gs-viewer__fill--active {
  animation: gs-sv-progress 5s linear forwards;
}
@keyframes gs-sv-progress {
  from { width: 0; }
  to   { width: 100%; }
}

/* Header */
.gs-viewer__header {
  position: absolute;
  top: 18px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  color: #fff;
}
.gs-viewer__header img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.gs-viewer__username { font-weight: 600; font-size: 14px; }
.gs-viewer__time { font-size: 12px; opacity: .7; }
.gs-viewer__close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

/* Media */
.gs-viewer__media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gs-viewer__media img,
.gs-viewer__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Caption */
.gs-viewer__caption {
  position: absolute;
  bottom: 24px;
  left: 16px;
  right: 16px;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  z-index: 10;
}

/* Nav zones */
.gs-viewer__nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  z-index: 5;
  cursor: pointer;
}
.gs-viewer__nav--prev { left: 0; }
.gs-viewer__nav--next { right: 0; }

/* ---- Loading shimmer ---- */
.gs-stories__loading {
  display: flex;
  gap: 8px;
  padding: 0 12px;
}
.gs-stories__skel {
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.gs-stories__skel-ring {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(110deg, #e8ecf1 30%, #f3f5f8 50%, #e8ecf1 70%);
  background-size: 200% 100%;
  animation: gs-shimmer 1.4s ease infinite;
}
.gs-stories__skel-name {
  width: 48px;
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(110deg, #e8ecf1 30%, #f3f5f8 50%, #e8ecf1 70%);
  background-size: 200% 100%;
  animation: gs-shimmer 1.4s ease infinite;
}
@keyframes gs-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
