/* ==========================================================================
   Win11 桌面时钟 · 样式
   Fluent / WinUI 3 视觉规范：8px 圆角卡片、4px 控件圆角、Acrylic 亚克力材质、
   Segoe UI Variable 字体、浅色 / 深色双主题
   ========================================================================== */

:root {
  --r-card: 8px;
  --r-ctrl: 4px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI",
          "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system,
          "PingFang SC", "Hiragino Sans GB", sans-serif;
}

/* ---------- 深色主题（默认，Win11 桌面 Bloom 观感） ---------- */
html[data-theme="dark"] {
  --bg-1: #04101f;
  --bg-2: #071c3a;
  --bg-3: #0a1730;
  --bloom-a: #1f6fe0;
  --bloom-b: #6b3fd4;
  --bloom-c: #d9457f;
  --surface: rgba(255, 255, 255, 0.058);
  --surface-2: rgba(255, 255, 255, 0.082);
  --surface-3: rgba(255, 255, 255, 0.115);
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --highlight: rgba(255, 255, 255, 0.14);
  --text: #f2f7ff;
  --text-2: rgba(242, 247, 255, 0.74);
  --text-3: rgba(242, 247, 255, 0.46);
  --accent: #6cc7ff;
  --accent-2: #a78bfa;
  --accent-on: #04121f;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.46);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.32);
  --dial-edge-a: rgba(255, 255, 255, 0.22);
  --dial-edge-b: rgba(255, 255, 255, 0.03);
  --glow: 0 0 42px rgba(108, 199, 255, 0.42);
  --grain: 0.045;
}

/* ---------- 浅色主题（Win11 云母观感） ---------- */
html[data-theme="light"] {
  --bg-1: #eef4fd;
  --bg-2: #e2ecfb;
  --bg-3: #f3f7ff;
  --bloom-a: #bcd8ff;
  --bloom-b: #d9ccff;
  --bloom-c: #ffd4e6;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-2: rgba(255, 255, 255, 0.78);
  --surface-3: rgba(255, 255, 255, 0.96);
  --stroke: rgba(255, 255, 255, 0.92);
  --stroke-strong: rgba(16, 24, 40, 0.10);
  --highlight: rgba(255, 255, 255, 0.96);
  --text: #0f172a;
  --text-2: rgba(15, 23, 42, 0.66);
  --text-3: rgba(15, 23, 42, 0.42);
  --accent: #0067c0;
  --accent-2: #6a4fd4;
  --accent-on: #ffffff;
  --shadow: 0 20px 48px rgba(23, 43, 77, 0.14);
  --shadow-soft: 0 8px 22px rgba(23, 43, 77, 0.10);
  --dial-edge-a: rgba(255, 255, 255, 0.95);
  --dial-edge-b: rgba(23, 43, 77, 0.08);
  --glow: 0 0 34px rgba(0, 103, 192, 0.24);
  --grain: 0.03;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  padding: 26px 20px 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: color 0.4s var(--ease), background 0.6s var(--ease);
}

/* ---------- 背景氛围（Bloom 光斑 + 极细噪点） ---------- */
.bloom {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 12% 6%, var(--bg-3) 0%, transparent 55%),
    linear-gradient(158deg, var(--bg-1) 0%, var(--bg-2) 48%, var(--bg-3) 100%);
}

.bloom::before,
.bloom::after,
.bloom i {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.62;
  will-change: transform;
}

.bloom::before {
  width: 68vmax; height: 68vmax; left: -20vmax; top: -26vmax;
  background: radial-gradient(circle at 38% 36%, var(--bloom-a), transparent 62%);
  animation: drift-a 30s ease-in-out infinite alternate;
}

.bloom::after {
  width: 60vmax; height: 60vmax; right: -18vmax; bottom: -22vmax;
  background: radial-gradient(circle at 62% 42%, var(--bloom-b), transparent 62%);
  animation: drift-b 36s ease-in-out infinite alternate;
}

