/* ==========================================================================
   日期 / 时间选择器（xp）
   --------------------------------------------------------------------------
   浏览器原生的 <input type="date"> / <input type="time"> 在手机上会弹出
   系统的 Material 控件（青绿色标题栏 + 圆盘时钟），跟站点的纸面、宋体、
   陶土色完全不搭；在桌面又限死了浏览器语言与格式。

   这里改成自绘：移动端底部抽屉，桌面居中卡片。
   日历走「年 → 月 → 日」三级，生日跨一百年也不用逐月翻；
   时间用双列滚轮，另给 12 个时辰快捷 —— 多数人只记得「我是卯时生的」，
   不该逼他先换算成 6 点还是 7 点。

   组件由 picker.js 创建，本文件只负责外观。
   ========================================================================== */

/* ---------- 遮罩 ---------- */
.xp-mask {
  position: fixed;
  inset: 0;
  z-index: 960;
  background: rgba(40, 34, 28, .34);
  opacity: 0;
  transition: opacity .22s linear;
  -webkit-tap-highlight-color: transparent;
}
.xp-mask.on { opacity: 1; }

/* ---------- 面板 ---------- */
.xp {
  position: fixed;
  z-index: 961;
  left: 50%;
  bottom: 0;
  width: min(430px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -14px 44px rgba(60, 48, 36, .18);
  transform: translate(-50%, 102%);
  transition: transform .32s cubic-bezier(.22, .82, .36, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  font-family: var(--font);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.xp.on { transform: translate(-50%, 0); }

/* 移动端抓手 */
.xp-grip {
  width: 36px;
  height: 4px;
  margin: 9px auto 0;
  border-radius: 2px;
  background: var(--border-2);
}

/* ---------- 顶栏：取消 / 标题 / 确定 ---------- */
.xp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px 4px;
}
.xp-title {
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--text-3);
  text-transform: uppercase;
}
.xp-btn {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--text-3);
  padding: 9px 6px;
  cursor: pointer;
  border-radius: 8px;
  transition: color .16s linear, background .16s linear;
}
.xp-btn:hover { color: var(--text); background: var(--surface-2); }
.xp-btn.ok {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .02em;
}
.xp-btn.ok:hover { background: var(--accent-soft); }
.xp-btn[disabled] { color: var(--text-4); cursor: default; background: none; }

/* ---------- 日历头部 ---------- */
.xp-cal { padding-bottom: 6px; }
.xp-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 12px 6px;
}
.xp-ym {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 5px;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  padding: 7px 22px 7px 12px;
  border-radius: 10px;
  transition: background .16s linear;
}
.xp-ym:hover { background: var(--surface-2); }
.xp-ym b {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}
.xp-ym span {
  font-size: 13px;
  color: var(--text-2);
}
/* 标题右侧一枚极小的下箭头，暗示「可以点」。
   用绝对定位：放在 flex 流里会跟着 baseline 跑，位置随字号漂。 */
.xp-ym::after {
  content: '';
  position: absolute;
  right: 9px;
  top: 50%;
  width: 5px; height: 5px;
  margin-top: -4px;
  border-right: 1.2px solid var(--text-4);
  border-bottom: 1.2px solid var(--text-4);
  transform: rotate(45deg);
}

.xp-nav {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  border-radius: 50%;
  color: var(--text-3);
  cursor: pointer;
  transition: background .16s linear, color .16s linear;
}
.xp-nav:hover { background: var(--surface-2); color: var(--text); }
.xp-nav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.xp-nav[disabled] { opacity: .3; cursor: default; background: none; }

/* ---------- 日历网格 ---------- */
.xp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 9px;
}
.xp-dow {
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--text-3);
  padding-bottom: 2px;
}
.xp-dow.we { color: var(--text-4); }

.xp-days { padding-bottom: 4px; }

.xp-day {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  width: 40px;
  height: 40px;
  margin: 2px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: background .14s linear, color .14s linear;
}
.xp-day.out { color: var(--text-4); }
.xp-day:hover { background: var(--surface-2); }
/* 今天：一圈极细的陶土环，不填色 —— 填色会和「已选中」混淆 */
.xp-day.today::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid rgba(138, 99, 83, .42);
  box-shadow: inset 0 0 0 3px rgba(138, 99, 83, .045);
}
.xp-day.sel {
  background: var(--accent);
  color: #FBFAF6;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(138, 99, 83, .28);
}
.xp-day.sel::before { display: none; }
.xp-day.sel:hover { background: var(--accent-2); }
.xp-day[disabled] {
  color: var(--text-4);
  opacity: .38;
  cursor: default;
  background: none;
}

