/* style.css — 江苏藏书楼 VR 云游展厅
   设计基调：中式典雅 —— 墨、宣纸、朱砂、金
   无障碍：大字号、高对比度模式、焦点可见、读屏专用 .sr-only */

:root {
  --ink: #1a1410;
  --paper: #f5efe3;
  --paper-dim: rgba(245, 239, 227, .92);
  --gold: #c9a45c;
  --gold-bright: #e8c87e;
  --cinnabar: #a03123;
  --shadow: rgba(0, 0, 0, .45);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: var(--font-serif);
  color: var(--paper);
  -webkit-tap-highlight-color: transparent;
}

/* 读屏专用（视觉隐藏，辅助技术可达） */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
}
/* Tab 聚焦点位列表时临时可见（键盘用户友好） */
.sr-only:focus-within {
  position: fixed !important;
  width: auto; height: auto;
  clip: auto; clip-path: none;
  margin: 0;
  top: 70px; left: 12px;
  background: var(--paper-dim);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px;
  z-index: 60;
  max-height: 70vh;
  overflow: auto;
  box-shadow: 0 8px 30px var(--shadow);
}
.sr-only:focus-within ul { list-style: none; display: grid; gap: 8px; }
.sr-only:focus-within button {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  padding: 10px 16px;
  border: 2px solid var(--cinnabar);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

/* VR 画布与过渡层 */
#vr-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

#scene-veil {
  position: fixed; inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
  z-index: 20;
}
#scene-veil.on { opacity: 1; }

/* 中央准星 */
.reticle {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s;
}
body.started .reticle { opacity: 1; }
.reticle svg { display: block; filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)); }
.reticle-bg {
  fill: none;
  stroke: rgba(245, 239, 227, .28);
  stroke-width: 2.5;
}
.reticle-progress {
  fill: none;
  stroke: var(--gold-bright);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 163.4;
  stroke-dashoffset: 163.4;
  transform: rotate(-90deg);
  transform-origin: center;
}
.reticle-dot {
  fill: rgba(245, 239, 227, .85);
  transition: fill .2s;
}
.reticle-dot.on { fill: var(--gold-bright); }
.reticle.charging .reticle-dot { fill: var(--cinnabar); }

/* 开场遮罩 */
.splash {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(160, 49, 35, .18), transparent 60%),
    radial-gradient(ellipse at center, #241a12 0%, #120c08 75%);
  transition: opacity .6s ease;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-inner {
  text-align: center;
  max-width: 640px;
  padding: 32px;
}
.splash-seal {
  width: 84px; height: 84px;
  margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--cinnabar);
  color: #f3e3c0;
  font-size: 2.6rem;
  border-radius: 14px;
  box-shadow: 0 0 0 3px rgba(201, 164, 92, .5), 0 10px 30px var(--shadow);
  transform: rotate(-4deg);
}
.splash h1 {
  font-size: 3.2rem;
  letter-spacing: .35em;
  text-indent: .35em;
  color: var(--gold-bright);
  text-shadow: 0 2px 18px rgba(232, 200, 126, .3);
  font-weight: 700;
}
.splash-sub {
  margin-top: 10px;
  font-size: 1.15rem;
  letter-spacing: .5em;
  text-indent: .5em;
  color: rgba(245, 239, 227, .8);
}
.splash-org {
  margin-top: 6px;
  font-size: .95rem;
  letter-spacing: .3em;
  text-indent: .3em;
  color: rgba(201, 164, 92, .9);
}
.splash-desc {
  margin: 26px auto 30px;
  font-size: 1.05rem;
  line-height: 2;
  color: rgba(245, 239, 227, .85);
}
.btn-start {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  letter-spacing: .4em;
  text-indent: .4em;
  padding: 18px 64px;
  color: var(--ink);
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 26px rgba(201, 164, 92, .4);
  transition: transform .2s, box-shadow .2s;
}
.btn-start:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(201,164,92,.55); }
.btn-start:disabled { opacity: .5; cursor: wait; }
.btn-start:focus-visible, .tbtn:focus-visible, .ibtn:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}
.splash-loading {
  margin-top: 22px;
  font-size: .95rem;
  color: rgba(245, 239, 227, .55);
  letter-spacing: .15em;
}

