/* ============================================================
   STORIES — кольцо «непросмотренного сториз» + вьюер как в Instagram
   ============================================================ */

/* ---------- кольцо аватара ---------- */
.avatar-ring {
  display: inline-grid; place-items: center;
  padding: 8px; border-radius: 50%;
  margin-bottom: 20px; cursor: pointer;
  box-shadow: 0 24px 52px -20px color-mix(in oklab, var(--accent) 60%, black);
  transition: transform .24s cubic-bezier(.2,.85,.25,1.05), box-shadow .28s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative; isolation: isolate;
  will-change: transform;
}
/* переливающийся вращающийся градиент «новых сториз» — насыщенный, с глянцевым бликом */
.avatar-ring::before {
  content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: 50%;
  background: conic-gradient(from 0deg,
    oklch(0.68 0.27 350),
    oklch(0.61 0.26 12),
    oklch(0.70 0.22 48),
    oklch(0.96 0.05 85),
    oklch(0.66 0.25 350),
    oklch(0.52 0.24 300),
    oklch(0.68 0.27 350));
  animation: ring-rotate 3s linear infinite;
}
.avatar-ring::after {
  /* мягкая «дышащая» подсветка-приглашение нажать */
  content: ""; position: absolute; border-radius: 50%;
  width: clamp(148px, 43vw, 184px); aspect-ratio: 1;
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 60%, transparent);
  animation: ring-pulse 2.3s ease-out infinite; pointer-events: none; z-index: -1;
}
/* наведение — кольцо «оживает»: подъём, усиленное свечение, ускоренный градиент */
.avatar-ring:hover {
  transform: scale(1.045);
  box-shadow: 0 28px 60px -18px color-mix(in oklab, var(--accent) 72%, black);
}
.avatar-ring:hover::before { animation-duration: 1.4s; }
/* нажатие — приятный отклик «вдавливания» */
.avatar-ring:active { transform: scale(0.93); transition-duration: .09s; }
.avatar-ring.viewed::before {
  background: color-mix(in oklab, var(--ink) 22%, transparent);
  animation: none;
}
.avatar-ring.viewed {
  box-shadow: 0 20px 44px -24px rgba(40,15,35,.4);
}
.avatar-ring.viewed::after { animation: none; }

/* вращение самого элемента — надёжно во всех браузерах */
@keyframes ring-rotate { to { transform: rotate(360deg); } }
@keyframes ring-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 58%, transparent); }
  70%  { box-shadow: 0 0 0 22px color-mix(in oklab, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar-ring::after { animation: none; }
  .avatar-ring::before { animation: none; }
}

.avatar-ring .avatar {
  width: clamp(132px, 40vw, 168px); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 3px var(--bg); margin: 0; display: block; position: relative;
}
.avatar-ring .avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; }

/* ---------- вьюер ---------- */
.story-viewer {
  position: fixed; inset: 0; z-index: 200;
  display: none; place-items: center;
  background: rgba(0,0,0,.92);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.story-viewer.open { display: grid; }
.story-viewer.closing { animation: sv-fade .26s ease forwards; }
@keyframes sv-fade { to { opacity: 0; } }

.sv-stage {
  position: relative; width: min(100vw, 440px); height: 100svh; max-height: 100svh;
  background: #111; overflow: hidden;
  display: flex; flex-direction: column;
  will-change: transform;
}
@media (min-width: 480px) {
  .sv-stage { height: min(92svh, 860px); border-radius: 14px; box-shadow: 0 40px 90px -30px rgba(0,0,0,.7); }
}
.story-viewer.open .sv-stage { animation: sv-in .3s cubic-bezier(.2,.7,.2,1); }
@keyframes sv-in { from { transform: scale(.92); opacity: .4; } to { transform: scale(1); opacity: 1; } }

/* прогресс-бар сегментами */
.sv-progress {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; gap: 4px; padding: 10px 10px 0;
}
.sv-seg { flex: 1 1 0; height: 2.5px; border-radius: 3px; background: rgba(255,255,255,.34); overflow: hidden; }
.sv-seg .fill { display: block; height: 100%; width: 0%; background: #fff; border-radius: 3px; }
.sv-seg.done .fill { width: 100%; }

/* шапка */
.sv-header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; gap: 11px;
  padding: 22px 12px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,.5), transparent);
  pointer-events: none;
}
.sv-header .sv-ava { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.5); }
.sv-header .sv-ava img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; }
.sv-name { color: #fff; font-weight: 700; font-size: 0.92rem; letter-spacing: .01em; }
.sv-time { color: rgba(255,255,255,.7); font-size: 0.82rem; font-weight: 500; }
.sv-close {
  margin-left: auto; color: #fff; font-size: 1.5rem; line-height: 1;
  width: 40px; height: 40px; display: grid; place-items: center; pointer-events: auto; cursor: pointer;
}

/* медиа */
.sv-media { position: absolute; inset: 0; background: #111; }
.sv-media img, .sv-media video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.sv-media .sv-loader {
  position: absolute; inset: 0; display: grid; place-items: center;
}
.sv-media .sv-loader::after {
  content: ""; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: sv-spin .8s linear infinite;
}
@keyframes sv-spin { to { transform: rotate(360deg); } }

/* зоны навигации (поверх медиа, под шапкой) */
.sv-zones { position: absolute; inset: 0; z-index: 4; display: flex; }
.sv-zones .z { height: 100%; }
.sv-zones .z-prev { flex: 0 0 32%; }
.sv-zones .z-next { flex: 1 1 auto; }

/* индикатор «звук выкл» */
/* заметная плашка «Включить звук» — по центру снизу */
.sv-mute {
  position: absolute; left: 50%; bottom: clamp(26px, 8vh, 64px); z-index: 7;
  transform: translateX(-50%) translateY(6px);
  display: none; align-items: center; gap: 9px;
  padding: 12px 20px 12px 16px; border-radius: 100px;
  background: rgba(18,8,16,.66); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: #fff; font-weight: 700; font-size: 0.98rem; line-height: 1; white-space: nowrap;
  box-shadow: 0 12px 34px -10px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.2);
  cursor: pointer; pointer-events: auto; opacity: 0;
  transition: opacity .28s ease, transform .28s ease, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.sv-mute.show {
  display: inline-flex; opacity: 1; transform: translateX(-50%) translateY(0);
  animation: mute-attn 2s ease-in-out infinite;
}
.sv-mute:hover { background: rgba(18,8,16,.82); }
.sv-mute:active { transform: translateX(-50%) translateY(0) scale(.95); }
.sv-mute svg { width: 21px; height: 21px; flex: none; display: block; }
@keyframes mute-attn {
  0%, 100% { box-shadow: 0 12px 34px -10px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.2); }
  50%      { box-shadow: 0 12px 34px -10px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.3), 0 0 0 7px rgba(255,255,255,.07); }
}
@media (prefers-reduced-motion: reduce) { .sv-mute.show { animation: none; } }

.story-viewer.paused .sv-progress,
.story-viewer.paused .sv-header { opacity: 0; transition: opacity .2s ease; }
