/* 第二章「情起时」— 欢愉 → 意象 → 鸳鸯 scroll-driven 叙事 */

.joy-imagery {
  position: relative;
  z-index: 1;
  background: var(--color-bg);
}

/* ── Phase 1: 欢愉 7 意象 — 转置矩阵 + 雨滴 ── */

.joy-imagery__phase--joy {
  position: relative;
  height: 100vh;
  height: 100dvh;
}

.joy-imagery.is-interaction-locked {
  z-index: 8;
}

.joy-imagery.is-interaction-locked .joy-imagery__phase--joy {
  overflow: hidden;
}

.joy-imagery.is-interaction-locked .joy-imagery__phase--joy ~ *,
.joy-imagery.is-interaction-locked ~ .reading-prose,
.joy-imagery.is-interaction-locked ~ .emotion-flow {
  visibility: hidden;
  pointer-events: none;
}

/* 欢愉意象交互时隐藏仍 pinned 的矩阵，避免叠字；不改 sticky z-index，卡片不受影响 */
html.joy-imagery-active .emotion-matrix.emotion-matrix--pinned,
html.joy-imagery-active .emotion-matrix.emotion-matrix--step-pinned {
  visibility: hidden;
  pointer-events: none;
}

.joy-imagery__pin-spacer {
  height: 0;
  pointer-events: none;
}

.joy-imagery__phase--joy.is-pinned .joy-imagery__sticky {
  background: var(--color-bg);
}

.joy-imagery__card-track {
  position: relative;
  height: 0;
  pointer-events: none;
}

.joy-imagery__card-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: visible;
  pointer-events: none;
  background: transparent;
}

.joy-imagery__phase--joy.is-card-scroll .joy-imagery__card-stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  height: auto;
  overflow: hidden;
}

.joy-imagery__phase--joy.is-card-scroll .joy-imagery__sticky {
  z-index: 2;
}

.joy-imagery__phase--joy.is-card-scroll .emotion-matrix__card.is-scroll-active {
  visibility: visible;
  pointer-events: auto;
}

.joy-imagery__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: 0 0.2vw;
  gap: 0;
}

.joy-imagery__joy-chart-host {
  width: 100%;
  max-width: none;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.joy-imagery__joy-chart-svg {
  width: 100%;
  max-height: 90vh;
  height: auto;
  display: block;
  overflow: visible;
  flex-shrink: 0;
  will-change: clip-path, transform;
}

.joy-imagery__joy-chart-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6.5vh;
  z-index: 2;
  margin: 0;
  padding: 0 1rem;
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
  text-align: center;
  pointer-events: none;
  min-height: 1.6em;
}

.joy-imagery__grid-drop .joy-imagery__drop-body {
  cursor: pointer;
  transition: fill-opacity 0.2s ease;
}

.joy-imagery__drop.is-slotted .joy-imagery__drop-body,
.joy-imagery__grid-drop.is-visible .joy-imagery__drop-body {
  cursor: pointer;
}

.joy-imagery__drop.is-slotted .joy-imagery__drop-body:hover,
.joy-imagery__grid-drop.is-visible .joy-imagery__drop-body:hover {
  fill-opacity: 1;
}

.joy-imagery__mist {
  z-index: 6;
  pointer-events: none;
}

.joy-imagery__mist .poem-sky__mist-core {
  padding: 0.95rem 1.15rem 1rem;
}

.joy-imagery__mist .poem-sky__genre {
  display: block;
  margin-top: 0.28rem;
}

.joy-imagery__joy-emotion-label {
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 300;
  font-size: 22px;
  fill: rgba(60, 60, 60, 0.38);
}

.joy-imagery__joy-emotion-label.is-lit {
  fill: rgba(36, 36, 36, 0.9);
  font-weight: 500;
}

.joy-imagery__joy-term-label {
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 300;
  font-size: 22px;
  fill: rgba(60, 60, 60, 0.38);
  opacity: 0;
  transition: opacity 0.4s ease, fill 0.4s ease;
}

.joy-imagery__joy-term-label.is-dimmed {
  opacity: 0.36;
  fill: rgba(72, 72, 72, 0.42);
  font-weight: 300;
}

.joy-imagery__joy-term-label.is-lit {
  opacity: 1;
  fill: rgba(36, 36, 36, 0.9);
  font-weight: 500;
}

