/* ==========================================================================
   yanger blog · components.css
   主题开关 / 文章卡片 / chip 与 tag / 搜索框 / loader / 状态块 / skip-link
   ========================================================================== */

/* ---------- skip link（键盘用户） ---------- */
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 8px 14px; border-radius: 8px;
  background: var(--ink); color: var(--page);
  font-size: 14px; text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- 主题切换（单图标按钮：浅色显月、深色显日） ---------- */
.theme-toggle {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .3s, background-color .3s;
}
.theme-toggle:hover { color: var(--ink); background: var(--surface); }
.theme-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.theme-toggle:disabled { cursor: default; }
.theme-icon {
  grid-area: 1 / 1; /* 两个图标重叠，靠透明度+旋转切换 */
  width: 18px; height: 18px;
  transition: opacity .35s, transform .45s cubic-bezier(.22, 1, .36, 1);
}
.theme-icon.moon { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-icon.sun { opacity: 0; transform: rotate(-70deg) scale(.55); }
[data-theme="dark"] .theme-icon.moon { opacity: 0; transform: rotate(70deg) scale(.55); }
[data-theme="dark"] .theme-icon.sun { opacity: 1; transform: rotate(0deg) scale(1); }

/* ---------- 搜索框（头部） ---------- */
.search-input {
  width: 150px; padding: 6px 12px;
  border: 1px solid var(--control-border); border-radius: 999px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 13.5px;
  outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color .25s, width .35s cubic-bezier(.22, 1, .36, 1), box-shadow .25s;
}
.search-input::placeholder { color: var(--faint); }
.search-input:focus { border-color: var(--ink); width: 210px; box-shadow: 0 0 0 4px var(--control-glow); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* 搜索页的大输入框（所有屏幕尺寸都可见，移动端同样可用） */
.search-box { margin: 0 0 28px; }
.search-input--page,
.search-input--page:focus {
  width: 100%;
  padding: 13px 18px;
  font-size: 16px; /* ≥16px：避免 iOS 聚焦时自动放大页面 */
  border-radius: 12px;
}

/* ---------- 头部全局搜索下拉面板 ---------- */
.site-search { position: relative; }
.search-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  width: 340px; max-width: calc(100vw - 32px);
  padding: 6px;
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 16px 48px var(--shadow);
}
.search-item { display: block; padding: 9px 12px; border-radius: 9px; text-decoration: none; }
.search-item:hover, .search-item[aria-selected="true"] { background: var(--surface); }
.search-item-title {
  display: block;
  font-size: 14px; line-height: 1.5; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-panel mark {
  background: transparent; color: inherit; padding: 0;
  font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.search-item-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.search-panel-status { margin: 0; padding: 8px 12px; font-size: 12.5px; color: var(--faint); }
.search-more {
  display: block; margin-top: 6px; padding: 9px 12px;
  border-top: 1px solid var(--rule);
  font-size: 13px; color: var(--muted); text-decoration: none;
  border-radius: 0 0 10px 10px;
}
.search-more:hover { color: var(--ink); }

/* ---------- 回到顶部（滚动到底部时出现） ---------- */
.back-to-top {
  position: fixed; z-index: 20;
  right: clamp(16px, 3vw, 32px);
  bottom: calc(clamp(16px, 3vw, 32px) + env(safe-area-inset-bottom, 0px));
  display: grid; place-items: center;
  width: 42px; height: 42px; padding: 0;
  border: 1px solid var(--rule); border-radius: 50%;
  background: var(--page); color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .35s, transform .35s, color .25s, border-color .25s;
}
.back-to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.back-to-top:hover { color: var(--ink); border-color: var(--ink); }
.back-to-top:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.back-to-top svg { width: 18px; height: 18px; }

/* ---------- 骨架屏（统一组件：基础条 + 语义尺寸 + 宽度变体，各页按真实结构组合） ---------- */
/* 加载完成即被真实内容原地替换；无 JS 时自动隐藏（见 base.css 的 .no-js 规则）。 */
.sk-bar {
  display: block;
  background: var(--skeleton);
  border-radius: 5px;
  animation: sk-pulse 1.6s ease-in-out infinite;
}
@keyframes sk-pulse { 50% { opacity: .6; } }

/* 语义尺寸：文章页与归档页共用同一套；宽度按各页真实内容在标记里指定 */
.sk-title { height: 34px; border-radius: 8px; margin: 10px 0; }    /* 页面 / 文章标题 */
.sk-meta { height: 13px; }                                         /* 篇数 / 日期等元信息 */
.sk-line { height: 13px; margin-bottom: 16px; }                    /* 正文行 */
.sk-chip { height: 27px; border-radius: 999px; }                   /* 标签胶囊 */
.sk-year { height: 24px; border-radius: 6px; margin: 6px 0 14px; } /* 归档年份 */
.sk-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.sk-time { height: 12px; width: 44px; flex: none; }
.sk-cell { height: 13px; }

/* 宽度变体 */
.sk-w60 { width: 60%; }
.sk-w80 { width: 80%; }

/* 首页列表：对齐 post-card 的边框与留白 */
.sk-card {
  display: flex; flex-direction: column; gap: 11px;
  padding: 26px 4px;
  border-top: 1px solid var(--rule);
}
.sk-card:last-child { border-bottom: 1px solid var(--rule); }
.sk-card .sk-line { margin-bottom: 0; }
.sk-card .sk-meta { width: 130px; }
.sk-card-title { height: 18px; width: 56%; }

/* 文章页：对齐 post-header / post-body 的间距节奏 */
.sk-article .sk-title { margin-bottom: 18px; }
.sk-article .sk-meta { margin-bottom: 40px; }
.sk-article .sk-gap { margin-top: 24px; }

/* 移动端：输入框收起，改为图标入口 */
.search-link-icon { display: none; color: var(--muted); transition: color .25s; }
.search-link-icon:hover { color: var(--ink); }
.search-link-icon svg { display: block; width: 18px; height: 18px; }
@media (max-width: 719px) {
  .site-search { display: none; }
  .search-link-icon { display: inline-flex; }
}

/* ---------- 文章卡片 ---------- */
.cards { display: flex; flex-direction: column; }
.post-card { border-top: 1px solid var(--rule); }
.post-card:last-child { border-bottom: 1px solid var(--rule); }
.card-link { display: block; padding: 26px 4px; text-decoration: none; }
.card-title {
  margin: 0 0 8px;
  font-size: 19px; font-weight: 600; line-height: 1.5;
  transition: opacity .25s;
}
.card-link:hover .card-title,
.card-link:focus-visible .card-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; }
.card-summary {
  margin: 0 0 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--muted); font-size: 14.5px; line-height: 1.8;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; color: var(--faint); }
.card-meta time { font-variant-numeric: tabular-nums; }

/* ---------- tag（静态）与 chip（可交互） ---------- */
.tag {
  display: inline-flex; padding: 2px 10px;
  border: 1px solid var(--rule); border-radius: 999px;
  font-size: 12px; color: var(--faint); white-space: nowrap;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 14px;
  border: 1px solid var(--rule); border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 13px; text-decoration: none; cursor: pointer;
  transition: border-color .25s, color .25s, background-color .25s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--page); }
