/* ============================================================
   layout.css — 深夜场景、玻璃容器、区块节奏、响应式
   ============================================================ */

body {
  position: relative;
  background:
    radial-gradient(120% 80% at 50% -10%, #16203a 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-night) 42%, #0A0D15 100%);
}

/* ============ 深夜氛围层（ambience.js 注入） ============ */
.ambience {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* 暖橘台灯光晕 */
.ambience__glow {
  position: absolute;
  top: -18%;
  left: 50%;
  width: 130vmax;
  height: 110vmax;
  transform: translateX(-50%);
  background:
    radial-gradient(38% 34% at 50% 34%, rgba(255, 184, 112, 0.24), transparent 68%),
    radial-gradient(28% 24% at 26% 58%, rgba(255, 122, 60, 0.16), transparent 70%),
    radial-gradient(30% 26% at 76% 62%, rgba(110, 150, 255, 0.1), transparent 72%);
  filter: blur(6px);
  transition: opacity var(--dur-lazy) var(--ease-in-out);
  will-change: opacity, transform;
}

.ambience__pulse {
  position: absolute;
  inset: -10%;
  background: radial-gradient(30% 30% at 50% 40%, rgba(255, 205, 150, 0.1), transparent 70%);
  animation: breathe 9s var(--ease-in-out) infinite;
  will-change: opacity;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.95;
  }
}

/* 柔光粒子容器 */
.ambience__particles {
  position: absolute;
  inset: 0;
}
.ambience__particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 168, 0.9), rgba(255, 174, 96, 0) 70%);
  will-change: transform, opacity;
}

/* 房间暗角，聚焦视线 */
.ambience__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}

/* 台灯关闭态（房间熄灯） */
body.lamp-off .ambience__glow {
  opacity: 0.16;
  transform: translateX(-50%) scale(1.08);
}
body.lamp-off .ambience__particles {
  opacity: 0;
}
body.lamp-off {
  filter: saturate(0.86) brightness(0.9);
}

/* ============ 常驻顶栏 ============ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 14px clamp(16px, 4vw, 40px);
  background: linear-gradient(180deg, rgba(8, 11, 19, 0.86), rgba(8, 11, 19, 0));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.topbar__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 0 14px 2px rgba(255, 154, 77, 0.7);
  animation: dotPulse 2.6s var(--ease-in-out) infinite;
}
@keyframes dotPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.82);
  }
}

.topbar__tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* 通用小圆按钮 */
.tool-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  font-size: 17px;
  line-height: 1;
  transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast) ease,
    background var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.tool-btn:hover {
  transform: translateY(-2px);
  border-color: var(--glass-border-hover);
  background: var(--glass-bg-strong);
  box-shadow: var(--glow-soft);
}
.tool-btn:active {
  transform: translateY(0) scale(0.94);
}
.tool-btn[aria-pressed="true"] {
  border-color: var(--lamp);
  color: var(--lamp-bright);
  box-shadow: var(--glow-soft);
}

/* ============ 主滚动容器 ============ */
.page {
  position: relative;
  z-index: 10;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--space-9) clamp(18px, 4vw, 32px) var(--space-8);
}

/* ============ 区块通用进入动效 ============ */
.reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity var(--dur-lazy) var(--ease-out), transform var(--dur-lazy) var(--ease-out);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ============ 玻璃卡片 ============ */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255, 220, 180, 0.07), transparent 42%);
  pointer-events: none;
}

/* ============ 区块标题 ============ */
.section {
  margin-top: var(--space-9);
}
.section__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-left: 2px;
}
.section__index {
  font-family: var(--font-round);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  color: var(--lamp);
  text-transform: uppercase;
}
.section__title {
  font-size: var(--fs-h2);
  color: var(--ink);
}
.section__hint {
  font-size: var(--fs-xs);
  color: var(--ink-ghost);
  margin-left: auto;
  letter-spacing: 0.04em;
}

/* ============================================================
   开场：深夜酒店房间
   分三层——窗（远景）/ 房间（中景）/ 桌面（近景），做滚动视差
   ============================================================ */
.hero {
  position: relative;
  text-align: center;
  padding-top: 26vh; /* 给窗户留出上方空间，文字不与窗户重叠 */
  padding-bottom: 22vh; /* 给桌面物件留出下方空间 */
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ---------- 房间场景（绝对铺满首屏区域） ---------- */
/* 注意：横向不做 -9999px 拉伸，否则百分比定位会把物件推到视口外 */
.room {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: calc(100% + 120px);
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* 窗外：夜雨 + 城市灯火 */
.room__window {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, 46vw);
  height: min(196px, 26vh);
  border-radius: 5px;
  background:
    linear-gradient(180deg, #0E1526 0%, #131E38 55%, #1A2440 100%);
  box-shadow:
    0 0 0 7px rgba(28, 22, 18, 0.9),
    0 0 60px -8px rgba(120, 160, 255, 0.24),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  opacity: 0.78;
}

/* 窗框十字 */
.room__window::before,
.room__window::after {
  content: "";
  position: absolute;
  background: rgba(20, 16, 13, 0.92);
  z-index: 4;
}
.room__window::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 5px;
  transform: translateX(-50%);
}
.room__window::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 5px;
  transform: translateY(-50%);
}

