/* ============================================================================
 * 阿月的宝库 · 前端规范层  theme.css
 * 用法：放在站点根，页面里 <link rel="stylesheet" href="/theme.css"> 覆盖原样式
 * 适用：现有液态玻璃首页 / Typecho 主题改造 / 以后新加的任意页面
 * 依据：emil-design-eng（动效决策）+ mobile-native（手机端平台层）
 * ==========================================================================*/

/* ---------- 1. 设计令牌：一套值，全站只认它 ---------- */
:root {
  /* 动效曲线 —— 内置 ease/ease-in-out 太弱，这里换强曲线 */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);      /* 进入、悬停、按压回复 */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);     /* 屏幕内位移/形变 */
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);      /* 抽屉、面板 */

  /* 时长 —— UI 一律 < 300ms */
  --t-press: 140ms;   /* 按压反馈 */
  --t-hover: 160ms;   /* 悬停变色 */
  --t-enter: 220ms;   /* 卡片/弹层进入 */

  /* 玻璃层（保留你的风格，但把成本压下来） */
  --glass-bg:     rgba(218, 236, 248, 0.55);
  --glass-blur:   16px;          /* 28px → 16px：手机上 blur 半径翻倍=掉帧 */
  --glass-border: rgba(255, 255, 255, 0.7);
  --radius:       22px;
  --radius-sm:    14px;

  /* 语义色 */
  --accent:       #2c8cb4;
  --accent-light: #5ab9dc;
  --text-primary: #1e3a4c;
  --text-muted:   rgba(36, 68, 82, 0.65);
}

/* ---------- 2. 平台层基线（mobile-native 的必做项） ---------- */
html {
  -webkit-tap-highlight-color: transparent;  /* 干掉 iOS/Android 点击灰蓝闪 */
  -webkit-text-size-adjust: 100%;            /* 横屏不放大字号 */
  overscroll-behavior-y: none;               /* 首页是单屏卡片流，禁下拉刷新抢滚动 */
  scroll-behavior: smooth;
}

/* 首屏高度用 svh：地址栏出现/收起都不跳 */
.hero,
.container {
  min-height: 100svh;
}

/* 可点元素：去掉 300ms 点击延迟 + 长按不选字 */
button, a, [role="button"], .nav-btn, .item-card {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
/* 正文必须可选（复制地址、报错信息） */
p, li, article, .post-content { -webkit-user-select: auto; user-select: auto; }

/* 输入框 16px 起：低于 16px iOS 会强制放大页面 */
input, textarea, select { font-size: 16px; }

/* ---------- 3. 玻璃卡片：进入动效改对 ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(31, 100, 135, .10), inset 0 1px 0 rgba(255, 255, 255, .9);
  /* 只过渡真正变化的属性，不用 `all` */
  transition:
    transform var(--t-enter) var(--ease-out),
    box-shadow var(--t-enter) var(--ease-out);
}

/* 进入：从 0.96 + opacity 起，不要 scale(0) */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.item-card, .header-card {
  animation: riseIn var(--t-enter) var(--ease-out) both;
}

/* 交错进场：30–80ms 一档，不要 150ms 那种拖沓节奏 */
.grid-wrap .item-card:nth-child(1) { animation-delay: 40ms; }
.grid-wrap .item-card:nth-child(2) { animation-delay: 80ms; }
.grid-wrap .item-card:nth-child(3) { animation-delay: 120ms; }

/* ---------- 4. 悬停必须门控：触摸屏上 :hover 会粘住 ---------- */
@media (hover: hover) and (pointer: fine) {
  .nav-btn:hover {
    background: rgba(100, 195, 230, 0.35);
    transform: translateY(-2px);
  }
  .item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(31, 100, 135, .14), inset 0 1px 0 rgba(255, 255, 255, .9);
  }
  .avatar:hover { transform: scale(1.04); }
}

/* 按压反馈：手指一落就有反应，不等 click */
.nav-btn:active,
.item-card:active,
button:active {
  transform: scale(0.97);
  transition-duration: var(--t-press);
}
.nav-btn { transition: transform var(--t-press) var(--ease-out), background var(--t-hover) ease; }

