/* ============================================================
   shell.css — 壳样式：主场景（香港天台）+ 子应用层 + 转场层
   色彩/字体全部引用 assets/theme.css 的统一令牌。
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--zc-bg); overscroll-behavior: none; }
body {
  font-family: var(--zc-font-body);
  color: var(--zc-ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

/* ============ 主场景 ============ */
#home { position: fixed; inset: 0; z-index: 10; opacity: 0; transition: opacity .5s var(--zc-ease-out); }
#home.on { opacity: 1; }

/* 舞台：JS 把它对位到背景图的 cover 绘制区，热区百分比才能与像素契约对齐 */
#hk-stage { position: absolute; }

#hk-stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; transition: opacity .35s ease;
}
#hk-stage img.on { opacity: 1; }

/* 昼夜时间流逝视频：挂载时透明（底图保持可见），首帧到达后淡入，消灭黑闪 */
#hk-tf {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: none; background: #000;
  opacity: 0; transition: opacity .28s ease;
}
#hk-tf.on { display: block; }
#hk-tf.visible { opacity: 1; }

.hk-veil {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(4,8,18,.34), transparent 24%, transparent 60%, rgba(4,8,18,.5));
}

/* ---------- 热区 ---------- */
#hotspots { position: absolute; inset: 0; }
.hot {
  position: absolute;
  border: 1px solid transparent; /* Only keyboard focus adds a boundary. */
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .22s ease;
}
/* Ring and two soft pale-yellow glow layers breathe as one: big -> zero -> big.
   Matching endpoints keep the return stroke continuous across every loop. */
.hot .hot-halo {
  --halo-size: clamp(54px, 5.8vw, 84px);
  --halo-rgb: 239, 218, 159;
  position: absolute; left: 50%; top: 50%;
  width: var(--halo-size); height: var(--halo-size);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle,
    rgba(var(--halo-rgb), .2) 0%, rgba(var(--halo-rgb), .08) 42%, transparent 70%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
  visibility: hidden;
  animation: halo-breathe 4.8s cubic-bezier(.45, 0, .55, 1) infinite;
  animation-play-state: paused;
}
.hot .hot-halo::before {
  content: '';
  position: absolute; inset: -28%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(var(--halo-rgb), .18) 0%, rgba(var(--halo-rgb), .11) 38%, transparent 70%);
}
.hot .hot-halo::after {
  content: '';
  position: absolute; inset: 10%;
  border: 1px solid rgba(var(--halo-rgb), .55);
  border-radius: 50%;
  box-shadow: 0 0 7px rgba(var(--halo-rgb), .08);
}
#home[data-mode="day"] .hot .hot-halo { --halo-rgb: 248, 235, 188; }
#home.halos-active .hot-halo { visibility: visible; animation-play-state: running; }
.hot[data-key="tv"] .hot-halo { left: 36%; top: 25%; }
.hot[data-key="art"] .hot-halo { left: 47%; top: 51%; animation-delay: -1.2s; }
.hot[data-key="cat"] .hot-halo { left: 45%; animation-delay: -2.4s; }
.hot[data-key="scope"] .hot-halo { left: 36%; top: 12%; animation-delay: -3.6s; }
@keyframes halo-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .78; }
  50% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

.hot:focus-visible {                   /* 键盘焦点环保留（a11y 不回退） */
  outline: 1px solid rgba(232, 216, 188, .48);
  outline-offset: 4px;
}
.hot .hot-tag {
  position: absolute; left: 0; bottom: calc(100% + 10px);
  display: flex; align-items: baseline; gap: 8px;
  white-space: nowrap;
  background: rgba(22, 22, 21, .52);
  border: 1px solid var(--zc-hairline);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 8px;
  padding: 7px 12px;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
}
.hot:hover .hot-tag, .hot:focus-visible .hot-tag { opacity: 1; }
.hot .hot-tag b {
  font-family: var(--zc-font-display);
  font-weight: 400;
  font-size: 15px;
  color: var(--zc-gold-bright);
  letter-spacing: .1em;
}
.hot .hot-tag span {
  font-size: 10px; letter-spacing: .22em;
  color: var(--zc-ink-dim);
  font-family: var(--zc-font-mono);
}
/* 顶部热区标签翻到框下方，避免出屏 */
.hot.tag-below .hot-tag { bottom: auto; top: calc(100% + 10px); }

/* 昼夜播放中：热区（连光圈）整体退场 */
#home.playing .hot { opacity: 0; pointer-events: none; transition: opacity .3s; }

/* Readiness waits acknowledge the click quietly, without a faster pulse. */
.hot.waiting .hot-tag { opacity: 1; }
.hot.waiting .hot-tag b { color: var(--zc-gold-bright); }

/* ---------- 顶栏 ---------- */
#home-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 30px;
  z-index: 5;
}
#home-top nav { display: flex; gap: 10px; align-items: center; }
#home-top nav .zc-chip { font-size: 11.5px; padding: 7px 15px; }
/* 左上角品牌容器：内容（.zc-brand）由 home.js 经 ZL.brand 生成（theme.css 皮肤） */

