﻿/* ==========================================================================
   time6 · 28 小时时钟
   一天 28 小时 / 一周 6 天 / 单一表盘
   ========================================================================== */

:root {
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --radius: 30px;
  --pad: clamp(18px, 4vw, 30px);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b16;
  --bg-art:
    radial-gradient(900px 600px at 20% -10%, rgba(255, 180, 84, 0.10), transparent 60%),
    radial-gradient(800px 560px at 85% 0%, rgba(142, 162, 255, 0.14), transparent 58%),
    linear-gradient(180deg, #0a1120 0%, #070b16 62%);
  --surface: rgba(17, 25, 43, 0.76);
  --surface-solid: #111a2c;
  --border: rgba(150, 166, 214, 0.16);
  --border-strong: rgba(150, 166, 214, 0.28);
  --text: #eef2ff;
  --muted: #9aa6c4;
  --faint: #7c89a8;
  --accent: #ffb454;
  --accent-text: #ffc477;
  --focus: #ffd08a;
  --sleep: #8ea2ff;
  --dial-rim: rgba(150, 166, 214, 0.18);
  --dial-track: #16203a;
  --dial-tick: rgba(150, 166, 214, 0.22);
  --dial-tick-major: rgba(150, 166, 214, 0.52);
  --dial-shadow: drop-shadow(0 24px 50px rgba(0, 0, 0, 0.45));
  --puck: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.06), transparent 62%);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.5);
  --topbar-bg: rgba(7, 11, 22, 0.76);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-art:
    radial-gradient(900px 600px at 8% -10%, rgba(255, 180, 84, 0.20), transparent 60%),
    radial-gradient(900px 600px at 92% -4%, rgba(110, 135, 250, 0.16), transparent 55%),
    linear-gradient(180deg, #f8f9fd 0%, #eef1f8 72%);
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #ffffff;
  --border: rgba(30, 45, 80, 0.10);
  --border-strong: rgba(30, 45, 80, 0.18);
  --text: #111827;
  --muted: #59647e;
  --faint: #66718a;
  --accent: #e08b1f;
  --accent-text: #a4550a;
  --focus: #b45309;
  --sleep: #4f5bd5;
  --dial-rim: rgba(30, 45, 80, 0.14);
  --dial-track: #e7ebf5;
  --dial-tick: rgba(30, 45, 80, 0.18);
  --dial-tick-major: rgba(30, 45, 80, 0.42);
  --dial-shadow: drop-shadow(0 18px 40px rgba(45, 60, 100, 0.14));
  --puck: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.8), transparent 62%);
  --shadow: 0 24px 70px rgba(35, 50, 90, 0.10);
  --topbar-bg: rgba(246, 248, 252, 0.8);
}

/* ---------- 基础 ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-art);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-text);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: var(--accent);
  color: #1a1206;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1206;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.fatal {
  max-width: 560px;
  margin: 40px auto;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--text);
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px max(20px, calc((100vw - 620px) / 2 + 20px));
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.22);
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  padding-left: 11px;
  border-left: 1px solid var(--border-strong);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: none;
}

/* ---------- 页面布局 ---------- */

main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 620px;
  min-height: calc(100svh - 64px);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px) 20px 0;
}

.clock-card {
  width: 100%;
  margin-top: auto;
  padding: var(--pad);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .clock-card,
  .topbar {
    background: var(--surface-solid);
  }
}

/* ---------- 表盘 ---------- */

.watch {
  position: relative;
  width: min(100%, 440px);
  margin-inline: auto;
  isolation: isolate;
}

.watch::before {
  content: "";
  position: absolute;
  inset: 4%;
  z-index: -1;
  border-radius: 50%;
  background: var(--puck);
  pointer-events: none;
}

.dial {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: var(--dial-shadow);
}

.dial-rim {
  fill: none;
  stroke: var(--dial-rim);
  stroke-width: 1;
}

.dial-tick {
  stroke: var(--dial-tick);
  stroke-width: 1;
  stroke-linecap: round;
}

.dial-tick.is-major {
  stroke: var(--dial-tick-major);
  stroke-width: 1.6;
}

.dial-track {
  fill: none;
  stroke: var(--dial-track);
  stroke-width: 20;
}

.dial-num {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.dial-num.is-bedtime {
  fill: var(--sleep);
  font-weight: 700;
}

.dial-bedtime-line {
  stroke: var(--sleep);
  stroke-width: 2.6;
  stroke-linecap: round;
}

.dial-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 20;
}

.dial-overdue {
  fill: none;
  stroke: var(--sleep);
  stroke-width: 20;
}

.dial-hand line {
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.42;
}

.dial-hand circle {
  fill: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent));
}

.dial-hand.is-past circle {
  fill: var(--sleep);
  filter: drop-shadow(0 0 8px var(--sleep));
}

.face {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56%;
  gap: 0.3rem;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.face-day {
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.face-time {
  font-size: clamp(2.8rem, 13vw, 4.1rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
}

.face-zone {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--faint);
}

/* ---------- 推荐入睡 / 倒计时 ---------- */

.sleep-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.sleep-block {
  min-width: 0;
}

.count-block {
  text-align: right;
}

.block-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.count-block .block-label {
  justify-content: flex-end;
}

.mark-sleep {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sleep);
  box-shadow: 0 0 8px var(--sleep);
}

.block-value {
  margin-top: 4px;
  font-size: clamp(1.25rem, 4.4vw, 1.6rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
}

.count-block .block-value {
  font-size: clamp(1.4rem, 5.2vw, 1.85rem);
}

.count-block.is-past .block-value,
.count-block.is-past .block-label {
  color: var(--sleep);
}

/* ---------- 页脚 ---------- */

.foot {
  margin-top: 18px;
  margin-bottom: auto;
  padding-bottom: 26px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.foot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

/* ---------- 窄屏 ---------- */

@media (max-width: 420px) {
  :root {
    --radius: 24px;
    --pad: 16px;
  }

  .brand-sub {
    display: none;
  }

  .topbar {
    min-height: 60px;
    padding-block: 10px;
  }

  main {
    min-height: calc(100svh - 60px);
  }

  .face-time {
    font-size: clamp(2.5rem, 12.5vw, 3.2rem);
  }

  .sleep-panel {
    margin-top: 18px;
    padding-top: 16px;
  }

  .block-label {
    font-size: 11.5px;
  }

  .block-value {
    font-size: 1.25rem;
  }

  .count-block .block-value {
    font-size: 1.45rem;
  }
}

/* ---------- 动效偏好 ---------- */

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