.bloom i {
  width: 42vmax; height: 42vmax; left: 46%; top: 44%;
  background: radial-gradient(circle at 50% 50%, var(--bloom-c), transparent 64%);
  opacity: 0.34;
  animation: drift-c 42s ease-in-out infinite alternate;
}

@keyframes drift-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(6vmax, 4vmax, 0) scale(1.14); } }
@keyframes drift-b { from { transform: translate3d(0, 0, 0) scale(1.06); } to { transform: translate3d(-5vmax, -4vmax, 0) scale(1); } }
@keyframes drift-c { from { transform: translate3d(-4vmax, 2vmax, 0) scale(0.96); } to { transform: translate3d(5vmax, -5vmax, 0) scale(1.12); } }

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- 亚克力材质 ---------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--r-card);
  box-shadow: var(--shadow), inset 0 1px 0 var(--highlight);
  -webkit-backdrop-filter: blur(38px) saturate(180%);
  backdrop-filter: blur(38px) saturate(180%);
}

/* ---------- 布局 ---------- */
.stage {
  width: 100%;
  max-width: 1060px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise 0.7s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ---------- 标题栏 ---------- */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--r-card);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand .logo { width: 18px; height: 18px; fill: var(--accent); flex: none; }

.brand-name { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-left: 10px;
  border-left: 1px solid var(--stroke-strong);
}

.tools { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 34px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-ctrl);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), transform 0.16s var(--ease);
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--stroke); }
.icon-btn:active { transform: scale(0.94); background: var(--surface); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--accent); border-color: var(--stroke-strong); }

.ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico .fill { fill: currentColor; stroke: none; }
.ico-moon { display: none; fill: currentColor; stroke: none; }
html[data-theme="light"] .ico-sun { display: none; }
html[data-theme="light"] .ico-moon { display: block; }

/* ---------- 主时钟 ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 42px 40px 34px;
}

.hero::after {
  content: "";
  position: absolute;
  left: 50%; top: -60%;
  width: 78%; height: 130%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--glow), transparent 72%);
  opacity: 0.5;
  pointer-events: none;
}

.hero-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }

.time {
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-weight: 600;
  font-size: clamp(58px, 12.5vw, 148px);
  line-height: 0.94;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

.seg { display: inline-block; min-width: 2ch; text-align: center; }

.seg-sec {
  color: var(--accent);
  font-size: 0.78em;
  min-width: 2ch;
  text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 45%, transparent);
}

.colon {
  display: inline-block;
  width: 0.42em;
  text-align: center;
  font-weight: 400;
  color: var(--text-3);
  animation: blink 2s steps(1, end) infinite;
}

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.34; } }

.date-line {
  font-size: clamp(19px, 2.5vw, 32px);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
}

.sub-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(12px, 1.15vw, 15px);
  color: var(--text-2);
}

.sub-line .sep { width: 1px; height: 12px; background: var(--stroke-strong); }

.festival {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.92em;
  font-weight: 600;
  color: var(--accent-on);
  background: var(--accent);
  box-shadow: var(--shadow-soft);
}

.progress-wrap { width: min(560px, 92%); margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: width 0.6s var(--ease);
}

.progress-label { font-size: 12px; color: var(--text-3); letter-spacing: 0.02em; }

/* ---------- 面板 ---------- */
.panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.card {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.card-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }

.card-tag {
  font-size: 11px;
  color: var(--text-3);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  white-space: nowrap;
}

.card-tag.live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 42%, transparent); }

/* ---------- 表盘 ---------- */
.dial-wrap { display: grid; place-items: center; padding: 2px 0 4px; }

.dial { width: min(210px, 74%); height: auto; overflow: visible; }

