/* Main × secondary emotion matrix — interactive raindrop rows */

.emotion-matrix {
  position: relative;
  z-index: 1;
  background: var(--color-bg);
  padding: 0;
}

.emotion-matrix--pinned,
.emotion-matrix--step-pinned {
  z-index: 8;
}

.emotion-matrix--joy {
  min-height: 100vh;
  min-height: 100dvh;
}

.emotion-matrix--step-pinned + .reading-prose {
  visibility: hidden;
}

/* 思念/离别矩阵之后：加长这段正文的滚动距离，避免一滑就错过。不改矩阵交互。 */
.reading-prose.reading-prose--after-longing-matrix {
  min-height: 108vh;
  min-height: 108dvh;
  padding-top: 22vh;
  padding-bottom: 28vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emotion-matrix__flow {
  position: relative;
  z-index: 2;
  padding: 10vh 1.2vw 14vh;
  background: var(--color-bg);
}

.emotion-matrix__flow-spacer {
  height: 0;
  pointer-events: none;
}

.emotion-matrix__post-spacer {
  height: 0;
  pointer-events: none;
}

.emotion-matrix__card-track {
  position: relative;
  z-index: 3;
  height: 0;
}

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

.emotion-matrix--card-scroll .emotion-matrix__card-stage {
  position: fixed;
  inset: 0;
  z-index: 4;
  height: auto;
  overflow: hidden;
}

.emotion-matrix--card-scroll .emotion-matrix__flow {
  z-index: 2;
}

.emotion-matrix--pinned .emotion-matrix__flow {
  background: var(--color-bg);
}

/* 交互 pin 期间遮住后续章节，避免下一节标题从底部露出 */
.emotion-matrix--step-pinned ~ * {
  visibility: hidden;
}

.emotion-matrix__card {
  position: absolute;
  left: 50%;
  top: 100vh;
  width: min(42rem, 92vw);
  margin: 0;
  padding: 0;
  pointer-events: none;
  visibility: hidden;
  will-change: transform, top;
  transform: translate3d(-50%, 0, 0);
  background: transparent;
  border: none;
  box-shadow: none;
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 300;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

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

.emotion-matrix__card .poem-sky__mist-glow {
  inset: -4px -5px;
  background: rgba(248, 250, 252, 0.22);
  filter: blur(3px);
}

.emotion-matrix__card .poem-sky__mist-core {
  padding: clamp(1.35rem, 3.2vw, 1.85rem) clamp(1.45rem, 3.6vw, 2rem);
}

.emotion-matrix__card .poem-sky__mist-core p {
  margin: 0;
  font-size: clamp(0.88rem, 1.55vw, 1.02rem);
  line-height: 2.15;
  letter-spacing: 0.08em;
  color: rgba(48, 48, 48, 0.78);
}

.emotion-matrix__card .poem-sky__mist-core p + p {
  margin-top: 1.65em;
}

.emotion-matrix__card .poem-sky__mist-core strong {
  font-weight: 700;
  font-synthesis: none;
}

.emotion-matrix__step-hint {
  grid-column: 1 / -1;
  margin: 0.75rem 0 0;
  font-family: "Noto Sans SC", var(--font-sans);
  font-weight: 300;
  font-size: clamp(0.78rem, 1.4vw, 0.88rem);
  letter-spacing: 0.06em;
  color: rgba(68, 76, 84, 0.48);
  text-align: center;
  animation: emotion-matrix-hint-pulse 2.4s ease-in-out infinite;
}

@keyframes emotion-matrix-hint-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.85;
  }
}

.emotion-matrix__panel {
  width: min(100%, 98vw);
  max-width: none;
  margin-inline: auto;
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  column-gap: 0.45rem;
  row-gap: 1.35rem;
}

.emotion-matrix__caption {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0;
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 400;
  font-synthesis: none;
  font-size: clamp(1.18rem, 2.55vw, 1.52rem);
  line-height: 1.5;
  letter-spacing: 0.14em;
  color: rgba(48, 48, 48, 0.78);
  text-align: left;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
}

.emotion-matrix__legend {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.15rem;
  min-height: 0;
}

.emotion-matrix__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  opacity: 0;
  transform: translateY(0.3rem);
  transition:
    opacity 0.8s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.8s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.emotion-matrix__legend-item.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.emotion-matrix__legend-drop {
  display: block;
  flex-shrink: 0;
}