/* ---------- 左下标题 ---------- */
#home-hud {
  position: absolute; left: 34px; bottom: 34px;
  text-shadow: 0 2px 26px rgba(0,0,0,.55);
  pointer-events: none;
}
#home-hud .eyebrow {
  font-family: var(--zc-font-mono);
  font-size: 10px; letter-spacing: .5em;
  color: var(--zc-ink-dim);
  margin-bottom: 10px;
}
#home-hud h1 {
  font-family: var(--zc-font-display);
  font-weight: 400;
  font-size: clamp(40px, 5.4vw, 74px);
  letter-spacing: .22em;
  line-height: 1.05;
}
#home-hud h1 span { display: block; }
/* 只有英文副标题走小号等宽样式；中文主标题保持 h1 的 clamp 大字号 */
#home-hud h1 span + span {
  font-family: var(--zc-font-mono);
  font-size: 12px; letter-spacing: .8em;
  color: var(--zc-gold);
  margin-top: 10px;
}
/* 英文语言下副标题行可能为空（ZL 补丁置 ''）——整行让位 */
#home-hud h1 span + span:empty { display: none; }
#home-hud .sub {
  margin-top: 8px;
  font-size: 12px; letter-spacing: .38em;
  color: var(--zc-ink-dim);
}

/* ---------- 底部中央导览 ---------- */
#guide {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(11, 10, 9, .55);
  border: 1px solid var(--zc-hairline);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 12.5px; letter-spacing: .12em;
  color: var(--zc-ink-dim);
  transition: opacity .24s ease;
  white-space: nowrap;
}
#guide .g-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--zc-gold-bright);
  opacity: .65;
}
#guide.hide { opacity: 0; pointer-events: none; }

/* 昼夜播放中的状态条 */
#tf-state {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: rgba(11, 10, 9, .6);
  border: 1px solid var(--zc-hairline);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 12px; letter-spacing: .22em;
  color: var(--zc-gold-bright);
  opacity: 0; pointer-events: none;
  transition: opacity .4s;
}
#home.playing #tf-state { opacity: 1; }
#home.playing #guide { opacity: 0; pointer-events: none; }

/* ---------- 统一天台导航条（home.js 经 zcnav.js 生成，id=home-nav） ----------
 * 席位与圆点的基础皮肤在 theme.css（.zc-nav，透明无底色）。
 * 这里只管天台层的落位：桌面顶部居中（theme 默认）；
 * 子应用打开 / 昼夜播放中时整体让位；窄屏沉到底部居中——
 * （接替已退役的 #mobile-nav 底部入口与 #btn-space 回到太空按钮） */
#home-nav { z-index: 7; }
body.app-open #home-nav { opacity: 0; pointer-events: none; }
#home.playing #home-nav { opacity: 0; pointer-events: none; }

/* ============ 子应用层 ============ */
#app-layer {
  position: fixed; inset: 0; z-index: 20;
  background: var(--zc-bg);
}
#app-layer[hidden] { display: none; }
/* 首屏握手等待期：应用层参与布局但不可见、不可点——
   天台与热区等待反馈保持可见，就绪后才揭幕（杜绝揭幕露空底） */
#app-layer.standby { visibility: hidden; pointer-events: none; }
.app-frame {
  width: 100%; height: 100%;
  border: 0; display: block;
  background: var(--zc-bg);
  color-scheme: normal;
}
/* Incoming frame dissolves over the still-visible previous application. */
.app-frame.overlay {
  position: absolute; inset: 0; z-index: 2;
}

/* ============ 转场层 ============ */
#fx { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
#fx-veil {
  position: absolute; inset: 0;
  background: var(--zc-bg);
  opacity: 0;
}
/* Legacy markup stays inert; Earth replay uses the single veil above. */
#fx-zip { display: none; }

/* ============ 全站颗粒（盖在天台之上；子应用打开时让位——
   视频要干净观看、像素电脑要保住像素边缘） ============ */
#site-grain {
  position: fixed; inset: -40px; z-index: 80;
  pointer-events: none;
  opacity: .05;
  transition: opacity .45s ease;
}
body.app-open #site-grain { opacity: 0; }

/* ============ 窄屏 ============ */
@media (max-width: 720px) {
  /* 安全区：viewport-fit=cover 下让开刘海与底部小黑条（env() 在桌面恒为 0，不影响桌面） */
  #home-top {
    padding: calc(14px + env(safe-area-inset-top, 0px))
             calc(16px + env(safe-area-inset-right, 0px))
             14px calc(16px + env(safe-area-inset-left, 0px));
  }
  #home-hud {
    left: calc(20px + env(safe-area-inset-left, 0px));
    bottom: calc(88px + env(safe-area-inset-bottom, 0px)); /* 让位给底部导航条 */
  }
  /* 导航条沉到底部居中（拇指位），替代退役的 #mobile-nav */
  #home-nav {
    top: auto;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    gap: clamp(8px, 3.8vw, 18px);
    padding: 7px 16px 5px;
    max-width: calc(100vw - 24px);
  }
  #guide { display: none; } /* 入口已显式列出，导览条让位 */
}
@media (max-width: 360px) {
  /* 更窄的机型：席位只留中文，标题上移避让 */
  .zc-nav-seat span { display: none; }
  #home-hud { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
}

/* ============ reduced-motion ============ */
@media (prefers-reduced-motion: reduce) {
  #home, .hot, .hot .hot-tag, #guide, #hk-tf, #hk-stage img { transition-duration: .001ms !important; animation: none !important; }
  .hot .hot-halo { animation: none !important; opacity: .24; transform: translate(-50%, -50%) scale(.7); }
}
