/* ==========================================================================
   MOMENTS — photography.css
   摄影页：中央 MOMENTS 面板 + 环绕式照片拼贴。
   基础重置、字体、品牌与焦点样式复用 css/style.css。
   ========================================================================== */

:root {
  --photo-header-h: var(--header-h);
  --photo-gap: clamp(10px, 1vw, 16px);
  --first-h: calc(100vh - var(--photo-header-h));
  --first-h: calc(100svh - var(--photo-header-h));

  /* JS 会把 --frame-top / --frame-side 量到中央卡片的外缘。 */
  --frame-top: 26%;
  --frame-side: 31vw;
  --band-gap: 6px;
  --band-pad: 6px;
  --band-mobile-h: 30%;

  --photo-paper: #F1EFE9;
  --photo-panel: #FFFFFF;
  --photo-soft: #E7E3D9;
}

body.photography-page {
  background-color: var(--photo-paper);
  background-image: none;
  color: var(--ink);
  overflow-x: hidden;
}

body.photography-page ::selection {
  background: var(--blue);
  color: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- 1. Header ---------- */
.photo-header {
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid var(--line);
  background: rgba(241, 239, 233, 0.9);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.photo-header-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--photo-header-h);
  padding-inline: var(--gutter);
}

.photo-header-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  color: var(--muted);
  white-space: nowrap;
}

.photo-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
}

.photo-nav a {
  color: var(--ink);
  opacity: 0.62;
  transition: opacity 0.3s var(--ease), color 0.3s var(--ease);
}

.photo-nav a:hover {
  opacity: 1;
  color: var(--blue);
}

.photo-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.13em;
  color: var(--ink);
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}

.photo-back:hover {
  color: var(--blue);
}

/* ---------- 2. Stage ---------- */
.photo-main {
  position: relative;
}

.photo-stage {
  position: relative;
  height: var(--first-h);
  min-height: var(--first-h);
  overflow: hidden;
  background: var(--photo-paper);
}

/* ---------- 四条持续循环的照片带 ---------- */
.photo-band {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  background: var(--photo-paper);
}

.photo-band--top,
.photo-band--bottom {
  left: 0;
  right: 0;
  height: var(--frame-top);
}

.photo-band--top {
  top: 0;
  padding-block: var(--band-pad);
}

.photo-band--bottom {
  bottom: 0;
  padding-block: var(--band-pad);
}

.photo-band--left,
.photo-band--right {
  top: var(--frame-top);
  bottom: var(--frame-top);
  width: var(--frame-side);
}

.photo-band--left {
  left: 0;
  padding-inline: var(--band-pad);
}

.photo-band--right {
  right: 0;
  padding-inline: var(--band-pad);
}

.photo-band-track {
  position: relative;
  display: flex;
  will-change: transform;
}

.photo-band--top .photo-band-track,
.photo-band--bottom .photo-band-track {
  width: max-content;
  height: 100%;
  align-items: center;
}

.photo-band--left .photo-band-track,
.photo-band--right .photo-band-track {
  flex-direction: column;
  width: 100%;
  height: max-content;
  align-items: center;
}

.photo-band-set {
  display: flex;
  flex: 0 0 auto;
  gap: var(--band-gap);
}

.photo-band--top .photo-band-set,
.photo-band--bottom .photo-band-set {
  height: 100%;
  align-items: center;
  padding-right: var(--band-gap);
}

.photo-band--left .photo-band-set,
.photo-band--right .photo-band-set {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  padding-bottom: var(--band-gap);
}

/* 左右两列错开 7px，避免照片墙变成完全对齐的表格。 */
.photo-band--left .photo-tile:nth-child(even),
.photo-band--right .photo-tile:nth-child(even) {
  transform: translateY(7px);
}

.photo-band--top .photo-band-track {
  animation: band-scroll-left 58s linear infinite;
}

.photo-band--bottom .photo-band-track {
  animation: band-scroll-right 72s linear infinite;
}

.photo-band--left .photo-band-track {
  animation: band-scroll-up 64s linear infinite;
}

.photo-band--right .photo-band-track {
  animation: band-scroll-down 78s linear infinite;
}

