/* Author: Yananart <yananart@yananart.cn> */

/*
 * Appearance tokens.
 *
 * A theme owns both a layout (home.css) and a paired light/dark palette. The
 * server writes data-theme and data-mode on <html>; data-mode="auto" follows
 * prefers-color-scheme in CSS, so the public page needs no script at all.
 * Components only reference the semantic roles below.
 */

:root {
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus);
}

#main:focus,
#blog-main:focus { outline: none; }

/* ---------- editorial · 晴日 ---------- */

:root,
[data-theme="editorial"] {
  color-scheme: light;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --surface-3: #e4e7ec;
  --ink: #17191f;
  --muted: #5c6270;
  --line: #e1e4ea;
  --line-strong: #7c8393;
  --control-line: #7c8393;
  --accent: #2f4bdb;
  --accent-hover: #283fc0;
  --accent-ink: #ffffff;
  --accent-soft: #e7eafc;
  --ok: #2f6b4f;
  --ok-soft: #d9f2e7;
  --warn: #8a5a00;
  --warn-soft: #fff0c7;
  --danger: #b3343f;
  --danger-soft: #f3e1e2;
  --danger-line: #d9b2b4;
  --focus: #1a1d2b;
  --chrome: #17191f;
  --chrome-ink: #f5f6f8;
  --chrome-muted: #a8afc4;
  --placeholder: #6d7690;
  --code-bg: #17191f;
  --code-ink: #f1f4ff;
  --shadow: #17191f14;
  --shadow-strong: #17191f26;
  --overlay: #0d1023cc;
}

[data-theme="editorial"][data-mode="dark"] {
  color-scheme: dark;
  --bg: #1b1f2a;
  --surface: #232837;
  --surface-2: #202532;
  --surface-3: #2b3142;
  --ink: #eef1f8;
  --muted: #b4bccd;
  --line: #343b4d;
  --line-strong: #8e97ab;
  --control-line: #8e97ab;
  --accent: #aebcff;
  --accent-hover: #c6d0ff;
  --accent-ink: #141827;
  --accent-soft: #2f3854;
  --ok: #9bd4b4;
  --ok-soft: #1e4232;
  --warn: #eccb7a;
  --warn-soft: #3d3527;
  --danger: #f0a0a6;
  --danger-soft: #40292d;
  --danger-line: #6d454b;
  --focus: #f3dfa4;
  --chrome: #151924;
  --chrome-ink: #eef1f8;
  --chrome-muted: #a9b2c9;
  --placeholder: #98a1b8;
  --code-bg: #121620;
  --code-ink: #eef1f8;
  --shadow: #04070f80;
  --shadow-strong: #04070fbf;
  --overlay: #05070dcc;
}

/* ---------- gallery · 画廊 ---------- */

[data-theme="gallery"] {
  color-scheme: light;
  --display: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", Georgia, "Times New Roman", serif;
  --bg: #eef4ef;
  --surface: #ffffff;
  --surface-2: #e4eee6;
  --surface-3: #d8e6dc;
  --ink: #17241c;
  --muted: #53685b;
  --line: #d7e3d9;
  --line-strong: #748a7c;
  --control-line: #748a7c;
  --accent: #2e6b4f;
  --accent-hover: #25573f;
  --accent-ink: #ffffff;
  --accent-soft: #ddebe1;
  --ok: #2f6b4f;
  --ok-soft: #d5f0e1;
  --warn: #7a5200;
  --warn-soft: #ffefc4;
  --danger: #a93b36;
  --danger-soft: #f1e1df;
  --danger-line: #d8b3af;
  --focus: #173e2e;
  --chrome: #17241c;
  --chrome-ink: #eef4ef;
  --chrome-muted: #a7c4b5;
  --placeholder: #5f7f70;
  --code-bg: #17241c;
  --code-ink: #e7f8ef;
  --shadow: #17241c14;
  --shadow-strong: #17241c26;
  --overlay: #07130ecc;
}

