/* ============================================================
   ARK 驾驶舱壳（Cockpit Shell）— Starfield 式 NASA 飞船系统大屏
   三区布局：顶栏操作舱 / 中央舷窗+右舷控制台 / 底栏系统状态
   红线：无循环动画，仅一次性 CSS transition
   ============================================================ */
/* ---------- CSS 变量：控制台宽度（单点驱动） ---------- */
:root {
  --console-width: 322px;
}

/* 座舱主体：CAD 式 dock grid — 左右贯通到底部, 底部被左右夹住 */
.ark-cockpit {
  position: fixed;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "left  main    right"
    "left  bottom  right";
  gap: 0;
  padding: 0;
  overflow: hidden;
}

/* 主视口：星图占满剩余空间（dock 展开时自动收缩） */
.ark-cockpit .ark-star-bg {
  grid-area: main;
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* HUD 角标：跟随主视口（星图区域），dock 变化时自动适应 */
.ark-hud-frame {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  z-index: 2;
}

.ark-hud-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid var(--ark-glow-strong);
}
.ark-hud-corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.ark-hud-corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.ark-hud-corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.ark-hud-corner.br { bottom: 0; right: 0; border-left: none; border-top: none; }

/* 复位按钮（HUD 右下角） */
.ark-hud-reset {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--ark-glow-strong);
  border-radius: 0;
  background: var(--ark-panel-bg);
  color: var(--ark-accent);
  font-size: 14px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
  pointer-events: auto;
}
.ark-hud-reset:hover {
  color: var(--ark-accent-bright);
  border-color: var(--ark-accent);
}

/* ---------- 右停靠视口（舰桥日报控制台） ---------- */
.ark-console {
  grid-area: right;
  width: var(--console-width);
  min-width: 0;
  align-self: stretch;
  border: 1px solid var(--ark-console-border);
  border-left: 2px solid var(--ark-console-border-left);
  border-radius: 0;
  background:
    linear-gradient(180deg, var(--ark-console-bg-1), var(--ark-console-bg-2) 24px),
    var(--ark-console-bg-2);
  box-shadow:
    -8px 0 28px rgba(0, 0, 0, 0.45),
    inset 0 0 40px var(--ark-glow),
    inset 0 1px 0 var(--ark-glow-strong);
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  position: relative;
  transition: width 0.3s ease;
}

/* 控制台折叠成窄条 */
.ark-console.collapsed {
  width: 36px;
  overflow: hidden;
}
.ark-console.collapsed .ark-console-tabs,
.ark-console.collapsed .ark-console-content,
.ark-console.collapsed .ark-console-drag,
.ark-console.collapsed::before {
  display: none;
}
.ark-console.collapsed::after {
  content: "≡ 日报";
  writing-mode: vertical-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ark-accent);
  cursor: pointer;
  pointer-events: auto;
}

/* 控制台拖拽手柄（左边框三圆点） */
.ark-console-drag {
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 36px;
  cursor: col-resize;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: auto;
}
.ark-console-drag-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ark-accent);
  opacity: 0.4;
  transition: opacity 0.2s ease;
}
.ark-console-drag:hover .ark-console-drag-dot {
  opacity: 0.85;
}

/* 宽度 tooltip */
.ark-console-width-tip {
  position: absolute;
  left: -60px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "DSEG7", monospace;
  font-size: 10px;
  color: var(--ark-accent);
  background: var(--ark-panel-bg);
  border: 1px solid var(--ark-panel-border);
  border-radius: 0;
  padding: 2px 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.ark-console-width-tip.visible { opacity: 1; }

/* 控制台内嵌的日报视图 */
.ark-console .t10-briefing {
  max-width: none;
  padding: 12px 14px;
  gap: 10px;
}

/* ---------- 控制台 HUD 仪表化 ---------- */

.ark-console .t10-briefing-head {
  margin: 0;
}
.ark-console .t10-briefing-head .ark-h1 {
  font-size: 15px;
  letter-spacing: 0.08em;
}

.ark-console .t10-section {
  background: var(--ark-console-section-bg);
  border: 1px solid var(--ark-console-section-border);
  border-radius: 0;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 var(--ark-glow);
}
.ark-console .t10-section .ark-h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ark-accent);
}