/* 远处楼宇灯火 */
.room__city {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 42%, rgba(255, 214, 150, 0.9), transparent),
    radial-gradient(2px 2px at 21% 55%, rgba(255, 214, 150, 0.7), transparent),
    radial-gradient(2.5px 2.5px at 33% 38%, rgba(180, 220, 255, 0.85), transparent),
    radial-gradient(2px 2px at 44% 62%, rgba(255, 200, 140, 0.75), transparent),
    radial-gradient(2px 2px at 58% 46%, rgba(255, 224, 170, 0.8), transparent),
    radial-gradient(2.5px 2.5px at 69% 58%, rgba(170, 210, 255, 0.7), transparent),
    radial-gradient(2px 2px at 79% 40%, rgba(255, 206, 150, 0.85), transparent),
    radial-gradient(2px 2px at 88% 54%, rgba(255, 220, 170, 0.6), transparent),
    radial-gradient(1.6px 1.6px at 27% 30%, rgba(255, 230, 190, 0.5), transparent),
    radial-gradient(1.6px 1.6px at 64% 33%, rgba(200, 225, 255, 0.5), transparent);
  opacity: 0.85;
  animation: cityTwinkle 6s var(--ease-in-out) infinite;
}
@keyframes cityTwinkle {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.55; }
}

/* 玻璃上的雨痕（斜向细线） */
.room__rain {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      104deg,
      rgba(190, 220, 255, 0.16) 0px,
      rgba(190, 220, 255, 0.16) 1px,
      transparent 1px,
      transparent 9px
    ),
    repeating-linear-gradient(
      99deg,
      rgba(160, 200, 255, 0.1) 0px,
      rgba(160, 200, 255, 0.1) 1px,
      transparent 1px,
      transparent 16px
    );
  background-size: 60px 100%, 90px 100%;
  opacity: 0.55;
  animation: rainFall 1.1s linear infinite;
}
@keyframes rainFall {
  from { background-position: 0 0, 0 0; }
  to { background-position: -22px 100%, -14px 100%; }
}

/* 顺着玻璃往下爬的水珠 */
.room__drop {
  position: absolute;
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, rgba(200, 225, 255, 0.55), transparent);
  animation: dropSlide 5.5s linear infinite;
}
@keyframes dropSlide {
  0% { transform: translateY(-20px); opacity: 0; }
  12% { opacity: 0.9; }
  88% { opacity: 0.9; }
  100% { transform: translateY(230px); opacity: 0; }
}

/* 窗玻璃反光 */
.room__window-glow {
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 60%;
  height: 90%;
  background: radial-gradient(ellipse at center, rgba(255, 180, 110, 0.22), transparent 70%);
  transform: rotate(-18deg);
  filter: blur(10px);
}

/* ---------- 台灯（左下角暖光源） ---------- */
.room__lamp {
  position: absolute;
  left: max(6%, 30px);
  bottom: 26%;
  width: 0;
  height: 0;
  opacity: 0.95;
}
.room__lamp-shade {
  position: absolute;
  left: -34px;
  bottom: 0;
  width: 68px;
  height: 34px;
  border-radius: 50% 50% 14% 14% / 70% 70% 30% 30%;
  background: linear-gradient(180deg, #E8A85E, #C87A3C);
  box-shadow: inset 0 -6px 12px rgba(120, 60, 20, 0.4);
}
/* 灯罩洒下的锥形光 */
.room__lamp-beam {
  position: absolute;
  left: -130px;
  bottom: -190px;
  width: 260px;
  height: 200px;
  clip-path: polygon(38% 0%, 62% 0%, 100% 100%, 0% 100%);
  background: linear-gradient(180deg, rgba(255, 200, 140, 0.34), rgba(255, 180, 110, 0));
  filter: blur(6px);
  animation: lampFlicker 5.5s var(--ease-in-out) infinite;
}
@keyframes lampFlicker {
  0%, 100% { opacity: 0.9; }
  48% { opacity: 0.78; }
  52% { opacity: 1; }
}
/* 灯泡核心光点 */
.room__lamp-core {
  position: absolute;
  left: -14px;
  bottom: -10px;
  width: 28px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFE3B8, rgba(255, 190, 120, 0.2) 70%);
  filter: blur(3px);
}
body.lamp-off .room__lamp-beam,
body.lamp-off .room__lamp-core {
  opacity: 0.12;
}

/* ---------- 桌面与物件（近景） ---------- */
/* 桌面：只占最下面一条，物件稳稳"站"在桌面上 */
.room__desk {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 15%;
  background: linear-gradient(180deg, rgba(58, 40, 29, 0.7), rgba(24, 16, 12, 0.96));
  box-shadow:
    inset 0 2px 0 rgba(255, 200, 145, 0.16),
    0 -18px 40px -20px rgba(255, 170, 100, 0.2);
}

