/* Botão flutuante STORY + visualizador (componente isolado, prefixo story-) */

.story-btn {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 210;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.story-btn[hidden] { display: none !important; }
.story-btn:focus { outline: none; }
.story-btn:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 12px; }

.story-icone {
  position: relative;
  display: block;
  width: 76px;
  height: 76px;
  animation: story-pulse .9s ease-in-out infinite;
}
.story-icone img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(236, 72, 153, .75)) drop-shadow(0 0 22px rgba(168, 85, 247, .45));
  animation: story-glow .9s ease-in-out infinite;
}
.story-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0b0516;
}
.story-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.3;
  color: #fff;
  background: linear-gradient(90deg, #db2777, #a855f7);
  padding: 3px 10px;
  border-radius: 7px;
  box-shadow: 0 2px 10px rgba(219, 39, 119, .45);
}

.story-btn.story-visto .story-badge { display: none; }

@keyframes story-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes story-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(236, 72, 153, .6)) drop-shadow(0 0 18px rgba(168, 85, 247, .35)); }
  50% { filter: drop-shadow(0 0 16px rgba(236, 72, 153, .95)) drop-shadow(0 0 32px rgba(168, 85, 247, .6)); }
}

/* ---------- Visualizador ---------- */
.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 1150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 2, 12, .92);
  font-family: inherit;
}
.story-viewer[hidden] { display: none !important; }
.story-box {
  position: relative;
  width: min(420px, 100%);
  height: min(740px, 100%);
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(160deg, #2a1155, #12062a 55%, #3a0b2e);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  color: #e9d5ff;
}
.story-barras { display: flex; gap: 4px; }
.story-barra { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.story-barra i { display: block; height: 100%; width: 0; background: #fff; }
.story-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 10px; }
.story-autor { display: flex; align-items: center; gap: 8px; min-width: 0; color: #fff; font-size: 13px; font-weight: 600; }
.story-autor img { width: 34px; height: 34px; flex-shrink: 0; object-fit: contain; }
.story-autor small { display: block; font-weight: 400; color: #8b78b0; font-size: 11px; }
.story-acoes { display: flex; align-items: center; gap: 2px; }
.story-x,
.story-som {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  border-radius: 8px;
}
.story-x { font-size: 26px; padding: 4px 8px; }
.story-som { font-size: 18px; padding: 6px 8px; }
.story-som[hidden] { display: none; }
.story-x:focus-visible,
.story-som:focus-visible,
.story-rodape button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.story-conteudo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 4px 8px 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.story-midia {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 55%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, .25);
}
.story-midia img,
.story-midia video { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.story-midia.is-video { flex: 1 1 auto; max-height: 62%; }
.story-midia.is-video video { width: 100%; height: 100%; }
.story-texto { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.story-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 700;
  color: #fff;
  background: #db2777;
  padding: 3px 9px;
  border-radius: 6px;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.story-titulo { color: #fff; font-size: 24px; line-height: 1.2; margin: 0 0 10px; font-weight: 700; overflow-wrap: anywhere; }
.story-corpo { font-size: 15px; line-height: 1.6; color: #e9d5ff; margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

.story-zona { position: absolute; top: 90px; bottom: 80px; width: 30%; z-index: 2; cursor: pointer; }
.story-zona.story-esq { left: 0; }
.story-zona.story-dir { right: 0; }

.story-rodape { display: flex; gap: 8px; position: relative; z-index: 3; }
.story-rodape button {
  flex: 1;
  min-width: 0;
  text-align: center;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  border: none;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.story-todas { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15) !important; }
.story-cta { background: linear-gradient(90deg, #a855f7, #ec4899); }

html.story-aberto,
html.story-aberto body { overflow: hidden !important; }

@media (max-width: 1023px) {
  .story-btn { right: 14px; bottom: var(--story-bottom, calc(76px + env(safe-area-inset-bottom, 0px))); }
  .story-icone { width: 64px; height: 64px; }
  .story-viewer { background: #0b0516; }
  .story-box {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .story-zona { top: calc(90px + env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .story-icone,
  .story-icone img { animation: none; }
}
