/* ---------------------------------------------------------
   ckinyu.com — 极简个人主页
   无外部依赖，无 JS，自动适配深色模式
   --------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #fafafa;
  --accent: #2563eb;
  --radius: 12px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e8e8ea;
    --muted: #9aa0aa;
    --line: #24272e;
    --card: #171a20;
    --accent: #6ea8fe;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0 24px;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

/* ---------- 页头 ---------- */

.site-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--fg);
}

.brand span { color: var(--muted); font-weight: 400; }

.site-header nav {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.site-header nav a {
  color: var(--muted);
  transition: color 0.15s;
}

.site-header nav a:hover { color: var(--fg); text-decoration: none; }

/* ---------- 主容器 ---------- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-bottom: 40px;
}

/* ---------- Hero（照片背景） ---------- */

.hero {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-bottom: 56px;
  padding: 132px max(24px, calc((100vw - var(--maxw)) / 2)) 108px;
  background-image: url("assets/hero.jpg");
  background-size: cover;
  background-position: center 42%;
  background-repeat: no-repeat;
  color: #fff;
  isolation: isolate;
}

/* 压暗一层，保证白字可读 */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    180deg,
    rgba(6, 12, 28, 0.28) 0%,
    rgba(6, 12, 28, 0.52) 55%,
    rgba(6, 12, 28, 0.78) 100%
  );
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 6vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
}

.tagline {
  margin: 0 0 16px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  max-width: 34em;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.3);
}

.meta {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.22);
  margin: 0 2px;
}

/* ---------- 区块 ---------- */

section { margin-bottom: 56px; }

section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 20px;
}

section p {
  margin: 0 0 16px;
  max-width: 38em;
}

/* ---------- 作品卡片 ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--muted);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card p {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tags span {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.card-link {
  font-size: 14px;
  font-weight: 500;
}

/* ---------- 相册卡片网格 ---------- */

/*
   列数由一个数控制：minmax(下面的数字, 1fr)
   容器最宽 720px，减去间距后：
     165px → 4 列（当前）
     200px → 3 列
     280px → 2 列
     340px → 1 列
   想改列数，只改这个数字即可。
*/
.places {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

.place {
  position: relative;
  display: flex;
  align-items: flex-end;
  aspect-ratio: 4 / 3;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  color: #fff;
  /* 没有照片时的底色，保证白字可读 */
  background: linear-gradient(150deg, #24303f 0%, #121821 100%);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.place:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.place-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  transition: transform 0.45s ease;
}

.place:hover .place-thumb { transform: scale(1.06); }

/* 底部压暗，让地名在亮照片上也看得清 */
.place::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(8, 12, 20, 0) 36%,
    rgba(8, 12, 20, 0.42) 66%,
    rgba(8, 12, 20, 0.84) 100%
  );
}

.place-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.place-date {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 5px;
}

.place-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.45);
}

.place-arrow {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  transition: transform 0.18s ease, color 0.18s ease;
}

.place:hover .place-arrow {
  transform: translateX(3px);
  color: #fff;
}

/* ---------- 相册卡片（整块可点，不用蓝色文字链接） ---------- */

.place-folder {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 140px;
  padding: 18px 16px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--fg);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

/* 卡片顶部的三张照片 */
.folder-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin: -6px -6px 12px;
  border-radius: 9px;
  overflow: hidden;
  min-width: 0;
}

.folder-preview img {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--line);
  transition: filter 0.2s ease;
}

.place-folder:hover .folder-preview img { filter: brightness(1.06); }

.place-folder:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--muted);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.14);
}

.place-folder:hover .folder-name { color: var(--accent); }

.folder-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  transition: color 0.15s ease;
}

