/* 相册页面：照片墙与灯箱。基础样式与导航复用 app.css。 */

/*
 * 相册的解锁弹窗只属于相册视图。
 * 它是全局的固定遮罩，没这条规则的话，在弹窗开着的时候切走（比如去看一起看），
 * 那层雾和卡片会一直盖在别的视图上——看得见、点不动，还找不到为什么。
 * 切回来它还在，输入的进度不会丢。
 */
body:not([data-view="space"]) #space-lock,
body:not([data-view="space"]) #space-repass { display: none; }

/* ---- 工具条 ----
   搜索、张数、刷新挤在一行，不占首屏。 */

.album-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.album-bar input[type=search] { flex: 1; min-width: 160px; }
.album-bar .icon-btn { flex: none; }

/* ---- 页签 ----
   照片墙与故事两页。做成两枚药丸而不是两行字：
   它们切换的是「同一批照片的两种看法」，不是去往另一个地方，所以留在相册这一层。 */

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  flex: none;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  padding: 6px 15px;
  font-size: 13.5px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
}

.tab:hover:not(:disabled) {
  border: none;
  background: transparent;
  color: var(--ink);
}

.tab.is-on {
  background: var(--surface);
  color: var(--accent-deep);
  box-shadow: 0 1px 3px rgba(150, 100, 70, .16);
}

.tab.is-on:hover:not(:disabled) { background: var(--surface); }

.album-count {
  flex: none;
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

#upload-note { margin-top: 10px; }
#upload-note:empty { margin-top: 0; min-height: 0; }

/* ---- 拖放 ----

   接住文件的是整个相册视图，所以高亮也得是整块：它得让人一眼看出
   「松手就落在这儿」，而不是只盯着抽屉里那块小框。
   用伪元素盖一层，照片墙的布局一点不动。 */

#view-space { position: relative; }

#view-space.drop-over::after {
  content: '松开就开始上传';
  position: absolute;
  inset: -4px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(253, 248, 243, .82);
  /* 底下的照片与抽屉不该和这句提示抢注意力：糊掉，只留落点这一层清晰 */
  backdrop-filter: blur(5px);
  color: var(--accent-deep);
  font-size: 14px;
  pointer-events: none;
}

/* ---- 时间线 ---- */

.month {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  margin: 30px 0 12px;
  letter-spacing: .04em;
}

.month:first-child { margin-top: 18px; }

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

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-sunk);
  border: none;
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
}

.tile:hover:not(:disabled) {
  transform: translateY(-2px);
  border: none;
  background: var(--surface-sunk);
  box-shadow: 0 12px 26px -14px rgba(150, 100, 70, .42);
}

.tile img, .tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  aspect-ratio: auto;
}

.tile .ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--ink-3);
  padding: 10px;
  text-align: center;
  word-break: break-all;
  overflow: hidden;
}

.tile .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 9px 7px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(40, 26, 20, .66));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile .busy {
  position: absolute;
  top: 7px;
  right: 7px;
  font-size: 10px;
  color: var(--ink-2);
  background: rgba(255, 253, 251, .9);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---- 灯箱 ---- */

.lightbox {
  position: fixed;
  inset: 0;
  /* 高于通话小窗（40）与片单（60）：看照片时它们都该让开 */
  z-index: 70;
  background: rgba(30, 22, 18, .95);
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.lightbox .frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.lightbox img, .lightbox video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  aspect-ratio: auto;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
}

.lightbox .bar-info {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: #f0e6df;
  font-size: 13px;
  padding: 14px 4px 4px;
}

.lightbox .bar-info .grow { flex: 1; min-width: 120px; }

.lightbox button {
  background: transparent;
  color: #f0e6df;
  border-color: rgba(255, 255, 255, .32);
}

.lightbox button:hover:not(:disabled) {
  border-color: #fff;
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.lightbox button.danger:hover:not(:disabled) {
  border-color: #ff9a86;
  color: #ff9a86;
  background: rgba(255, 122, 96, .12);
}

.empty {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-3);
  padding: 44px 20px;
  text-align: center;
}

/* ================= 故事 =================
   一条故事 = 一个时间 + 一段描述 + 一组照片。
   阅读态是一条沿竖轴左右交错的线，编辑态是一列可以改的条目。
   两种样子说的是同一份数据，改完存下就是加密后的一整份密文。 */

/* ---- 阅读态 ---- */

#story-read { position: relative; padding: 10px 0 40px; }

.story-line { position: relative; }

/* 竖轴。两端渐隐，免得线在首尾被硬生生截断。 */
.story-line::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: linear-gradient(transparent, var(--line-2) 10%, var(--line-2) 90%, transparent);
}

.story-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 62px;
  margin-bottom: 34px;
  /* 滚到哪条哪条浮现。起始态在这里，IntersectionObserver 只负责加 .is-in。 */
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s cubic-bezier(.22, .7, .3, 1);
}

.story-item.is-in { opacity: 1; transform: none; }
.story-item:last-child { margin-bottom: 0; }

