/* ============================================================
   睡愈力 · 睡眠日历 — 页面视觉
   月夜暖金暗夜风（tokens 见 site.css），与测评页同属一套语言
   签名元素：日历格子里的情绪小脸（测评状态的图形化）
   注意：状态第三档用陶土色而非紫色（DESIGN.md §1.6 禁紫色系）
   ============================================================ */

[x-cloak] { display: none !important; }

/* ============================================================
   页面级导航（同资源中心语言：品牌 + 分隔线 + 页签）
   ============================================================ */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(11,13,19,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.4s, box-shadow 0.4s;
}
.nav.topbar--on {
  background: rgba(11,13,19,0.82);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 6px 24px rgba(0,0,0,0.35);
}
.nav__inner {
  width: min(1160px, 100% - 48px); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.nav__brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  letter-spacing: 0.1em; color: var(--gold-pale);
  transition: opacity 0.2s;
}
.nav__brand:hover { opacity: 0.8; }
.nav__logo-img { height: 34px; width: auto; display: block; }
.nav__brand-divider {
  width: 1px; height: 22px;
  background: linear-gradient(to bottom, transparent, rgba(196,162,101,0.3), transparent);
  margin: 0 6px;
}
.nav__brand-tag {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--gold-pale);
  text-shadow: 0 0 24px rgba(196,162,101,0.18);
}
.nav__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
@media (max-width: 768px) {
  .nav__brand-tag { font-size: 15px; letter-spacing: 0.2em; }
  .nav__logo-img { height: 28px; }
}

.cal { position: relative; }
/* 注意：.cal 不能加 z-index——否则蒙版被困在局部堆叠上下文，
   导航栏(z-100)/页脚(z-1) 会压到蒙版上面（实测踩过） */

/* ============================================================
   未登录引导（复用 assessment.css 的 .st-lock 卡）
   ============================================================ */
.cal-guest {
  width: min(640px, 100% - 32px);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 80px) 0 80px;
}

/* ============================================================
   主体：左侧情绪栏 + 右侧日历（参考稿分栏，断点 768）
   ============================================================ */
.cal-body {
  width: min(1120px, 100% - 48px);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 48px) 0 80px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 48px;
  align-items: start;
}

