/* ============================================================
 * 铸剑学堂 H5 · 竖屏布局适配
 * 由运行时在 body 上切换 .portrait / .landscape（基于
 * innerWidth/innerHeight 实时比较，兼容夸克等不响应
 * orientation 媒体查询的浏览器）。
 * ============================================================ */

/* ---------- 滚动框架：竖屏内容纵向排列并允许滚动 ---------- */
body.portrait .design-viewport {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
body.portrait .page-scaled {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

/* ---------- absolute 定位层改文档流（撑开父容器高度） ---------- */
body.portrait .command-layer,
body.portrait .conduct-layer,
body.portrait .victory-layer,
body.portrait .command-operation,
body.portrait .conduct-operation,
body.portrait .victory-operation {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  min-height: calc(100dvh - 52px);
  height: auto;
  max-height: none;
}

/* ---------- 通用：左窄栏 + 右内容的 grid 全部改上下堆叠 ---------- */
/* overview（章总览） */
body.portrait .command-overview,
body.portrait .conduct-overview,
body.portrait .campaign-overview {
  display: flex !important;
  flex-direction: column;
  gap: 14px;
  padding: 14px 14px 20px;
}
body.portrait .overview-copy .overview-title {
  font-size: 22px;
}
body.portrait .primary-command {
  max-width: 320px;
}

/* 关卡地图：纵向列表卡片化 */
body.portrait .command-map,
body.portrait .conduct-map,
body.portrait .campaign-map {
  gap: 10px;
}
body.portrait .command-node,
body.portrait .conduct-node,
body.portrait .campaign-node {
  padding: 14px;
}

/* brief（任务简报） */
body.portrait .act-brief,
body.portrait .stage-brief {
  display: flex !important;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 22px;
}
body.portrait .act-brief-index,
body.portrait .stage-brief-index {
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}
body.portrait .act-index-number,
body.portrait .stage-index-number {
  font-size: 30px;
}
body.portrait .act-brief-copy,
body.portrait .stage-brief-copy {
  min-width: 0;
}
body.portrait .act-brief-body,
body.portrait .stage-brief-body {
  white-space: normal;
}

/* 关卡结果 / 全章结果 */
body.portrait .act-result,
body.portrait .stage-result,
body.portrait .campaign-result {
  display: flex !important;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 22px;
}
body.portrait .act-result-index,
body.portrait .stage-result-index {
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}
body.portrait .act-result-number,
body.portrait .stage-result-number {
  font-size: 30px;
}
body.portrait .level-result-actions,
body.portrait .campaign-result-actions {
  flex-direction: column;
  gap: 10px;
}
body.portrait .level-result-actions .primary-command,
body.portrait .campaign-result-actions .primary-command {
  max-width: none;
}
body.portrait .campaign-result-body {
  white-space: normal;
}

/* quiz 层（victory 知识核验）：侧栏改横条 */
body.portrait .quiz-layer {
  flex-direction: column;
  overflow: visible;
  min-height: calc(100dvh - 52px);
}
body.portrait .quiz-side {
  width: auto;
  min-width: 0;
  max-width: none;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
}
body.portrait .quiz-side-index {
  font-size: 22px;
}
body.portrait .quiz-stage-progress {
  margin-top: 0;
}
body.portrait .quiz-total-progress {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  margin-left: auto;
}
body.portrait .quiz-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
}
body.portrait .quiz-content {
  overflow: visible;
}

/* ---------- command / conduct / victory 的 operation 游戏层 ---------- */
body.portrait .command-operation,
body.portrait .conduct-operation,
body.portrait .victory-operation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 20px;
}
body.portrait .game-heading,
body.portrait .operation-heading {
  flex: 0 0 auto;
}

body.portrait .game-board,
body.portrait .mine-game-board,
body.portrait .artillery-game-board,
body.portrait .image-game-board,
body.portrait .mine-traverse-board,
body.portrait .spot-game-board,
body.portrait .match-game-board,
body.portrait .quote-game-board {
  overflow: visible;
}

