/* ============================================================
   OCL 3D Packaging Review — v0.1
   简洁暗色风格，手机横屏/竖屏自适应
   ============================================================ */

:root {
  --bg: #101216;
  --bg-elev: #1a1d23;
  --text: #f2f4f7;
  --text-dim: #9aa3af;
  --accent: #f07a2b;
  --accent-dim: #c95a1e;
  --radius: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* hidden 属性必须优先生效（避免被下方 display 规则覆盖） */
[hidden] {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

#viewer-container {
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 20%, #23262d 0%, var(--bg) 65%);
}

/* ---------- model-viewer ---------- */
model-viewer {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  background: transparent;
}

/* 加载完成前隐藏模型闪白 */
model-viewer:not(.revealed)::part(default-progress-bar) {
  display: none;
}

/* ---------- 顶部标题 ---------- */
#header {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 5;
  padding: 0 16px;
}

#header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

#header p {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}

/* ---------- 加载进度 ---------- */
#loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  z-index: 20;
  transition: opacity 0.4s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(240, 122, 43, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-text {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: min(240px, 60vw);
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.25s ease;
}

/* ---------- 错误提示 ---------- */
#error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(16, 18, 22, 0.94);
  z-index: 20;
  text-align: center;
  padding: 24px;
}

.error-title {
  font-size: 17px;
  font-weight: 700;
  color: #ff6b6b;
}

.error-detail {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 420px;
  word-break: break-all;
}

#error-overlay button,
#controls button {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#error-overlay button:active,
#controls button:active {
  background: #262a32;
  border-color: rgba(255, 255, 255, 0.3);
}

#error-overlay button {
  margin-top: 6px;
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1208;
  font-weight: 600;
}

/* ---------- 底部控制栏 ---------- */
#controls {
  position: absolute;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 5;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}

#controls button.active-state {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1208;
  font-weight: 600;
}

/* ---------- 轻提示 ---------- */
#toast {
  position: absolute;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(26, 29, 35, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  z-index: 30;
  white-space: nowrap;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 全屏沉浸模式（浏览器不支持原生全屏时的降级） ---------- */
body.immersive #header,
body.immersive #controls {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* ---------- 手机横屏 ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  #header h1 { font-size: 15px; }
  #header p { font-size: 11px; }
  #header { top: calc(8px + var(--safe-top)); }
  #controls { bottom: calc(10px + var(--safe-bottom)); }
  #controls button { padding: 7px 14px; font-size: 12px; }
}

/* ---------- 大屏 ---------- */
@media (min-width: 900px) {
  #header h1 { font-size: 22px; }
  #header p { font-size: 14px; }
}
