/* ============================================================
   FLIP — 24h 翻页时钟 · 视觉核心
   画布基准：1180 × 820（iPad 11" 横屏 pt），整体等比缩放
   ============================================================ */

:root {
  --sans: "PingFang SC", -apple-system, BlinkMacSystemFont, "SF Pro Display",
          "Helvetica Neue", "Hiragino Sans GB", sans-serif;
  --num: "PingFang SC", -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* 默认（暗夜）主题 · 也供页面外的单卡示例使用 */
  --paper: #E9E9E5;
  --bg: #000000;
  --card-a: #212226;
  --card-b: #1C1D21;
  --seam: #040506;
  --edge: rgba(255, 255, 255, .06);
  --meta: #6C6C66;
  --dim: #8B8B84;
  --card-shadow: 0 34px 60px -22px rgba(0, 0, 0, .95), 0 2px 4px rgba(0, 0, 0, .55);
}

.clock-root {
  --cw: 400px;
  --ch: 420px;
  --fs: 290px;
  --gap: 12px;
  --r: 24px;
  --colon-w: 32px;
  --dot: 14px;
  --dot-gap: 46px;

  position: absolute;
  left: 50%;
  top: 50%;
  width: 1180px;
  height: 820px;
  overflow: hidden;
  background: var(--bg);
  transform-origin: center center;
  font-family: var(--sans);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 显示秒：三张卡，整体缩小一档 */
.clock-root.has-seconds {
  --cw: 310px;
  --ch: 380px;
  --fs: 224px;
  --gap: 10px;
  --r: 20px;
  --colon-w: 28px;
  --dot: 12px;
  --dot-gap: 38px;
}

/* ---------- 主题 ---------- */
.clock-root[data-theme="paper"] {
  --paper: #0B0B0C;
  --bg: #FFFFFF;
  --card-a: #F8F1E2;
  --card-b: #F0E7D5;
  --seam: #D6CAB5;
  --edge: rgba(255, 255, 255, .95);
  --meta: #8F887B;
  --dim: #837C6F;
  --card-shadow: 0 30px 54px -28px rgba(72, 56, 30, .42), 0 2px 6px rgba(72, 56, 30, .09);
}

.clock-root[data-theme="night"] {
  --paper: #DFB67C;
  --bg: #050403;
  --card-a: #110E0A;
  --card-b: #0E0C09;
  --seam: #050403;
  --edge: rgba(255, 200, 140, .07);
  --meta: #4E4438;
  --dim: #6B5A44;
  --card-shadow: 0 34px 60px -22px rgba(0, 0, 0, .95), 0 2px 4px rgba(0, 0, 0, .55);
}

/* ---------- 日期 ---------- */
.clock-date {
  position: absolute;
  left: 0;
  right: 0;
  top: 96px;
  text-align: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: .22em;
  text-indent: .22em;
  color: var(--meta);
  font-feature-settings: "tnum" 1;
  z-index: 2;
}

/* ---------- 冒号 ---------- */
.colon {
  flex: 0 0 var(--colon-w);
  width: var(--colon-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--dot-gap);
  z-index: 4;
}

.colon i {
  display: block;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--paper);
  opacity: .92;
}

.clock-root:not(.has-seconds) .colon-b {
  display: none;
}

@keyframes colonBlink {
  0%, 10% { opacity: 1; }
  48%, 56% { opacity: .08; }
  94%, 100% { opacity: 1; }
}

.clock-root.is-blinking .colon {
  animation: colonBlink 1s ease-in-out infinite;
  animation-delay: var(--blink-delay, 0ms);
}

/* ---------- 卡片组 ---------- */
.clock-cards {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  gap: var(--gap);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.flip {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--r);
  background: var(--card-b);
  box-shadow: var(--card-shadow), inset 0 1px 0 var(--edge);
  perspective: 1500px;
  transform-style: preserve-3d;
  overflow: hidden;
}

/* 上下两个翻页面 */
.flip-face {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: var(--card-a);
}

.flip-top {
  top: 0;
  border-radius: var(--r) var(--r) 0 0;
}

.flip-bottom {
  top: 50%;
  border-radius: 0 0 var(--r) var(--r);
  background: var(--card-b);
}

