/* 故事时间轴 — 双线双列 + 中央金轴 */

#screen-timeline,
#screen-timeline-detail {
  background: transparent;
  isolation: isolate;
}

/* 背景门户：挂在 #app 下，仅在时间轴页显示 */
.tl-bg-portal {
  display: none;
  pointer-events: none;
}

#app:has(#screen-timeline.active) .tl-bg-portal,
#app:has(#screen-timeline-detail.active) .tl-bg-portal {
  display: block;
}

/* 固定背景层（对齐 #app 宽度，滑动时不随内容滚动） */
.tl-bg-portal .tl-bg-layer {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, 100%);
  height: 100vh;
  height: 100dvh;
  z-index: 8;
  pointer-events: none;
  background: url('../images/故事时间轴背景.png') center top / cover no-repeat;
}

.tl-bg-portal .tl-bg-veil {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, 100%);
  height: 100vh;
  height: 100dvh;
  z-index: 8;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.02) 0%,
    rgba(0, 0, 0, 0.1) 100%
  );
}

#screen-timeline > .topbar,
#screen-timeline > .tl-page,
#screen-timeline-detail > .topbar,
#screen-timeline-detail > #timeline-detail-body {
  position: relative;
  z-index: 1;
}

#screen-timeline .topbar {
  position: sticky;
  z-index: 20;
  background: rgba(28, 10, 16, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: rgba(212, 175, 55, 0.22);
}

.tl-page {
  position: relative;
  z-index: 1;
  padding: 0 10px 24px;
}

.tl-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  overflow: hidden;
  margin: 12px 0 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.tl-legend__anna {
  background: linear-gradient(135deg, rgba(80, 15, 15, 0.62), rgba(40, 8, 8, 0.72));
  border-right: 1px solid rgba(212, 175, 55, 0.25);
  padding: 12px 8px;
  text-align: center;
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  color: #fca5a5;
  letter-spacing: 0.05em;
  position: relative;
}

.tl-legend__anna::before {
  content: '🩸';
  font-size: 10px;
  display: block;
  margin-bottom: 2px;
}

.tl-legend__anna.is-active {
  border-bottom: 2px solid #b91c1c;
}

.tl-legend__levin {
  background: linear-gradient(135deg, rgba(15, 40, 25, 0.62), rgba(8, 25, 15, 0.72));
  padding: 12px 8px;
  text-align: center;
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  color: #86efac;
  letter-spacing: 0.05em;
  position: relative;
}

.tl-legend__levin::before {
  content: '🌾';
  font-size: 10px;
  display: block;
  margin-bottom: 2px;
}

.tl-legend__levin.is-active {
  border-bottom: 2px solid #15803d;
}

.tl-track {
  position: relative;
  padding: 8px 0 20px;
}

/* 中央竖轴 */
.tl-axis {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 32px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
}

.tl-axis-line {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  width: 1.5px;
  transform: translateX(-50%) scaleY(0);
  transform-origin: top center;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(212, 175, 55, 0.35) 10%,
    rgba(212, 175, 55, 0.65) 50%,
    rgba(212, 175, 55, 0.35) 90%,
    transparent 100%
  );
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.25);
  transition: transform 1.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.tl-track.tl-axis--drawn .tl-axis-line {
  transform: translateX(-50%) scaleY(1);
}

.tl-rows {
  position: relative;
  z-index: 3;
}

/* 每一行：左安娜 | 中轴节点 | 右列文 */
.tl-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  margin-bottom: 20px;
}

.tl-node-col {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 4;
}

.tl-node {
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(26, 8, 12, 0.9);
  border: 2px solid #d4af37;
  border-radius: 0;
  transform: rotate(45deg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow:
    0 0 12px rgba(201, 168, 76, 0.4),
    0 0 24px rgba(201, 168, 76, 0.15);
}

.tl-node span {
  display: block;
  transform: rotate(-45deg);
  font-size: 10px;
  color: #d4af37;
}

.tl-node--red span {
  color: #fca5a5;
}

.tl-node--gold span {
  color: #d4af37;
}

.tl-node:hover,
.tl-node:focus-visible {
  transform: rotate(45deg) scale(1.15);
  box-shadow:
    0 0 16px rgba(201, 168, 76, 0.55),
    0 0 28px rgba(201, 168, 76, 0.25);
  outline: none;
}

/* 章节卡片 */
.tl-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: none;
  padding: 0;
  margin: 0 4px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
  opacity: 0;
  transition:
    transform 0.65s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.55s ease,
    box-shadow 0.25s ease,
    filter 0.25s ease;
}

