/* ═══════════════════════════════════════════════════════════════
   Story Modal — Hirono's emotional storytelling
   Layered: vignette + particles + glass panel + image frame + text
   Mood: candlelit, melancholic, sacred. Warm gold + parchment.
   ═══════════════════════════════════════════════════════════════ */

.story-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.story-modal[hidden] { display: none; }

.story-modal--open {
  pointer-events: auto;
  opacity: 1;
}

/* When story is active, prevent body scroll. Page dim is handled by
   the modal's own vignette overlay (cannot use filter on body — it
   compounds onto the modal itself, making everything dark). */

/* ─── Vignette: background dimmer + radial darkening at corners ─── */
.story-modal__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(8, 6, 4, 0.65) 0%, rgba(0, 0, 0, 0.92) 90%),
    rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
}

/* ─── Floating dust particles (10 small motes, slow drift) ─── */
.story-modal__particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.story-modal__particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(212, 175, 111, 0.7) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0;
  animation: storyDrift 14s linear infinite;
  animation-delay: calc(var(--i) * -1.4s);
  left: calc(8% + (var(--i) * 9%));
  top: 100%;
}

@keyframes storyDrift {
  0%   { transform: translate(0, 0) scale(0.6); opacity: 0; }
  10%  { opacity: 0.8; }
  50%  { transform: translate(40px, -45vh) scale(1); opacity: 1; }
  90%  { opacity: 0.6; }
  100% { transform: translate(-20px, -100vh) scale(0.4); opacity: 0; }
}

/* ─── Story panel — warm parchment glass ─── */
.story-modal__panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(31, 37, 32, 0.92) 0%, rgba(15, 20, 16, 0.96) 100%);
  border: 1px solid rgba(212, 175, 111, 0.22);
  border-radius: 20px;
  padding: 48px 40px 40px;
  box-shadow:
    0 0 60px -10px rgba(212, 175, 111, 0.18),
    0 24px 64px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: scale(0.94) translateY(8px);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
}

.story-modal--open .story-modal__panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

@media (max-width: 639px) {
  .story-modal {
    padding: 0;
  }
  .story-modal__panel {
    padding: 60px 22px 32px;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    max-width: 100%;
  }
}

/* ─── Close button — discrete, top-right ─── */
.story-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 111, 0.3);
  color: rgba(242, 235, 217, 0.7);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.story-modal__close:hover {
  background: rgba(212, 175, 111, 0.15);
  color: #F2EBD9;
  border-color: rgba(212, 175, 111, 0.6);
}

/* ─── Image frame — sepia + blur + halo + ornate corners ─── */
.story-modal__image-frame {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 32px;
  border-radius: 12px;
  overflow: visible;
}

.story-modal__halo {
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle at center,
    rgba(232, 197, 134, 0.35) 0%,
    rgba(212, 175, 111, 0.18) 30%,
    transparent 70%);
  filter: blur(16px);
  z-index: 0;
  animation: storyHalo 4.5s ease-in-out infinite;
}

@keyframes storyHalo {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.08); }
}

.story-modal__image {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  filter: blur(2px) sepia(0.35) saturate(0.85) brightness(0.92);
  border: 1px solid rgba(212, 175, 111, 0.35);
  animation: storyBreathing 4s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

@keyframes storyBreathing {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.025); }
}

/* Decorative engraved corners — Akashic Records signature */
.story-modal__corner {
  position: absolute;
  z-index: 2;
  font-size: 18px;
  color: #D4AF6F;
  opacity: 0.65;
  text-shadow: 0 0 8px rgba(212, 175, 111, 0.4);
  pointer-events: none;
}
.story-modal__corner--tl { top: -10px; left: -10px; }
.story-modal__corner--tr { top: -10px; right: -10px; transform: scaleX(-1); }
.story-modal__corner--bl { bottom: -10px; left: -10px; transform: scaleY(-1); }
.story-modal__corner--br { bottom: -10px; right: -10px; transform: scale(-1, -1); }

/* ─── Story text — Cormorant italic, parchment ─── */
.story-modal__text-wrap {
  text-align: center;
  max-width: 580px;
  margin: 0 auto;
}

.story-modal__text {
  font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
  font-size: clamp(18px, 2.2vw, 22px);
  font-style: italic;
  font-weight: 400;
  line-height: 1.85;
  letter-spacing: 0.01em;
  color: #F2EBD9;
  text-shadow: 0 0 24px rgba(212, 175, 111, 0.08);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 2em;
  margin: 0;
}

/* Blinking cursor while typing */
.story-modal__text--typing::after {
  content: '▋';
  display: inline-block;
  margin-left: 2px;
  color: #D4AF6F;
  animation: storyCursor 0.9s steps(2, start) infinite;
  font-style: normal;
}

@keyframes storyCursor {
  0%, 50%   { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* ─── End signature ritual ─── */
.story-modal__signature {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 36px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-style: italic;
  color: rgba(212, 175, 111, 0.85);
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.story-modal__signature--visible {
  opacity: 1;
  transform: translateY(0);
}

.story-modal__signature-line {
  flex: 0 0 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 111, 0.5), transparent);
}

.story-modal__signature-text {
  white-space: nowrap;
}

/* ─── Skip button — discreet ─── */
.story-modal__skip {
  display: block;
  margin: 32px auto 0;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid rgba(212, 175, 111, 0.2);
  border-radius: 100px;
  color: rgba(184, 172, 145, 0.6);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s;
}

.story-modal__skip:hover {
  border-color: rgba(212, 175, 111, 0.5);
  color: #F2EBD9;
  background: rgba(212, 175, 111, 0.06);
}

@media (prefers-reduced-motion: reduce) {
  .story-modal__halo,
  .story-modal__image,
  .story-modal__particle {
    animation: none;
  }
}
