/* =========================================================================
   我的小家 · 基础骨架（变量 / 顶栏 / 抽屉 / 页脚 / 响应式）
   ========================================================================= */

/* ---------------------------------------------------------- 变量与主题 */
:root {
  --brand: #6d8cff;
  --brand-2: #a06bff;

  --radius: 18px;
  --radius-sm: 12px;
  --wrap: 1180px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
          "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0b0f19;
  --bg-soft: #0e1424;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #141b2e;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9edf7;
  --muted: #8d99b8;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
  --glow: radial-gradient(60% 55% at 50% 0%, rgba(109, 140, 255, 0.30), transparent 72%);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f5f7fc;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --line: rgba(16, 24, 40, 0.09);
  --line-strong: rgba(16, 24, 40, 0.16);
  --text: #131a2b;
  --muted: #5d6784;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.10);
  --glow: radial-gradient(60% 55% at 50% 0%, rgba(109, 140, 255, 0.22), transparent 72%);
  color-scheme: light;
}

/* ----------------------------------------------------------------- 基础 */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.75 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 主内容撑满视口，页脚在短页面（如 404）贴住底部 */
.page { flex: 1 0 auto; }

/* 顶部氛围光 —— 让暗色页面不显得死板 */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 520px;
  background: var(--glow);
  pointer-events: none;
  z-index: 0;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
      stroke-linecap: round; stroke-linejoin: round; }

::selection { background: rgba(109, 140, 255, 0.35); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 6px; }

/* 表单占位符：AA 对比度（不再用默认浅灰） */
::placeholder { color: var(--muted); opacity: 1; }

/* ---------- 丝滑动效基座：统一缓动 + 平滑滚动 + 进场淡入 ---------- */
html { scroll-behavior: smooth; }

.page { animation: page-in .38s cubic-bezier(.2,.7,.2,1) both; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.notice { animation: page-in .3s cubic-bezier(.2,.7,.2,1) both; }

/* 弹层（编辑器/灯箱/选图）开合 */
.editor, .lb, [data-pick-modal] { animation: veil-in .22s cubic-bezier(.2,.7,.2,1) both; }
.editor__panel, .lb__panel { animation: pop-in .26s cubic-bezier(.2,.7,.2,1) both; }
@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* 触感反馈：按下有物理回馈 */
.btn:active, .icon-btn:active, .lib-chip:active, .pager__num:active, .pager__btn:active {
  transform: translateY(1px) scale(.98);
}
.card:active, .qz:active, .us-mod:active, .album-card:active, .us-side__card:active {
  transform: scale(.995);
}

/* 减弱动效：关闭位移/缩放/进场 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .page, .notice, .editor, .lb, [data-pick-modal], .editor__panel, .lb__panel { animation: none; }
  .btn:active, .icon-btn:active, .lib-chip:active, .pager__num:active,
  .pager__btn:active, .card:active, .qz:active, .us-mod:active,
  .album-card:active, .us-side__card:active {
    transform: none;
  }
  .btn:hover, .us-mod:hover, .album-card:hover, .lib-card:hover { transform: none; }
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px;
        position: relative; z-index: 1; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #0b0f19; padding: 10px 16px; border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

/* --------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .3s;
}
.topbar.is-scrolled { box-shadow: 0 8px 24px rgba(0, 0, 0, .22); }

.topbar__inner { display: flex; align-items: center; gap: 18px; min-height: 64px; }

.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand__avatar { border-radius: 50%; border: 1px solid var(--line-strong); object-fit: cover; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text strong { font-size: 15px; }
.brand__text small { color: var(--muted); font-size: 12px; }

.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a {
  padding: 8px 14px; border-radius: 999px; font-size: 14.5px; color: var(--muted);
  transition: color .2s, background .2s;
}
.topnav a:hover { color: var(--text); background: var(--panel); }
.topnav a.is-active { color: var(--text); background: var(--panel); border: 1px solid var(--line); }
.topnav__admin { font-size: 13px !important; opacity: .7; }

.topbar__actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid transparent; color: var(--muted);
  transition: color .2s, background .2s, border-color .2s;
}
.icon-btn:hover { color: var(--text); background: var(--panel); border-color: var(--line); }
.icon-btn--menu { display: none; }
.icon-btn { min-width: 44px; min-height: 44px; }

/* 主题图标按当前模式切换显示 */
html[data-theme="dark"] .i-sun { display: block; }
html[data-theme="dark"] .i-moon { display: none; }
html[data-theme="light"] .i-sun { display: none; }
html[data-theme="light"] .i-moon { display: block; }

/* ------------------------------------------------------------- 抽屉菜单 */
.drawer {
  position: fixed; top: 0; right: 0; z-index: 60;
  width: min(330px, 86vw); height: 100dvh;
  background: var(--panel-solid); border-left: 1px solid var(--line);
  padding: 18px; display: flex; flex-direction: column; gap: 18px;
  transform: translateX(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
}
/* ⚠️ 作者样式里的 display 会覆盖 HTML hidden 属性，必须显式兜底，
   否则"关闭"状态下抽屉依然存在于页面上（可能截获点击与焦点） */
.drawer[hidden] { display: none; }

.drawer.is-open { transform: translateX(0); }
.drawer__head { display: flex; align-items: center; gap: 12px; }
.drawer__head img { border-radius: 50%; }
.drawer__head strong { display: block; font-size: 15px; }
.drawer__head small { color: var(--muted); font-size: 12.5px; }
.drawer__head .icon-btn { margin-left: auto; }
.drawer__nav { display: flex; flex-direction: column; gap: 4px; }
.drawer__nav a {
  padding: 12px 14px; border-radius: var(--radius-sm); color: var(--muted);
  transition: background .2s, color .2s;
}
.drawer__nav a:hover, .drawer__nav a.is-active { background: var(--panel); color: var(--text); }
.drawer__foot { margin-top: auto; color: var(--muted); font-size: 13px; }

.drawer-mask {
  position: fixed; inset: 0; z-index: 55; background: rgba(4, 7, 14, .6);
  backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s;
}
.drawer-mask[hidden] { display: none; }
.drawer-mask.is-open { opacity: 1; }

/* ---------------------------------------------------------- 布局与页脚 */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 26px;
          align-items: start; padding-bottom: 40px; }
.layout__side { position: sticky; top: 84px; }

.footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 26px 0 40px; }
.footer__inner { text-align: center; color: var(--muted); font-size: 13px; }
.footer__inner a { transition: color .2s; }
.footer__inner a:hover { color: var(--brand); }
.footer__dot { margin: 0 8px; opacity: .5; }

/* ---------------------------------------------------- 滚动淡入动画 */
.reveal { opacity: 0; transform: translateY(22px);
          transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.is-in { opacity: 1; transform: none; }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .layout__side { position: static; }
}

@media (max-width: 720px) {
  .topnav { display: none; }
  .icon-btn--menu { display: grid; }
  .brand__text small { display: none; }

  .post-item { grid-template-columns: 1fr !important; gap: 12px; }
  .post-item__no { padding-top: 0; }
  .post-item__foot { flex-wrap: wrap; }
  .read-more { margin-left: 0 !important; }
}

/* 尊重系统的"减少动态效果"偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