.ark-console .t10-stat-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0 6px;
}
.ark-console .t10-stat {
  padding: 6px 4px;
  border-radius: 0;
  background: var(--ark-console-stat-bg);
  border: 1px solid var(--ark-console-stat-border);
}
.ark-console .t10-stat-value {
  font-size: 14px;
}
.ark-console .t10-stat-label {
  font-size: 10px;
  letter-spacing: 0.06em;
}

.ark-console .t10-task-card {
  padding: 8px 10px;
}
.ark-console .t10-task-name { font-size: 13px; }
.ark-console .t10-task-reason { font-size: 11px; }
.ark-console .t10-alerts { margin: 4px 0; padding: 4px 8px; }
.ark-console .t10-alert-item { font-size: 12px; }
.ark-console .t10-sector-chip { padding: 8px 10px; gap: 8px; }
.ark-console .t10-sector-name { font-size: 12px; }
.ark-console .t10-sector-meta { font-size: 11px; }
.ark-console .t10-quote-text { font-size: 13px; }
.ark-console .t10-collect-btn { padding: 7px 14px; font-size: 13px; }
.ark-console .t10-assessment-text { font-size: 13px; }
.ark-console .ark-error { font-size: 12px; }

/* 控制台右侧标注条（HUD 系统铭牌） */
.ark-console::before {
  content: "BRIDGE CONSOLE · 舰桥控制台";
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 28px;
  z-index: 1;
  padding: 8px 4px;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ark-accent);
  opacity: 0.55;
  background: var(--ark-panel-bg);
  border-left: 1px solid var(--ark-panel-border);
}

/* ---------- 控制台三页签（日报/飞船/勘探） ---------- */
.ark-console-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  background: var(--ark-panel-bg);
  border-bottom: 1px solid var(--ark-panel-border);
}

.ark-console-tab {
  flex: 1;
  padding: 5px 0;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ark-text-dim);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ark-console-tab:hover {
  color: var(--ark-text);
  border-color: var(--ark-glow-strong);
}

.ark-console-tab.active {
  color: var(--ark-accent);
  border-color: var(--ark-accent);
  background: var(--ark-glow);
  box-shadow: inset 0 0 12px var(--ark-glow);
}

.ark-console-fold {
  flex: none;
  width: 22px;
  padding: 5px 0;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ark-accent);
  opacity: 0.5;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.ark-console-fold:hover {
  color: var(--ark-accent-bright);
  opacity: 1;
  border-color: var(--ark-glow-strong);
}

.ark-console-content {
  padding: 10px 12px 14px;
}

.ark-console .t09-wrap {
  padding: 0;
  border: none;
  background: transparent;
}
.ark-console .t09-layout {
  flex-direction: column;
  gap: 10px;
}
.ark-console .t09-head .ark-h1 { font-size: 15px; margin: 2px 0 6px; }
.ark-console .t09-wrap > .ark-dim { font-size: 11px; margin: 2px 0 8px; }

.ark-console .t05-wrap { padding: 0; }
.ark-console .t05-head .t05-h1 { font-size: 15px; }
.ark-console .t05-ore-row { padding: 7px 8px; }
.ark-console .t05-ore-terms { display: none; }

/* ---------- 底栏系统状态（readout 行） ---------- */
.ark-bottom {
  display: flex;
  align-items: center;
  gap: 18px;
}

.ark-bottom-status {
  font-family: "DSEG7", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ark-accent);
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 舷窗内左下角扫描线读出 ---------- */
.ark-scanline {
  position: absolute;
  left: 22px;
  bottom: 18px;
  z-index: 2;
  pointer-events: none;
  font-family: "DSEG7", monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--ark-accent);
  opacity: 0.5;
  white-space: pre;
}

/* ---------- 左停靠视口（勘探 + 开采） ---------- */
.ark-sidebar-left {
  grid-area: left;
  width: 500px;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: auto;
  overflow: hidden;
  position: relative;
  transition: width 0.3s ease;
}