.folder-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.folder-tag {
  align-self: flex-start;
  margin-top: auto;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 区块下方的「更多」链接 */
.more {
  margin: 22px 0 0;
  font-size: 14px;
}

.more a {
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.more a:hover {
  text-decoration: none;
  border-bottom-color: currentColor;
}

/* ---------- 链接列表 ---------- */
.links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.links a {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s;
}

.links a:hover {
  text-decoration: none;
  border-color: var(--muted);
  background: var(--card);
}

/* ---------- 页脚 ---------- */

.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 0 48px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.site-footer p { margin: 0; }

/* ---------- 手机 ---------- */

@media (max-width: 560px) {
  body { padding: 0 20px; font-size: 15px; }
  .hero {
    padding: 96px 20px 72px;
    margin-bottom: 40px;
    background-position: center 40%;
  }
  section { margin-bottom: 44px; }
  .site-header nav { gap: 16px; }
  .places { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .place { aspect-ratio: 1 / 1; padding: 14px; }
  .place-name { font-size: 14px; }
}

/* =========================================================
   相册页（photos.html）
   ========================================================= */

.album {
  margin-bottom: 64px;
  scroll-margin-top: 24px;   /* 从首页锚点跳过来时留出呼吸空间 */
}

.album-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.album-head time {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.album-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.album-note {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 40em;
}

/* 缩略图网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.shot {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
}

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.28s ease;
}

.shot:hover img { transform: scale(1.05); }

/* 图片还没上传时显示占位，不出现破图 */
.shot.empty img { display: none; }

.shot.empty::after {
  content: "待上传";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
}

/* 大图浮层 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.92);
  cursor: zoom-out;
}

.lightbox.open { display: grid; }

.lightbox figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.lightbox img {
  max-width: 100%;
  max-height: 86vh;
  border-radius: 8px;
  display: block;
}

.lightbox figcaption {
  margin-top: 14px;
  font-size: 13px;
  color: #d6d6d6;
  text-align: center;
}

.album-end {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin: 0 0 24px;
}

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
  .album { margin-bottom: 48px; }
}

/* ---------- 大图左右箭头 ---------- */

.lb-prev,
.lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(20, 20, 24, 0.55);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  z-index: 2;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, transform 0.15s ease;
}

.lb-prev { left: max(16px, 3vw); }
.lb-next { right: max(16px, 3vw); }

.lb-prev:hover,
.lb-next:hover { background: rgba(45, 45, 52, 0.85); }

.lb-prev:active,
.lb-next:active { transform: translateY(-50%) scale(0.93); }

.lb-prev:focus-visible,
.lb-next:focus-visible {
  outline: 2px solid #6ea8fe;
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .lb-prev,
  .lb-next {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

/* =========================================================
   相册页 v2：深色 + 等高行（fast-gallery 风格）
   ========================================================= */

body.album-dark {
  background: #0b0c0e;
  color: #f1f2f4;
  color-scheme: dark;
}

body.album-dark .site-header .brand,
body.album-dark .site-header .brand span {
  color: #f1f2f4;
}

body.album-dark .site-header nav a { color: #9aa0aa; }
body.album-dark .site-header nav a:hover { color: #f1f2f4; }

body.album-dark .site-footer {
  color: #7c828c;
  border-top-color: #24272e;
}

body.album-dark .site-footer a { color: #9aa0aa; }

/* 顶部标题条 */
.album-head-bar {
  max-width: 1800px;
  margin: 32px auto 0;
  padding: 0 clamp(16px, 4vw, 48px);
}

.album-head-bar h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.album-head-bar p {
  margin: 6px 0 0;
  font-size: 14px;
  color: #9aa0aa;
}

.album-head-bar .back {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  color: #9aa0aa;
}

.album-head-bar .back:hover { color: #f1f2f4; text-decoration: none; }

/* 等高行网格：宽度按比例伸缩，每行自动对齐 */
.jg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1800px;
  margin: 24px auto 0;
  padding: 0 clamp(16px, 4vw, 48px) clamp(32px, 5vw, 64px);
}

/* 最后一行不留半截空白 */
.jg::after {
  content: "";
  flex-grow: 1e9;
}

.jg-item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #1a1c20;
  flex-grow: var(--r, 1.5);
  flex-shrink: 1;
  flex-basis: calc(var(--r, 1.5) * 220px);
  outline-offset: 3px;
}

/* 高度由百分比 padding 撑开（Safari 对 flex 子项的 aspect-ratio 支持有问题） */
.jg-item::before {
  content: "";
  display: block;
  padding-top: calc(100% / var(--r, 1.5));
}

.jg-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.jg-item img.ready { opacity: 1; }

@media (hover: hover) {
  .jg-item:hover img { transform: scale(1.03); }
  .jg-item:hover .jg-cap { opacity: 1; }
}

.jg-cap {
  position: absolute;
  inset: auto 0 0 0;
  padding: 22px 10px 8px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .jg-item { flex-basis: calc(var(--r, 1.5) * 140px); }
  .jg { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .jg-item img { transition: none; }
}
