/* Midnight Archive: 深夜 01:00–04:00 · CRT + 数字档案 · 深蓝 / 微白光 / 噪点 */
:root {
  --bg: #040814;
  --bg-glow: #0b1830;
  --fg: #e9eef5;
  --fg-dim: rgba(225, 232, 242, 0.34);
  --accent: rgba(232, 238, 248, 0.82);
  --moon: rgba(230, 238, 252, 0.92);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse 130% 90% at 50% 100%, var(--bg-glow) 0%, var(--bg) 52%);
  background-color: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

/* Full page: slow emergence (1–2s) */
body.page-reveal {
  opacity: 0;
  animation: pageReveal 1.75s ease-out 0.05s forwards;
}

@keyframes pageReveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 边缘略收光，像独自面对屏幕的深夜 */
#archive-vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(
    ellipse 92% 78% at 50% 44%,
    transparent 0%,
    transparent 42%,
    rgba(2, 6, 16, 0.5) 100%
  );
  mix-blend-mode: multiply;
}

#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  z-index: 2;
}

/* Fine CRT-style snow — separate from coarse grain */
#crt-noise {
  position: fixed;
  inset: -8px;
  pointer-events: none;
  z-index: 3;
  opacity: 0.072;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='cn'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.22' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23cn)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: soft-light;
  animation: crtNoiseDrift 18s linear infinite, crtNoiseHum 7s ease-in-out infinite alternate;
}

@keyframes crtNoiseDrift {
  0% { background-position: 0 0; }
  100% { background-position: 180px 120px; }
}

@keyframes crtNoiseHum {
  from { opacity: 0.055; }
  to { opacity: 0.09; }
}

#crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 8, 24, 0.42) 1px,
    rgba(0, 8, 24, 0.42) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.88;
}

#crt-scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0) 5px,
    rgba(200, 220, 255, 0.045) 5px,
    rgba(200, 220, 255, 0.045) 6px
  );
  mix-blend-mode: overlay;
  opacity: 0.92;
  animation: crtScanRoll 11s linear infinite;
}

@keyframes crtScanRoll {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, 7px, 0); }
}

/* Old device “boot” when switching rooms */
.room-enter-fx {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.room-enter-fx__flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 105% 75% at 50% 42%,
    rgba(248, 252, 255, 0.55) 0%,
    rgba(200, 218, 245, 0.32) 38%,
    rgba(60, 85, 120, 0.12) 72%,
    transparent 100%
  );
  opacity: 0;
  mix-blend-mode: screen;
}

.room-enter-fx.is-on .room-enter-fx__flash {
  animation: roomEnterFlash 1.42s ease-out forwards;
}

@keyframes roomEnterFlash {
  0% {
    opacity: 0;
    filter: brightness(1.35) contrast(0.92);
  }
  14% {
    opacity: 0.62;
    filter: brightness(1.5) contrast(0.88);
  }
  42% {
    opacity: 0.22;
    filter: brightness(1.08) contrast(0.98);
  }
  100% {
    opacity: 0;
    filter: brightness(1) contrast(1);
  }
}

.room-enter-fx__sweep {
  position: absolute;
  left: -8%;
  width: 116%;
  height: 14%;
  top: -18%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(220, 235, 255, 0.06) 38%,
    rgba(240, 248, 255, 0.2) 50%,
    rgba(200, 220, 245, 0.08) 62%,
    transparent 100%
  );
  box-shadow: 0 0 40px rgba(180, 210, 255, 0.06);
  opacity: 0;
  mix-blend-mode: overlay;
}

.room-enter-fx.is-on .room-enter-fx__sweep {
  animation: roomEnterSweep 1.22s cubic-bezier(0.42, 0, 0.2, 1) forwards;
}

@keyframes roomEnterSweep {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 0;
  }
  6% {
    opacity: 0.95;
  }
  88% {
    opacity: 0.5;
  }
  100% {
    transform: translate3d(0, 118vh, 0);
    opacity: 0;
  }
}

html.room-boot {
  animation: roomBootShake 1.24s steps(14, end);
}

