/* Stories composer and viewer overlay (loaded on the portal). */
/* Overlay (composer and viewer) */
body.story-open {
  overflow: hidden;
}

.story-layer {
  align-items: center;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: fixed;
  z-index: 10050;
}

.story-viewer-layer {
  background: #0b1020;
  padding: 0;
}

.story-bg-dawn { background: linear-gradient(160deg, #f59e0b, #db2777 60%, #7c3aed); }
.story-bg-ocean { background: linear-gradient(160deg, #0ea5e9, #3a66e0 55%, var(--brand-primary-ink, #27348f)); }
.story-bg-forest { background: linear-gradient(160deg, #10b981, #047857 55%, #064e3b); }
.story-bg-dusk { background: linear-gradient(160deg, #6366f1, #7c3aed 55%, #4c1d95); }
.story-bg-night { background: linear-gradient(160deg, #334155, #1e293b 55%, #0f172a); }
.story-bg-rose { background: linear-gradient(160deg, #fb7185, #e11d48 55%, #9f1239); }

.story-composer {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
  box-sizing: border-box;
  color: #0f172a;
  display: grid;
  gap: 12px;
  max-height: calc(100dvh - 32px);
  max-width: 460px;
  overflow: auto;
  padding: 16px;
  width: 100%;
}

.story-composer header,
.story-composer footer {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.story-composer header strong {
  font-size: 18px;
}

.story-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.story-kind {
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #334155;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
  padding: 0 12px;
}

.story-kind.active {
  background: #eef2ff;
  border-color: #3a66e0;
  color: var(--brand-primary-ink, #27348f);
}

.story-preview {
  border-radius: 20px;
  display: grid;
  min-height: 220px;
  padding: 18px;
  position: relative;
}

.story-preview textarea {
  background: transparent;
  border: 0;
  color: #fff;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
  min-height: 180px;
  outline: none;
  resize: none;
  text-align: center;
  unicode-bidi: plaintext;
}

.story-preview textarea::placeholder {
  color: rgba(255, 255, 255, 0.75);
}

.story-count {
  bottom: 8px;
  color: rgba(255, 255, 255, 0.8);
  inset-inline-end: 12px;
  position: absolute;
}

.story-safety {
  background: #fff7ed;
  border-radius: 12px;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  padding: 10px 12px;
}

.story-error {
  color: #b91c1c;
  font-size: 13px;
  margin: 0;
}

.story-secondary,
.story-icon-button {
  background: #f1f5f9;
  border: 0;
  border-radius: 999px;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 40px;
  min-width: 40px;
  padding: 0 14px;
}

.story-composer footer .primary-button {
  min-height: 44px;
  padding: 0 26px;
}

.story-viewer {
  box-sizing: border-box;
  color: #fff;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;
  max-width: 480px;
  padding: max(10px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  position: relative;
  width: 100%;
}

@media (min-width: 600px) {
  .story-viewer {
    border-radius: 24px;
    height: min(860px, calc(100dvh - 40px));
  }
}

.story-progress-row {
  display: flex;
  gap: 4px;
}

.story-progress {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 99px;
  flex: 1 1 0;
  height: 3px;
  overflow: hidden;
}

.story-progress i {
  background: #fff;
  display: block;
  height: 100%;
  width: 0;
}

.story-progress.done i {
  width: 100%;
}

.story-progress.current i {
  animation: story-progress linear forwards;
}

.story-viewer.is-paused .story-progress.current i {
  animation-play-state: paused;
}

@keyframes story-progress {
  from { width: 0; }
  to { width: 100%; }
}

.story-viewer-head {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 10px;
  position: relative;
  z-index: 2;
}

.story-who {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

.story-who small {
  opacity: 0.8;
}

.story-viewer .story-icon-button {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.story-tap {
  background: transparent;
  border: 0;
  bottom: 120px;
  cursor: pointer;
  position: absolute;
  top: 80px;
  width: 35%;
  z-index: 1;
}

.story-tap.prev { inset-inline-start: 0; }
.story-tap.next { inset-inline-end: 0; }

.story-body {
  align-self: center;
  display: grid;
  gap: 10px;
  padding: 0 8px;
  text-align: center;
}

.story-kind-label {
  font-size: 14px;
  font-weight: 700;
  opacity: 0.9;
}

.story-body p {
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 800;
  line-height: 1.7;
  margin: 0;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
  white-space: pre-wrap;
}

.story-viewer-foot {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.story-pray {
  background: #fff;
  border: 0;
  border-radius: 999px;
  color: var(--brand-primary-ink, #27348f);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  min-height: 52px;
}

.story-pray.done {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.story-owner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.story-chip {
  background: rgba(255, 255, 255, 0.2);
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
}

.story-chip.is-plain {
  align-items: center;
  cursor: default;
  display: inline-flex;
}

.story-chip.is-danger {
  background: rgba(185, 28, 28, 0.75);
}

.story-prayer-list {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  display: grid;
  gap: 8px;
  max-height: 160px;
  overflow: auto;
  padding: 10px;
}

.story-prayer-list > span {
  align-items: center;
  display: flex;
  gap: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .story-progress.current i { animation: none; width: 100%; }
}

/* Phase 3: photo, voice, audience */
.story-media-row,
.story-audience {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.story-file {
  align-items: center;
  display: inline-flex;
}

.story-recording {
  color: #dc2626;
  font-size: 13px;
  font-weight: 700;
}

.story-close-hint {
  color: #475569;
  font-size: 12px;
  margin: 0;
}

.story-preview.has-media {
  gap: 10px;
  min-height: 0;
}

.story-preview.has-media textarea {
  font-size: 16px;
  min-height: 70px;
}

.story-media-preview img {
  border-radius: 14px;
  display: block;
  max-height: 260px;
  object-fit: contain;
  width: 100%;
}

.story-media-preview audio,
.story-audio {
  width: 100%;
}

.story-body.has-image {
  align-self: stretch;
  align-content: center;
}

.story-image {
  border-radius: 18px;
  display: block;
  margin: 0 auto;
  max-height: 58dvh;
  max-width: 100%;
  object-fit: contain;
}

.story-body.has-image p {
  font-size: clamp(16px, 4.5vw, 20px);
}

.story-image.media-load-failed,
.story-audio.media-load-failed {
  opacity: 0.4;
}

/* Phase 4: report */
.story-report-button {
  font-size: 13px;
}

.story-report-sheet {
  background: #fff;
  border-radius: 22px 22px 0 0;
  bottom: 0;
  box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.35);
  color: #0f172a;
  display: grid;
  gap: 10px;
  inset-inline: 0;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  position: absolute;
  z-index: 5;
}

.story-report-sheet p {
  color: #475569;
  font-size: 13px;
  margin: 0;
}

.story-report-reasons {
  display: grid;
  gap: 6px;
}

.story-report-reasons label {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 36px;
}

.story-report-sheet textarea {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font: inherit;
  min-height: 60px;
  padding: 8px 10px;
}

.story-report-sheet footer {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.story-secondary.is-danger {
  color: #b91c1c;
}