[data-theme="gallery"][data-mode="dark"] {
  color-scheme: dark;
  --bg: #101913;
  --surface: #17231b;
  --surface-2: #141f18;
  --surface-3: #202d23;
  --ink: #e9f1eb;
  --muted: #a9bbaf;
  --line: #26352b;
  --line-strong: #7f9487;
  --control-line: #7f9487;
  --accent: #9ed3b3;
  --accent-hover: #b6e2c7;
  --accent-ink: #0d1b13;
  --accent-soft: #263a2e;
  --ok: #9ed3b3;
  --ok-soft: #1b3527;
  --warn: #e8c774;
  --warn-soft: #3a3325;
  --danger: #e8a0a0;
  --danger-soft: #3a282c;
  --danger-line: #654148;
  --focus: #ead9a0;
  --chrome: #0a120d;
  --chrome-ink: #e9f1eb;
  --chrome-muted: #9caf9f;
  --placeholder: #8da594;
  --code-bg: #08100b;
  --code-ink: #e9f1eb;
  --shadow: #00000080;
  --shadow-strong: #000000bf;
  --overlay: #040a07cc;
}
/* ---------- cinema · 银幕 ---------- */

[data-theme="cinema"] {
  color-scheme: light;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #e9eaf1;
  --surface-3: #dfe1ea;
  --ink: #1d2030;
  --muted: #5b6075;
  --line: #e0e2ea;
  --line-strong: #7d8298;
  --control-line: #7d8298;
  --accent: #4b5a9e;
  --accent-hover: #3e4b86;
  --accent-ink: #ffffff;
  --accent-soft: #e5e7f7;
  --ok: #2f6b4f;
  --ok-soft: #d9f2e7;
  --warn: #8a5a00;
  --warn-soft: #fff0c7;
  --danger: #b3343f;
  --danger-soft: #f3e1e2;
  --danger-line: #d9b2b4;
  --focus: #1b2038;
  --chrome: #1d2030;
  --chrome-ink: #f2f2f7;
  --chrome-muted: #a9aec2;
  --placeholder: #6b7088;
  --code-bg: #1d2030;
  --code-ink: #f0f2ff;
  --shadow: #1d203014;
  --shadow-strong: #1d203026;
  --overlay: #0d1023cc;
}

[data-theme="cinema"][data-mode="dark"] {
  color-scheme: dark;
  --bg: #232735;
  --surface: #2b3040;
  --surface-2: #282d3b;
  --surface-3: #343a4b;
  --ink: #f0f0ea;
  --muted: #adb3c2;
  --line: #3c4252;
  --line-strong: #7e8699;
  --control-line: #7e8699;
  --accent: #aeb9f2;
  --accent-hover: #c4cdf7;
  --accent-ink: #1a1e2b;
  --accent-soft: #343b57;
  --ok: #8fcfac;
  --ok-soft: #1d4132;
  --warn: #e8c774;
  --warn-soft: #3e3728;
  --danger: #e89a9a;
  --danger-soft: #3e2a2e;
  --danger-line: #6b444a;
  --focus: #ead9a0;
  --chrome: #1c2030;
  --chrome-ink: #f0f0ea;
  --chrome-muted: #a8aecb;
  --placeholder: #9299bd;
  --code-bg: #1b1e2b;
  --code-ink: #f0f0ea;
  --shadow: #080a1259;
  --shadow-strong: #06081499;
  --overlay: #05060dcc;
}

/* ---------- index · 莓果 ---------- */

[data-theme="index"] {
  color-scheme: light;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #fbf0f4;
  --surface: #ffffff;
  --surface-2: #f6e4eb;
  --surface-3: #efd5df;
  --ink: #2b1b24;
  --muted: #6d4d5c;
  --line: #ecd9e2;
  --line-strong: #987383;
  --control-line: #987383;
  --accent: #a33c66;
  --accent-hover: #8c3157;
  --accent-ink: #ffffff;
  --accent-soft: #f6dde8;
  --ok: #2f6b4f;
  --ok-soft: #d9f2e7;
  --warn: #8a5a00;
  --warn-soft: #fff0c7;
  --danger: #b3343f;
  --danger-soft: #f3e1e2;
  --danger-line: #d9b2b4;
  --focus: #3b1b2a;
  --chrome: #2b1b24;
  --chrome-ink: #fbf0f4;
  --chrome-muted: #c3a7b4;
  --placeholder: #856171;
  --code-bg: #2b1b24;
  --code-ink: #fdf1f6;
  --shadow: #2b1b2414;
  --shadow-strong: #2b1b2426;
  --overlay: #1b0712cc;
}