@keyframes roomBootShake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  7% {
    transform: translate3d(1.5px, -1px, 0);
  }
  14% {
    transform: translate3d(-1px, 1.5px, 0);
  }
  21% {
    transform: translate3d(1px, 1px, 0);
  }
  28% {
    transform: translate3d(-1.5px, -0.5px, 0);
  }
  35% {
    transform: translate3d(0.5px, 1px, 0);
  }
  42% {
    transform: translate3d(1px, -1px, 0);
  }
  49% {
    transform: translate3d(-1px, 0.5px, 0);
  }
  56% {
    transform: translate3d(0.5px, -1px, 0);
  }
  63% {
    transform: translate3d(-0.5px, 1px, 0);
  }
  70% {
    transform: translate3d(1px, 0, 0);
  }
  77% {
    transform: translate3d(-1px, -0.5px, 0);
  }
  84% {
    transform: translate3d(0, 0.5px, 0);
  }
  91% {
    transform: translate3d(0.5px, 0, 0);
  }
}

html.room-boot .section-tab {
  pointer-events: none;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10vmin 8vw 14vmin;
  text-align: center;
  transition: padding 1.35s cubic-bezier(0.22, 0.9, 0.36, 1), align-items 1.35s cubic-bezier(0.22, 0.9, 0.36, 1);
}

body.is-exhibition main {
  align-items: flex-start;
  padding-top: min(12rem, 18vh);
}

.archive {
  position: relative;
  width: 100%;
  max-width: 32rem;
  display: grid;
  grid-template: 1fr / 1fr;
  justify-items: center;
}

body.is-exhibition .archive {
  max-width: 38rem;
  justify-items: stretch;
}

.view {
  grid-area: 1 / 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition:
    opacity 1.35s cubic-bezier(0.22, 0.9, 0.36, 1),
    transform 1.35s cubic-bezier(0.22, 0.9, 0.36, 1),
    visibility 1.35s;
}

.view.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
}

.view:not(.is-hidden) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.view--exhibition {
  align-items: stretch;
  text-align: left;
}

.exhibition-foyer {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.52rem;
  font-weight: 300;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: rgba(200, 218, 255, 0.26);
  margin: 0 0 2.5rem;
  padding: 0;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(200, 215, 245, 0.12);
  padding-bottom: 0.45rem;
  align-self: flex-start;
  cursor: pointer;
  transition: color 1.25s ease, border-color 1.25s ease;
}

.exhibition-foyer:hover,
.exhibition-foyer:focus-visible {
  outline: none;
  color: rgba(220, 232, 248, 0.48);
  border-bottom-color: rgba(210, 228, 255, 0.22);
}

.exhibition-slug {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.52rem;
  font-weight: 300;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(200, 218, 255, 0.28);
  margin: 0 0 2.75rem;
}

.section-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin: 0 0 2.5rem;
  padding: 0;
  border: none;
  border-top: 1px solid rgba(200, 215, 245, 0.1);
}

.section-tab {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.52rem;
  font-weight: 300;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  text-align: left;
  color: rgba(200, 218, 255, 0.34);
  background: none;
  border: none;
  border-bottom: 1px solid rgba(200, 215, 245, 0.08);
  padding: 1.15rem 0 1.2rem;
  margin: 0;
  cursor: pointer;
  transition: color 1.25s ease, box-shadow 1.25s ease, padding-left 1.25s ease;
}

.section-tab:hover,
.section-tab:focus-visible {
  outline: none;
  color: rgba(228, 236, 252, 0.58);
}

.section-tab.is-active {
  color: rgba(240, 244, 252, 0.82);
  padding-left: 0.65rem;
  box-shadow: inset 2px 0 0 rgba(200, 220, 255, 0.35);
}

.section-panels {
  position: relative;
  width: 100%;
  min-height: 16rem;
  text-align: left;
  padding-top: 0.25rem;
}

.section-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
  transform: scale(0.982) translateY(8px);
  transform-origin: 50% 20%;
  transition:
    opacity 1.2s cubic-bezier(0.22, 0.9, 0.36, 1),
    transform 1.2s cubic-bezier(0.22, 0.9, 0.36, 1);
}