.tl-panel--anna {
  transform: translateX(16px);
  background: linear-gradient(145deg, rgba(22, 8, 8, 0.72) 0%, rgba(14, 4, 4, 0.78) 100%);
  border: 1px solid rgba(212, 175, 55, 0.42);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.tl-panel--levin {
  transform: translateX(-16px);
  background: linear-gradient(145deg, rgba(8, 22, 14, 0.72) 0%, rgba(4, 14, 8, 0.78) 100%);
  border: 1px solid rgba(212, 175, 55, 0.42);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.tl-row.tl-row--visible .tl-panel--anna {
  transform: translateX(0);
  opacity: 1;
}

.tl-row.tl-row--visible .tl-panel--levin {
  transform: translateX(0);
  opacity: 1;
}

.tl-row.tl-row--lit .tl-panel--anna,
.tl-row.tl-row--lit .tl-panel--levin {
  filter: brightness(1.12);
  box-shadow:
    0 0 0 1px rgba(201, 168, 76, 0.45),
    0 8px 28px rgba(201, 168, 76, 0.2);
}

/* 情绪样式 */
.tl-mood--fate {
  border: 1px solid rgba(201, 168, 76, 0.45);
  box-shadow:
    inset 0 24px 40px -20px rgba(201, 168, 76, 0.2),
    inset 0 0 0 1px rgba(201, 168, 76, 0.2);
}

.tl-mood--tragedy {
  border: 1px solid rgba(139, 26, 26, 0.4);
  background-image: linear-gradient(90deg, rgba(139, 26, 26, 0.55) 0%, rgba(139, 26, 26, 0.55) 3px, transparent 3px);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.tl-panel--anna.tl-mood--tragedy {
  background-color: #2a1010;
  background-image: linear-gradient(90deg, #8b1a1a 0%, #8b1a1a 3px, transparent 3px),
    linear-gradient(165deg, #2a1212 0%, #1a0a0a 100%);
}

.tl-panel--levin.tl-mood--tragedy {
  background-color: #1a1818;
  background-image: linear-gradient(90deg, #6b2020 0%, #6b2020 3px, transparent 3px),
    linear-gradient(165deg, #1a1414 0%, #121010 100%);
}

.tl-mood--pastoral {
  border: 1px solid rgba(74, 120, 90, 0.5);
  box-shadow: inset 0 -20px 36px -24px rgba(180, 140, 80, 0.12);
}

.tl-panel--levin.tl-mood--pastoral {
  background: linear-gradient(165deg, #1a3228 0%, #122018 100%);
}

.tl-mood--social {
  border: 1px solid rgba(160, 165, 175, 0.4);
  box-shadow: inset 0 0 0 1px rgba(192, 196, 204, 0.08);
}

.tl-panel--anna.tl-mood--social {
  background: linear-gradient(165deg, #2a2224 0%, #1a1214 100%) !important;
}

.tl-panel--levin.tl-mood--social {
  background: linear-gradient(165deg, #1e2428 0%, #141a1e 100%) !important;
}

/* 左上角书签标签（第几部） */
.tl-part-badge {
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 5;
  background: linear-gradient(180deg, #8b1a1a, #6b1212);
  color: #fecaca;
  font-family: 'Noto Serif SC', Georgia, serif;
  font-size: 10px;
  padding: 4px 8px 6px;
  border-radius: 0 0 6px 6px;
  writing-mode: horizontal-tb;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  line-height: 1;
  pointer-events: none;
}

.tl-panel--levin .tl-part-badge {
  background: linear-gradient(180deg, #1a5c3a, #0f3d26);
  color: #bbf7d0;
}

/* 图片区 */
.tl-img-wrap {
  position: relative;
  background: #0a0806;
  line-height: 0;
}

.tl-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.tl-panel--anna .tl-img-wrap::after {
  background: linear-gradient(180deg, rgba(80, 10, 10, 0.2), rgba(25, 8, 8, 0.7));
}

.tl-panel--levin .tl-img-wrap::after {
  background: linear-gradient(180deg, rgba(10, 40, 20, 0.2), rgba(6, 25, 12, 0.7));
}

.tl-img-tint,
.tl-img-fade {
  display: none;
}

.tl-img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  vertical-align: top;
  position: relative;
  z-index: 0;
  -webkit-mask-image: linear-gradient(180deg, black 60%, transparent 100%);
  mask-image: linear-gradient(180deg, black 60%, transparent 100%);
}

.tl-body {
  padding: 8px 0 24px;
  z-index: 1;
}

.tl-read-link {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 2;
  font-size: 10px;
  font-family: 'Noto Serif SC', Georgia, serif;
  letter-spacing: 0.03em;
  color: rgba(201, 168, 76, 0.45);
  pointer-events: none;
}

.tl-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  font-weight: 700;
  color: #e8d5b7;
  line-height: 1.4;
  margin: 0;
  padding: 0 12px 4px;
}

.tl-short {
  font-size: 12px;
  color: #a89070;
  line-height: 1.7;
  margin: 0;
  padding: 0 12px 12px;
}

#screen-timeline-detail .topbar {
  background: rgba(28, 10, 16, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: rgba(212, 175, 55, 0.22);
}

/* 详情页保留原比例 */
.tl-img-slot {
  background: #0c0a08;
  line-height: 0;
}

.tl-img-slot--detail {
  max-width: 280px;
  margin: 0 auto;
}

@media (prefers-reduced-motion: reduce) {
  .tl-panel,
  .tl-axis-line {
    transition: none;
  }
  .tl-panel--anna,
  .tl-panel--levin {
    opacity: 1;
    transform: none;
  }
  .tl-axis-line {
    transform: translateX(-50%) scaleY(1);
  }
}
