/* ═══════════════════════════════
   假日自习室 H5 — Style
   ═══════════════════════════════ */

/* ── Fonts ── */
@font-face {
  font-family: '字潮慵懒懒';
  src: url('../fonts/字潮慵懒懒.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'SourceHanSansCNBold';
  src: url('../fonts/%20思源黑体SourceHanSansCN-Bold.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'SourceHanSansCNLight';
  src: url('../fonts/%20思源黑体SourceHanSansCN-Light.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'SourceHanSansCNNormal';
  src: url('../fonts/思源黑体SourceHanSansCN-Normal.otf') format('opentype');
  font-display: swap;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fff;
  --bg-card: #FFFFFF;
  --primary: #2C3E50;
  --accent: #E67E22;
  --accent-light: #F39C12;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, 'PingFang SC', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Pages ── */
.page {
  display: none;
  min-height: 100vh;
  padding: 20px;
  animation: fadeIn 0.4s ease;
}
.page.active { display: flex; flex-direction: column; align-items: center; }

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

/* ── Back-to-top button ── */
.btn-back-top {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-back-top:active { opacity: 0.7; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 14px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  margin: 6px;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
  background: var(--primary);
  color: #fff;
}
.btn-secondary:hover { opacity: 0.9; }

.btn-back {
  background: transparent;
  color: var(--text-light);
  border: 1px solid #ddd;
}
.btn-back:hover { border-color: #bbb; }

.btn-start {
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  padding: 16px 40px;
  font-family: '字潮慵懒懒', cursive;
}

/* ── ① 引页（首屏动画） ── */
#page-intro.page {
  padding: 0;
  overflow: hidden;
  background: #000;
}
.intro-gif-wrap {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.intro-gif {
  width: 100vw;
  height: 100vh;
  display: block;
  object-fit: contain;
}

/* ── ② 选位页（竖屏，自适应铺满） ── */
#page-select.page {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* 背景图容器：填满整个视口 */
.select-bg {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.select-bg-img {
  display: block;
  height: 100vh;
  width: auto;
  /* 如果宽高比＞视口宽高比，则宽度填满 */
  max-width: 100vw;
  object-fit: contain;
  object-position: top center;
  z-index: 1;
}

/* 所有内部元素基于背景图实际渲染尺寸，由JS动态设置 */
:root {
  --select-scale: 1;
}

/* 无椅平面图：设计稿左下角(12.5, -230.03) 尺寸350×272.3 */
#page-select .floorplan-wrapper {
  position: absolute;
  width: 350px;
  height: 272.3px;
  left: 12.5px;
  top: calc(677px - 230.03px - 272.3px);
  z-index: 2;
  transform-origin: top left;
  transform: scale(var(--select-scale));
}
#page-select .floorplan-wrapper .floorplan-img {
  display: block;
  width: 350px;
  height: 272.3px;
}

/* 椅子图片 + 热区 + 标签由JS生成，使用720空间坐标系 */
#page-select .seat-hotzone {
  transition: box-shadow 0.2s, opacity 0.2s;
  opacity: 0.3;
  border-radius: 4px;
}
#page-select .seat-hotzone:hover {
  opacity: 0.6;
  background: rgba(230,126,34,0.15);
}
#page-select .seat-hotzone.selected {
  opacity: 0.5;
  background: rgba(230,126,34,0.25);
  box-shadow: 0 0 0 2px #E67E22;
}

/* 横屏按钮：固定在屏幕底部居中，距底部60px */
.btn-landscape {
  position: fixed;
  width: 80px;
  height: 80px;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  z-index: 5;
  cursor: pointer;
}
.btn-landscape-img {
  display: block;
  width: 80px;
  height: 80px;
}
.btn-landscape:active { transform: translateX(-50%) scale(0.92); }

/* 首页按钮：固定在右上角 */
.btn-home {
  position: fixed;
  width: 90px;
  height: 90px;
  top: 12px;
  right: 12px;
  z-index: 5;
  cursor: pointer;
}
.btn-home-img {
  display: block;
  width: 90px;
  height: 90px;
}
.btn-home:active { transform: scale(0.92); }

/* ── ②b 选位页（横屏） ── */
#page-select-landscape.page {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}
.select-bg-ls {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.select-bg-ls-img {
  display: block;
  height: 100vh;
  width: auto;
  max-width: 100vw;
  object-fit: contain;
  object-position: top center;
  z-index: 1;
}

/* 横屏平面图：旋转90°缩放到475.58×370，距顶150px，水平居中，整体transform */
.floorplan-ls-wrapper {
  position: fixed;
  left: 50%;
  top: 150px;
  z-index: 2;
}

/* 整个720×560平面图模块：根据视口宽度自适应 */
.floorplan-ls-inner {
  position: relative;
  width: 720px;
  height: 560px;
  transform-origin: center center;
}
.floorplan-ls-img {
  display: block;
  width: 720px;
  height: 560px;
}

/* 竖屏按钮：固定在左上角，距上30px、距左30px */
.btn-portrait {
  position: fixed;
  width: 80px;
  height: 80px;
  top: 30px;
  left: 30px;
  z-index: 5;
  cursor: pointer;
}
.btn-portrait-img {
  display: block;
  width: 80px;
  height: 80px;
}
.btn-portrait:active { transform: scale(0.92); }
.floorplan-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}
.floorplan-wrapper {
  position: relative;
  width: 720px;
  height: 560px;
  margin: 0 auto;
}
.floorplan-wrapper .floorplan-img {
  display: block;
  width: 720px;
  height: 560px;
}

/* ── Chair overlays ── */
.chair-overlay {
  pointer-events: none;
  user-select: none;
}

/* ── Seat hot zones ── */
.seat-hotzone {
  transition: box-shadow 0.2s, opacity 0.2s;
  opacity: 0.3;
  border-radius: 6px;
}
.seat-hotzone:hover {
  opacity: 0.6;
  background: rgba(230,126,34,0.15);
}
.seat-hotzone.selected {
  opacity: 0.5;
  background: rgba(230,126,34,0.25);
  box-shadow: 0 0 0 2px #E67E22;
}

/* ── Chair label badges ── */
.chair-label {
  pointer-events: none;
  user-select: none;
  font-family: -apple-system, 'PingFang SC', sans-serif;
}

/* ── ③ 选座成功页（选中页） ── */
#page-selected.page {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* 背景图：自适应铺满屏幕，上对齐 */
.selected-bg {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.selected-bg-img {
  display: block;
  height: 100vh;
  width: auto;
  max-width: 100vw;
  object-fit: contain;
  object-position: top center;
  z-index: 1;
}

/* 选中页内容层：所有元素堆叠在背景之上 */
.selected-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 选中页GIF：320×240，距顶70px，水平居中，黑框5.2px */
.selected-char-wrap {
  width: 320px;
  height: 240px;
  margin-top: 70px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.selected-char-img {
  width: 320px;
  height: 240px;
  display: block;
  object-fit: contain;
  border: 5.2px solid #000;
  border-radius: 4px;
}

/* 人格金句文本框：300×108，与卡通图紧贴（margin-top:0） */
.selected-quote-box {
  width: 300px;
  min-height: 108px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}
.selected-quote-text {
  font-family: 'SourceHanSansCNBold', 'PingFang SC', sans-serif;
  color: #000;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}

/* 人格按钮：280×55，与金句框紧贴 */
.btn-personality {
  width: 280px;
  height: 45px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: #000;
  color: #fff;
  font-family: 'SourceHanSansCNBold', 'PingFang SC', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-personality:active {
  opacity: 0.8;
}

/* 桌椅按钮 / 统计按钮：共用黑色按钮样式 */
.btn-chair-info, .btn-stats {
  width: 280px;
  height: 45px;
  flex-shrink: 0;
  margin-top: 10px;
  border: none;
  border-radius: 12px;
  background: #000;
  color: #fff;
  font-family: 'SourceHanSansCNBold', 'PingFang SC', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-chair-info:active, .btn-stats:active {
  opacity: 0.8;
}

/* 返回按钮：100×50，距桌椅按钮10px */
.btn-selected-back {
  width: 72px;
  height: 65px;
  flex-shrink: 0;
  margin-top: 10px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}
.btn-selected-back-img {
  width: 72px;
  height: 65px;
  display: block;
}
.btn-selected-back:active {
  opacity: 0.7;
}

/* ── ④a 人格结果页（人格页） ── */
#page-result.page {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* 复用选中页的 background 样式 */

/* 人格页内容层 */
.result-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 人格卡通图：250×214.2857，距顶50px */
.result-char-wrap {
  width: 250px;
  height: 214.2857px;
  margin-top: 70px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-char-img {
  width: 250px;
  height: 214.2857px;
  display: block;
  object-fit: contain;
}

/* 人格详细解说文本框：300×220（自适应高度） */
.result-desc-box {
  width: 300px;
  min-height: 220px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.result-desc-text {
  font-family: 'SourceHanSansCNBold', 'PingFang SC', sans-serif;
  color: #000;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
  text-align: left;
  width: 100%;
  white-space: pre-line;
}
.result-desc-text .disclaimer {
  font-family: 'SourceHanSansCNLight', 'PingFang SC', sans-serif;
  color: #999;
  font-size: 0.75rem;
}

/* ── ④b 椅子介绍页（桌椅页） ── */
#page-chair.page {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* 复用选中页的 background 样式 */

/* 桌椅页内容层 */
.chair-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 桌椅手绘图：250×215，距顶50px */
.chair-handdraw-wrap {
  width: 250px;
  height: 215px;
  margin-top: 70px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chair-handdraw-img {
  width: 250px;
  height: 215px;
  display: block;
  object-fit: contain;
}

/* 桌椅详细解说框：300×285（自适应高度） */
.chair-desc-box {
  width: 300px;
  min-height: 285px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.chair-desc-text {
  margin: 0;
  text-align: left;
  width: 100%;
  white-space: pre-line;
}

/* 桌椅名字（①） */
.chair-desc-name {
  font-family: 'SourceHanSansCNBold', 'PingFang SC', sans-serif;
  color: #000;
  font-size: 1.05rem;
  display: block;
  margin-bottom: 4px;
}
/* 产地 · 品牌（②·③） */
.chair-desc-origin {
  font-family: 'SourceHanSansCNLight', 'PingFang SC', sans-serif;
  color: #888;
  font-size: 0.8rem;
  display: block;
  margin-bottom: 8px;
}
/* 简介（④）— 字号自动调节由JS处理 */
.chair-desc-intro {
  font-family: 'SourceHanSansCNNormal', 'PingFang SC', sans-serif;
  color: #000;
  display: block;
  line-height: 1.6;
}

/* ── ⑤ 统计页 ── */
#page-stats.page {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* 统计页内容层：可滚动 */
.stats-content {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  overflow-y: visible;
  padding: 30px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 统计页背景图跟随内容一起滚动 */
#page-stats .selected-bg {
  position: absolute;
  top: 0;
  left: 0;
}
#page-stats.page {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 三条统计文案 */
.stats-banners {
  width: 100%;
  max-width: 320px;
  margin-top: 50px;
  margin-bottom: 32px;
  flex-shrink: 0;
}
.stats-banner-item {
  font-family: 'SourceHanSansCNBold', 'PingFang SC', sans-serif;
  color: #000;
  font-size: 0.85rem;
  line-height: 1.8;
  margin-bottom: 2px;
  text-align: center;
}
.stats-banner-item .highlight-seat {
  font-family: 'SourceHanSansCNBold', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

/* 数据条列表 */
.stats-list {
  width: 100%;
  max-width: 320px;
  flex-shrink: 0;
  margin-left: -10px;
}

/* 单行：编号+名称 | 数据条 | 人数 */
.stats-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  height: 24px;
  gap: 6px;
}
.stats-row-label {
  font-family: 'SourceHanSansCNNormal', 'PingFang SC', sans-serif;
  font-size: 0.8rem;
  color: #333;
  white-space: nowrap;
  width: 75px;
  flex-shrink: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-row-bar-wrap {
  flex: 1;
  height: 14px;
  background: #eee;
  border-radius: 7px;
  overflow: hidden;
  min-width: 0;
}
.stats-row-bar {
  height: 100%;
  border-radius: 7px;
  background: #727171;
  transition: width 0.3s ease;
}
.stats-row-bar.highlight {
  background: #000;
}
.stats-row.highlight-row .stats-row-label {
  font-family: 'SourceHanSansCNBold', sans-serif;
  font-weight: 700;
  color: #000;
}

/* 底部小字 */
.stats-footer {
  font-family: 'SourceHanSansCNLight', 'PingFang SC', sans-serif;
  font-size: 0.7rem;
  color: #bbb;
  text-align: center;
  margin-top: 16px;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (min-width: 500px) {
  .page:not(#page-select) { padding: 40px; }
}
