/* ============================================================
   万年历 · 页面样式（复用 style.css 的纸张/墨色变量）
   ============================================================ */

.topnav a.is-current { color: var(--seal); }
.topnav a.is-current::after { right: 0; background: var(--seal); }

.cal-adwrap { margin-top: 20px; }

/* ------------------------------ 广告位预留 ------------------------------ */
.ad {
  --ad-h: 90px;
  --ad-h-mobile: 56px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--ad-h);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--muted);
  overflow: hidden;
  text-align: center;
}
.ad[hidden] { display: none; }
.ad__tag {
  position: absolute;
  top: 6px; left: 8px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0 4px;
  border-radius: 2px;
  line-height: 1.6;
}
.ad__label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; color: var(--ink-soft); }
.ad__label--mobile { display: none; }
.ad__hint { font-size: 10px; opacity: 0.72; }
.ad[data-ad-slot="cal-sidebar"] { min-height: 250px; }
.ad[data-ad-slot="cal-footer"] { margin-bottom: 26px; }
.ad[data-ad-slot="cal-inline"] { margin-top: 18px; }
.ad iframe, .ad img, .ad ins { max-width: 100%; }

/* -------------------------------- 页头区 -------------------------------- */
.cal-hero {
  display: grid;
  grid-template-columns: 1fr 380px;
  align-items: center;
  gap: 32px;
  padding-top: 34px;
  padding-bottom: 26px;
}
.cal-hero__title {
  margin: 8px 0 10px;
  font-family: var(--serif);
  font-size: clamp(30px, 4.2vw, 46px);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.3;
}
.cal-hero__sub { margin: 0; font-size: 13.5px; line-height: 1.9; color: var(--ink-soft); }

