/* 流程计时器 v0.3 —— 深色投屏友好主题 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --dim: #8b949e;
  --accent: #2f81f7;
  --accent-soft: #58a6ff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;          /* 根除垂直滚动条：内容一屏放下 */
  overscroll-behavior: none; /* 阻止 iOS/触控板橡皮筋回弹 */
  -webkit-tap-highlight-color: transparent;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.title { font-size: 18px; font-weight: 600; letter-spacing: 1px; }

/* 主舞台：窄屏单列；宽屏（≥900px）两栏 grid，见 media query */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 18px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

/* 左栏容器 */
.main-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* 大圆环：宽度受视口高度约束（窄屏 500px 预算），max 兑底防极矮窗口负宽；也是拖放启动区 */
.ring-wrap { position: relative; width: min(78vw, 320px, max(140px, calc(100vh - 500px))); aspect-ratio: 1; transition: transform 0.15s; }
.ring-wrap.drop-hover { transform: scale(1.03); }
.ring-wrap.drop-hover .ring-progress { stroke: var(--good); }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 12; }
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 867; /* 2πr, r=138 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}
.ring-wrap.running .ring-progress { stroke: var(--accent); }
.ring-wrap.warn .ring-progress { stroke: var(--warn); }
.ring-wrap.done .ring-progress { stroke: var(--bad); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  min-width: 0;
}
.time {
  font-size: clamp(34px, 11vw, 72px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.state { color: var(--dim); font-size: 14px; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state.done { color: var(--bad); font-weight: 600; }

/* 控制按钮 */
.controls { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.primary-btn {
  flex: 1;
  padding: 14px 0;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn.paused { background: var(--good); }

.ghost-btn {
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.ghost-btn:active { transform: scale(0.98); }
.ghost-btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* 选项 */
.options {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  color: var(--dim);
  font-size: 13px;
}
.opt { display: flex; align-items: center; gap: 6px; }
.opt select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
}
.dim { color: var(--dim); }

/* 时间线 */
.timeline { width: 100%; max-width: 420px; }
.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.timeline-head h2 { font-size: 13px; color: var(--dim); font-weight: 500; }

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 事件行（甘特图式）：手柄 + 名称标签 + 时长条（真实比例） */
.event-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: grab;
  user-select: none;
}
.event-row:active { cursor: grabbing; }
.event-row.dragging { opacity: 0.5; cursor: grabbing; }
.event-row.active .event-label { color: var(--accent-soft); font-weight: 600; }

.drag-handle {
  flex: 0 0 12px;
  color: var(--dim);
  font-size: 15px;
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols", system-ui, sans-serif; /* ⠿ 符号回退 */
  cursor: grab;
  user-select: none;
}

.event-label {
  flex: 0 0 70px;   /* 固定名称列（窄屏） */
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

/* 时长条：flex-grow 由 JS 按秒数设置 → 真实比例（100min 是 5min 的 20 倍宽） */
.event-bar {
  position: relative;
  flex-grow: 0;
  flex-basis: 0;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.event-bar-dur {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

/* 玻璃管进度：在时长条内，无自身圆角，靠 overflow hidden 裁剪 → 涂色与圆角矩形严丝合缝 */
.event-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(180deg, #ffd24a, #ff8a00); /* 亮金 → 活力橙，鲜明有活力 */
  pointer-events: none;
  transition: width 0.2s linear;
}

.event-del {
  position: absolute;
  top: -6px;
  right: -4px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  background: var(--bad);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: none;
  user-select: none;
}
.event-row:hover .event-del { display: block; }

/* 添加事件表单：虚线边框 + 区分底色，与列表方块明显不同 */
.event-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--dim);
  border-radius: 12px;
  background: rgba(22, 27, 34, 0.4);
}
.event-form .event-name {
  flex: 1 1 130px;
  padding: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.event-form .opt { white-space: nowrap; }
.event-form input[type="number"] {
  width: 60px;
  padding: 8px;
  font-size: 15px;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hint { margin-top: 8px; color: var(--dim); font-size: 12px; text-align: center; }

.foot {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

/* 窄屏（<900px）：单列，甘特图基线样式已适配（label 70px），无需额外覆盖 */

/* 宽屏（≥900px）：两栏 grid，左大圆环 + 右时间线（剪视频软件式布局） */
@media (min-width: 900px) {
  .stage {
    max-width: 1400px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    gap: 32px;
    align-items: start;
  }
  .main-col { gap: 14px; }
  .ring-wrap { width: min(40vw, 440px, max(180px, calc(100vh - 260px))); }
  .controls { max-width: 440px; }
  .options { max-width: 440px; }
  .timeline { width: 100%; max-width: none; }
  /* 宽屏甘特图：名称列加宽、间距拉大、时长条更舒展 */
  .event-row { gap: 8px; }
  .drag-handle { flex-basis: 16px; font-size: 17px; }
  .event-label { flex-basis: 96px; font-size: 13px; }
  .event-bar { min-width: 6px; }
}

/* 全屏态：左大圆环 + 右时间线（两栏保留，学生/观众能看整体流程与当前进度）；
   只隐藏编辑类元素（顶栏/控制按钮/铃声/表单/手柄/删除钮/恢复默认） */
:fullscreen .topbar,
:fullscreen .options,
:fullscreen .controls,
:fullscreen .event-form,
:fullscreen .hint,
:fullscreen .foot,
:fullscreen .drag-handle,
:fullscreen .event-del,
:fullscreen .resetEventsBtn { display: none; }
body:fullscreen .topbar,
body:fullscreen .options,
body:fullscreen .controls,
body:fullscreen .event-form,
body:fullscreen .hint,
body:fullscreen .foot,
body:fullscreen .drag-handle,
body:fullscreen .event-del,
body:fullscreen .resetEventsBtn { display: none; }

:fullscreen .stage,
body:fullscreen .stage {
  display: grid; /* 保持两栏 grid */
  gap: 28px;
  padding: 24px;
  max-width: none;
  align-items: center;
}
:fullscreen .main-col,
body:fullscreen .main-col { width: 100%; }
:fullscreen .ring-wrap,
body:fullscreen .ring-wrap { width: min(64vh, 92%); }
:fullscreen .time,
body:fullscreen .time { font-size: clamp(56px, 14vh, 130px); }
:fullscreen .state,
body:fullscreen .state { font-size: 20px; color: var(--dim); max-width: none; }
:fullscreen .timeline,
body:fullscreen .timeline { width: 100%; max-width: none; }

/* 时间到：整体闪烁提示 */
.ring-wrap.done { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