/* ---------- 5. 背景层：把持续动画的成本压下来 ---------- */
/* 四个 520px 的 blur(80px) 光斑在手机上等于持续掉帧。
   改成：颜色保留、动画降级为透明度呼吸、移动端直接静止。 */
.liquid-bg .blob {
  filter: blur(60px);
  opacity: .45;
  will-change: transform;
}
@media (max-width: 640px) {
  .liquid-bg .blob { animation: none !important; filter: blur(48px); opacity: .35; }
  /* 移动端不锁背景：iOS 上 background-attachment: fixed 会拖慢滚动 */
  body { background-attachment: scroll; }
}

/* ---------- 6. 光斑动画只动 transform（合成层，不触发重排重绘） ---------- */
@keyframes driftA { 50% { transform: translate3d(40px, 60px, 0) scale(1.06); } }
@keyframes driftB { 50% { transform: translate3d(-60px, -40px, 0) scale(1.1); } }
.blob-1 { animation: driftA 26s var(--ease-in-out) infinite; }
.blob-2 { animation: driftB 32s var(--ease-in-out) infinite; }

/* ---------- 7. 回到顶部 / 浮动按钮：可打断的 transition，不用 keyframes ---------- */
.back-to-top,
.bg-toggle-btn {
  transition:
    opacity var(--t-enter) var(--ease-out),
    transform var(--t-enter) var(--ease-out),
    visibility var(--t-enter);
}
.back-to-top { opacity: 0; visibility: hidden; transform: translateY(10px); }
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:active,
.bg-toggle-btn:active { transform: scale(0.94); }

/* ---------- 8. 列表 / 资源卡片（软件、安全、论坛通用） ---------- */
.list-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: transform var(--t-press) var(--ease-out), background var(--t-hover) ease;
  touch-action: manipulation;
}
.list-item:active { transform: scale(0.985); background: rgba(255, 255, 255, 0.6); }

@media (hover: hover) and (pointer: fine) {
  .list-item:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.58); }
}

/* 列表进入用 opacity+位移，一次只动 8px，别做大位移 */
@keyframes listIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.list-item { animation: listIn 200ms var(--ease-out) both; }

/* ---------- 9. 下载按钮：点击后必须给状态，不能"点了没反应" ---------- */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--t-press) var(--ease-out), filter var(--t-hover) ease;
}
.btn-download:active { transform: scale(0.97); }
.btn-download[data-state="loading"] { filter: saturate(0.4) brightness(1.1); pointer-events: none; }
.btn-download[data-state="loading"]::after {
  content: "";
  width: 12px; height: 12px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 600ms linear infinite;   /* 转得快一点=显得加载快 */
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 10. 焦点可见（键盘用户） ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 11. 减弱动效：留透明度和颜色，去掉位移 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .liquid-bg .blob { animation: none !important; }
  .item-card, .header-card, .list-item { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ---------- 12. 头图/头像等装饰元素：只动 transform，不动宽高 ---------- */
.avatar {
  transition: transform var(--t-enter) var(--ease-out);
  will-change: transform;
}

/* ---------- 13. 图片基线 + 选中态 + 页脚（2026-10-24 优化追加） ---------- */
/* 图片永远不撑破容器；带 width/height 属性的图保持比例，避免布局抖动 */
img {
  max-width: 100%;
  height: auto;
  -webkit-user-drag: none;
}
/* 头像/图标有显式尺寸规则覆盖，不写死在这里 */

::selection {
  background: rgba(90, 185, 220, 0.28);
  color: var(--text-primary);
}

/* 站点名用 h1（SEO），去掉浏览器默认外边距 */
h1.nickname {
  margin: 0 0 10px;
  font-size: clamp(26px, 4vw, 32px);
  line-height: 1.25;
  letter-spacing: 1px;
}

/* 页脚附加链接行（首页新增：内容站 / 小工具 / 站点地图） */
footer .foot-links {
  margin-top: 10px;
  font-size: 13.5px;
  opacity: 0.9;
}
footer .foot-links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(44, 140, 180, 0.28);
  padding-bottom: 1px;
  transition: color var(--t-hover) ease, border-color var(--t-hover) ease;
}
@media (hover: hover) and (pointer: fine) {
  footer .foot-links a:hover { color: var(--accent-light); border-color: var(--accent-light); }
}