[data-theme="index"][data-mode="dark"] {
  color-scheme: dark;
  --bg: #1c1722;
  --surface: #251e2c;
  --surface-2: #211a27;
  --surface-3: #2e2536;
  --ink: #f1e8ee;
  --muted: #beacb8;
  --line: #382e40;
  --line-strong: #8c7988;
  --control-line: #8c7988;
  --accent: #e3a3c0;
  --accent-hover: #edb8ce;
  --accent-ink: #24121b;
  --accent-soft: #3c2b39;
  --ok: #9ccfaf;
  --ok-soft: #223b2b;
  --warn: #e8c774;
  --warn-soft: #3a3325;
  --danger: #e8a0a0;
  --danger-soft: #3a282c;
  --danger-line: #654148;
  --focus: #ead9a0;
  --chrome: #120d16;
  --chrome-ink: #f1e8ee;
  --chrome-muted: #b09aa9;
  --placeholder: #9d8494;
  --code-bg: #100b13;
  --code-ink: #f1e8ee;
  --shadow: #00000080;
  --shadow-strong: #000000bf;
  --overlay: #050307cc;
}
/* ---------- paper · 纸页 ---------- */

[data-theme="paper"] {
  color-scheme: light;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif CJK SC", "Noto Serif", Georgia, "Times New Roman", serif;
  --bg: #f3efe6;
  --surface: #faf7f0;
  --surface-2: #ebe5d8;
  --surface-3: #e2dac9;
  --ink: #1c1a15;
  --muted: #676052;
  --line: #d8d0bf;
  --line-strong: #9b8f7b;
  --control-line: #8f826b;
  --accent: #b2471f;
  --accent-hover: #963816;
  --accent-ink: #ffffff;
  --accent-soft: #f0e3d8;
  --ok: #3f6b4d;
  --ok-soft: #dbeadd;
  --warn: #7a5200;
  --warn-soft: #f7e8c4;
  --danger: #a33a2a;
  --danger-soft: #f2dfd9;
  --danger-line: #d6b1a6;
  --focus: #1c1a15;
  --chrome: #1c1a15;
  --chrome-ink: #f3efe6;
  --chrome-muted: #b8ad99;
  --placeholder: #7b7160;
  --code-bg: #1d1a14;
  --code-ink: #f0eadc;
  --shadow: #1c1a1514;
  --shadow-strong: #1c1a1526;
  --overlay: #0d0b08cc;
}

[data-theme="paper"][data-mode="dark"] {
  color-scheme: dark;
  --bg: #12100d;
  --surface: #1a1713;
  --surface-2: #191611;
  --surface-3: #241f18;
  --ink: #eee9dd;
  --muted: #a49b89;
  --line: #2e2a23;
  --line-strong: #6e6250;
  --control-line: #6e6250;
  --accent: #e27c53;
  --accent-hover: #f0946d;
  --accent-ink: #17130e;
  --accent-soft: #2a211a;
  --ok: #9ccfaf;
  --ok-soft: #1e3b2c;
  --warn: #e8c774;
  --warn-soft: #3e3728;
  --danger: #e8a0a0;
  --danger-soft: #3e2a2e;
  --danger-line: #6b444a;
  --focus: #ead9a0;
  --chrome: #070605;
  --chrome-ink: #eee9dd;
  --chrome-muted: #a49b89;
  --placeholder: #8c8272;
  --code-bg: #070605;
  --code-ink: #eee9dd;
  --shadow: #00000080;
  --shadow-strong: #000000bf;
  --overlay: #050403cc;
}

/* ---------- automatic mode ---------- */