.joy-imagery__drop {
  transition: opacity 0.35s ease;
}

.joy-imagery__drop-float {
  transform-box: fill-box;
  transform-origin: center center;
}

.joy-imagery__drop.is-floating .joy-imagery__drop-float {
  animation: joy-drop-float 4.2s ease-in-out infinite;
}

.joy-imagery__drop[data-index="0"].is-floating .joy-imagery__drop-float { animation-delay: 0s; }
.joy-imagery__drop[data-index="1"].is-floating .joy-imagery__drop-float { animation-delay: 0.55s; }
.joy-imagery__drop[data-index="2"].is-floating .joy-imagery__drop-float { animation-delay: 1.1s; }
.joy-imagery__drop[data-index="3"].is-floating .joy-imagery__drop-float { animation-delay: 0.25s; }
.joy-imagery__drop[data-index="4"].is-floating .joy-imagery__drop-float { animation-delay: 0.85s; }
.joy-imagery__drop[data-index="5"].is-floating .joy-imagery__drop-float { animation-delay: 1.45s; }
.joy-imagery__drop[data-index="6"].is-floating .joy-imagery__drop-float { animation-delay: 0.4s; }

@keyframes joy-drop-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

.joy-imagery__drop-body {
  transition: fill-opacity 0.35s ease, fill 0.35s ease;
}

.joy-imagery__joy-chart-host.is-matrix-uniform .joy-imagery__drop-body {
  fill-opacity: 0.9;
}

.joy-imagery__drop-term {
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 500;
  fill: rgba(32, 32, 32, 0.92);
  pointer-events: none;
}

.joy-imagery__drop-count {
  font-family: "Noto Sans SC", var(--font-sans);
  font-weight: 400;
  fill: rgba(48, 56, 64, 0.82);
  pointer-events: none;
}

.joy-imagery__caption--phase-a,
.joy-imagery__caption--phase-b {
  display: block;
  transition: opacity 0.5s ease;
}

.joy-imagery__caption--phase-b {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  opacity: 0;
}

/* ── Phase 2: 42 × 8 矩阵 ── */

.joy-imagery__phase--matrix {
  position: relative;
  height: 320vh;
  height: 320dvh;
}

.joy-imagery__matrix-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6vh var(--space-md);
  gap: 1.5rem;
}

.joy-imagery__matrix-scroll {
  width: 100%;
  max-width: min(680px, 96vw);
  max-height: min(68vh, 640px);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(36, 52, 68, 0.18) transparent;
}

.joy-imagery__matrix-scroll::-webkit-scrollbar {
  height: 4px;
}

.joy-imagery__matrix-scroll::-webkit-scrollbar-thumb {
  background: rgba(36, 52, 68, 0.18);
  border-radius: 2px;
}

.joy-imagery__matrix-host {
  min-width: 520px;
  opacity: 0;
}

.joy-imagery__matrix-svg {
  width: 100%;
  height: auto;
  display: block;
}

.joy-imagery__matrix-col-label {
  font-family: "Noto Sans SC", var(--font-sans);
  font-size: 10px;
  font-weight: 400;
  fill: rgba(80, 80, 80, 0.65);
}

.joy-imagery__matrix-row-label {
  font-family: "Noto Serif SC", var(--font-serif);
  font-size: 9.5px;
  font-weight: 300;
  fill: rgba(60, 60, 60, 0.62);
}

.joy-imagery__matrix-row-label.is-key-term {
  font-weight: 500;
  fill: rgba(36, 36, 36, 0.82);
}

.joy-imagery__matrix-dot {
  transition: opacity 0.4s ease, fill 0.4s ease;
}

.joy-imagery__matrix-caption {
  margin: 0;
  font-family: "Noto Sans SC", var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  text-align: center;
}

