/* === landing.css · 主页面、卡片、长信、浮层、音乐控件 === */

/* 用 @property 注册可被插值的"位移倍率"变量，
   hover 时把 back/mid 沿自己原本的散开方向再往外推一些；
   hover-out 时变量回到 1，sheet 平滑滑回原位 */
@property --bo {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}
@property --mo {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

/* hover 时让奶油白洗层的"四周透明度"沿径向渐进到 0，打出圆形发散感 */
@property --edge-a {
  syntax: "<number>";
  inherits: false;
  initial-value: 0.62;
}

/* ---------- 主容器 ---------- */
.landing {
  opacity: 0;
  visibility: hidden;
  transition: opacity 800ms var(--ease),
    visibility 800ms var(--ease);
  padding: var(--s-8) var(--s-5) var(--s-7);
  max-width: 1080px;
  margin: 0 auto;
}

.landing.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ---------- Header ---------- */
.landing__header {
  text-align: center;
  margin-bottom: var(--s-7);
}

.landing__brand {
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  margin-bottom: var(--s-5);
}

.landing__brand img {
  display: block;
  width: clamp(220px, 36vw, 560px);
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.landing__title {
  font-size: clamp(20px, 3.4vw, 28px);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.6;
  color: var(--fg);
}

.landing__subtitle {
  margin-top: var(--s-4);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--fg-2);
}

/* ---------- 卡片网格 ---------- */
.cards {
  margin-bottom: var(--s-8);
}

.cards__list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-8);
}

@media (min-width: 720px) {
  .cards__list {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-8) var(--s-7);
  }
}

/* 手机 / 触摸设备：让卡片散乱程度更收敛，避免照片堆边缘溢出/视觉过乱 */
@media (hover: none), (max-width: 719px) {
  .cards__list {
    --scatter: 0.55;
  }
}

/* ---------- 单张卡片 ---------- */
.card {
  position: relative;
  isolation: isolate;
}

.card__stack {
  position: relative;
  aspect-ratio: 4 / 3;
  cursor: pointer;
  transition: transform var(--dur-2) var(--ease);
}

/* 三层"堆叠胶片"：底层两片为装饰，最上一层是主面
   主面尺寸约 stack 的 76% × 76%（≈58% 面积），居中放置；
   back / mid 通过更大的位移和角度向外散开，让前后照片露出更多 */
.card__sheet {
  position: absolute;
  width: 76%;
  height: 76%;
  top: 50%;
  left: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-1);
  /* 让位移倍率（--bo / --mo）和 sheet 自身位移一起平滑过渡，
     hover-out 时自动滑回原位 */
  transition: --bo 520ms var(--ease), --mo 540ms var(--ease) 40ms,
    transform var(--dur-3) var(--ease),
    box-shadow var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}

.card__sheet--back {
  /* 每张卡的 back 用各自的 --bx / --by / --brot 描述静态散开；
     hover 时整体倍率 --bo 增大，沿同方向再向外推；
     --scatter 是全局散乱程度（移动端会被缩小） */
  transform: translate(
      calc(-50% + var(--bx, 30px) * var(--bo) * var(--scatter, 1)),
      calc(-50% + var(--by, -34px) * var(--bo) * var(--scatter, 1))
    )
    rotate(calc(var(--brot, 3.6deg) * var(--scatter, 1)));
  opacity: 0.5;
  /* 如有 --tint-1 / --tint-2，混入中性底色做出淡淡的偏色 */
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--tint-1, var(--bg-2)) 14%, var(--bg-2)),
      color-mix(in srgb, var(--tint-2, var(--bg-2)) 14%, var(--bg-2))
    );
}

.card__sheet--mid {
  transform: translate(
      calc(-50% + var(--mx, -36px) * var(--mo) * var(--scatter, 1)),
      calc(-50% + var(--my, 18px) * var(--mo) * var(--scatter, 1))
    )
    rotate(calc(var(--mrot, -2.4deg) * var(--scatter, 1)));
  opacity: 0.78;
  background:
    linear-gradient(
      315deg,
      color-mix(in srgb, var(--tint-2, var(--bg-2)) 10%, var(--bg-2)),
      color-mix(in srgb, var(--tint-1, var(--bg-2)) 10%, var(--bg-2))
    );
}

.card__sheet--top {
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-2);
  border-radius: 14px;
}

/* 6 张卡片各自"看上去随机"的散落方向（不再对称） */
.card:nth-child(1) { --bx: 30px;  --by: -34px; --brot: 3.6deg;
                     --mx: -36px; --my: 18px;  --mrot: -2.4deg; }
.card:nth-child(2) { --bx: -42px; --by: -8px;  --brot: -4.8deg;
                     --mx: 22px;  --my: 32px;  --mrot: 2.2deg; }