/* 数字 */
.flip-num {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--ch);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--num);
  font-size: var(--fs);
  font-weight: 600;
  -webkit-text-stroke: calc(var(--fs) * 0.008) currentColor;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
}

.flip-bottom .flip-num {
  top: calc(var(--ch) / -2);
}

/* 轴缝 */
.flip-seam {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 3px;
  margin-top: -1.5px;
  background: var(--seam);
  box-shadow: 0 -1px 0 var(--edge);
  z-index: 5;
  pointer-events: none;
}

/* ---------- AM / PM（仅 12 小时制） ---------- */
.ampm {
  position: absolute;
  left: 24px;
  bottom: 20px;
  z-index: 6;
  font-family: var(--sans);
  font-size: 19px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: .16em;
  color: var(--dim);
  pointer-events: none;
}

.has-seconds .ampm {
  left: 20px;
  bottom: 16px;
  font-size: 16px;
}

.clock-root:not(.is-12h) .ampm {
  display: none;
}

/* 翻页动画切片 */
.leaf {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  z-index: 8;
  backface-visibility: hidden;
  will-change: transform;
}

.leaf-top {
  top: 0;
  transform-origin: 50% 100%;
}

.leaf-bottom {
  top: 50%;
  transform-origin: 50% 0%;
}

/* ---------- 设置入口 ---------- */
.clock-gear {
  position: absolute;
  top: 30px;
  right: 32px;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--dim);
  opacity: .7;
  cursor: pointer;
  z-index: 25;
  transition: opacity .18s, background .18s;
}

.clock-gear svg {
  width: 21px;
  height: 21px;
  display: block;
}

.clock-gear:hover,
.clock-gear.is-on {
  opacity: 1;
  background: color-mix(in srgb, var(--paper) 7%, transparent);
}

/* ---------- 设置面板 ---------- */
.settings {
  position: absolute;
  top: 88px;
  right: 30px;
  width: 342px;
  z-index: 30;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: #101012;
  box-shadow: 0 36px 70px -24px rgba(0, 0, 0, .9);
  color: #EDEDE8;
  font-size: 13px;
}

.settings[hidden] {
  display: none;
}

.set-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.set-h b {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
}

.set-x {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8A8A83;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.set-x:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 14px;
}

.set-sw {
  position: relative;
  width: 44px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .15);
  cursor: pointer;
  transition: background .18s;
}

.set-sw i {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}

.set-sw[aria-checked="true"] {
  background: #8FB183;
}

.set-sw[aria-checked="true"] i {
  transform: translateX(18px);
}

.set-sec {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-top: 12px;
  margin-top: 2px;
}

.set-lbl {
  font-size: 10.5px;
  letter-spacing: .1em;
  color: #7C7C75;
  margin-bottom: 10px;
}

.presets {
  display: flex;
  gap: 8px;
}

.preset {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  background: #161618;
  color: #B5B5AE;
  font-size: 10px;
  cursor: pointer;
}

.preset[aria-pressed="true"] {
  border-color: #A9C1A1;
  color: #EDEDE8;
}

.pv {
  width: 100%;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pv-bg, #000);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10);
}

.pv b {
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--pv-card, #1C1D21);
  color: var(--pv-fg, #E9E9E5);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
}

.c-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
}

.c-row > span {
  width: 34px;
  color: #B5B5AE;
}

.c-row b {
  flex: 1;
  font-weight: 400;
  font-size: 11px;
  letter-spacing: .04em;
  color: #7C7C75;
  font-family: ui-monospace, Menlo, monospace;
}

.c-row input[type="color"] {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.c-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.c-row input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

/* ---------- 时间格式分段控件 ---------- */
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
}

.seg button {
  border: 0;
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  color: #A8A8A1;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .02em;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: #E9E9E5;
  color: #111214;
}

/* ---------- 迷你预览（概念板用） ---------- */
.clock-root.compact .clock-date,
.clock-root.compact .clock-gear,
.clock-root.compact .ampm {
  display: none;
}

.clock-root.compact .clock-cards {
  transform: translate(-50%, -50%) scale(1.06);
}

.clock-root:not(.has-seconds) .flip-sec {
  display: none;
}
