/* =========================================================
   作品集 · 分类页
   白底、四列（竖屏两列）、每页十张。
   ========================================================= */

:root {
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --ink: #2b2c28;
  --muted: #87847a;
  --paper: #fbfaf7;
  --line: #e8e4db;
  --line-strong: #d8d3c8;
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

::selection {
  background: rgba(154, 160, 140, 0.28);
}

:focus-visible {
  outline: 1.5px solid #5e6257;
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 10px 16px;
  color: var(--ink);
  background: #fff;
  border-radius: 999px;
  font-size: 12px;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- 返回按钮 ---------- */

.back {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  left: calc(20px + env(safe-area-inset-left));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px 0 13px;
  color: #43443e;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(251, 250, 247, 0.93);
  transition: border-color 0.25s ease, background 0.25s ease;
}

.back svg {
  width: 16px;
  height: 16px;
}

.back:hover {
  border-color: var(--line-strong);
  background: #fff;
}

/* ---------- 页面 ---------- */

.gallery-main {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding:
    calc(clamp(96px, 11vw, 148px) + env(safe-area-inset-top))
    clamp(18px, 4.2vw, 68px)
    clamp(42px, 6vw, 76px);
}

.gallery-head {
  position: relative;
  max-width: 850px;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.3em;
  line-height: 1;
}

.gallery-head__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.gallery-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.55rem, 6.1vw, 5.3rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1;
}

.gallery-head h1:focus {
  outline: none;
}

.gallery-count {
  margin: 0 0 0.55em;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.gallery-desc {
  max-width: 34em;
  margin: 23px 0 0;
  color: #79776e;
  font-family: var(--serif);
  font-size: clamp(12px, 1.15vw, 14px);
  line-height: 1.9;
  letter-spacing: 0.05em;
}

.demo-note {
  display: inline-flex;
  margin: 22px 0 0;
  padding: 7px 11px;
  color: #858278;
  font-size: 10px;
  letter-spacing: 0.05em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

/* ---------- 作品网格 ---------- */

.art-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.45vw, 21px);
  margin-top: clamp(32px, 4.6vw, 62px);
}

.art-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
  color: #fff;
  text-align: left;
  text-decoration: none;
  border: 1px solid rgba(43, 44, 40, 0.055);
  border-radius: clamp(4px, 0.5vw, 8px);
  background:
    linear-gradient(140deg, rgba(230, 226, 216, 0.58), rgba(245, 242, 235, 0.8));
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.5s ease var(--delay, 0ms),
    transform 0.6s cubic-bezier(0.2, 0.7, 0.25, 1) var(--delay, 0ms);
}

.art-card--pdf {
  cursor: pointer;
}

.art-card.is-in {
  opacity: 1;
  transform: translateY(0);
}

.art-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.25, 1);
}

.art-card.is-loaded img {
  opacity: 1;
}

.art-card.is-error {
  cursor: default;
}

.art-card.is-error img {
  display: none;
}

.art-card.is-error::before {
  content: "图片读取失败";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  background: #f1eee7;
}

.art-card__veil {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 34px 14px 12px;
  background: linear-gradient(to top, rgba(19, 19, 16, 0.48), rgba(19, 19, 16, 0));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.art-card__index {
  font-size: 9px;
  letter-spacing: 0.16em;
  opacity: 0.72;
}

.art-card__name {
  overflow: hidden;
  max-width: 76%;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.art-card__pdf {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  color: #55564f;
  font-size: 8px;
  letter-spacing: 0.14em;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: rgba(249, 247, 241, 0.9);
  box-shadow: 0 2px 10px rgba(20, 20, 16, 0.08);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .art-card:hover img {
    transform: scale(1.025);
  }

  .art-card:hover .art-card__veil {
    opacity: 1;
  }
}

.art-card:focus-visible {
  outline-offset: 3px;
}

.art-card:focus-visible .art-card__veil {
  opacity: 1;
}

/* ---------- 状态提示 ---------- */

.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 26vh;
  margin-top: 22px;
  color: var(--muted);
  text-align: center;
}

.status__line {
  display: block;
  width: 1px;
  height: 34px;
  background: linear-gradient(to bottom, transparent, var(--line-strong));
}

.status p {
  margin: 0;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.status__link {
  color: #55564f;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-underline-offset: 4px;
}

.status.is-error .status__line {
  background: var(--line-strong);
}

/* ---------- 翻页 ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: clamp(42px, 6.8vw, 78px);
  padding-top: clamp(18px, 2.6vw, 26px);
  border-top: 1px solid var(--line);
}

.pager__meta {
  min-width: 108px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.pager__numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.pager__controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pager__number,
.pager__arrow {
  display: grid;
  place-items: center;
  height: 36px;
  color: #737168;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.pager__number {
  min-width: 32px;
  padding: 0 5px;
  font-size: 11px;
  letter-spacing: 0.05em;
  border-radius: 999px;
}

.pager__number:hover,
.pager__arrow:hover:not(:disabled) {
  color: var(--ink);
  background: #f0ede6;
}

.pager__number[aria-current="page"] {
  color: var(--ink);
  background: #ebe7de;
}

.pager__ellipsis {
  display: grid;
  place-items: center;
  width: 20px;
  height: 36px;
  color: #b1ada3;
  font-size: 11px;
}

.pager__arrow {
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.pager__arrow svg {
  width: 15px;
  height: 15px;
}

.pager__arrow:disabled {
  color: #c7c3b9;
  cursor: default;
  opacity: 0.55;
}

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

.site-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: clamp(56px, 8vw, 96px);
  padding-top: 20px;
  color: #aba79d;
  font-size: 8px;
  letter-spacing: 0.22em;
  border-top: 1px solid rgba(232, 228, 219, 0.6);
}

/* ---------- 大图浏览 ---------- */

.is-locked,
.is-locked body {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #161714;
  color: #f6f2e9;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0s linear 0.32s;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.32s ease, visibility 0s linear 0s;
}

.lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding:
    clamp(58px, 8vh, 88px)
    clamp(58px, 8.5vw, 120px)
    clamp(30px, 5vh, 48px);
}

.lightbox__stage {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.lightbox__image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.25);
  transition: opacity 0.3s ease;
  user-select: none;
}