/* 时间轴：竖屏下 8 槽改 4 列 2 行网格，事件卡两列 */
body.portrait .timeline-game {
  grid-template-rows: auto auto;
  gap: 12px;
}
body.portrait .timeline-lane {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: none;
}
body.portrait .timeline-slot {
  min-height: 92px;
  max-height: 120px;
  padding: 10px 4px;
}
body.portrait .timeline-slot .slot-year {
  font-size: 15px;
  line-height: 1.2;
}
body.portrait .timeline-slot .slot-event {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.3;
}
body.portrait .timeline-events {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
/* 4×2 网格下隐藏横穿的轨道金线（网格本身已表达时间轴语义） */
body.portrait .timeline-rail {
  display: none;
}
body.portrait .timeline-event {
  padding: 11px 8px;
}
body.portrait .timeline-event .timeline-event-label {
  font-size: 12px;
  line-height: 1.35;
}

/* HUD 指标紧凑化：竖屏顶部一行放得下，不换行 */
body.portrait .command-hud .hud-metric,
body.portrait .conduct-hud .hud-metric,
body.portrait .victory-hud .hud-metric {
  margin-left: 8px;
}
body.portrait .hud-metric-label {
  font-size: 10px;
  line-height: 13px;
}
body.portrait .hud-metric-value {
  font-size: 15px;
  line-height: 17px;
  white-space: nowrap;
}
body.portrait .command-brand-title,
body.portrait .conduct-brand-title,
body.portrait .victory-brand-title {
  font-size: 14px;
}
body.portrait .command-progress,
body.portrait .conduct-progress,
body.portrait .victory-progress {
  min-width: 0;
}

/* victory 识图 / 找不同 / 配对：左右改上下 */
body.portrait .image-game-board,
body.portrait .spot-game-board,
body.portrait .match-game-board {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.portrait .image-game-visual {
  max-height: 300px;
}
body.portrait .spot-scenes {
  flex-direction: column;
}
body.portrait .spot-scene .spot-image {
  max-height: 200px;
}
body.portrait .match-core {
  flex-direction: row;
  justify-content: space-between;
  padding: 10px 12px;
}

/* game 页（独立场景页）：检查点面板、结果层窄屏化 */
body.portrait .checkpoint-panel {
  width: min(560px, 94vw);
  grid-template-columns: 1fr;
}
body.portrait .checkpoint-side {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
body.portrait .checkpoint-number {
  font-size: 26px;
}
body.portrait .operation-layer {
  position: relative;
  padding-bottom: 20px;
}
body.portrait .layer {
  position: relative;
  min-height: calc(100dvh - 52px);
}
body.portrait .briefing-layer {
  padding: 16px 16px 24px;
}
body.portrait .result-layer {
  padding: 16px 16px 24px;
}
body.portrait .result-data {
  flex-wrap: wrap;
}

/* ---------- HUD：放回文档流（原为 absolute 且避让小程序胶囊），层内容随其下排 ---------- */
body.portrait .command-hud,
body.portrait .conduct-hud,
body.portrait .victory-hud,
body.portrait .hud {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  z-index: 5;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 6px;
}
body.portrait .hud-metric {
  margin-left: 10px;
}

/* ---------- 首页 ---------- */
body.portrait .cover-screen {
  display: flex;
  flex-direction: column;
  padding-bottom: 90px;
}
body.portrait .cover-top {
  padding-right: 0;
}
body.portrait .cover-copy {
  width: 100%;
  max-width: none;
  height: auto;
  flex: 1 1 auto;
  justify-content: center;
  padding-left: 0;
}
body.portrait .cover-title {
  font-size: 42px;
}
body.portrait .cover-footer {
  position: relative;
  right: auto;
  bottom: auto;
  left: auto;
  padding-top: 12px;
}
body.portrait .route-screen {
  display: flex;
  flex-direction: column;
  height: auto;
  padding-bottom: 20px;
}
body.portrait .route-topbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding-bottom: 8px;
}
body.portrait .route-actions {
  margin-right: 0;
}
body.portrait .route-intro {
  padding: 12px 2px 4px;
}
body.portrait .route-title {
  font-size: 24px;
}
body.portrait .route-progress {
  margin: 6px 2px 12px;
}
body.portrait .mission-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 0;
}
body.portrait .mission {
  min-height: 110px;
  padding: 14px;
}
body.portrait .mission-center {
  margin: 12px 0;
}
body.portrait .mission-bottom {
  padding-top: 10px;
}
body.portrait .route-status {
  margin-top: 16px;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  white-space: normal;
}

/* ---------- 需要拖拽的元素在竖屏滚动容器中禁掉页面手势 ---------- */
body.portrait .signal-game,
body.portrait .timeline-events,
body.portrait .gucai-card,
body.portrait .quote-token,
body.portrait .artillery-cannon-model,
body.portrait .artillery-fire-control,
body.portrait .beacon-tower,
body.portrait .gucai-track-wrap {
  touch-action: none;
}