.story-dot {
  position: absolute;
  top: 13px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.story-card {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  text-align: right;
}

.story-item:nth-child(even) .story-card {
  grid-column: 2;
  align-items: flex-start;
  text-align: left;
}

.story-when {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .03em;
}

.story-text {
  margin: 0;
  max-width: 340px;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- 堆叠预览 ----
   一叠错开的卡片，最上面一张是这条的第一张，右下角标总数。
   点开才逐张看——一条挂多少张都行，堆叠的形状不随张数变形。 */

.story-stack {
  position: relative;
  display: block;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4 / 3;
  /* 下面垫片要露出边，给它留出地方 */
  margin: 0 0 20px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.story-stack:hover:not(:disabled) { border: none; background: transparent; }

.story-stack .stack-sheet,
.story-stack .stack-top {
  position: absolute;
  inset: 0;
  border-radius: 16px;
}

/*
 * 垫片要比页面底色亮出来才看得见：它和卡片的区别只在下沿那一线，
 * 若用跟背景同色系的浅色，堆叠看起来就是一张孤零零的照片，
 * 「这一组还有别的」这件事就传不出去。
 */
.story-stack .stack-sheet {
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: 0 4px 12px -9px rgba(150, 100, 70, .5);
}

/* 垫片只向下错开，不往右——横向错开在窄屏上会被裁掉一半 */
.story-stack .stack-sheet.s1 { transform: translateY(8px) scale(.99); }
.story-stack .stack-sheet.s2 { transform: translateY(16px) scale(.98); }

.story-stack .stack-top {
  overflow: hidden;
  background: var(--surface-sunk);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}

.story-stack:hover .stack-top {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px -18px rgba(150, 100, 70, .5);
}

.story-stack .stack-top img,
.story-stack .stack-top video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  aspect-ratio: auto;
}

.story-stack .ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--ink-3);
}

.story-stack .stack-badge {
  position: absolute;
  right: 12px;
  bottom: 18px;
  z-index: 2;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  color: #fff;
  background: rgba(40, 26, 20, .6);
  backdrop-filter: blur(4px);
}

/* ---- 编辑态 ---- */

.sedit { display: flex; flex-direction: column; gap: 14px; padding-bottom: 10px; }

.sedit-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sedit-hint { font-size: 12.5px; color: var(--ink-3); }

.se {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.se-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.se-idx { flex: none; font-size: 12px; color: var(--ink-3); }

/* 日期输入在移动端是原生选择器，改得太狠会把它弄坏——只对齐外观与字号。 */
.se-date {
  flex: none;
  width: auto;
  min-width: 0;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface-sunk);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}

.se-acts { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.se-acts button { padding: 6px 13px; font-size: 12.5px; }

.se-text {
  min-height: 62px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.75;
}

.se-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.se-thumb, .se-add {
  position: relative;
  flex: none;
  width: 76px;
  height: 76px;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-sunk);
  border: 1px solid var(--line-2);
}

.se-thumb img, .se-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  aspect-ratio: auto;
}

.se-thumb .ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  overflow: hidden;
}

.se-add { font-size: 22px; line-height: 1; color: var(--ink-3); }

/* 选中态只在「选择」打开时才有意义，所以它挂在 .picking 下面 */
.se.picking .se-thumb { cursor: pointer; }

.se-thumb.is-picked {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.se-thumb .mark {
  position: absolute;
  top: 4px;
  right: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  font-size: 12px;
  color: #fff;
  background: var(--accent);
}

.se-thumb.is-picked .mark { display: flex; }

/* ---- 挑照片 ---- */

.picker {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(30, 22, 18, .55);
  backdrop-filter: blur(3px);
}

.picker-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(880px, 100%);
  max-height: 86vh;
  padding: 18px;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px -30px rgba(60, 40, 30, .6);
}

.picker-head { display: flex; align-items: center; gap: 12px; }
.picker-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; }
.picker-hint { margin: 0; font-size: 12.5px; color: var(--ink-3); }
#picker-grid { flex: 1; min-height: 0; overflow-y: auto; }
.picker-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.picker-foot .grow { flex: 1; }

/* 可勾选的缩略图：左上角一枚圆标，选中才显勾 */
.tile .mark {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .85);
  background: rgba(0, 0, 0, .3);
  color: #fff;
  font-size: 13px;
}

.tile .mark::after { content: '✓'; opacity: 0; }
.tile.is-picked .mark { background: var(--accent); border-color: #fff; }
.tile.is-picked .mark::after { opacity: 1; }
.tile.is-picked { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }

/* ---- 灯箱翻页 ---- */

.lb-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  margin-top: -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}

.lb-nav svg { width: 22px; height: 22px; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-pos { color: #cfc2b8; font-variant-numeric: tabular-nums; }

/* ---- 窄屏 ---- */

@media (max-width: 760px) {
  /* 左右交错在窄屏上会挤成一团：改成单列，竖轴挪到左边 */
  .story-line::before { left: 5px; }

  .story-item { grid-template-columns: 1fr; column-gap: 0; padding-left: 26px; }

  .story-card,
  .story-item:nth-child(even) .story-card {
    grid-column: 1;
    align-items: flex-start;
    text-align: left;
  }

  .story-dot { left: 5px; }
  .story-stack { max-width: none; }
  .story-text { max-width: none; }

  .lb-nav { width: 38px; height: 38px; margin-top: -19px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }

  .se-thumb, .se-add { width: 64px; height: 64px; }
}

/* 系统开了「减弱动态效果」就别动：内容直接呈现，不浮现、不上浮。 */
@media (prefers-reduced-motion: reduce) {
  .story-item {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .story-stack .stack-top { transition: none; }
}