.cal-today {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: var(--radius);
  padding: 16px 20px 18px;
  box-shadow: var(--shadow-sm);
}
.cal-today__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cal-today__label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; color: var(--muted); }
.cal-today__week { font-size: 11.5px; color: var(--ink-soft); letter-spacing: 0.08em; }
.cal-today__solar {
  display: flex; align-items: baseline; gap: 10px;
  margin-top: 6px;
  font-family: var(--serif);
  line-height: 1;
}
.cal-today__day { font-size: 52px; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }
.cal-today__ym { font-size: 15px; color: var(--ink-soft); letter-spacing: 0.08em; }
.cal-today__lunar {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft);
  font-family: var(--serif); font-size: 15px; color: var(--ink-soft); line-height: 1.7;
}
.cal-today__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cal-today__yi {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tag {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(168, 52, 42, 0.35);
  color: var(--seal);
  background: rgba(168, 52, 42, 0.06);
}
.tag--neutral { border-color: var(--line); color: var(--muted); background: transparent; }
.tag--rest { border-color: rgba(44, 93, 87, 0.4); color: var(--teal); background: rgba(44, 93, 87, 0.06); }

/* -------------------------------- 主体布局 ------------------------------- */
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 22px;
  padding-top: 12px;
  align-items: start;
}
.cal-main { min-width: 0; }
.cal-side { display: flex; flex-direction: column; gap: 16px; }

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--paper-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav__btn {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-soft);
  border-radius: 2px;
  font-size: 18px;
  line-height: 1;
  transition: all 0.18s;
}
.cal-nav__btn:hover { border-color: var(--seal); color: var(--seal); }
.cal-nav__title { display: flex; align-items: center; gap: 4px; font-family: var(--serif); font-size: 17px; letter-spacing: 0.06em; }
.cal-nav__title select {
  appearance: none;
  border: 0;
  border-bottom: 1px dashed var(--line);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  padding: 2px 18px 2px 4px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 8px) 55%, calc(100% - 4px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.cal-nav__title select:focus { outline: none; border-bottom-color: var(--seal); }
.cal-nav__title option { color: var(--ink); background: var(--paper-2); }

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--paper-3);
}
.cal-week span {
  padding: 8px 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.cal-week span:first-child, .cal-week span:last-child { color: var(--seal); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 88px;
  padding: 8px 9px 9px;
  border: 0;
  background: var(--paper-2);
  text-align: left;
  color: var(--ink);
  transition: background 0.16s, box-shadow 0.16s;
}
.cal-cell:hover { background: var(--paper-3); }
.cal-cell:focus-visible { outline: 2px solid var(--seal); outline-offset: -2px; }
.cal-cell.is-other { background: var(--paper); opacity: 0.48; }
.cal-cell.is-weekend .cal-cell__d { color: var(--seal); }
.cal-cell.is-today { background: rgba(168, 52, 42, 0.055); box-shadow: inset 0 0 0 1px rgba(168, 52, 42, 0.5); }
.cal-cell.is-selected { background: rgba(168, 52, 42, 0.1); box-shadow: inset 0 0 0 2px var(--seal); }
.cal-cell__row { display: flex; align-items: baseline; justify-content: space-between; width: 100%; gap: 4px; }
.cal-cell__d { font-family: var(--mono); font-size: 17px; line-height: 1.2; letter-spacing: -0.02em; }
.cal-cell__badge {
  font-size: 9px;
  line-height: 1.5;
  padding: 0 3px;
  border-radius: 2px;
  color: var(--teal);
  border: 1px solid rgba(44, 93, 87, 0.45);
}
.cal-cell__badge.is-work { color: var(--gold); border-color: rgba(169, 133, 57, 0.55); }
.cal-cell__lunar {
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-cell__lunar.is-fest { color: var(--seal); font-weight: 600; }
.cal-cell__events { margin-top: auto; display: flex; align-items: center; gap: 4px; font-size: 9.5px; color: var(--muted); }
.cal-cell__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); flex: none; }
.cal-cell__n { font-family: var(--mono); font-size: 9.5px; opacity: 0.8; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.lg--today { box-shadow: inset 0 0 0 1.5px var(--seal); }
.lg--event { background: var(--gold); border-radius: 50%; width: 6px; height: 6px; }
.lg--fest { background: var(--seal); }
.lg--rest { border: 1px solid var(--teal); }

/* ------------------------------- 日期详情 ------------------------------- */
.day-panel {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.day-panel__close { display: none; }
.dp-head {
  position: relative;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(168, 52, 42, 0.045), transparent);
}
.dp-head__date { font-family: var(--serif); font-size: 23px; letter-spacing: 0.04em; line-height: 1.35; }
.dp-head__week { font-size: 11.5px; color: var(--muted); letter-spacing: 0.08em; margin-left: 8px; }
.dp-head__lunar { margin-top: 4px; font-family: var(--serif); font-size: 13.5px; color: var(--ink-soft); }
.dp-head__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dp-body { padding: 16px 20px 22px; }
.dp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.dp-grid > div { background: var(--paper-2); padding: 8px 10px; }
.dp-grid dt { font-size: 10px; letter-spacing: 0.12em; color: var(--muted); }
.dp-grid dd { margin: 2px 0 0; font-family: var(--serif); font-size: 13px; color: var(--ink); }
.dp-sub { margin: 18px 0 9px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; color: var(--muted); }
.dp-yiji { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dp-yiji > div { border: 1px solid var(--line-soft); border-radius: 2px; padding: 10px 12px; background: var(--paper-3); }
.dp-yiji h5 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.14em; font-weight: 600; }
.dp-yiji .is-yi h5 { color: var(--teal); }
.dp-yiji .is-ji h5 { color: var(--seal); }
.dp-yiji p { margin: 0; font-size: 12px; line-height: 1.85; color: var(--ink-soft); }

.dp-events { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.dp-event {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 9px 11px;
  background: var(--paper-2);
  font-size: 12px;
  color: var(--ink-soft);
  border: 0;
  text-align: left;
  width: 100%;
}
.dp-event.is-link:hover { background: var(--paper-3); }
.dp-event__year { font-family: var(--mono); font-size: 10.5px; color: var(--seal); text-align: right; }
.dp-event__title { line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dp-more { margin-top: 10px; }
.dp-note { margin: 8px 0 0; font-size: 10.5px; color: var(--muted); }

.cal-scrim {
  position: fixed; inset: 0; z-index: 85;
  background: rgba(20, 16, 10, 0.4);
  animation: calFade 0.2s ease;
}
.cal-scrim[hidden] { display: none; }
@keyframes calFade { from { opacity: 0; } to { opacity: 1; } }

/* -------------------------------- 响应式 -------------------------------- */
@media (max-width: 1080px) {
  .cal-hero { grid-template-columns: 1fr 320px; gap: 20px; }
  .cal-layout { grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
}

@media (max-width: 900px) {
  .only-desktop { display: none; }
  .cal-hero { grid-template-columns: 1fr; gap: 18px; padding-top: 24px; }
  .cal-hero__title { font-size: 32px; }
  .cal-today { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .cal-today__top { grid-column: 1 / -1; }
  .cal-today__solar { grid-column: 1; }
  .cal-today__lunar { grid-column: 2; margin-top: 0; padding-top: 0; border-top: 0; align-self: center; }
  .cal-today__tags, .cal-today__yi { grid-column: 1 / -1; }

  .cal-layout { display: block; padding-top: 4px; }
  .cal-side { display: contents; }
  .cal-side > .ad { display: none !important; }

  .day-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    max-height: 84vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    box-shadow: 0 -18px 44px -22px rgba(0, 0, 0, 0.45);
    transform: translateY(104%);
    transition: transform 0.32s cubic-bezier(0.3, 0.8, 0.3, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .day-panel.is-open { transform: translateY(0); }
  .day-panel__close {
    display: grid; place-items: center;
    position: absolute; top: 10px; right: 12px;
    width: 32px; height: 32px;
    border: 1px solid var(--line);
    background: var(--paper-2);
    border-radius: 50%;
    font-size: 19px; line-height: 1;
    color: var(--muted);
  }
  .dp-head { padding-right: 54px; }
  .ad { min-height: var(--ad-h-mobile); }
  .ad__label--desktop { display: none; }
  .ad__label--mobile { display: inline; }
  .ad__hint { display: none; }
}

@media (max-width: 620px) {
  .wrap { padding: 0 12px; }
  .masthead { padding: 16px 0 22px; }
  .masthead__bar { gap: 8px; }
  .brand__seal { width: 34px; height: 34px; font-size: 19px; }
  .brand__title { font-size: 17px; }
  .brand__eyebrow { display: none; }
  .topnav { gap: 10px; font-size: 12px; }
  .topnav a:nth-child(1) { display: none; }
  .icon-btn { width: 30px; height: 30px; }

  .cal-adwrap { margin-top: 12px; }
  .cal-hero { padding-top: 20px; padding-bottom: 18px; }
  .cal-hero__sub { font-size: 12.5px; }
  .cal-today { padding: 13px 14px 14px; }
  .cal-today__day { font-size: 42px; }
  .cal-today__lunar { font-size: 13px; }

  .cal-toolbar { padding: 9px 10px; gap: 8px; }
  .cal-nav { gap: 6px; }
  .cal-nav__btn { width: 36px; height: 36px; }
  .cal-nav__title { font-size: 15px; }
  .cal-nav__title select { font-size: 16px; }
  .cal-actions .ghostbtn { padding: 7px 10px; }

  .cal-week span { padding: 7px 0; font-size: 10px; letter-spacing: 0.06em; }
  .cal-grid { border-radius: 0 0 3px 3px; }
  .cal-cell { min-height: 60px; padding: 5px 4px 6px; gap: 1px; }
  .cal-cell__d { font-size: 14px; }
  .cal-cell__lunar { font-size: 9.5px; letter-spacing: -0.02em; }
  .cal-cell__badge { font-size: 8px; padding: 0 2px; }
  .cal-cell__events { gap: 2px; }
  .cal-cell__dot { width: 4px; height: 4px; }
  .cal-cell__n { display: none; }
  .cal-legend { gap: 10px; font-size: 10px; margin-top: 10px; }

  .dp-head { padding: 14px 16px 12px; }
  .dp-head__date { font-size: 20px; }
  .dp-body { padding: 14px 16px 20px; }
  .dp-yiji { gap: 8px; }
  .dp-yiji > div { padding: 8px 10px; }
  .dp-yiji p { font-size: 11.5px; }
  .dp-grid dd { font-size: 12px; }
  .cal-side { padding-bottom: 0; }
  .footer { padding: 26px 0 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .day-panel, .cal-scrim { animation: none !important; transition: none !important; }
}