@media (prefers-color-scheme: dark) {
  [data-theme="editorial"][data-mode="auto"] {
    color-scheme: dark;
    --bg: #1b1f2a;
    --surface: #232837;
    --surface-2: #202532;
    --surface-3: #2b3142;
    --ink: #eef1f8;
    --muted: #b4bccd;
    --line: #343b4d;
    --line-strong: #8e97ab;
    --control-line: #8e97ab;
    --accent: #aebcff;
    --accent-hover: #c6d0ff;
    --accent-ink: #141827;
    --accent-soft: #2f3854;
    --ok: #9bd4b4;
    --ok-soft: #1e4232;
    --warn: #eccb7a;
    --warn-soft: #3d3527;
    --danger: #f0a0a6;
    --danger-soft: #40292d;
    --danger-line: #6d454b;
    --focus: #f3dfa4;
    --chrome: #151924;
    --chrome-ink: #eef1f8;
    --chrome-muted: #a9b2c9;
    --placeholder: #98a1b8;
    --code-bg: #121620;
    --code-ink: #eef1f8;
    --shadow: #04070f80;
    --shadow-strong: #04070fbf;
    --overlay: #05070dcc;
  }

  [data-theme="gallery"][data-mode="auto"] {
    color-scheme: dark;
    --bg: #101913;
    --surface: #17231b;
    --surface-2: #141f18;
    --surface-3: #202d23;
    --ink: #e9f1eb;
    --muted: #a9bbaf;
    --line: #26352b;
    --line-strong: #7f9487;
    --control-line: #7f9487;
    --accent: #9ed3b3;
    --accent-hover: #b6e2c7;
    --accent-ink: #0d1b13;
    --accent-soft: #263a2e;
    --ok: #9ed3b3;
    --ok-soft: #1b3527;
    --warn: #e8c774;
    --warn-soft: #3a3325;
    --danger: #e8a0a0;
    --danger-soft: #3a282c;
    --danger-line: #654148;
    --focus: #ead9a0;
    --chrome: #0a120d;
    --chrome-ink: #e9f1eb;
    --chrome-muted: #9caf9f;
    --placeholder: #8da594;
    --code-bg: #08100b;
    --code-ink: #e9f1eb;
    --shadow: #00000080;
    --shadow-strong: #000000bf;
    --overlay: #040a07cc;
  }

  [data-theme="cinema"][data-mode="auto"] {
    color-scheme: dark;
    --bg: #232735;
    --surface: #2b3040;
    --surface-2: #282d3b;
    --surface-3: #343a4b;
    --ink: #f0f0ea;
    --muted: #adb3c2;
    --line: #3c4252;
    --line-strong: #7e8699;
    --control-line: #7e8699;
    --accent: #aeb9f2;
    --accent-hover: #c4cdf7;
    --accent-ink: #1a1e2b;
    --accent-soft: #343b57;
    --ok: #8fcfac;
    --ok-soft: #1d4132;
    --warn: #e8c774;
    --warn-soft: #3e3728;
    --danger: #e89a9a;
    --danger-soft: #3e2a2e;
    --danger-line: #6b444a;
    --focus: #ead9a0;
    --chrome: #1c2030;
    --chrome-ink: #f0f0ea;
    --chrome-muted: #a8aecb;
    --placeholder: #9299bd;
    --code-bg: #1b1e2b;
    --code-ink: #f0f0ea;
    --shadow: #080a1259;
    --shadow-strong: #06081499;
    --overlay: #05060dcc;
  }

  [data-theme="index"][data-mode="auto"] {
    color-scheme: dark;
    --bg: #1c1722;
    --surface: #251e2c;
    --surface-2: #211a27;
    --surface-3: #2e2536;
    --ink: #f1e8ee;
    --muted: #beacb8;
    --line: #382e40;
    --line-strong: #8c7988;
    --control-line: #8c7988;
    --accent: #e3a3c0;
    --accent-hover: #edb8ce;
    --accent-ink: #24121b;
    --accent-soft: #3c2b39;
    --ok: #9ccfaf;
    --ok-soft: #223b2b;
    --warn: #e8c774;
    --warn-soft: #3a3325;
    --danger: #e8a0a0;
    --danger-soft: #3a282c;
    --danger-line: #654148;
    --focus: #ead9a0;
    --chrome: #120d16;
    --chrome-ink: #f1e8ee;
    --chrome-muted: #b09aa9;
    --placeholder: #9d8494;
    --code-bg: #100b13;
    --code-ink: #f1e8ee;
    --shadow: #00000080;
    --shadow-strong: #000000bf;
    --overlay: #050307cc;
  }
  [data-theme="paper"][data-mode="auto"] {
    color-scheme: dark;
    --bg: #12100d;
    --surface: #1a1713;
    --surface-2: #191611;
    --surface-3: #241f18;
    --ink: #eee9dd;
    --muted: #a49b89;
    --line: #2e2a23;
    --line-strong: #6e6250;
    --control-line: #6e6250;
    --accent: #e27c53;
    --accent-hover: #f0946d;
    --accent-ink: #17130e;
    --accent-soft: #2a211a;
    --ok: #9ccfaf;
    --ok-soft: #1e3b2c;
    --warn: #e8c774;
    --warn-soft: #3e3728;
    --danger: #e8a0a0;
    --danger-soft: #3e2a2e;
    --danger-line: #6b444a;
    --focus: #ead9a0;
    --chrome: #070605;
    --chrome-ink: #eee9dd;
    --chrome-muted: #a49b89;
    --placeholder: #8c8272;
    --code-bg: #070605;
    --code-ink: #eee9dd;
    --shadow: #00000080;
    --shadow-strong: #000000bf;
    --overlay: #050403cc;
  }

}