/* 桌上的物件（静止摆放，仅悬停时轻轻抬起） */
/* bottom 值基于完整 .room 高度，需要大于桌面高度才能"站"在桌面上 */
.room__item {
  position: absolute;
  bottom: 12.5%;
  pointer-events: auto;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.7));
  transition: transform var(--dur-base) var(--ease-spring), filter var(--dur-base) ease;
}
.room__item:hover,
.room__item:focus-visible {
  transform: translateY(-9px) scale(1.18);
  filter: drop-shadow(0 12px 22px rgba(255, 170, 90, 0.6));
}
.room__item:active {
  transform: translateY(-3px) scale(0.96);
}
.room__item--1 { left: 17%; }
.room__item--2 { left: 34%; }
.room__item--3 { left: 50%; margin-left: -13px; }
.room__item--4 { left: 66%; }
.room__item--5 { left: 83%; }

/* 床：右下角一角床面，被子平铺其上（不再悬浮） */
.room__bed {
  position: absolute;
  right: 0;
  bottom: 15%;
  width: 30%;
  height: 12%;
  border-radius: 30px 0 0 8px;
  background: linear-gradient(170deg, rgba(104, 86, 76, 0.7), rgba(50, 40, 36, 0.9));
  box-shadow:
    inset 0 3px 0 rgba(255, 214, 176, 0.16),
    0 -16px 32px -18px rgba(0, 0, 0, 0.75);
  opacity: 0.82;
}
/* 平铺的被子：只用一条暖色横带，贴在床面上 */
.room__bed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46%;
  border-radius: 0 0 0 8px;
  background: linear-gradient(180deg, rgba(226, 206, 184, 0.3), rgba(180, 158, 138, 0.14));
  box-shadow: inset 0 2px 0 rgba(255, 240, 220, 0.22);
}

/* ---------- 首屏文字（压在场景之上，但只有文字可点，其余地方穿透给场景） ---------- */
.hero__inner {
  position: relative;
  z-index: 2;
  pointer-events: none;
  display: contents;
}
.hero__kicker,
.hero__title,
.hero__sub,
.hero__time,
.hero__scroll {
  pointer-events: auto;
}
/* 让文字块回到正常流并居中（display:contents 后由父级 flex 负责布局） */
.hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-tiny);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 7px 15px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: rgba(12, 15, 24, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: var(--space-5);
}
.hero__title {
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: 1.24;
  background: linear-gradient(120deg, var(--lamp-core), var(--lamp-bright) 45%, var(--lamp-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 30px rgba(255, 154, 77, 0.3));
  margin-bottom: var(--space-4);
  cursor: pointer;
}
.hero__sub {
  font-size: var(--fs-body);
  color: var(--ink-soft);
  max-width: 30em;
  margin: 0 auto;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}
.hero__time {
  margin-top: var(--space-5);
  font-family: var(--font-round);
  font-size: var(--fs-tiny);
  letter-spacing: 0.2em;
  line-height: 1.9;
  color: var(--ink-soft);
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
}
.hero__scroll {
  margin-top: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-tiny);
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}
.hero__scroll-arrow {
  font-size: 15px;
  line-height: 1;
  animation: nudge 2.4s var(--ease-in-out) infinite;
}

/* 窗外独白气泡 */
.room__murmur {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translate(-50%, 8px);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(10, 13, 21, 0.82);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) ease, transform var(--dur-base) var(--ease-out);
  z-index: 5;
}
.room__murmur.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .hero {
    min-height: 68vh;
  }
  .room__window {
    top: 3%;
    width: 70vw;
    height: 22vh;
  }
  .room__lamp {
    left: 12%;
    bottom: 30%;
  }
  .room__item {
    font-size: 21px;
  }
  .room__bed {
    display: none;
  }
  .room__murmur {
    white-space: normal;
    max-width: 76vw;
    text-align: center;
    line-height: 1.6;
  }
}
@keyframes nudge {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(7px);
    opacity: 1;
  }
}

/* ============ 页脚 ============ */
.foot {
  margin-top: var(--space-9);
  text-align: center;
  padding-bottom: var(--space-6);
  color: var(--ink-ghost);
  font-size: var(--fs-xs);
}
.foot__line {
  width: 44px;
  height: 1px;
  margin: 0 auto var(--space-4);
  background: linear-gradient(90deg, transparent, rgba(255, 154, 77, 0.55), transparent);
}
.foot__heart {
  color: var(--lamp);
}

/* 给固定在右下角的柴犬留出安全区 */
.page__spacer {
  height: 150px;
}

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .page {
    padding-top: 88px;
  }
  .section {
    margin-top: var(--space-8);
  }
  .section__hint {
    display: none;
  }
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }
  /* 窄屏：品牌名缩成一行小字，四个按钮等距排开 */
  .topbar__brand {
    font-size: var(--fs-tiny);
    letter-spacing: 0.02em;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }
  .topbar__tools {
    gap: 6px;
    flex: none;
  }
  .tool-btn {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
}

@media (max-width: 420px) {
  .topbar__brand span:last-child {
    display: none;
  }
}