.joy-imagery__matrix-highlight {
  margin: 0;
  min-height: 2.4em;
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 300;
  font-size: clamp(0.85rem, 1.45vw, 0.98rem);
  letter-spacing: 0.06em;
  color: rgba(48, 48, 48, 0.78);
  text-align: center;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.joy-imagery__matrix-highlight span {
  display: none;
}

.joy-imagery__matrix-highlight.is-yuanyang .joy-imagery__hl-yuanyang {
  display: inline;
}

.joy-imagery__matrix-highlight.is-both .joy-imagery__hl-both {
  display: inline;
}

.joy-imagery__matrix-highlight strong {
  font-weight: 700;
  color: rgba(36, 36, 36, 0.88);
}

/* ── Phase 3: 鸳鸯横向 bar chart ── */

.joy-imagery__phase--yuanyang {
  position: relative;
  height: 260vh;
  height: 260dvh;
}

.joy-imagery__bar-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6vh var(--space-md);
  gap: 1.75rem;
}

.joy-imagery__bar-title {
  margin: 0;
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 300;
  font-size: clamp(0.92rem, 1.6vw, 1.05rem);
  letter-spacing: 0.1em;
  color: rgba(42, 42, 42, 0.86);
  text-align: center;
}

.joy-imagery__bar-host {
  width: min(560px, 94vw);
}

.joy-imagery__bar-svg {
  width: 100%;
  height: auto;
  display: block;
}

.joy-imagery__bar-row {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.joy-imagery__bar-label {
  font-family: "Noto Serif SC", var(--font-serif);
  font-size: 13px;
  font-weight: 300;
  fill: rgba(48, 48, 48, 0.78);
}

.joy-imagery__bar-fill {
  fill: rgba(36, 52, 68, 0.55);
}

.joy-imagery__bar-fill.is-joy {
  fill: rgba(36, 52, 68, 0.32);
}

.joy-imagery__bar-count {
  font-family: "Noto Sans SC", var(--font-sans);
  font-size: 11px;
  font-weight: 300;
  fill: rgba(80, 80, 80, 0.62);
}

.joy-imagery__bar-note {
  margin: 0;
  font-family: "Noto Sans SC", var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: 300;
  letter-spacing: 0.03em;
  color: var(--color-text-faint);
  text-align: center;
  max-width: 28rem;
  line-height: 1.7;
}

.joy-imagery__joy-contrast {
  margin: 0;
  padding: 0.6rem 1rem;
  font-family: "Noto Sans SC", var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(60, 60, 60, 0.72);
  text-align: center;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.joy-imagery__joy-contrast strong {
  font-weight: 500;
  color: rgba(36, 36, 36, 0.88);
}

/* ── 内嵌 prose ── */

.joy-imagery .reading-prose {
  padding: 14vh var(--space-md) 16vh;
}

.joy-imagery .reading-prose .reading-reveal {
  opacity: 0;
  transform: translateY(var(--reading-fade-shift));
}

.joy-imagery .reading-prose.is-visible .reading-reveal {
  animation: reading-fade-in var(--reading-fade-duration-body) ease forwards;
}

.joy-imagery .reading-prose.is-visible .reading-reveal:nth-child(1) {
  animation-delay: 0.08s;
}

.joy-imagery .reading-prose.is-visible .reading-reveal:nth-child(2) {
  animation-delay: 0.52s;
}

.joy-imagery .reading-prose.is-visible .reading-reveal:nth-child(3) {
  animation-delay: 0.96s;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .joy-imagery__phase--joy {
    height: 100vh;
    height: 100dvh;
  }

  .joy-imagery__phase--matrix {
    height: 280vh;
    height: 280dvh;
  }

  .joy-imagery__phase--yuanyang {
    height: 240vh;
    height: 240dvh;
  }

  .joy-imagery__joy-chart-host {
    width: 100%;
    padding: 0;
  }

  .joy-imagery__drop-term {
    font-size: 18px;
  }

  .joy-imagery__drop-count {
    font-size: 14px;
  }

  .joy-imagery__joy-emotion-label,
  .joy-imagery__joy-term-label {
    font-size: 18px;
  }

  .joy-imagery__matrix-host {
    min-width: 480px;
  }

  .joy-imagery__matrix-col-label {
    font-size: 9px;
  }

  .joy-imagery__matrix-row-label {
    font-size: 8.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .joy-imagery__drop,
  .joy-imagery__bar-row,
  .joy-imagery__matrix-dot,
  .joy-imagery__matrix-highlight,
  .joy-imagery__joy-contrast,
  .joy-imagery__joy-term-label {
    transition: none;
  }

  .joy-imagery__drop.is-floating .joy-imagery__drop-float {
    animation: none;
  }
}
