/* ============================================================
 * LRainner Blog — common.css
 * 亮/暗主题只维护这一份变量表，html.dark 只做变量翻转。
 * ============================================================ */

/* ---- Cascadia Mono（可变字重 200-700，latin 子集）---- */
@font-face {
  font-family: 'Cascadia Mono';
  src: url('../font/cascadia/CascadiaMono.woff2') format('woff2-variations');
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cascadia Mono';
  src: url('../font/cascadia/CascadiaMonoItalic.woff2') format('woff2-variations');
  font-weight: 200 700;
  font-style: italic;
  font-display: swap;
}

/* ---- 设计令牌 ---- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f4f6f7;
  --ink: #22272b;
  --muted: #66707a;
  --line: #e6e8ea;
  --accent: #0b7a55;
  --accent-soft: rgba(11, 122, 85, 0.12);
  --selection: rgba(11, 122, 85, 0.18);
  --shadow: 0 1px 3px rgba(20, 30, 40, 0.08);

  --font-mono: 'Cascadia Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
}

html.dark {
  color-scheme: dark;
  --bg: #12161c;
  --bg-soft: #1a212b;
  --ink: #d3dae4;
  --muted: #8b949e;
  --line: #2a3340;
  --accent: #3dd68c;
  --accent-soft: rgba(61, 214, 140, 0.14);
  --selection: rgba(61, 214, 140, 0.28);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ---- 基础 ---- */
html {
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--font-body);
  overflow-y: overlay;
}
html[transition] {
  transition: background-color 500ms ease, color 500ms ease;
}
body {
  max-width: 700px;
  padding: 0 20px;
  margin: 0 auto;
  line-height: 1.7;
}
* {
  -webkit-tap-highlight-color: transparent;
}
::selection {
  background-color: var(--selection);
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
ol,
ul {
  list-style: none;
}
p,
h1,
h2,
h3,
h4,
h5,
h6,
ul,
ol,
li,
blockquote,
figure {
  padding: 0;
  margin: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
input,
select,
textarea {
  font-family: inherit;
  outline: 0;
  appearance: none;
  border: none;
}
pre,
code,
kbd {
  font-family: var(--font-mono);
}
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  background-color: transparent;
}
::-webkit-scrollbar-thumb {
  border-radius: 2px;
  background-color: var(--line);
}

/* ---- 工具类 ---- */
.hide {
  display: none !important;
}

/* 下划线从中间扫出——全站唯一的 hover 语言 */
.hover-underline {
  position: relative;
}
.hover-underline::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 1.5px;
  bottom: -3px;
  left: 0;
  background-color: var(--accent);
  visibility: hidden;
  transform: scaleX(0);
  transition: transform 200ms ease-in-out;
}
.hover-underline:hover::after {
  visibility: visible;
  transform: scaleX(1);
}

/* ---- 头部 ---- */
.header {
  padding: 44px 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header .logo {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-image: url(../img/logo.jpg);
  background-size: cover;
  box-shadow: var(--shadow);
  -webkit-user-drag: none;
}
.header .menu {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  user-select: none;
}
.header .menu a {
  display: inline-block;
  margin: 4px 0 4px 18px;
  color: var(--muted);
  transition: color 150ms ease;
}
.header .menu a:hover {
  color: var(--ink);
}

/* ---- 页脚 ---- */
.footer {
  padding: 24px 0 40px;
  margin-top: 48px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}
.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}
.footer a:hover {
  color: var(--accent);
}

/* ---- 悬浮按钮（主题切换 / 回顶）---- */
.footer-btn {
  position: fixed;
  z-index: 99;
  width: 36px;
  height: 36px;
  cursor: pointer;
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: border-color 150ms ease;
}
.footer-btn:hover {
  border-color: var(--accent);
}
.footer-btn.theme-toggler {
  right: 16px;
  bottom: 68px;
}
.footer-btn.to-top {
  right: 16px;
  bottom: -50px;
  transition: bottom 200ms ease-in-out, border-color 150ms ease;
}
.footer-btn.to-top.show {
  bottom: 16px;
}

/* ---- 图标（mask 方式，颜色跟随墨色）---- */
.svg-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  mask-size: 100% 100%;
  -webkit-mask-size: 100% 100%;
  background-color: var(--ink);
  font-size: 20px;
}
.icon-loading {
  mask-image: url('../img/icon-loading.svg');
  -webkit-mask-image: url('../img/icon-loading.svg');
}
.icon-theme-dark {
  mask-image: url('../img/icon-theme-dark.svg');
  -webkit-mask-image: url('../img/icon-theme-dark.svg');
}
.icon-theme-light {
  mask-image: url('../img/icon-theme-light.svg');
  -webkit-mask-image: url('../img/icon-theme-light.svg');
}
.icon-arrow-top {
  mask-image: url('../img/icon-arrow-top.svg');
  -webkit-mask-image: url('../img/icon-arrow-top.svg');
}

/* ---- 移动端 ---- */
@media screen and (max-width: 560px) {
  .header {
    padding: 28px 0 20px;
    flex-wrap: wrap;
  }
  .header .menu a {
    margin: 4px 0 4px 14px;
  }
}
