/* ==========================================================================
   dashboard.css · 首页工作台与首页改版（升级项 07b / 07c，只在首页加载）
   --------------------------------------------------------------------------
   这里的每一条改版规则都挂在 html[data-labs~="dashboard"] 后面（07c 起开关默认打开），
   访客在主题页关掉开关就回到改版前的首页。<html data-labs> 由 js/theme-custom.js 在首帧前写好，
   所以首帧就是对应的版式，不会等脚本跑完再跳一次。
   ========================================================================== */

/* ---------- 开关关闭时：新增的节点不占位 ---------- */
.dashboard,
.hero__date,
.hero__today { display: none; }
.hero__main { display: contents; }

/* ======================================================================
   首屏：左侧日期 / 农历 + 标题 + 搜索，右侧今日概览（07c）
   ====================================================================== */
html[data-labs~="dashboard"] .hero { padding-block: clamp(1.25rem, 3vw, 2.25rem); }
html[data-labs~="dashboard"] .hero__inner {
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
  align-items: center;
  justify-items: stretch;
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
  row-gap: var(--space-4);
  text-align: start;
}
html[data-labs~="dashboard"] .hero__main {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  min-width: 0;
}
html[data-labs~="dashboard"] .hero__title { max-width: none; }
html[data-labs~="dashboard"] .hero__search { max-width: 640px; }

html[data-labs~="dashboard"] .hero__date {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  min-height: 1.75rem;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.hero__date strong { color: var(--text); font-weight: 650; }

html[data-labs~="dashboard"] .hero__today {
  display: block;
  min-width: 0;
  padding: var(--space-4) var(--space-5) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.hero__today-title {
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 650;
  color: var(--text-muted);
}
/* 渲染前按实测高度预留，避免首屏内容出现时推开下面的版块（数字两行 197px；一行 / 窄屏见下方媒体查询） */
.hero__today-body:empty { min-height: 197px; }

.today-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}
.today-stat { display: grid; gap: 2px; min-width: 0; }
.today-stat__label { font-size: var(--text-xs); color: var(--text-muted); }
.today-stat__value {
  font-size: var(--text-xl);
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.today-stat__hint { font-size: var(--text-xs); color: var(--text-faint); }
.today-stat__bar {
  display: block;
  height: 4px;
  margin-top: var(--space-1);
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent) var(--progress, 0%), var(--surface-strong) var(--progress, 0%));
}

@media (max-width: 900px) {
  html[data-labs~="dashboard"] .hero__inner { grid-template-columns: minmax(0, 1fr); }
}
/* 单栏但还够宽：四个数字排成一行，首屏不超过 60vh */
@media (min-width: 481px) and (max-width: 900px) {
  .today-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero__today-body:empty { min-height: 93px; }
}
@media (max-width: 480px) {
  .hero__today-body:empty { min-height: 170px; }
  html[data-labs~="dashboard"] .hero__desc { display: none; }
  html[data-labs~="dashboard"] .hero__today { padding: var(--space-3) var(--space-4) var(--space-4); }
  .today-stats { gap: var(--space-3) var(--space-4); }
  .today-stat__value { font-size: var(--text-lg); }
}

/* 工作台取代原来的「我的收藏」版块（快捷访问里就是收藏） */
html[data-labs~="dashboard"] #favorites { display: none; }

/* ======================================================================
   工作台（07b）
   ====================================================================== */
html[data-labs~="dashboard"] .dashboard { display: block; padding-block: clamp(0.75rem, 1.6vw, 1.25rem); }

.dashboard__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.dashboard__title { font-size: var(--text-lg); font-weight: 650; }
.dashboard__title:focus { outline: none; }
.dashboard__title:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-xs); }
.dashboard__tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.dashboard__hidden {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); color: var(--text-muted);
}
.dashboard__tools .btn:disabled { opacity: 0.5; cursor: default; }

.dashboard__grid {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  margin: 0; padding: 0; list-style: none;
}
@media (max-width: 1100px) { .dashboard__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .dashboard__grid { grid-template-columns: minmax(0, 1fr); } }

/* 首屏防偏移：卡片由延迟脚本渲染，渲染前按默认布局（三张卡片、没有收藏）的实测高度预留，只作用于 :empty。
   卡片内容大改时请重新量（量法见 tests/e2e/dashboard.spec.js 的 CLS 用例）。 */