/* 开场双按钮：开始 + 安装 */
.splash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  align-items: center;
}
.btn-install {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  letter-spacing: .2em;
  text-indent: .2em;
  padding: 14px 28px;
  color: var(--paper);
  background: rgba(26, 20, 16, .55);
  border: 1.5px solid rgba(201, 164, 92, .65);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s;
}
.btn-install:hover {
  background: rgba(58, 36, 23, .9);
  border-color: var(--gold-bright);
  transform: translateY(-1px);
}
.btn-install:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}

/* PWA 离线缓存进度 */
.offline-status {
  margin: 18px auto 0;
  max-width: 420px;
  text-align: center;
}
.offline-status-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(245, 239, 227, .12);
  overflow: hidden;
}
.offline-status-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width .25s ease;
}
.offline-status.ready .offline-status-fill {
  background: linear-gradient(90deg, #2a7a5a, #5ecf9a);
}
.offline-status[data-state="error"] .offline-status-fill {
  background: linear-gradient(90deg, var(--cinnabar), #c9502f);
  width: 100%;
}
.offline-status-text {
  margin-top: 10px;
  font-size: .88rem;
  letter-spacing: .08em;
  color: rgba(245, 239, 227, .62);
  line-height: 1.5;
}
.offline-status.ready .offline-status-text {
  color: rgba(142, 216, 176, .95);
}

/* 顶部栏 */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(18, 12, 8, .88), rgba(18, 12, 8, 0));
  opacity: 0;
  transition: opacity .5s;
  pointer-events: none;
}
body.started .topbar { opacity: 1; pointer-events: auto; }
.topbar-title { display: flex; align-items: baseline; gap: 12px; }
.topbar-main {
  font-size: 1.5rem;
  letter-spacing: .25em;
  color: var(--gold-bright);
  text-shadow: 0 1px 8px rgba(0,0,0,.7);
}
.topbar-sub {
  font-size: .85rem;
  letter-spacing: .3em;
  color: rgba(245, 239, 227, .65);
}
.topbar-btns { display: flex; gap: 10px; }
.tbtn {
  font-family: var(--font-serif);
  font-size: 1rem;
  padding: 10px 20px;
  color: var(--paper);
  background: rgba(26, 20, 16, .75);
  border: 1.5px solid rgba(201, 164, 92, .55);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .2s, border-color .2s;
}
.tbtn:hover { background: rgba(58, 36, 23, .9); border-color: var(--gold-bright); }
.btn-home { border-color: var(--cinnabar); color: #f0b9a8; }
.btn-vr { border-color: #5a9; color: #8fd8b8; }
.btn-vr:hover { background: rgba(85, 170, 153, .25); border-color: #7fc; }
.btn-install-bar { border-color: rgba(201, 164, 92, .7); color: var(--gold-bright); }
.btn-install-bar:hover { background: rgba(201, 164, 92, .18); }

/* 音量滑条 */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 14px;
  background: rgba(26, 20, 16, .75);
  border: 1.5px solid rgba(201, 164, 92, .45);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  color: var(--paper);
  font-family: var(--font-serif);
  font-size: .9rem;
}
.volume-label {
  letter-spacing: .12em;
  color: rgba(245, 239, 227, .8);
  white-space: nowrap;
  cursor: pointer;
}
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 6px;
  border-radius: 999px;
  background: rgba(245, 239, 227, .2);
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid #3a2417;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid #3a2417;
  cursor: pointer;
}
.volume-slider:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}
.volume-value {
  min-width: 3.2em;
  text-align: right;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

/* VR 沉浸时隐藏 DOM 准星（头显只渲染 WebGL，用 3D 视线球代替） */
body.vr-presenting .reticle { opacity: 0 !important; }

/* 点位信息卡片 */
.info-card {
  position: fixed;
  left: 20px; bottom: 110px;
  z-index: 30;
  width: min(420px, calc(100vw - 40px));
  padding: 22px 24px;
  background: var(--paper-dim);
  color: var(--ink);
  border-radius: 16px;
  border-left: 6px solid var(--cinnabar);
  box-shadow: 0 12px 40px var(--shadow);
  backdrop-filter: blur(8px);
}
.info-head {
  display: flex; align-items: baseline; gap: 12px;
  border-bottom: 1.5px solid rgba(160, 49, 35, .25);
  padding-bottom: 10px;
}
.info-head h2 { font-size: 1.7rem; letter-spacing: .1em; }
.info-city { font-size: .95rem; color: var(--cinnabar); }
.info-meta { margin-top: 8px; font-size: .9rem; color: #6b5b45; }
.info-intro { margin-top: 10px; font-size: 1rem; line-height: 1.8; }
.info-progress {
  margin-top: 14px;
  height: 6px;
  background: rgba(26, 20, 16, .12);
  border-radius: 999px;
  overflow: hidden;
}
.info-progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--cinnabar), #c9502f);
  border-radius: 999px;
  transition: width .2s linear;
}
.info-actions { margin-top: 14px; display: flex; gap: 10px; }
.ibtn {
  font-family: var(--font-serif);
  font-size: 1rem;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--cinnabar);
  background: transparent;
  color: var(--cinnabar);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.ibtn:hover { background: var(--cinnabar); color: var(--paper); }