@keyframes band-scroll-left {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-50%, 0, 0); }
}

@keyframes band-scroll-right {
  from { transform: translate3d(-50%, 0, 0); }
  to { transform: translate3d(0, 0, 0); }
}

@keyframes band-scroll-up {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, -50%, 0); }
}

@keyframes band-scroll-down {
  from { transform: translate3d(0, -50%, 0); }
  to { transform: translate3d(0, 0, 0); }
}

/* ---------- 3. Photo tiles inside the moving bands ---------- */
.photo-tile {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: var(--photo-soft);
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(23, 25, 29, 0.04);
  transition: box-shadow 0.4s var(--ease), transform 0.4s var(--ease);
}

/* 任意原始比例的照片都只做居中裁剪，不拉伸。 */
.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.001);
  transition: transform 0.6s var(--ease);
}

.photo-band--top .photo-tile,
.photo-band--bottom .photo-tile {
  width: auto;
  height: 100%;
}

.photo-tile.is-missing {
  min-height: 0;
  background: repeating-linear-gradient(
    45deg,
    #e5e1d7,
    #e5e1d7 8px,
    #ddd8cc 8px,
    #ddd8cc 16px
  );
}

.photo-tile.is-missing img {
  display: none;
}

.photo-tile.is-missing::after {
  content: "PHOTO MISSING";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.photo-tile:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  z-index: 25;
}

/* 悬停暂停由 JS 控制，弹窗关闭时可以显式清除，不依赖 :hover / :focus-within。 */
.photo-band.is-hover-paused .photo-band-track {
  animation-play-state: paused;
}

@media (hover: hover) and (pointer: fine) {
  .photo-tile:hover {
    z-index: 4;
    box-shadow: 0 26px 60px -32px rgba(23, 25, 29, 0.65),
      0 0 0 1px rgba(23, 25, 29, 0.08);
  }

  .photo-tile:hover img {
    transform: scale(1.045);
  }
}

body.modal-open .photo-band-track,
body.is-page-hidden .photo-band-track {
  animation-play-state: paused;
}

/* ---------- 4. Central MOMENTS panel ---------- */
.moments-panel {
  position: absolute;
  top: calc(var(--first-h) / 2);
  left: 50%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: clamp(340px, 38vw, 580px);
  max-width: calc(100vw - 40px);
  height: clamp(260px, 44vh, 430px);
  padding: clamp(18px, 2vw, 30px);
  transform: translate(-50%, -50%);
  background: var(--photo-panel);
  border: 1px solid rgba(23, 25, 29, 0.08);
  box-shadow: 0 36px 90px -52px rgba(23, 25, 29, 0.55);
}

.moments-kicker {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-align: center;
  color: var(--muted);
  text-transform: uppercase;
}

.moments-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 7px 0;
}

#moments-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.moments-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-sans);
  font-size: clamp(2.2rem, 6vw, 5rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.moments-panel.is-ready .moments-fallback {
  display: none;
}

.moments-foot {
  text-align: center;
}

.moments-meta {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--ink);
}

.moments-hint {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.hint-tap {
  display: none;
}

@media (hover: none) {
  .hint-hover {
    display: none;
  }

  .hint-tap {
    display: inline;
  }
}

/* ---------- 5. Photo detail modal ---------- */
.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 48px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s var(--ease), visibility 0s linear 0.35s;
}

.photo-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s var(--ease), visibility 0s;
}

.photo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 17, 18, 0.58);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  cursor: pointer;
}

.photo-modal-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.85fr);
  width: min(1180px, 94vw);
  max-height: 88vh;
  overflow: hidden;
  background: #F7F5EF;
  box-shadow: 0 44px 110px -46px rgba(0, 0, 0, 0.7);
  transform: translateY(18px) scale(0.985);
  transition: transform 0.35s var(--ease);
}

.photo-modal.is-open .photo-modal-dialog {
  transform: translateY(0) scale(1);
}

.photo-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.92);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

.photo-modal-close span:last-child {
  font-size: 14px;
  line-height: 1;
}