.ark-sidebar-left.collapsed {
  width: 36px;
}
.ark-sidebar-left.collapsed .ark-sidebar-section {
  display: none;
}
.ark-sidebar-left.collapsed::after {
  content: "▸ 停靠";
  writing-mode: vertical-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ark-accent);
  cursor: pointer;
  pointer-events: auto;
  background: var(--ark-sidebar-bg);
  border: 1px solid var(--ark-panel-border);
  border-radius: 0;
  user-select: none;
}

.ark-sidebar-section {
  background: var(--ark-sidebar-bg);
  border: 1px solid var(--ark-panel-border);
  border-radius: 0;
  overflow: hidden;
  flex: 1 1 0;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

.ark-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  min-height: 80px;
  background: var(--ark-sidebar-header-bg);
  border-bottom: none;
  border-right: 1px solid var(--ark-panel-border);
  cursor: pointer;
  user-select: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.ark-sidebar-header h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ark-accent);
  font-weight: 600;
}

.ark-sidebar-toggle {
  font-size: 12px;
  color: var(--ark-accent);
  opacity: 0.5;
  transition: transform 0.2s ease;
}

/* 侧栏 section 关闭按钮 */
.ark-sidebar-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ark-text-dim);
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  padding: 0;
  z-index: 2;
}
.ark-sidebar-close:hover {
  opacity: 1;
  color: var(--ark-accent-bright);
  border-color: var(--ark-glow-strong);
}

.ark-sidebar-header {
  position: relative;
}

.ark-sidebar-section.collapsed .ark-sidebar-toggle {
  transform: rotate(-90deg);
}

.ark-sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}

.ark-sidebar-section.collapsed .ark-sidebar-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

/* ---------- dock resize handle（hover 外边框可拖拽调整大小） ---------- */
.ark-dock-resize {
  position: absolute;
  z-index: 10;
  pointer-events: auto;
  transition: background 0.15s ease;
}
.ark-dock-resize::after {
  content: "";
  position: absolute;
  background: var(--ark-accent);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ark-dock-resize:hover::after {
  opacity: 0.6;
}
/* 左dock：右侧边框 */
.ark-dock-resize-left {
  top: 0; right: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
}
.ark-dock-resize-left::after {
  top: 0; right: 0; bottom: 0;
  width: 2px;
}
/* 右dock：左侧边框 */
.ark-dock-resize-right {
  top: 0; left: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
}
.ark-dock-resize-right::after {
  top: 0; left: 0; bottom: 0;
  width: 2px;
}
/* 底dock：顶部边框 */
.ark-dock-resize-bottom {
  left: 0; top: 0; right: 0;
  height: 6px;
  cursor: row-resize;
}
.ark-dock-resize-bottom::after {
  left: 0; top: 0; right: 0;
  height: 2px;
}

/* dock resize tooltip */
.ark-dock-resize-tip {
  position: fixed;
  font-family: "DSEG7", monospace;
  font-size: 10px;
  color: var(--ark-accent);
  background: var(--ark-panel-bg);
  border: 1px solid var(--ark-panel-border);
  border-radius: 0;
  padding: 2px 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 100;
}
.ark-dock-resize-tip.visible { opacity: 1; }

/* ---------- 底部停靠视口（船员 + 飞船左右并列） ---------- */
.ark-bottom-bar {
  grid-area: bottom;
  display: flex;
  flex-direction: row;
  gap: 0;
  overflow: hidden;
  position: relative;
}

.ark-bottom-bar > * {
  pointer-events: auto;
}

/* 船员 dock：grid 三行 — content(对话区) 占满上方, 底部合并行(tabbar+header) */
.ark-crew-bar {
  flex: 1;
  min-width: 0;
  max-height: 260px;
  background: var(--ark-sidebar-bg);
  border: 1px solid var(--ark-panel-border);
  border-radius: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: 1fr auto;
  transition: max-height 0.3s ease;
}

.ark-crew-bar-content {
  grid-row: 1;
  grid-column: 1 / -1;
  min-height: 0;
  overflow: hidden;
}

.ark-crew-tabbar {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--ark-crew-tab-bg);
  border-top: 1px solid var(--ark-panel-border);
  gap: 4px;
  flex-wrap: wrap;
}

