/* ============================================================
   BARBERFLOW - STORIES PREMIUM MODULE
   Visual-only StoryCard refinements. Keeps existing JS hooks.
============================================================ */

/* Stories section heading spacing */
.stories-tagline {
  margin: 4px 0 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--gold-dark);
  font-family: var(--font-display);
  font-size: var(--fs-section-title);
  font-weight: var(--fw-section-title);
}

/* Wrapper injetado pelo StoriesCarousel.js (garante overflow:hidden) */
.stories-carousel-wrap {
  overflow: hidden;
  width: 100%;
}

/* Horizontal rail: sem padding horizontal para evitar peek do card fora da tela */
.stories-scroll {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  margin: 0;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stories-scroll::-webkit-scrollbar { display: none; }

/* Reusable StoryCard shell */
.story-card {
  position: relative;
  width: calc((100% - 20px) / 3);
  min-width: 0;
  max-width: none;
  flex-shrink: 0;
  scroll-snap-align: start;
  border-radius: 15px;
  background: var(--card);
  border: 1.5px solid var(--gold-border);
  box-shadow: 0 8px 18px rgba(43, 27, 18, .08);
  overflow: hidden;
  isolation: isolate;
  transform: translateZ(0);
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
}
.story-card:active {
  transform: scale(.985);
  box-shadow: 0 4px 12px rgba(43, 27, 18, .12);
}
.story-card:hover {
  border-color: rgba(107, 74, 50, .36);
  box-shadow: 0 12px 24px rgba(43, 27, 18, .12);
}

.story-video-wrap {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 8.8;
  border-radius: 15px;
  overflow: hidden;
  background: linear-gradient(180deg, #efe2d5 0%, #f8f1e9 100%);
  cursor: pointer;
}

/* Shimmer light state while media is loading */
.story-video-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255,255,255,0) 20%, rgba(255,255,255,.45) 45%, rgba(255,255,255,0) 70%);
  transform: translateX(-120%);
  animation: storyShimmer 1.3s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
.story-video-wrap.is-loaded::before {
  opacity: 0;
  animation: none;
}

.story-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Leve realce para a capa do card parecer mais nítida.
   (A compressão do vídeo limita o detalhe real; isto só aumenta contraste/cor.)
   Cobre <img>/<video> de fundo dos dois apps, sem afetar o badge da barbearia. */
.story-video-wrap > img:not(.story-shop-badge),
.story-video-wrap > video {
  filter: contrast(1.07) saturate(1.06);
  image-rendering: auto;
}

/* Optional readability overlay */
.story-video-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(43, 27, 18, .38) 0%, rgba(43, 27, 18, .06) 46%, rgba(43, 27, 18, 0) 70%);
  z-index: 2;
  pointer-events: none;
}

.story-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  background: rgba(43, 27, 18, .16);
  transition: opacity .2s ease;
  pointer-events: none;
  z-index: 4;
}
.story-play-btn.playing { opacity: 0; }

.story-card-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.story-card-name {
  margin: 0;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-card-addr {
  margin: 0;
  font-family: var(--font);
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.25;
  color: rgba(255, 255, 255, .84);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-like-btn {
  all: unset;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(43, 27, 18, .18);
  box-shadow: 0 2px 8px rgba(43, 27, 18, .14);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--ease), background var(--ease);
}
.story-like-btn:active { transform: scale(.96); }

.story-like-btn img {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.story-like-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font);
  font-size: .67rem;
  font-weight: 600;
  color: rgba(255, 255, 255, .92);
}

/* Lightweight eye indicator */
.story-like-count::before {
  content: '';
  width: 10px;
  height: 6px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 999px;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.story-shop-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 160, 23, .75);
  background: #fff;
  object-fit: cover;
  z-index: 7;
  box-shadow: 0 3px 10px rgba(43, 27, 18, .15);
}

@keyframes storyShimmer {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(130%); }
}

/* Legacy mini stories rail (cliente.html) */
.h-scroll.story-rail {
  gap: 10px;
  padding: 10px 0 4px;
}
.h-scroll.story-rail .story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.h-scroll.story-rail .story-ring {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  padding: 1.5px;
  background: linear-gradient(135deg, rgba(212, 160, 23, .9), rgba(107, 74, 50, .65));
  box-shadow: 0 7px 14px rgba(43, 27, 18, .10);
}
.h-scroll.story-rail .story-inner {
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.72);
  background: linear-gradient(180deg, #f3e8dc 0%, #f8f2eb 100%);
}
.h-scroll.story-rail .story-name {
  max-width: 64px;
  font-family: var(--font);
  font-size: .75rem;
  font-weight: 600;
  color: var(--gold-dark);
}