.photo-modal-close:hover {
  background: var(--ink);
  color: var(--bg);
}

.photo-modal-media {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: clamp(16px, 2.6vw, 32px);
  background: #E8E4DA;
}

.photo-modal-media img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.photo-modal-body {
  padding: clamp(44px, 4vw, 64px) clamp(24px, 3vw, 44px) clamp(30px, 3vw, 44px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.photo-modal-kicker {
  margin-bottom: 14px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.photo-modal-title {
  font-size: clamp(1.5rem, 2.4vw, 2.15rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.photo-modal-meta {
  margin-top: 22px;
  border-top: 1px solid var(--line);
}

.photo-modal-meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.photo-modal-meta-row dt {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
  white-space: nowrap;
}

.photo-modal-meta-row dd {
  margin: 0;
  font-size: 11.5px;
  text-align: right;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.photo-modal-section {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.photo-modal-section h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--blue);
}

.photo-modal-section h3 span {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.photo-modal-section p {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-line;
}

.photo-modal-section[data-section="feeling"] p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
}

/* ---------- 6. Misc ---------- */
.photo-noscript {
  max-width: 520px;
  margin: 24px auto;
  padding: 16px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 7. Responsive ---------- */
@media (max-width: 1080px) {
  /* 加入 TECHNOLOGY 入口后，窄桌面宽度下让出居中标签，避免与右侧导航重叠 */
  .photo-header-label {
    display: none;
  }
}

@media (max-width: 900px) {
  .photo-header-label,
  .photo-nav {
    display: none;
  }

  .photo-back {
    margin-left: auto;
  }
}

@media (max-width: 899px), (max-aspect-ratio: 5 / 4) {
  :root {
    --band-gap: 6px;
    --band-pad: 6px;
    --band-mobile-h: 30%;
  }

  .photo-band--top,
  .photo-band--bottom {
    height: var(--band-mobile-h);
  }

  .photo-band--left,
  .photo-band--right {
    display: none;
  }

  .photo-band--top .photo-band-track {
    animation-duration: 64s;
  }

  .photo-band--bottom .photo-band-track {
    animation-duration: 76s;
  }

  .moments-panel {
    width: min(86vw, 520px);
    height: clamp(210px, 30svh, 300px);
    padding: 15px;
  }

  .moments-kicker {
    font-size: 7.5px;
    letter-spacing: 0.18em;
  }

  .moments-meta {
    font-size: 7.5px;
  }

  .moments-hint {
    font-size: 7px;
  }

  .photo-modal-dialog {
    grid-template-columns: minmax(0, 1fr);
    max-height: 90vh;
    overflow-y: auto;
  }

  .photo-modal-media {
    padding: 14px;
  }

  .photo-modal-media img {
    max-height: 42vh;
  }

  .photo-modal-body {
    padding: 30px 20px 34px;
    overflow-y: visible;
  }

  .photo-modal-close {
    top: 10px;
    right: 10px;
  }
}

@media (max-width: 620px) {
  :root {
    --band-gap: 6px;
    --band-pad: 6px;
    --band-mobile-h: 29%;
  }

  .photo-header-inner {
    gap: 16px;
  }

  .photo-back {
    font-size: 8px;
  }

  .moments-panel {
    height: clamp(205px, 29svh, 260px);
  }

  .photo-modal {
    padding: 10px;
  }

  .photo-modal-dialog {
    width: 100%;
    max-height: 94vh;
  }

  .photo-modal-media {
    max-height: 40vh;
  }

  .photo-modal-media img {
    max-height: 36vh;
  }

  .photo-modal-title {
    font-size: 1.4rem;
  }
}

@media (max-width: 380px) {
  :root {
    --band-gap: 6px;
    --band-pad: 6px;
    --band-mobile-h: 28%;
  }

  .moments-panel {
    width: 88vw;
    height: 205px;
    padding: 12px;
  }
}

/* ---------- 8. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .photo-band-track {
    animation: none !important;
  }

  .photo-tile:hover img,
  .photo-tile:focus-visible img {
    transform: none;
  }

  .photo-modal,
  .photo-modal-dialog {
    transition: none;
  }
}
