/* ------------------------------------------------------------------
   发条照相馆 · darwinz.net
   苹果式极简 / 低饱和 / 无彩色强调
   ------------------------------------------------------------------ */

:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-sunken: #f2f2f4;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #a1a1a6;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .22);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --nav-h: 52px;
  --frame: 1320px;
  /* 照片墙列数（只作用于宽屏那一档）：列数越大，单张越小、一屏看到越多。
     9 列时 1320px 容器下单张约 131px。嫌小改 8，嫌大改 10。
     各断点的降列阶梯在下面的 .grid 处，改这里要顺手对齐那一阶梯。 */
  --cols: 9;
  --danger: #a33c2c;
}

* { box-sizing: border-box; }

/* ------------------------------------------------------------------
   网页字体：朝华打字机（ZhaohuaTypeWriter Light）—— 只给首页主标题用。
   原文件 26.22 MB / 32,510 字形，这里只挂了**子集**（public/fonts/zhaohua-v2.woff2，
   48 KB / 374 字形，由 `_tools/subset_font.py --auto=h1` 生成）。
   ⚠️ 子集里只有「在妳最美丽的时候让我遇到妳」这几个字 + ASCII + 标点（另留了一个
      「你」，方便日后改回来不用重传字体）。
      改标题文字务必重跑：`python _tools/subset_font.py <源.ttf> <输出.woff2> --auto=h1`
      —— `--auto=h1` 会直接从 index.html 读当前文案，避免「文案改了、字库没跟上」，
      那种情况**不报错**，只是新字静默逐字回退、字形不统一。
   font-display: swap —— 字体没到之前先用回退字体渲染，不阻塞首屏。
   ------------------------------------------------------------------ */