/* ---------- shared footer ---------- */

.site-footer {
  margin-top: clamp(64px, 8vw, 92px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 28px;
  padding: 24px 0 48px;
}

.site-footer-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 22px;
  min-width: 0;
}

.site-footer-main > span,
.site-footer-main > a { min-width: 0; }

.site-note {
  flex-basis: 100%;
  font-size: 11.5px;
  line-height: 1.7;
}

.site-footer-aside {
  margin-left: auto;
  text-align: right;
}

.site-tech {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-version { font-variant-numeric: tabular-nums; }

.site-footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.16s ease, text-decoration-color 0.16s ease;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

@media (max-width: 760px) {
  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .site-footer-main > .site-icp,
  .site-footer-main > .site-police {
    flex-basis: 100%;
  }

  .site-footer-aside {
    margin-left: 0;
    width: 100%;
    text-align: left;
  }

  .site-tech { white-space: normal; overflow-wrap: anywhere; }
}

/* ---------- progressive images ---------- */

/*
 * 图片的实际字节仍由 <img> 请求，这一层只负责占位和出现方式。骨架放在
 * 框的 ::after 里并置于图片之下，图片透明时能看到，解码完成后移除。
 */
.media-frame {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-color: var(--surface-2);
}

.media-frame.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, transparent 18%, var(--surface-3) 48%, transparent 78%);
  pointer-events: none;
  transform: translateX(-110%);
  animation: media-sweep 1.45s var(--ease-out) infinite;
}

.media-frame.is-loading img,
.media-img.is-loading {
  opacity: 0;
  /* 脚本异常时也不能让图片永久隐身；到时即使字节还没到，骨架仍在
   * 图片下方可见。 */
  animation: media-failsafe 0.01s linear 8s forwards;
}

.media-img.is-ready { animation: media-reveal 0.55s var(--ease-out); }

.media-frame.is-broken img,
.media-img.is-broken { opacity: 0.12; }

@keyframes media-sweep {
  from { transform: translateX(-110%); }
  to { transform: translateX(110%); }
}

@keyframes media-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes media-failsafe {
  to { opacity: 1; }
}

/* 禁用 JavaScript 时脚本不会移除 is-loading，直接按普通图片显示。 */
@media (scripting: none) {
  .media-frame.is-loading img,
  .media-img.is-loading { opacity: 1; animation: none; }
  .media-frame.is-loading::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .media-frame.is-loading::after { animation: none !important; opacity: 0.55; }
  .media-img.is-ready { animation: none !important; }
}