.chip-count { font-size: 11px; color: var(--faint); }
.chip[aria-current="true"] .chip-count { color: var(--page); opacity: .72; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--control-border); border-radius: 10px;
  background: transparent; color: var(--ink);
  font-size: 14px; cursor: pointer;
  transition: border-color .25s, box-shadow .25s;
}
.btn:hover { border-color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- 加载 / 状态块 ---------- */
.global-loader {
  position: fixed; z-index: 10; inset: 0;
  display: grid; place-items: center;
  background: var(--page);
  transition: opacity .45s ease;
}
.loader-orbit {
  position: relative; width: 36px; height: 36px;
  border: 1px solid var(--loader-track);
  border-top-color: var(--ink); border-right-color: var(--ink);
  border-radius: 50%;
  animation: orbit 1.1s linear infinite;
}
.loader-orbit::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 12px var(--control-glow);
}
.is-ready .global-loader { opacity: 0; pointer-events: none; }
@keyframes orbit { to { transform: rotate(360deg); } }

.list-status { margin: 0; padding: 24px 0; font-size: 14px; color: var(--muted); }
.status-box {
  border: 1px solid var(--rule); border-radius: 12px;
  padding: 20px 24px;
  font-size: 14px; line-height: 1.9; color: var(--muted);
}
.status-box strong { color: var(--ink); }
.status-box code {
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono); font-size: 12.5px;
}
.status-box a { color: var(--ink); }

/* ---------- 归档 ---------- */
/* 年份、标签两行筛选共用一套样式：相同外观，各自独立换行 / 横向滚动 */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.archive-filters { display: grid; gap: 10px; padding-bottom: 32px; }
.archive-group { margin-bottom: 40px; }
.archive-year { margin: 0 0 14px; font-family: var(--display); font-size: 26px; font-weight: 400; }
.archive-items { list-style: none; margin: 0; padding: 0; }
.archive-items li {
  display: flex; gap: 16px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.archive-items time { flex: none; width: 4.5em; color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.archive-items a { text-decoration: none; }
.archive-items a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; }

/* 移动端标签过多时会换行成七八行，把归档列表挤出可视区。
   改为单行横向滚动：筛选区高度固定，列表始终有足够空间。 */
@media (max-width: 719px) {
  .screen--split .archive-filters { gap: 2px; padding-bottom: 14px; }
  .screen--split .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
    /* 抵消 .container 的内边距，让滚动区贴到屏幕两侧，首尾标签仍与内容对齐 */
    margin-inline: -18px;
    padding: 5px 18px;
  }
  .screen--split .filter-row::-webkit-scrollbar { display: none; width: 0; height: 0; }
  .screen--split .filter-row .chip { flex: none; }
  /* 两侧渐隐提示「还有更多标签」，同时避免边缘芯片被硬生生切断 */
  .screen--split .filter-row.can-scroll-right {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .screen--split .filter-row.can-scroll-left {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
  }
  .screen--split .filter-row.can-scroll-left.can-scroll-right {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  }
}

/* ---------- 关于 ---------- */
.about-avatar { display: block; width: 88px; height: 88px; border-radius: 50%; margin: 0 0 28px; }

/* Canvas 个人证件：投影跟随卡片实际轮廓（canvas 背景透明，用 drop-shadow 而非 box-shadow） */
.idcard-figure { margin: 0 0 44px; }
.idcard {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 680 / 420; /* JS 按窄屏切换为 360 / 540 */
  filter: drop-shadow(0 14px 28px var(--shadow));
}
.idcard-caption {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--faint);
}
.idcard-caption span:last-child { font-family: var(--mono); letter-spacing: .04em; }