.lightbox__image.is-loaded {
  opacity: 1;
}

.lightbox__loading {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(246, 242, 233, 0.2);
  border-top-color: rgba(246, 242, 233, 0.85);
  border-radius: 50%;
  opacity: 0;
  animation: lightbox-spin 0.9s linear infinite;
}

.lightbox.is-loading .lightbox__loading {
  opacity: 1;
}

@keyframes lightbox-spin {
  to {
    transform: rotate(360deg);
  }
}

.lightbox__caption {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  max-width: 80vw;
  padding-top: 20px;
  color: rgba(246, 242, 233, 0.52);
  font-size: 9px;
  letter-spacing: 0.17em;
  line-height: 1.5;
}

.lightbox__name {
  overflow: hidden;
  max-width: 52vw;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  color: rgba(246, 242, 233, 0.85);
  border: 1px solid rgba(246, 242, 233, 0.17);
  border-radius: 50%;
  background: rgba(246, 242, 233, 0.04);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.lightbox__close:hover,
.lightbox__nav:hover {
  color: #fff;
  border-color: rgba(246, 242, 233, 0.4);
  background: rgba(246, 242, 233, 0.1);
}

.lightbox__close {
  top: calc(20px + env(safe-area-inset-top));
  right: calc(20px + env(safe-area-inset-right));
  width: 42px;
  height: 42px;
}

.lightbox__nav {
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translateY(-50%);
}

.lightbox__nav--prev {
  left: calc(20px + env(safe-area-inset-left));
}

.lightbox__nav--next {
  right: calc(20px + env(safe-area-inset-right));
}

.lightbox__close svg {
  width: 18px;
  height: 18px;
}

.lightbox__nav svg {
  width: 18px;
  height: 18px;
}

.lightbox__nav[hidden] {
  display: none;
}

/* ---------- 竖屏：两列 ---------- */

@media (orientation: portrait) {
  .art-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-head {
    max-width: 100%;
  }

  .gallery-desc {
    max-width: 28em;
  }

  .gallery-main {
    padding-top: calc(clamp(88px, 15vw, 120px) + env(safe-area-inset-top));
  }
}

@media (max-width: 700px) {
  .gallery-main {
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-left: calc(16px + env(safe-area-inset-left));
  }

  .art-grid {
    gap: 9px;
  }

  .gallery-count {
    margin-bottom: 0.35em;
    font-size: 9px;
  }

  .gallery-desc {
    margin-top: 18px;
    line-height: 1.8;
  }

  .pager {
    gap: 8px;
  }

  .pager__controls {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .pager__meta {
    display: none;
  }

  .pager__numbers {
    gap: 1px;
  }

  .pager__number {
    min-width: 28px;
    font-size: 10px;
  }

  .pager__ellipsis {
    width: 14px;
  }

  .pager__arrow {
    width: 38px;
  }

  .lightbox__figure {
    padding:
      calc(58px + env(safe-area-inset-top))
      54px
      calc(22px + env(safe-area-inset-bottom));
  }

  .lightbox__nav {
    top: auto;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: none;
  }

  .lightbox__nav--prev {
    left: calc(24px + env(safe-area-inset-left));
  }

  .lightbox__nav--next {
    right: calc(24px + env(safe-area-inset-right));
  }

  .lightbox__caption {
    padding-bottom: 60px;
  }

  .lightbox__name {
    max-width: 46vw;
  }
}

@media (max-width: 430px) {
  .back {
    top: calc(14px + env(safe-area-inset-top));
    left: calc(14px + env(safe-area-inset-left));
    min-height: 38px;
    padding: 0 14px 0 11px;
    font-size: 10px;
  }

  .gallery-head__row {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }

  .gallery-count {
    margin: 0;
  }

  .gallery-head h1 {
    font-size: clamp(2.2rem, 11vw, 3rem);
  }

  .lightbox__figure {
    padding-right: 14px;
    padding-left: 14px;
  }

  .lightbox__image {
    max-height: 100%;
  }

  .lightbox__nav {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .lightbox__nav--prev {
    left: calc(18px + env(safe-area-inset-left));
  }

  .lightbox__nav--next {
    right: calc(18px + env(safe-area-inset-right));
  }

  .lightbox__caption {
    gap: 10px;
    padding-bottom: 58px;
  }

  .lightbox__name {
    max-width: 48vw;
    font-size: 10px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .art-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .art-card {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .art-card img {
    transition: none;
  }

  .lightbox,
  .lightbox__image,
  .art-card__veil {
    transition: none;
  }

  .lightbox__loading {
    animation: none;
  }
}

@keyframes page-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes page-fade-in {
  from {
    opacity: 0;
  }
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: page-fade-out 0.22s ease both;
}

::view-transition-new(root) {
  animation: page-fade-in 0.4s ease both;
}