.emotion-matrix__legend-value {
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", sans-serif;
  font-weight: 200;
  font-synthesis: none;
  font-size: clamp(0.82rem, 1.65vw, 0.96rem);
  letter-spacing: 0.06em;
  color: rgba(58, 58, 58, 0.62);
  -webkit-font-smoothing: antialiased;
  white-space: nowrap;
}

.emotion-matrix__rows {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.emotion-matrix__row {
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 0.45rem;
  row-gap: 0.55rem;
}

.emotion-matrix__label-wrap {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  width: 100%;
  text-align: center;
}

.emotion-matrix__col-header {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  min-width: 0;
  min-height: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.85s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.emotion-matrix__row--col-active .emotion-matrix__col-header,
.emotion-matrix__row--blue-active .emotion-matrix__col-header {
  min-height: 1.6rem;
  height: auto;
  overflow: visible;
  opacity: 1;
}

.emotion-matrix__drops {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  overflow: visible;
}

.emotion-matrix__col-label {
  display: block;
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 400;
  font-synthesis: none;
  font-size: clamp(1.18rem, 2.55vw, 1.52rem);
  letter-spacing: 0.14em;
  padding-right: 0.14em;
  color: rgba(48, 48, 48, 0.78);
  text-align: center;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  opacity: 0;
  transform: translateY(0.35rem);
  transition:
    opacity 0.85s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.85s cubic-bezier(0.22, 0.61, 0.36, 1);
  -webkit-font-smoothing: antialiased;
  pointer-events: none;
}

.emotion-matrix__col-label.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.emotion-matrix__label {
  display: block;
  font-family: "Noto Serif SC", var(--font-serif);
  font-weight: 400;
  font-synthesis: none;
  font-size: clamp(1.18rem, 2.55vw, 1.52rem);
  letter-spacing: 0.14em;
  padding-right: 0.14em;
  color: rgba(48, 48, 48, 0.78);
  white-space: nowrap;
  writing-mode: horizontal-tb;
  -webkit-font-smoothing: antialiased;
}

.emotion-matrix__count {
  display: block;
  width: 100%;
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", sans-serif;
  font-weight: 200;
  font-synthesis: none;
  font-size: clamp(0.82rem, 1.65vw, 0.96rem);
  letter-spacing: 0.06em;
  text-align: center;
  color: rgba(58, 58, 58, 0.62);
  -webkit-font-smoothing: antialiased;
  white-space: nowrap;
}

.emotion-matrix__gray-trigger {
  position: absolute;
  left: 0;
  top: 12%;
  width: 100%;
  height: 1px;
  pointer-events: none;
  visibility: hidden;
}

.emotion-matrix__green-trigger {
  width: 100%;
  height: 38vh;
  pointer-events: none;
  visibility: hidden;
}

.emotion-matrix__canvas {
  display: block;
  width: 100%;
  touch-action: manipulation;
}

.emotion-matrix__mist {
  z-index: 2;
  pointer-events: none;
}

.emotion-matrix__mist .poem-sky__mist-core {
  padding: 0.95rem 1.15rem 1rem;
}

.emotion-matrix__row--multi .emotion-matrix__col-header {
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0;
}

.emotion-matrix__row--multi .emotion-matrix__col-label {
  flex: 0 0 auto;
  box-sizing: border-box;
  text-align: center;
  overflow: hidden;
}

.emotion-matrix--joy .emotion-matrix__legend {
  max-width: min(100%, 52rem);
}

.emotion-matrix--joy.emotion-matrix--pinned .emotion-matrix__flow {
  background: var(--color-bg);
  top: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  overflow: visible;
}

.emotion-matrix__mist .poem-sky__genre {
  display: none;
}

@media (max-width: 720px) {
  .emotion-matrix__caption {
    white-space: normal;
    font-size: clamp(1.05rem, 4vw, 1.18rem);
    line-height: 1.65;
  }
}

@media (max-width: 520px) {
  .emotion-matrix__flow {
    padding-inline: 2vw;
  }

  .emotion-matrix__panel,
  .emotion-matrix__row {
    grid-template-columns: 4.8rem minmax(0, 1fr);
  }

  .emotion-matrix__caption,
  .emotion-matrix__label,
  .emotion-matrix__col-label {
    font-size: 1.05rem;
  }

  .emotion-matrix__count,
  .emotion-matrix__legend-value {
    font-size: 0.76rem;
  }

  .emotion-matrix__card .poem-sky__mist-core {
    padding: 1.2rem 1.15rem 1.28rem;
  }

  .emotion-matrix__card .poem-sky__mist-core p {
    font-size: 0.86rem;
    line-height: 2.05;
  }
}