.dial-face { fill: var(--surface-2); }
.dial-rim { fill: none; stroke: url(#dialEdge); stroke-width: 1.4; }
#dialEdge stop:first-child { stop-color: var(--dial-edge-a); }
#dialEdge stop:last-child { stop-color: var(--dial-edge-b); }

.dial-ticks line { stroke: var(--text-3); stroke-width: 1.3; stroke-linecap: round; }
.dial-ticks line.major { stroke: var(--text-2); stroke-width: 2.2; }

.dial-nums text {
  fill: var(--text-2);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  text-anchor: middle;
  dominant-baseline: central;
}

.hand { stroke-linecap: round; }
.hand-hour { stroke: var(--text); stroke-width: 6; }
.hand-min { stroke: var(--text-2); stroke-width: 4; }
.hand-sec { stroke: var(--accent); stroke-width: 1.8; }
.dial-cap { fill: var(--accent); }

/* ---------- 读数 ---------- */
.readout {
  font-size: clamp(28px, 3.1vw, 40px);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

.readout .cs { font-size: 0.62em; color: var(--accent); margin-left: 1px; }

/* ---------- 按钮 ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  flex: 1 1 auto;
  min-width: 74px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--stroke-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.12s var(--ease), color 0.15s var(--ease), opacity 0.15s var(--ease);
}

.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(0.97); opacity: 0.82; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn.accent {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-on);
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}

.btn.accent:hover:not(:disabled) { filter: brightness(1.08); }

.btn.ghost { background: transparent; border-color: var(--stroke); color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

/* ---------- 计次列表 ---------- */
.laps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 118px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.laps::-webkit-scrollbar { width: 8px; }
.laps::-webkit-scrollbar-thumb { background: var(--stroke-strong); border-radius: 999px; }

.laps li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  padding: 5px 8px;
  border-radius: var(--r-ctrl);
  background: var(--surface);
  animation: lap-in 0.24s var(--ease) both;
}

.laps li .lap-idx { color: var(--text-3); }
.laps li .lap-diff { color: var(--accent); }
.laps .laps-empty { background: transparent; color: var(--text-3); justify-content: center; padding: 8px 0; }

@keyframes lap-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- 倒计时 ---------- */
.cd-top { display: flex; align-items: center; gap: 14px; }

.ring { width: 46px; height: 46px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-track { stroke: var(--surface-3); }
.ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 125.66;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s var(--ease);
}

.cd-readout { flex: 1 1 auto; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.chip:hover { background: var(--surface-3); color: var(--text); }
.chip.active { background: var(--accent); border-color: transparent; color: var(--accent-on); font-weight: 600; }

.field-row { display: flex; align-items: flex-end; gap: 6px; }

.field { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 1 0; min-width: 0; }
.field span { font-size: 11px; color: var(--text-3); }

.field input {
  width: 100%;
  height: 34px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--stroke-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.field input:focus { border-color: var(--accent); background: var(--surface-3); }
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.field-colon { padding-bottom: 20px; color: var(--text-3); }

/* ---------- 提示与告警 ---------- */
.hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-3);
}

.hint kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-right: 4px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--stroke);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 11px;
  text-align: center;
}

.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 62%);
}

.flash.on { animation: flash 1.1s var(--ease) 3; }

@keyframes flash { 0%, 100% { opacity: 0; } 45% { opacity: 0.85; } }

/* 倒计时结束：卡片轻微脉冲 */
.card.done { animation: done 0.8s var(--ease) 3; }

@keyframes done {
  0%, 100% { border-color: var(--stroke); transform: none; }
  50% { border-color: var(--accent); transform: translateY(-2px); }
}

/* ---------- 紧凑模式 ---------- */
body.compact { padding: 18px; align-items: center; }
body.compact .stage { max-width: 560px; gap: 12px; }
body.compact .panels,
body.compact .hint,
body.compact .progress-wrap,
body.compact .brand-sub { display: none; }
body.compact .hero { padding: 24px 22px 20px; }
body.compact .time { font-size: clamp(40px, 8.6vw, 96px); }
body.compact .seg-sec { font-size: 0.8em; }
body.compact .date-line { font-size: clamp(16px, 2vw, 24px); }
body.compact .sub-line { font-size: 12px; }

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panels > article:first-child { grid-column: span 2; }
  .dial { width: min(190px, 46%); }
}

@media (max-width: 620px) {
  body { padding: 16px 12px 26px; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .panels > article:first-child { grid-column: auto; }
  .hero { padding: 30px 20px 26px; }
  .brand-sub { display: none; }
  .hint { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