.card:nth-child(3) { --bx: 12px;  --by: 36px;  --brot: -3.2deg;
                     --mx: 38px;  --my: -14px; --mrot: 5.4deg; }
.card:nth-child(4) { --bx: -36px; --by: -26px; --brot: -2.6deg;
                     --mx: -18px; --my: 34px;  --mrot: 4.4deg; }
.card:nth-child(5) { --bx: 36px;  --by: 14px;  --brot: 4.6deg;
                     --mx: -28px; --my: -30px; --mrot: -3.8deg; }
.card:nth-child(6) { --bx: -10px; --by: -38px; --brot: 2.2deg;
                     --mx: 34px;  --my: 22px;  --mrot: -4.4deg; }

.card__placeholder {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--fg);
  letter-spacing: 0.28em;
  font-size: 15px;
  font-weight: 400;
  padding: 0 var(--s-4);
  transition: transform var(--dur-2) var(--ease);
}

/* 默认就显示淡色 preview 作底图，hover 不变（更安静） */
.card__preview {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.6;
  filter: blur(3px) contrast(0.96) brightness(1.04) saturate(0.95);
  border-radius: 14px;
}

/* 与卡面同色的"奶油白"洗一层；默认均匀覆盖，
hover 后变成发散渐变：中间保持奶油白，四周逐渐透明 */
.card__preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at center,
    rgba(242, 242, 239, 0.62) 0%,
    rgba(242, 242, 239, 0.62) 32%,
    rgba(242, 242, 239, var(--edge-a)) 100%
  );
  transition: --edge-a var(--dur-3) var(--ease);
}

/* 预览态 meta：整块在卡内水平居中，文字本身左对齐 */
.card__preview-meta {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 14px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease);
  pointer-events: none;
  z-index: 2;
  color: var(--fg-2);
  text-align: left;
  width: max-content;
  max-width: calc(100% - var(--s-5) * 2);
}

.card__meta-row {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-start;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--fg);
}

.card__meta-label {
  color: var(--fg-2);
  flex-shrink: 0;
  min-width: 32px;
  text-align: left;
}

/* hover / 长按 触发预览 */
.card.is-preview .card__sheet--top {
  box-shadow: var(--shadow-2);
}

/* hover 时：保留"关于xxx"，往上轻移；meta 在其下方左对齐淡入。
   背景图本身保持原本的淡色与虚化，只在奶油白洗层上做发散效果：中心不变、四周透明 */
.card.is-preview .card__placeholder {
  transform: translateY(-22px);
}

.card.is-preview .card__preview::after {
  --edge-a: 0;
}

.card.is-preview .card__preview-meta {
  opacity: 1;
  transform: translate(-50%, 4px);
}

/* hover / 预览态：保持每张卡片自己的散落方向，
   通过倍率 --bo/--mo 让后两片沿原方向再向外推一点；
   主面只做轻微放大 */
.card.is-preview .card__stack {
  transform: scale(1.012);
}
.card.is-preview .card__sheet--back { --bo: 1.55; }
.card.is-preview .card__sheet--mid { --mo: 1.55; }

/* 桌面 hover */
@media (hover: hover) {
  .card__stack:hover {
    transform: scale(1.012);
  }
  .card__stack:hover .card__sheet--top {
    box-shadow: var(--shadow-2);
  }
  .card__stack:hover .card__placeholder {
    transform: translateY(-22px);
  }
  .card__stack:hover .card__preview::after {
    --edge-a: 0;
  }
  .card__stack:hover .card__preview-meta {
    opacity: 1;
    transform: translate(-50%, 4px);
  }
  .card__stack:hover .card__sheet--back { --bo: 1.55; }
  .card__stack:hover .card__sheet--mid { --mo: 1.55; }
}

/* 已点亮态：按原设计完整呈现照片，不再叠标题/meta/奶油洗 */
.card.is-lit .card__placeholder {
  display: none;
}

.card.is-lit .card__preview {
  opacity: 1;
  filter: none;
}

.card.is-lit .card__preview::after {
  background: none;
}

.card.is-lit .card__preview-meta {
  display: none;
}

/* 已点亮态：back / mid 也是真实照片，提高不透明度让前后清晰可见 */
.card.is-lit .card__sheet--back {
  opacity: 0.78;
  background-size: cover;
  background-position: center;
}
.card.is-lit .card__sheet--mid {
  opacity: 0.92;
  background-size: cover;
  background-position: center;
}