/* — 左侧情绪栏 — */
.cal-intro__title {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 28px); font-weight: 600;
  line-height: 1.3; letter-spacing: 0.02em;
  margin: 24px 0 20px;
}
.cal-intro__title em { font-style: normal; color: var(--gold); }
.cal-intro__lead {
  font-size: 14px; line-height: 1.9; color: var(--text-muted);
  margin-bottom: 32px;
}
.cal-streak {
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-streak__label { font-size: 12px; color: var(--text-muted); }
.cal-streak__num {
  font-family: var(--font-display);
  font-size: 42px; line-height: 1; color: var(--gold-pale);
  margin: 12px 0 8px;
}
.cal-streak__num small { font-family: inherit; font-size: 16px; color: var(--gold); }
.cal-streak__note { font-size: 12px; color: var(--text-dim); }
.cal-streak__note b { color: var(--gold-dim); font-weight: 600; }

.cal-legend { margin-top: 32px; }
.cal-legend__title {
  font-size: 11px; letter-spacing: 0.12em; color: var(--text-muted);
  margin-bottom: 12px;
}
.cal-legend__row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); margin-top: 8px;
}
.cal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cal-dot--sage { background: var(--sage, #b8c8a0); }
.cal-dot--tan { background: var(--tan, #c9a87c); }
.cal-dot--clay { background: #c77e52; } /* 与测评页 --weak 同色 */

/* ============================================================
   右侧：月份头 + 日历 + 今日卡
   ============================================================ */
.cal-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.cal-head__kicker {
  font-size: 11px; letter-spacing: 0.11em; color: var(--gold);
  margin-bottom: 8px;
}
.cal-head__month {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600; color: var(--text);
  letter-spacing: 0.02em;
}
.cal-head__en {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 400; color: var(--text-dim);
  margin-left: 8px; letter-spacing: 0.06em;
}
.cal-head__nav { display: flex; align-items: center; gap: 8px; }

.cal-navbtn {
  min-width: 44px; min-height: 44px; /* §10.2 触控 */
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-light); border-radius: var(--radius-full);
  color: var(--text-muted); font-size: 18px;
  transition: border-color 0.2s, color 0.2s;
}
.cal-navbtn:hover { border-color: var(--gold-dim); color: var(--gold-pale); }
.cal-navbtn--today {
  padding: 0 20px; font-size: 13px;
  color: var(--gold-pale); border-color: rgba(196,162,101,0.42);
}

.cal-trendbtn {
  min-height: 44px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid rgba(196,162,101,0.3); border-radius: var(--radius-full);
  background: rgba(196,162,101,0.06);
  font-size: 13px; color: var(--gold-dim); letter-spacing: 0.04em;
  margin-right: 8px;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.cal-trendbtn:hover { border-color: var(--gold); color: var(--gold-pale); }

/* — 日历面板 — */
.cal-grid {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: rgba(24,27,35,0.62);
  padding: 20px;
}
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding-bottom: 12px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px; letter-spacing: 0.08em; color: var(--text-dim);
  text-align: center;
}
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
}
.cal-day {
  position: relative;
  min-height: 88px;
  padding: 8px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: background 0.2s;
}
.cal-day--out { opacity: 0.28; }
.cal-day--rec { cursor: pointer; }
.cal-day--rec:hover { background: var(--bg-elevated); }
.cal-day--rec:focus-visible { outline: 2px solid var(--gold-dim); outline-offset: 1px; }
.cal-day--today {
  border-color: rgba(196,162,101,0.75);
  background: rgba(196,162,101,0.07);
}
.cal-day--today .cal-day__num { color: var(--gold-pale); font-weight: 600; }
.cal-day--today::after {
  content: '今日'; position: absolute; right: 8px; top: 8px;
  font-size: 10px; color: var(--gold);
}
.cal-day__num { font-size: 12px; }

/* 情绪小脸（纯 CSS：双眼 + 嘴形，参考稿技法） */
.cal-mood {
  display: block; position: relative;
  width: 32px; height: 32px; border-radius: 50%;
  margin: 16px auto 0;
}
.cal-mood::before, .cal-mood::after {
  content: ''; position: absolute; top: 9px;
  width: 4px; height: 5px; border-radius: 50%;
  background: rgba(11,13,19,0.72);
}
.cal-mood::before { left: 9px; }
.cal-mood::after { right: 9px; }
.cal-mood i {
  position: absolute; left: 9px; top: 19px;
  width: 14px; height: 7px;
  border-bottom: 2px solid rgba(11,13,19,0.72);
  border-radius: 0 0 14px 14px; /* 微笑 */
}
.cal-mood--tan i {
  top: 21px; height: 0;
  border-bottom: 0; border-top: 2px solid rgba(11,13,19,0.72);
  border-radius: 0; /* 平直 */
}
.cal-mood--clay i {
  top: 21px;
  border-bottom: 0; border-top: 2px solid rgba(11,13,19,0.72);
  border-radius: 14px 14px 0 0; /* 下垂 */
}
.cal-mood--sage { background: var(--sage, #b8c8a0); }
.cal-mood--tan { background: var(--tan, #c9a87c); }
.cal-mood--clay { background: #c77e52; }

.cal-day__check {
  position: absolute; right: 8px; bottom: 8px;
  width: 14px; height: 14px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(196,162,101,0.16); color: var(--gold);
  font-size: 9px;
}

/* — 今日长条卡 — */
.cal-today {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left;
  margin-top: 24px; padding: 20px 24px;
  border: 1px solid rgba(196,162,101,0.38); border-radius: var(--radius-lg);
  background: linear-gradient(105deg, rgba(196,162,101,0.13), rgba(196,162,101,0.04));
  cursor: pointer;
  transition: border-color 0.2s;
}
.cal-today:hover { border-color: var(--gold); }
.cal-today:focus-visible { outline: 2px solid var(--gold-dim); outline-offset: 2px; }
.cal-today__left { display: flex; align-items: center; gap: 16px; }
.cal-today__icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: rgba(196,162,101,0.16); border: 1px solid rgba(196,162,101,0.34);
  color: var(--gold);
}
.cal-today__eyebrow { font-size: 11px; letter-spacing: 0.08em; color: var(--gold); margin-bottom: 4px; }
.cal-today__title {
  font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text);
}
.cal-today__meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-wrap: pretty; }
.cal-today__arrow {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid rgba(196,162,101,0.48); border-radius: 50%;
  color: var(--gold-pale); font-size: 18px;
  transition: transform 0.2s;
}
.cal-today:hover .cal-today__arrow { transform: translateX(3px); }

.cal-note { margin-top: 16px; font-size: 11px; color: var(--text-dim); }

/* ============================================================
   蒙版（结果 / 趋势 共用）
   ============================================================ */
.cal-mask {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(11,13,19,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cal-modal {
  position: relative;
  width: min(640px, 100%);
  max-height: 86vh; overflow-y: auto;
  overscroll-behavior: contain; /* 蒙版内滚到底不再穿透到主页面 */
  background: var(--bg-elevated);
  border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  padding: 40px 32px 32px;
}
.cal-modal__close {
  position: absolute; top: 12px; right: 12px;
  width: 44px; height: 44px; /* §10.2 触控 */
  display: grid; place-items: center;
  border-radius: 50%; color: var(--text-muted);
  font-size: 22px; line-height: 1;
  transition: color 0.2s, background 0.2s;
}
.cal-modal__close:hover { color: var(--gold-pale); background: rgba(255,255,255,0.04); }
.cal-modal__close:focus-visible { outline: 2px solid var(--gold-dim); }

/* 蒙版内结果：维度条间距收紧（整页版的 24px 间距在 640px 弹窗里偏散） */
.cal-modal .st-dims { gap: 20px; margin-bottom: 32px; }
.cal-modal .st-score { padding-bottom: 32px; margin-bottom: 32px; }
.cal-modal__date {
  text-align: center; font-size: 12px; color: var(--text-dim);
  margin-bottom: 20px; letter-spacing: 0.06em;
}

/* V2 结果弹窗（2026-09-07 按新结果页重改）：模块间距在弹窗内整体收紧 */
.cal-modal .st-main { padding-bottom: 24px; margin-bottom: 20px; }
.cal-modal .st-main__num { font-size: clamp(56px, 10vw, 72px); }
.cal-modal .st-main__line { margin-top: 36px; } /* 与刻度尺下标拉开（同结果页 2026-09-07 间距裁定） */
.cal-modal .st-persona { margin-bottom: 20px; }
.cal-modal .st-mod, .cal-modal .st-care, .cal-modal .st-mildbar { padding: 16px 18px; }
.cal-modal .st-flags { margin-bottom: 16px; }
.cal-modal .st-flag { padding: 12px 16px; }
.cal-modal .st-next { padding: 20px 0 4px; }
.cal-modal .st-legal { margin-top: 20px; padding-top: 20px; }
/* 归因条目在弹窗内静态展开（非按钮，无 hover 态） */
.cal-cause__head { cursor: default; padding: 12px 0; }
.cal-cause__head:hover { background: none; }
.cal-cause__explain {
  padding: 0 0 12px 38px; /* 与标签对齐（徽章 26 + 间距 12） */
  font-size: 13px; line-height: 1.8; color: var(--text-muted);
}

/* 趋势图 */
.cal-trend-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  color: var(--text); text-align: center; margin-bottom: 8px;
}
.cal-trend-sub {
  text-align: center; font-size: 12px; color: var(--text-dim); margin-bottom: 24px;
}
.cal-trend-canvas { width: 100%; height: 260px; display: block; }
.cal-trend-empty {
  text-align: center; font-size: 13px; color: var(--text-muted);
  padding: 48px 0; line-height: 1.9;
}

/* 今日已完成打卡提醒卡（紧凑版蒙版卡） */
.cal-done {
  width: min(420px, 100%);
  text-align: center;
}
.cal-done__title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600;
  letter-spacing: 0.03em; color: var(--gold-pale);
  margin-bottom: 12px;
}
.cal-done__desc {
  font-size: 13px; line-height: 1.8; color: var(--text-muted);
  margin-bottom: 24px;
}
.cal-done .st-lock__moon { margin-bottom: 24px; }

/* ============================================================
   移动端（≤768px）
   ============================================================ */
@media (max-width: 768px) {
  .cal-body {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-top: calc(var(--nav-h) + 32px);
  }
  .cal-intro { text-align: center; }
  .cal-intro__lead { margin-bottom: 24px; }
  .cal-legend { display: flex; justify-content: center; gap: 20px; }
  .cal-legend__title { display: none; }
  .cal-legend__row { margin-top: 0; }
  .cal-head { align-items: center; }
  .cal-grid { padding: 12px; }
  .cal-day { min-height: 56px; padding: 4px; }
  .cal-day--today::after { content: none; }
  .cal-day__num { font-size: 11px; }
  .cal-mood { width: 22px; height: 22px; margin-top: 10px; }
  .cal-mood::before, .cal-mood::after { top: 6px; width: 3px; height: 4px; }
  .cal-mood::before { left: 6px; }
  .cal-mood::after { right: 6px; }
  .cal-mood i { left: 6px; top: 13px; width: 10px; height: 5px; }
  .cal-mood--tan i, .cal-mood--clay i { top: 15px; }
  .cal-day__check { right: 4px; bottom: 4px; width: 12px; height: 12px; font-size: 8px; }
  .cal-today { padding: 16px; }
  /* 移动端文案纵排：eyebrow/标题/说明各占一行，避免标题跨行截断（2026-09-07 审计 F-A3） */
  .cal-today__eyebrow, .cal-today__title, .cal-today__meta { display: block; }
  .cal-today__title { margin-top: 2px; }
  .cal-today__arrow { width: 40px; height: 40px; }
  .cal-modal { padding: 32px 20px 24px; }
}

/* ============================================================
   降低动效（系统偏好）
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .cal-day, .cal-today, .cal-today__arrow, .cal-navbtn, .cal-trendbtn,
  .cal-modal__close { transition: none; }
}
