/* =====================================================================
   魔法猫 · 样式表
   移动优先：一屏一天；宽度 100vw，最大 540px 居中。
   视觉「活扣」：5 套主题 = 5 组 CSS 变量（--title/--soft/--sub/--ink/
   --sub2/--arrow/--divider/--accent/--card/--paper）+ 1 张底图。
   换视觉只改对应 .t-* 块的变量或底图；历史每天用其当日 theme，
   渲染时读取 data 里的 theme，永不随后更。
   ===================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: #c9d2d5;
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  color: #33414a;
  overscroll-behavior: none;
}

.app {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #e7edee;
  box-shadow: 0 0 40px rgba(40, 60, 70, .18);
}

/* ---- 横向滑动轨道：一屏一天 ---- */
.track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }

.screen {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
}

/* ---- 背景底图 + 顶部雾/柔光 ---- */
.bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.bg::after { content: ""; position: absolute; inset: 0; }

/* ---- 内容容器 ---- */
.inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 26px) 24px
           calc(env(safe-area-inset-bottom, 0px) + 18px);
}

/* 1. 头部（固定在上，两行） */
.head { flex: 0 0 auto; }
.head h1 {
  font-size: clamp(25px, 7.2vw, 34px);
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--title);
}
.head .tag {
  margin-top: 3px;
  font-size: 12px;
  letter-spacing: .34em;
  color: var(--soft);
}

/* 2. 动态行：城市 · 天气 · 日期 */
.dyn {
  flex: 0 0 auto;
  margin-top: 10px;
  font-size: clamp(13px, 3.8vw, 16px);
  letter-spacing: .02em;
  color: var(--sub);
}

/* 3. 大图（圆角、cover 裁满、不留黑边、相纸白边） */
.photo {
  flex: 1 1 auto;
  min-height: 0;
  margin: 16px 2px 0;
  padding: 7px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(50, 70, 80, .22);
}
.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 11px;
}

/* 4-6. 正文卡：一句话 · 分割线 · 一书 */
.card-body {
  flex: 0 0 auto;
  margin-top: 14px;
  padding: 16px 20px 18px;
  background: var(--card);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.quote {
  font-size: clamp(16px, 4.5vw, 21px);
  line-height: 1.7;
  letter-spacing: .01em;
  color: var(--ink);
}
.quote::before { content: "「"; color: var(--soft); }
.quote::after  { content: "」"; color: var(--soft); }

.divider {
  margin: 14px 0 13px;
  border: 0;
  border-top: 1px solid var(--divider);
}

.bname {
  font-size: clamp(17px, 4.6vw, 21px);
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--title);
}
.bnote {
  margin-top: 9px;
  font-size: clamp(12px, 3.5vw, 14px);
  line-height: 1.65;
  color: var(--sub2);
}
.read {
  margin-top: 14px;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--sub2);
  opacity: .55;
}

/* 7. 底部：日期篇号 + 日历 */
.card-foot {
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  font-size: clamp(12px, 3.5vw, 15px);
  color: var(--sub2);
}
.cal-btn {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: clamp(13px, 3.8vw, 16px);
  color: var(--accent);
  cursor: pointer;
  padding: 2px 2px 2px 10px;
}

/* 8. 两侧大箭头 */
.arrow {
  position: absolute;
  top: 40%;
  transform: translateY(-50%);
  z-index: 6;
  width: 44px;
  height: 78px;
  border: 0;
  background: transparent;
  color: var(--arrow, rgba(90, 110, 120, .8));
  font-family: serif;
  font-size: 54px;
  line-height: 78px;
  cursor: pointer;
  user-select: none;
  transition: opacity .2s;
}
.arrow:active { opacity: .5; }
.arrow.l { left: -4px; }
.arrow.r { right: -4px; }
.arrow[disabled] { opacity: .22; pointer-events: none; }