.ark-crew-bar-header {
  grid-row: 2;
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--ark-sidebar-header-bg);
  border-top: 1px solid var(--ark-panel-border);
  border-left: 1px solid var(--ark-panel-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.ark-crew-bar-header:hover {
  background: var(--ark-sidebar-header-bg);
  filter: brightness(1.3);
}
.ark-crew-bar-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ark-accent);
  font-weight: 600;
}

/* 折叠：只收起对话区，tabbar + header 常驻 */
.ark-crew-bar.collapsed .ark-crew-bar-content {
  min-height: 0;
  height: 0;
  overflow: hidden;
}
.ark-crew-bar.collapsed .ark-crew-chat-wrap {
  display: none;
}

/* 飞船栏 header 恢复水平（底部行内不适用竖排） */
.ark-ship-section {
  flex: none;
  width: 340px;
  max-width: 30%;
  max-height: 260px;
  background: var(--ark-sidebar-bg);
  border: 1px solid var(--ark-panel-border);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
}
.ark-ship-section .ark-sidebar-header {
  writing-mode: horizontal-tb;
  text-orientation: initial;
  min-height: auto;
  border-right: none;
  border-bottom: 1px solid var(--ark-panel-border);
  padding: 8px 12px;
}
.ark-ship-section .ark-sidebar-body {
  overflow-y: auto;
}
.ark-ship-section.collapsed {
  width: auto;
  flex: none;
}
.ark-ship-section.collapsed .ark-sidebar-body,
.ark-ship-section.collapsed .ark-sidebar-toggle {
  display: none;
}
.ark-ship-section.collapsed .ark-sidebar-header {
  padding: 4px 14px;
  height: auto;
}

.ark-crew-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ark-accent);
  opacity: 0.7;
  white-space: nowrap;
}

/* 隐藏底栏状态行（驾驶舱模式下不需要） */
.ark-bottom { display: none; }

.ark-crew-tab {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ark-text-dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.ark-crew-tab:hover {
  color: var(--ark-text);
  border-color: var(--ark-glow-strong);
}

.ark-crew-tab.active {
  color: var(--ark-accent);
  border-color: var(--ark-accent);
  background: var(--ark-glow);
}

.ark-crew-chat-wrap {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}
.ark-crew-chat-wrap.open {
  max-height: 320px;
  opacity: 1;
}

.ark-crew-chat {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  min-height: 120px;
  max-height: 280px;
}

.ark-crew-chat-empty {
  color: var(--ark-text-dim);
  opacity: 0.4;
  font-size: 12px;
  text-align: center;
  padding: 20px 0;
}

.ark-crew-composer {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--ark-panel-border);
}

.ark-crew-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--ark-input-border);
  border-radius: 0;
  background: var(--ark-input-bg);
  color: var(--ark-text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
}

.ark-crew-input:focus {
  border-color: var(--ark-accent);
}

.ark-crew-send {
  padding: 6px 14px;
  border: 1px solid var(--ark-glow-strong);
  border-radius: 0;
  background: var(--ark-glow);
  color: var(--ark-accent);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ark-crew-send:hover {
  background: var(--ark-glow-strong);
}

.ark-crew-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.ark-crew-bubble {
  padding: 6px 10px;
  border-radius: 0;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 85%;
  word-break: break-word;
}

.ark-crew-bubble-user {
  background: var(--ark-bubble-user);
  border: 1px solid var(--ark-bubble-user-border);
  margin-left: auto;
  text-align: right;
}

.ark-crew-bubble-npc {
  background: var(--ark-bubble-npc);
  border: 1px solid var(--ark-bubble-npc-border);
}

.ark-crew-bubble-typing {
  opacity: 0.5;
  font-style: italic;
}

/* 窄屏：dock 收起为主视口全宽 + 控制台抽屉 */
@media (max-width: 1100px) {
  .ark-cockpit {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
  }
  .ark-sidebar-left { display: none; }
  .ark-bottom-bar { display: none; }
  .ark-hud-frame { inset: 10px; }

  .ark-console {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    margin: 0;
    width: min(var(--console-width), 86vw);
    transform: translateX(calc(100% + 14px));
    transition: transform 0.3s cubic-bezier(0.34, 1.0, 0.64, 1);
    z-index: 5;
  }
  .ark-console.ark-console-open { transform: translateX(0); }
  .ark-console.collapsed { transform: translateX(calc(100% + 14px)); }
}