@font-face {
  font-family: 'ZhaohuaTypeWriter';
  src: url('/fonts/zhaohua-v2.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* 副标题用的「方正静蕾体」子集（23.6 KB / 263 字形，源 6.91 MB）。
   同样只挂了这一句用得上的字 —— 改副标题文案请重跑
   `python _tools/subset_font.py <静蕾体.ttf> <输出.woff2> --auto=sub`。 */
@font-face {
  font-family: 'FZJingLei';
  src: url('/fonts/jingleti.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------------- 导航 ---------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .74);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--frame);
  margin: 0 auto;
  height: var(--nav-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: .08em;
  /* 站名带了一串后缀，窄屏宁可截断也不要撑破导航 */
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-links { display: flex; align-items: center; gap: 26px; flex: none; }
.nav-link {
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: .06em;
  transition: color .25s var(--ease);
  white-space: nowrap;
}
.nav-link:hover { color: var(--ink); }

/* 背景音乐开关：排版沿用 .nav-link（元素同时带两个类），这里只清掉 <button> 自带的浏览器外观 */
.bgm-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
}
/* 静音态：一道细删除线，不加任何彩色，维持"无彩色强调"的调子 */
.bgm-btn.is-off {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* 窄屏：站名和导航链接一起缩，留出呼吸 */
@media (max-width: 900px) {
  .brand { font-size: 15px; letter-spacing: .04em; }
  .nav-links { gap: 16px; }
}
@media (max-width: 620px) {
  .brand { font-size: 13px; letter-spacing: 0; }
  .nav-link { font-size: 12px; }
  .nav-inner { padding: 0 16px; }
}

/* ---------------- Hero ---------------- */
.hero {
  padding: 92px 24px 48px;
  text-align: center;
}
.hero h1 {
  /* 注意：.hero 是 flex column，子项默认按内容宽度收缩而不换行 —— 必须给 width */
  width: 100%;
  max-width: 17em;
  margin: 0 auto;
  font-size: clamp(15px, 3.6vw, 34px);
  /* 主标题用「朝华打字机」；后面留一整套回退，缺字时逐字回退（不会出豆腐块） */
  font-family: 'ZhaohuaTypeWriter', "Songti SC", "STSong", "SimSun", "PingFang SC", serif;
  font-weight: 400;   /* 字体本身只有 Light 一档，写 600 会触发浏览器的合成加粗，字形会糊 */
  letter-spacing: -.02em;
  line-height: 1.26;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.hero-sub {
  width: 100%;
  margin: 22px auto 0;
  max-width: 34em;
  font-size: clamp(15px, 1.5vw, 18px);
  /* 副标题用「方正静蕾体」；后面留一整套回退，缺字时逐字回退（不会出豆腐块） */
  font-family: 'FZJingLei', "Songti SC", "STSong", "SimSun", "PingFang SC", serif;
  font-weight: 400;   /* 该字体只有 Regular 一档，写粗体会触发浏览器的合成加粗，字形会糊 */
  color: var(--ink-2);
  line-height: 1.6;
}
.hero-meta {
  margin: 28px 0 0;
  font-size: 11.5px;
  letter-spacing: .22em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ---------------- 相册筛选 ---------------- */
.filters {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 0 24px 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: .03em;
  padding: 7px 17px;
  border-radius: 980px;
  cursor: pointer;
  transition: color .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.chip .n { opacity: .5; margin-left: 6px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .n { opacity: .65; }

/* ---------------- 照片墙 ---------------- */
/* 宽屏默认 9 列（最初 3 列时单张竖图高 600px+，一屏只看得到一张多一点）。
   每降一档视口就少一列，单张宽度稳定在 125~160px，不会"越窄越大"。 */
.grid {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 0 24px 140px;
  columns: var(--cols);
  column-gap: 12px;
}
/* 逐级降列（单张宽度实测）：1180→8 列≈131px、1000→7 列≈126px、
   860→6 列≈125px、700→5 列≈122px、540→3 列≈159px、380→2 列≈158px */
@media (max-width: 1180px) { .grid { columns: 8; } }
@media (max-width: 1000px) { .grid { columns: 7; } }
@media (max-width: 860px)  { .grid { columns: 6; } }
@media (max-width: 700px)  { .grid { columns: 5; column-gap: 10px; } }
@media (max-width: 540px)  { .grid { columns: 3; column-gap: 8px; } }
@media (max-width: 380px) {
  .grid { columns: 2; column-gap: 8px; padding-bottom: 96px; }
  .hero { padding: 84px 20px 48px; }
}
/* 窄屏：长标题按语义折成两行（span 在宽屏是行内，窄屏转块级） */
@media (max-width: 520px) {
  .hero h1 {
    font-size: clamp(13px, 4.8vw, 18px);
    line-height: 1.38;
  }
  .hero h1 span { display: block; }
}

.tile {
  break-inside: avoid;
  position: relative;
  margin: 0 0 14px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-sunken);
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.tile.in { opacity: 1; transform: none; }
.tile img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 1s var(--ease);
}
.tile:hover img { transform: scale(1.028); }
.tile::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42%;
  background: linear-gradient(to top, rgba(0, 0, 0, .46), rgba(0, 0, 0, 0));
  opacity: 0;
  transition: opacity .45s var(--ease);
  pointer-events: none;
}
.tile.has-cap:hover::after { opacity: 1; }
.tile-cap {
  position: absolute;
  left: 15px; right: 15px; bottom: 13px;
  z-index: 2;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
  pointer-events: none;
}
.tile.has-cap:hover .tile-cap { opacity: 1; transform: none; }

.empty {
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  padding: 60px 24px 140px;
  letter-spacing: .04em;
}

/* ---------------- 页脚 ---------------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 54px 24px 62px;
  text-align: center;
}
.f-line {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: .06em;
}
.f-sub {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.f-views {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .18em;
  font-variant-numeric: tabular-nums;
}
/* 备案号：大陆节点必须展示，并链接到工信部备案管理系统 */
.f-icp {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.f-icp a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, .14);
  padding-bottom: 1px;
}
.f-icp a:hover { border-bottom-color: rgba(0, 0, 0, .42); }
/* 公安联网备案号：平台规定「备案图标在左、备案编号在右」，不要写反 */
.f-police {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.f-police a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  text-decoration: none;
}
.f-police img { display: block; flex: none; }
.f-police a:hover { color: var(--ink-2); }

/* 违法和不良信息举报入口。
   ⚠️ 这不是可选项：安全评估表「是否建立投诉举报机制」选了"是"，
   就必须在页面上真的公布一个可用途径，否则属于"填了却做不到"。
   样式沿用 .f-icp 的处理，保持页脚整体一致。 */
.f-report {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.f-report a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, .14);
  padding-bottom: 1px;
}
.f-report a:hover { border-bottom-color: rgba(0, 0, 0, .42); }

/* ---------------- 灯箱 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(250, 250, 250, .93);
  -webkit-backdrop-filter: saturate(160%) blur(30px);
  backdrop-filter: saturate(160%) blur(30px);
  opacity: 0;
  transition: opacity .32s var(--ease);
}
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }

.lb-figure {
  margin: 0;
  max-width: min(1180px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 78vh;
}
.lb-stage img {
  max-width: min(1180px, 92vw);
  max-height: 78vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .18);
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.lb-stage img.ready { opacity: 1; }

.lb-info {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  text-align: center;
}
.lb-cap {
  font-size: 14px;
  color: var(--ink);
  max-width: 76vw;
  letter-spacing: .01em;
}
.lb-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .16em;
  text-transform: uppercase;
}
/* 没有内容时整行不占位，避免灯箱下方留出多余空隙
   （说明行可能只剩相册名，甚至全空 —— 日期与序号已去掉） */
.lb-cap:empty,
.lb-meta:empty { display: none; }

.lb-close,
.lb-nav {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 50%;
  transition: color .25s var(--ease), background .25s var(--ease);
}
.lb-close:hover,
.lb-nav:hover { background: rgba(0, 0, 0, .05); color: var(--ink); }
.lb-close { top: 18px; right: 20px; width: 40px; height: 40px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
@media (max-width: 640px) {
  .lb-nav { width: 40px; height: 40px; }
  .lb-prev { left: 4px; }
  .lb-next { right: 4px; }
  .lb-stage img { max-height: 66vh; }
}

/* ---------------- 来客足迹（首页底部） ----------------
   ⚠️ 只展示来访「地区 + 时间」，绝不展示访客 IP（见 config.js 注释）。
   访客本人的 IP 单独一行回显，只给他自己看。 */
.visitors {
  padding: 0 24px 110px;
  scroll-margin-top: calc(var(--nav-h) + 24px);   /* 导航是 sticky，锚点别被盖住 */
}
.visitors-inner { max-width: 560px; margin: 0 auto; }
.visitors-title {
  margin: 0 0 8px;
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 600;
  letter-spacing: -.01em;
  text-align: center;
}
.visitors-you {
  margin: 0 0 26px;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.visitors-you b { color: var(--ink-2); font-weight: 500; }

/* 滚动窗口：固定高度 + 上下淡出，内容由 JS 决定是否启动动画 */
.visitors-stage {
  position: relative;
  height: 176px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
}
.visitors-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.visitors-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 2px;
  font-size: 13px;
  letter-spacing: .03em;
}
.visitors-region {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.visitors-time {
  margin-left: auto;
  flex: none;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* .rolling 由 JS 在条目够多时加上；--v-dur 控制一圈时长 */
.visitors-stage.rolling .visitors-list { animation: vscroll var(--v-dur, 26s) linear infinite; }
.visitors-stage.rolling:hover .visitors-list,
.visitors-stage.rolling:focus-within .visitors-list { animation-play-state: paused; }
@keyframes vscroll {
  from { transform: translateY(0); }
  to   { transform: translateY(-50%); }   /* 列表被复制成两份，滚过一份即为无缝 */
}
@media (prefers-reduced-motion: reduce) {
  .visitors-stage.rolling .visitors-list { animation: none; }
  .visitors-stage { overflow-y: auto; }
}
.visitors-note {
  margin: 20px 0 0;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--ink-3);
}
@media (max-width: 540px) {
  .visitors { padding: 0 20px 90px; }
  .visitors-stage { height: 150px; }
}

/* ---------------- 键盘焦点 ----------------
   站点原先没有任何 :focus-visible 规则 —— 靠键盘（Tab）操作的人
   完全看不出焦点落在哪个相册筛选、哪个灯箱按钮上。
   用 :where() 包一层把特异性压到 0，不会覆盖任何既有样式；
   只认 :focus-visible（键盘/辅助技术触发），鼠标点击不会出现这个圈。 */
:where(a, button, select, input, [tabindex]):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
/* 深色底上的焦点圈要反白，否则看不见（灯箱是浅底，这里只处理筛选选中的深底胶囊） */
.chip[aria-pressed="true"]:focus-visible {
  outline-color: #fff;
  outline-offset: 2px;
}

/* ---------------- 滚动条：更安静 ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .14); border-radius: 10px; border: 2px solid #fff; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .24); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .01ms !important; }
  .tile { opacity: 1; transform: none; }
}