.dashboard__grid:empty { min-height: 288px; }
@media (max-width: 1100px) { .dashboard__grid:empty { min-height: 538px; } }
@media (max-width: 767px) { .dashboard__grid:empty { min-height: 660px; } }
/* 开关 notes 打开（08 发布起默认）：五张卡片（多了待办、最近笔记，都是空的）的实测高度 */
html[data-labs~="notes"] .dashboard__grid:empty { min-height: 462px; }
@media (max-width: 1100px) { html[data-labs~="notes"] .dashboard__grid:empty { min-height: 710px; } }
@media (max-width: 767px) { html[data-labs~="notes"] .dashboard__grid:empty { min-height: 965px; } }

/* ---------- 卡片 ---------- */
.dash-card {
  display: flex; flex-direction: column; gap: var(--space-3);
  min-width: 0; padding: var(--space-3) var(--space-4) var(--space-4);
}
.dash-card__head { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; }
.dash-card__head .sortable-handle { margin-inline-start: calc(var(--space-2) * -1); }
.dash-card__icon { width: 16px; height: 16px; color: var(--accent); flex: none; }
.dash-card__title { margin-inline-end: auto; font-size: var(--text-sm); font-weight: 650; }
.dash-card .dash-card__hide { width: 32px; min-height: 32px; color: var(--text-faint); }
.dash-card .dash-card__hide:hover { color: var(--text); }
.dash-card .dash-card__hide .icon { width: 16px; height: 16px; }
.dash-card.is-grabbed { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }
.dash-card.is-dragging {
  position: relative; z-index: 5;
  background: var(--bg-elev); border-color: var(--accent-line); box-shadow: var(--shadow-lg);
}
@media (pointer: coarse) {
  .dash-card .dash-card__hide { width: 44px; min-height: 44px; }
}

.dash-empty { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
.dash-empty span { margin-inline-end: var(--space-2); }
.dash-empty--all {
  grid-column: 1 / -1; padding: var(--space-4);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-md); list-style: none;
}
.dash-more { font-size: var(--text-xs); font-weight: 600; color: var(--accent); }
.dash-more:hover { text-decoration: underline; }