/* 点击 lit 卡片：堆叠"散开" + 主面放大，并把整组淡出，让画廊接上 */
.card.is-opening .card__stack {
  transform: scale(1.08);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.card.is-opening .card__sheet--back {
  --bo: 3.2;
  opacity: 0;
}
.card.is-opening .card__sheet--mid {
  --mo: 3.2;
  opacity: 0;
}
.card.is-opening .card__sheet--top {
  opacity: 0;
  transition: opacity 280ms ease 120ms,
    transform var(--dur-3) var(--ease);
}

/* ---------- 长信 ---------- */
.letter {
  max-width: 640px;
  margin: 0 auto var(--s-8);
  padding: var(--s-7) var(--s-4);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.letter__title {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: #7C8A6A; /* 与信封内壁同色 · 深苔绿 */
  margin-bottom: var(--s-6);
}

.letter__body p {
  font-size: 15px;
  line-height: 2;
  color: var(--fg);
  margin-bottom: var(--s-4);
  letter-spacing: 0.04em;
}

.letter__signature {
  text-align: center;
  margin-top: var(--s-6);
  font-size: 15px;
  color: #7C8A6A; /* 与信封内壁同色 · 深苔绿 */
  letter-spacing: 0.12em;
  font-weight: 600;
}

/* ---------- Footer ---------- */
.landing__footer {
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--fg-2);
  padding: var(--s-6) 0 calc(var(--s-6) + 40px);
}

/* ---------- 大图浮层 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(43, 43, 43, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}

.lightbox[hidden] {
  display: none;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox__close {
  position: absolute;
  top: var(--s-5);
  right: var(--s-5);
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  color: var(--bg);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lightbox__figure {
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
}

.lightbox__figure img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: var(--bg);
  border-radius: 12px;
}

.lightbox__figure figcaption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  color: var(--bg);
  text-align: center;
}

.lightbox__date {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.lightbox__note {
  font-size: 13px;
  max-width: 420px;
  letter-spacing: 0.04em;
  line-height: 1.8;
}

/* ---------- 音乐控件 ---------- */
.audio-ctrl {
  position: fixed;
  left: 50%;
  bottom: var(--s-5);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 16px 8px 10px;
  background: rgba(242, 242, 239, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(10px);
  opacity: 0.85;
  cursor: pointer;
  transform: translateX(-50%);
  transition: opacity var(--dur-2) var(--ease);
}

.audio-ctrl:hover {
  opacity: 1;
}

.audio-ctrl.is-blocked {
  opacity: 1;
  animation: pulse 1.4s ease-in-out 2;
  cursor: pointer;
}

/* 信封动画期间隐藏音乐控件，等 landing 显出再出现 */
.envelope[aria-hidden="false"] ~ .audio-ctrl {
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms var(--ease);
}

.audio-ctrl__toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.audio-ctrl__name {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--fg);
  font-weight: 500;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(184, 161, 138, 0);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(184, 161, 138, 0.18);
  }
}

/* ---------- 整组照片画廊（散开后进入滚动查看） ---------- */
.gallery {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: var(--bg);
  opacity: 0;
  transition: opacity 320ms var(--ease);
}

.gallery[hidden] {
  display: none;
}

.gallery.is-open {
  opacity: 1;
}

.gallery__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--s-7) var(--s-5);
}

.gallery__head {
  max-width: 720px;
  margin: 0 auto var(--s-7);
  text-align: center;
}

.gallery__eyebrow {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--fg-2);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-bottom: var(--s-3);
}

.gallery__title {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--fg);
  line-height: 1.5;
}

.gallery__sub {
  margin-top: var(--s-3);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--fg-2);
}

/* gallery 头部的 meta：标题下方居中，每行内容左对齐 */
.gallery__meta {
  margin: var(--s-4) auto 0;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
}
.gallery__meta .card__meta-row {
  font-size: 12px;
}

.gallery__list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-6);
  max-width: 880px;
}

.gallery__item {
  width: 100%;
  display: flex;
  justify-content: center;
}

.gallery__img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 760px;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.06);
  background: var(--bg-2);
}

.gallery__item[data-orient="portrait"] .gallery__img {
  max-width: 520px;
}

.gallery__bottom-spacer {
  height: calc(var(--s-8) + 56px);
}

/* 底部返回按钮 */
.gallery__back {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%) translateY(8px);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px 10px 18px;
  background: rgba(31, 31, 31, 0.92);
  color: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  letter-spacing: 0.2em;
  cursor: pointer;
  opacity: 0;
  transition: opacity 280ms var(--ease) 160ms,
    transform 280ms var(--ease) 160ms, background 200ms var(--ease);
}

.gallery.is-open .gallery__back {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.gallery__back:hover {
  background: rgba(31, 31, 31, 1);
}

.gallery__back-arrow {
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.gallery__back-text {
  font-size: 12px;
  letter-spacing: 0.32em;
}

@media (max-width: 640px) {
  .gallery__scroll {
    padding: var(--s-6) var(--s-4);
  }
  .gallery__list {
    gap: var(--s-5);
  }
  .gallery__bottom-spacer {
    height: calc(var(--s-7) + 56px);
  }
}