/* 底部字幕条 */
.caption {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  z-index: 30;
  width: min(880px, calc(100vw - 32px));
  padding: 16px 28px;
  background: rgba(18, 12, 8, .85);
  border: 1px solid rgba(201, 164, 92, .35);
  border-radius: 14px;
  backdrop-filter: blur(8px);
}
.caption p {
  font-size: 1.12rem;
  line-height: 1.9;
  color: var(--paper);
  max-height: 7.6em;
  overflow-y: auto;
}

/* WebGL 降级列表 */
.fallback {
  position: fixed; inset: 0;
  z-index: 40;
  padding: 40px 24px;
  overflow-y: auto;
  background: #120c08;
  font-size: 1.1rem;
  line-height: 2;
}
.fallback-btn {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 16px;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  text-align: left;
  background: rgba(201, 164, 92, .12);
  color: var(--paper);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  cursor: pointer;
}

/* 高对比度模式（弱视友好） */
body.high-contrast { background: #000; }
body.high-contrast .topbar { background: #000; border-bottom: 3px solid #ffdd00; }
body.high-contrast .topbar-main { color: #ffdd00; }
body.high-contrast .reticle-progress { stroke: #ffdd00; }
body.high-contrast .tbtn {
  background: #000; color: #ffdd00;
  border: 3px solid #ffdd00;
  font-weight: bold;
}
body.high-contrast .info-card {
  background: #000; color: #ffff00;
  border: 3px solid #ffdd00; border-left-width: 8px;
}
body.high-contrast .info-head h2,
body.high-contrast .info-city { color: #ffff00; }
body.high-contrast .info-meta,
body.high-contrast .info-intro { color: #fff; }
body.high-contrast .info-head { border-color: #ffdd00; }
body.high-contrast .ibtn { color: #ffdd00; border: 3px solid #ffdd00; font-weight: bold; }
body.high-contrast .ibtn:hover { background: #ffdd00; color: #000; }
body.high-contrast .caption { background: #000; border: 3px solid #ffdd00; }
body.high-contrast .caption p { color: #fff; font-size: 1.25rem; }
body.high-contrast .reticle-bg { stroke: rgba(255, 221, 0, .4); }
body.high-contrast .reticle-dot { fill: #ffdd00; }
body.high-contrast .splash { background: #000; }
body.high-contrast .splash h1 { color: #ffdd00; text-shadow: none; }
body.high-contrast .splash-sub,
body.high-contrast .splash-desc,
body.high-contrast .splash-org { color: #fff; }
body.high-contrast .btn-start { background: #ffdd00; color: #000; }

/* 小屏适配 */
@media (max-width: 640px) {
  .splash h1 { font-size: 2.2rem; }
  .topbar-main { font-size: 1.1rem; }
  .topbar-sub { display: none; }
  .tbtn { padding: 8px 12px; font-size: .9rem; }
  .volume-wrap { padding: 4px 8px 4px 10px; gap: 6px; font-size: .8rem; }
  .volume-slider { width: 72px; }
  .volume-value { min-width: 2.6em; font-size: .8rem; }
  .info-card { bottom: 96px; padding: 16px 18px; }
  .info-head h2 { font-size: 1.35rem; }
  .caption p { font-size: 1rem; max-height: 5.7em; }
}

/* 横屏一体机（大字号强化） */
@media (min-width: 1280px) {
  .caption p { font-size: 1.3rem; }
  .info-head h2 { font-size: 2rem; }
  .info-intro { font-size: 1.12rem; }
}

/* 尊重系统"减弱动态效果"偏好 */
@media (prefers-reduced-motion: reduce) {
  .splash, .tbtn, .ibtn, .btn-start, #scene-veil { transition: none !important; }
}