/* 快捷访问 */
.dash-links {
  display: grid; gap: var(--space-1) var(--space-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0; padding: 0; list-style: none;
}
.dash-link {
  display: flex; align-items: center; gap: var(--space-2);
  min-width: 0; padding: var(--space-2);
  color: var(--text); border-radius: var(--radius-md);
}
.dash-link:hover { background: var(--surface-hover); }
.dash-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dash-link__mono.feature__icon { width: 28px; height: 28px; font-size: 14px; flex: none; }
.dash-link__name { overflow: hidden; font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.dash-link__tag { margin-inline-start: auto; flex: none; }

/* 待办（08c，开关 notes） */
.dash-todo-form { margin: 0; }
.dash-todo-form__input { min-height: 36px; padding-block: 0.4em; font-size: var(--text-sm); }
.dash-todos { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.dash-todo { display: flex; align-items: center; gap: var(--space-2); min-width: 0; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.dash-todo:hover { background: var(--surface-hover); }
.dash-todo.is-high { box-shadow: inset 2px 0 0 var(--accent); }
.dash-todo__check { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent-solid); cursor: pointer; }
.dash-todo__text { flex: 1; min-width: 0; overflow: hidden; font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.dash-todo__due { flex: none; font-size: var(--text-xs); color: var(--text-muted); }
.dash-todo__due--today { color: var(--accent); font-weight: 600; }
.dash-todo__due--overdue { color: var(--danger); font-weight: 600; }
@media (pointer: coarse) { .dash-todo { min-height: 44px; } .dash-todo__check { width: 20px; height: 20px; } }

/* 最近笔记（08c，开关 notes） */
.dash-notes { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.dash-note { display: flex; align-items: center; gap: var(--space-2); min-width: 0; padding: var(--space-2); color: var(--text); border-radius: var(--radius-sm); }
.dash-note:hover { background: var(--surface-hover); }
.dash-note:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dash-note__pin { width: 13px; height: 13px; flex: none; color: var(--accent); }
.dash-note__title { flex: 1; min-width: 0; overflow: hidden; font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.dash-note__time { flex: none; font-size: var(--text-xs); color: var(--text-faint); }
.dash-notes__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin: 0; }

/* 常用工具 */
.dash-tools {
  display: grid; gap: var(--space-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0; padding: 0; list-style: none;
}
.dash-tool {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
  font: inherit; text-align: start; color: var(--text);
  background: var(--surface-strong); border: 1px solid var(--border); border-radius: var(--radius-md);
  cursor: pointer;
}
.dash-tool:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.dash-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dash-tool__name { font-size: var(--text-sm); font-weight: 600; }
.dash-tool__desc {
  display: -webkit-box; overflow: hidden;
  font-size: var(--text-xs); color: var(--text-muted);
  -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}

/* 快速操作 */
.dash-actions { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.dash-action { width: 100%; justify-content: flex-start; gap: var(--space-2); }
.dash-action__label { margin-inline-end: auto; }
.dash-action kbd { font-size: var(--text-xs); color: var(--text-faint); }

/* ======================================================================
   全部网站：紧凑行卡（07c）
   卡片 DOM 不变（js/toolkit.js），只改排版：字母标 | 名称 + 域名 | 收藏星标；说明与分类徽章收起。
   ====================================================================== */
html[data-labs~="dashboard"] #siteGrid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2) var(--space-3);
}
@media (max-width: 1024px) { html[data-labs~="dashboard"] #siteGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { html[data-labs~="dashboard"] #siteGrid { grid-template-columns: minmax(0, 1fr); } }

html[data-labs~="dashboard"] #siteGrid .site-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "icon title fav" "icon url fav";
  align-items: center;
  column-gap: var(--space-3);
  row-gap: 0;
  height: auto;
  padding: var(--space-2) var(--space-3);
}
html[data-labs~="dashboard"] #siteGrid .site-card__head { display: contents; }
html[data-labs~="dashboard"] #siteGrid .site-card__head .badge,
html[data-labs~="dashboard"] #siteGrid .site-card .feature__desc { display: none; }
html[data-labs~="dashboard"] #siteGrid .feature__icon { grid-area: icon; width: 32px; height: 32px; font-size: 15px; }
html[data-labs~="dashboard"] #siteGrid .card-fav { grid-area: fav; margin: 0; }
html[data-labs~="dashboard"] #siteGrid .site-card .feature__title {
  grid-area: title;
  min-height: 0;
  margin: 0;
  font-size: var(--text-sm);
  -webkit-line-clamp: 1;
}
html[data-labs~="dashboard"] #siteGrid .site-card__url {
  grid-area: url;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

/* 首屏防偏移：紧凑行卡的实测高度（默认 16 个站点），覆盖 layout.css 里按大卡片预留的高度 */
html[data-labs~="dashboard"] #siteGrid:empty { min-height: 381px; }
@media (max-width: 1024px) { html[data-labs~="dashboard"] #siteGrid:empty { min-height: 503px; } }
@media (max-width: 600px) { html[data-labs~="dashboard"] #siteGrid:empty { min-height: 988px; } }

/* ======================================================================
   热爱：两张大图卡左右并列（07c 起是整宽横幅，V2.1 改为并列）
   ≥900px 两列等宽等高，窄屏上下排。图片全不透明铺满，index.html 写了 800w / 1200w 的 srcset，
   sizes 按半宽声明，浏览器按实际宽度与像素密度选一档，同一张图只下载一次。
   文字整块压在卡片下半部，遮罩自上而下：上半部露出照片，文字处是与原卡片同色的近实色，
   对比度与改版前一致（components.css §热爱专题）。
   ====================================================================== */
html[data-labs~="dashboard"] .passion-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
@media (min-width: 900px) {
  html[data-labs~="dashboard"] .passion-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
}
html[data-labs~="dashboard"] .passion-card {
  justify-content: flex-end;
  gap: var(--space-4);
  min-height: clamp(340px, 34vw, 420px);
}
html[data-labs~="dashboard"] .passion-card__media { opacity: 1; }
html[data-labs~="dashboard"] .passion-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  /* 文字块约占卡片下方 55%：从 52% 起是近实色，上方逐渐透出照片 */
  background: linear-gradient(180deg, transparent 0%, var(--passion-fade) 32%, var(--passion-scrim) 52%, var(--passion-scrim) 100%);
}
html[data-labs~="dashboard"] .passion-card--city {
  --passion-scrim: rgba(234, 244, 250, 0.96);
  --passion-fade: rgba(234, 244, 250, 0.55);
}
html[data-labs~="dashboard"] .passion-card--racing {
  --passion-scrim: rgba(7, 10, 16, 0.94);
  --passion-fade: rgba(7, 10, 16, 0.5);
}
/* 照片主体在上半部：取景往上偏，避免人物头部被遮罩盖住 */
html[data-labs~="dashboard"] .passion-card__media img { object-position: center 20%; }
/* 只在允许动效时放大：系统「减少动态效果」与站内「减少动效」两种来源都不放大（13c 修复：这条特异性高于 components.css 的复位） */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  html[data-labs~="dashboard"]:not([data-motion="reduce"]) .passion-card:hover .passion-card__media { transform: scale(1.03); opacity: 1; }
}