/* ---------- 月 / 年 选择 ---------- */
.xp-mgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 18px 18px;
}
.xp-m {
  appearance: none;
  height: 50px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: border-color .16s linear, background .16s linear, color .16s linear;
}
.xp-m:hover { border-color: var(--border-2); background: var(--surface-2); }
.xp-m.sel {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 视图切换：轻微上浮淡入，避免生硬替换 */
.xp-body > * { animation: xp-in .2s ease-out both; }
@keyframes xp-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 快捷行 ---------- */
.xp-quick {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.xp-quick button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .16s linear, color .16s linear, background .16s linear;
}
.xp-quick button:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 时间：双列滚轮 ---------- */
.xp-time { padding: 2px 0 16px; }

.xp-wheels {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 0 8px;
}
/* 选中带：两条 1px 细线，像账本的行线，比高亮底色安静 */
/* 只画上下两条横线。原先还封了左右两边，四条线围成一个框，
   看起来像个输入框，把「滚轮」的语义盖掉了。 */
.xp-band {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 156px;
  height: 40px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  pointer-events: none;
}

.xp-wheel {
  height: 176px;
  width: 66px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  padding: 68px 0;
  text-align: center;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  mask-image: linear-gradient(180deg, transparent 0, #000 30%, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 30%, #000 70%, transparent 100%);
}
.xp-wheel::-webkit-scrollbar { display: none; }

.xp-wi {
  height: 40px;
  line-height: 40px;
  scroll-snap-align: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--text-4);
  transition: color .14s linear, font-size .14s linear, opacity .14s linear;
}
.xp-wi.on {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: .01em;
}

.xp-colon {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-3);
  transform: translateY(-1px);
}

/* ---------- 时辰快捷 ---------- */
.xp-shi {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
}
.xp-shi-lb {
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--text-3);
  margin-bottom: 9px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.xp-shi-lb em {
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0;
  color: var(--text-4);
}
.xp-shi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.xp-ss {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
  padding: 5px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  cursor: pointer;
  color: var(--text-2);
  transition: border-color .16s linear, background .16s linear, color .16s linear;
}
.xp-ss b { font-family: var(--font-display); font-size: 14px; font-weight: 600; }
.xp-ss small { font-size: 8.5px; color: var(--text-4); letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.xp-ss:hover { border-color: var(--border-2); background: var(--surface-2); }
.xp-ss.on {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.xp-ss.on small { color: var(--accent); opacity: .72; }

/* ---------- 触发控件：自绘图标 + 只读观感 ---------- */
[data-xp] {
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 24 24' fill='none' stroke='%238A8F90' stroke-width='1.6' stroke-linecap='round'%3E%3Crect x='3.4' y='5' width='17.2' height='15.4' rx='2.4'/%3E%3Cpath d='M3.4 10h17.2M8.2 3.2v3.4M15.8 3.2v3.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
[data-xp="time"] {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 24 24' fill='none' stroke='%238A8F90' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8.6'/%3E%3Cpath d='M12 7.2V12l3.2 2'/%3E%3C/svg%3E");
}
[data-xp]:focus { outline: none; }
[data-xp]:focus-visible {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 桌面：改成居中卡片 ---------- */
@media (min-width: 720px) {
  .xp {
    bottom: auto;
    top: 50%;
    width: 372px;
    border-radius: 20px;
    box-shadow: 0 26px 70px rgba(60, 48, 36, .22), 0 0 0 1px rgba(60, 48, 36, .04);
    transform: translate(-50%, -46%) scale(.97);
    opacity: 0;
    transition: transform .26s cubic-bezier(.22, .82, .36, 1), opacity .2s linear;
  }
  .xp.on { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .xp-grip { display: none; }
  .xp .xp-head { padding-top: 14px; }
  .xp .xp-shi-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- 小屏收窄 ---------- */
@media (max-width: 360px) {
  .xp-day { width: 36px; height: 36px; font-size: 13.5px; }
  .xp-mgrid { padding: 4px 12px 16px; gap: 7px; }
  .xp-m { height: 48px; }
  .xp-ss small { display: none; }
}

/* ---------- 深色模式 ---------- */
@media (prefers-color-scheme: dark) {
  .xp-mask { background: rgba(8, 10, 10, .58); }
  .xp { box-shadow: 0 -14px 44px rgba(0, 0, 0, .5); }
  .xp-day.sel { color: #1B1B18; }
  .xp-ss.on small { color: var(--accent); }
}

/* ---------- 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  .xp, .xp-mask { transition: none; }
  .xp-body > * { animation: none; }
}

/* 年视图标题：没有上一级，去掉箭头、不显示手型 */
.xp-ym.is-flat { padding-right: 12px; cursor: default; }
.xp-ym.is-flat::after { content: none; }
.xp-ym.is-flat:hover { background: none; }

/* 触摸设备上 :hover 会粘在最后点过的元素上（点日期后那一格留着淡底），
   看起来像选中了但又没有对勾。触屏下统一关掉 hover 观感。 */
@media (hover: none) {
  .xp-day:hover { background: none; }
  .xp-day.sel:hover { background: var(--accent); }
  .xp-m:hover { background: var(--surface); border-color: var(--border); }
  .xp-m.sel:hover { background: var(--accent-soft); border-color: var(--accent); }
  .xp-nav:hover { background: none; color: var(--text-3); }
  .xp-btn:hover { background: none; color: var(--text-3); }
  .xp-btn.ok:hover { background: none; color: var(--accent); }
  .xp-ss:hover { background: var(--surface); border-color: var(--border); }
  .xp-ss.on:hover { background: var(--accent-soft); border-color: var(--accent-line); }
  .xp-ym:hover { background: none; }
  .xp-quick button:hover { background: var(--surface); border-color: var(--border); color: var(--text-2); }
}