.section-panel.is-active {
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

.section-panel__meta {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.52rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(200, 218, 255, 0.3);
  margin: 0 0 1.15rem;
}

.section-panel__title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: clamp(1.2rem, 3.8vw, 1.65rem);
  font-style: italic;
  letter-spacing: 0.03em;
  line-height: 1.35;
  color: rgba(238, 242, 250, 0.92);
  margin: 0 0 0.9rem;
}

.section-panel__body {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.55;
  color: rgba(228, 232, 240, 0.46);
  margin: 0;
  max-width: 30em;
}

.section-panel__body + .section-panel__body {
  margin-top: 0.9rem;
}

.exhibition-guide {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  font-style: italic;
  line-height: 1.65;
  color: rgba(218, 226, 240, 0.44);
  max-width: 22em;
  margin: 0 0 3rem;
  opacity: 0;
  animation: fadeIn 7.2s ease-out 2.1s forwards;
}

.entry-link {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.62rem;
  font-weight: 300;
  letter-spacing: 0.48em;
  text-indent: 0.48em;
  text-transform: uppercase;
  color: rgba(228, 236, 248, 0.52);
  background: none;
  border: none;
  border-bottom: 1px solid rgba(210, 228, 255, 0.22);
  padding: 0.5rem 0 0.65rem;
  margin: 0;
  cursor: pointer;
  transition: color 1.35s ease, border-color 1.35s ease, text-shadow 1.35s ease;
  text-shadow:
    0 0 14px rgba(200, 220, 255, 0.08),
    0 0 28px rgba(160, 195, 235, 0.04);
  opacity: 0;
  animation: fadeIn 7s ease-out 2.85s forwards;
}

.entry-link:hover,
.entry-link:focus-visible {
  outline: none;
  color: rgba(246, 248, 252, 0.88);
  border-bottom-color: rgba(230, 240, 255, 0.42);
  text-shadow:
    0 0 18px rgba(210, 228, 255, 0.16),
    0 0 36px rgba(170, 200, 240, 0.08);
}

.entry-link:focus-visible {
  box-shadow: 0 1px 0 0 rgba(200, 220, 255, 0.4);
}

.entry-link:active {
  color: rgba(220, 230, 245, 0.6);
}

.signal {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  font-weight: 300;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fadeIn 6.2s ease-out 0.75s forwards;
}

h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: clamp(1.5rem, 4.5vw, 2.15rem);
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.35;
  max-width: 16em;
  margin: 0 0 1.75rem;
  color: var(--moon);
  text-shadow: 0 0 48px rgba(200, 220, 255, 0.07);
  opacity: 0;
  animation: fadeIn 7.5s ease-out 1.35s forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.sound-toggle {
  position: fixed;
  right: max(1.25rem, 4vw);
  bottom: max(1.25rem, 4vw);
  z-index: 7;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.48rem;
  font-weight: 300;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  text-transform: uppercase;
  color: rgba(200, 218, 255, 0.32);
  background: rgba(4, 10, 22, 0.45);
  border: none;
  border-bottom: 1px solid rgba(200, 215, 245, 0.14);
  padding: 0.55rem 0 0.6rem;
  cursor: pointer;
  transition: color 1.2s ease, border-color 1.2s ease, opacity 1s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  outline: none;
  color: rgba(228, 236, 252, 0.55);
  border-bottom-color: rgba(220, 235, 255, 0.28);
}

@media (prefers-reduced-motion: reduce) {
  body.page-reveal {
    animation: none;
    opacity: 1;
  }

  .signal, h1, .exhibition-guide, .entry-link {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .view {
    transition: none;
  }

  .view.is-hidden {
    transform: none;
  }

  .section-panel {
    transition: none;
    transform: none;
  }

  .section-panel.is-active {
    transform: none;
  }

  main {
    transition: none;
  }

  html.room-boot {
    animation: none !important;
  }

  .room-enter-fx.is-on .room-enter-fx__flash,
  .room-enter-fx.is-on .room-enter-fx__sweep {
    animation: none !important;
    opacity: 0 !important;
    transform: none !important;
    filter: none !important;
  }

  #crt-noise,
  #crt-scanlines::after {
    animation: none !important;
  }

  #crt-noise {
    opacity: 0.07;
  }
}