/* ======================= 点大图放大 ======================= */
.lightbox {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(10, 14, 18, .94);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

/* ======================= 日历（底部弹出） ======================= */
.cal-mask {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  background: rgba(30, 40, 46, .34);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fade .18s ease;
}
.cal-mask[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.cal {
  width: 100%;
  background: #fbfcfc;
  border-radius: 20px 20px 0 0;
  padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 18px);
  color: #33414a;
  animation: rise .22s ease;
  box-shadow: 0 -12px 40px rgba(30, 45, 52, .28);
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }

.cal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.cal-title { font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.cal-nav {
  width: 40px; height: 34px;
  border: 0; background: transparent;
  font-size: 24px; color: #5c6b73; cursor: pointer;
}
.cal-week, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-week span {
  text-align: center;
  font-size: 11px;
  color: #aeb9bd;
  padding-bottom: 6px;
  font-family: system-ui, sans-serif;
}
.cal-grid .cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: 9px;
  color: #8b9aa0;
  font-family: system-ui, sans-serif;
  border: 0;
  background: transparent;
}
.cal-grid .cell.empty { visibility: hidden; }
.cal-grid .cell.has {
  color: #2c3a42;
  font-weight: 700;
  background: rgba(90, 110, 120, .10);
  cursor: pointer;
}
.cal-grid .cell.has::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #d28024;
}
.cal-grid .cell.cur { background: #3a4a52; color: #fff; }
.cal-grid .cell.cur::after { background: #fff; }
.cal-close {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: rgba(58, 74, 82, .08);
  color: #5c6b73;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ======================= 主题（视觉活扣） ======================= */

/* 热闹 · 晴：浅蓝米白＋多彩点。花底 → 米白卡 + 顶部白雾渐隐 */
.t-hot {
  background: #eef2f4;
  --title: #282214; --soft: #78848c; --sub: #5e6872;
  --ink: #342c1e; --sub2: #66727c;
  --arrow: rgba(90, 110, 120, .82);
  --divider: rgba(120, 130, 140, .5);
  --accent: #d28024;
  --card: rgba(255, 255, 253, .78);
  --paper: #fffffc;
}
.t-hot .bg {
  background-image:
    linear-gradient(180deg, rgba(255,255,253,.88) 0, rgba(255,255,253,0) 210px),
    url("assets/bg/hot.jpg");
}

/* 温暖 · 多云/阴：米黄棕＋纸纹。浅底 → 米白卡 */
.t-warm {
  background: #f3ece0;
  --title: #362614; --soft: #9a8060; --sub: #7a6246;
  --ink: #44301c; --sub2: #826a4e;
  --arrow: rgba(140, 110, 78, .82);
  --divider: rgba(150, 122, 92, .5);
  --accent: #a06e38;
  --card: rgba(255, 252, 245, .80);
  --paper: #fdf9f1;
}
.t-warm .bg {
  background-image:
    linear-gradient(180deg, rgba(255,252,245,.88) 0, rgba(255,252,245,0) 210px),
    url("assets/bg/warm.jpg");
}

/* 文艺 · 风：莫兰迪柔彩＋手绘点缀。花底 → 米白卡 + 轻雾 */
.t-art {
  background: #ecebe6;
  --title: #2c2a24; --soft: #848682; --sub: #646664;
  --ink: #36342e; --sub2: #6a6e6c;
  --arrow: rgba(120, 118, 110, .82);
  --divider: rgba(120, 122, 116, .5);
  --accent: #966e46;
  --card: rgba(250, 249, 244, .76);
  --paper: #faf8f2;
}
.t-art .bg {
  background-image:
    linear-gradient(180deg, rgba(250,249,244,.62) 0, rgba(250,249,244,0) 205px),
    url("assets/bg/art.jpg");
}

/* 安静 · 雪：冷白灰。浅底 → 白卡 */
.t-calm {
  background: #eef2f4;
  --title: #24323a; --soft: #9cacb6; --sub: #5e6e78;
  --ink: #303c44; --sub2: #6a7a84;
  --arrow: rgba(110, 132, 144, .82);
  --divider: rgba(130, 152, 162, .5);
  --accent: #466474;
  --card: rgba(255, 255, 255, .78);
  --paper: #fcfdfe;
}
.t-calm .bg {
  background-image:
    linear-gradient(180deg, rgba(255,255,255,.78) 0, rgba(255,255,255,0) 205px),
    url("assets/bg/calm.jpg");
}

/* 清爽 · 雨：极淡冷灰青蓝，纯代码生成（无底图）。
   对角渐变 #DEE4E7→#AABAC0 + 径向柔雾团（近似原高斯雾）。 */
.t-cool {
  background: #dee4e7;
  --title: #22323a; --soft: #96a8b2; --sub: #5c6c76;
  --ink: #2e3c44; --sub2: #687882;
  --arrow: rgba(104, 126, 136, .82);
  --divider: rgba(120, 145, 155, .5);
  --accent: #365c6a;
  --card: rgba(250, 252, 253, .55);
  --paper: #fafcfd;
}
.t-cool .bg {
  background-image: linear-gradient(155deg, #dee4e7 0%, #c8d2d6 52%, #aabac0 100%);
}
.t-cool .bg::after {
  background-image:
    radial-gradient(closest-side, rgba(236,240,242,.95), rgba(236,240,242,0) 72%) 22% 19% / 54% 44% no-repeat,
    radial-gradient(closest-side, rgba(236,240,242,.90), rgba(236,240,242,0) 72%) 80% 41% / 62% 46% no-repeat,
    radial-gradient(closest-side, rgba(236,240,242,.85), rgba(236,240,242,0) 72%) 17% 70% / 56% 46% no-repeat,
    radial-gradient(closest-side, rgba(236,240,242,.78), rgba(236,240,242,0) 72%) 87% 89% / 50% 40% no-repeat;
  filter: blur(34px);
}

/* 桌面宽屏：给手机框一点纵向留白，模拟手机竖屏 */
@media (min-width: 560px) {
  body { background: #b9c4c8; }
  .app { height: min(100dvh, 960px); margin-top: max(0px, calc((100dvh - 960px) / 2)); border-radius: 18px; }
}