@media (min-width: 640px) {
  .stories-scroll {
    gap: 12px;
    padding-top: 18px;
    padding-bottom: 18px;
  }
  .story-card {
    width: calc((100% - 24px) / 3); /* fallback CSS; JS sobrescreve com pixel-exact */
  }
  .story-card-name { font-size: .86rem; }
}

/* ── MediaViewer — fullscreen overlay unificado (stories vídeo) ─ */
/* Visual espelha .pp-prism-viewer: mesmas cores, mesmo botão fechar */
.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 9000;               /* acima de .pp-prism-viewer (z:1000) e qualquer painel */
  background: rgba(8, 6, 4, .94); /* idêntico ao .pp-prism-viewer */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.media-viewer__video {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Idêntico ao .pp-prism-close — visual unificado sem duplicar CSS */
.media-viewer__close {
  all: unset;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .15);
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .2s;
}
.media-viewer__close:hover,
.media-viewer__close:focus-visible {
  background: rgba(255, 255, 255, .12);
  transform: scale(1.06);
}

/* Botão de som — aparece quando autoplay com som é bloqueado */
.media-viewer__sound {
  all: unset;
  position: absolute;
  bottom: max(32px, env(safe-area-inset-bottom, 32px));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}
.media-viewer__sound:hover { background: rgba(255, 255, 255, .22); }

body.media-viewer-open { overflow: hidden; }

/* ── Story card — estados de erro e retry ────────────────────── */
.story-card.story-failed .story-play-btn { display: none; }

.story-retry-btn {
  all: unset;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: rgba(255, 255, 255, .9);
  background: rgba(43, 27, 18, .32);
  cursor: pointer;
  z-index: 5;
  border-radius: inherit;
  transition: background .2s;
}
.story-retry-btn:hover { background: rgba(43, 27, 18, .5); }

/* ── Sem seleção de texto ao duplo clique/duplo toque ──────────────────
   Precisa vir DEPOIS de .story-like-btn/.story-retry-btn (que usam
   `all: unset`) para não ser sobrescrita pelo reset. Não altera cursor
   nem eventos de clique. */
.story-video-wrap,
.story-like-btn,
.story-retry-btn {
  -webkit-user-select: none;
  user-select: none;
}

/* ── Badge de contagem de stories no card (Ajuste 6 — mostra somente se > 1) ─ */
.story-count-badge {
  position: absolute;
  top: 8px;
  left: 44px;                   /* à direita do .story-shop-badge */
  z-index: 8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(43, 27, 18, .65);
  border: 1px solid rgba(212, 175, 55, .55);
  color: rgba(255, 255, 255, .92);
  font-family: var(--font);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .3px;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  white-space: nowrap;
}

/* ── Botão "🔊 Tocar com som" dentro do viewer fullscreen ─────────── */
.sv-sound-btn {
  all: unset;
  position: absolute;
  bottom: max(80px, calc(env(safe-area-inset-bottom, 0px) + 80px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(43, 27, 18, .78);
  border: 1px solid rgba(212, 175, 55, .45);
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .2s;
}
.sv-sound-btn:hover  { background: rgba(212, 175, 55, .25); }
.sv-sound-btn:active { transform: translateX(-50%) scale(.96); }

/* ── Overlays de identidade sobre a thumbnail do card ──────────── */
.story-public-identity {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 16px);
  padding: 3px 7px 3px 3px;
  border-radius: 999px;
  background: rgba(43, 27, 18, .58);
  border: 1px solid rgba(212, 175, 55, .42);
  box-shadow: 0 3px 10px rgba(43, 27, 18, .18);
  pointer-events: none;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.story-public-identity__avatar {
  position: static;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(212, 160, 23, .85);
  background: #fff;
  flex-shrink: 0;
}

.story-public-identity__name {
  min-width: 0;
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font);
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .72);
}

.story-barber-overlay {
  position: absolute;
  top: 46px;
  left: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.story-barber-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, .85);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(43, 27, 18, .25);
}

.story-barber-name {
  font-family: var(--font);
  font-size: .72rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
  white-space: nowrap;
  overflow: hidden;
  max-width: 80px;
  text-overflow: ellipsis;
}

.story-public-identity .story-public-identity__avatar {
  position: static;
  width: 30px;
  height: 30px;
}

.story-shop-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.story-shop-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, .6);
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(43, 27, 18, .2);
}

.story-shop-name {
  font-family: var(--font);
  font-size: .68rem;
  color: rgba(255, 255, 255, .9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
  max-width: 64px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Overlay do barbeiro no viewer fullscreen (2ª linha dentro de .sv-top) ── */
.sv-barber-overlay {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  pointer-events: none;
}

.sv-barber-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(212, 175, 55, .75);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.sv-barber-name {
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
  white-space: nowrap;
  overflow: hidden;
  max-width: 160px;
  text-overflow: ellipsis;
}
