/* ═══════════════════════════════════════════
   timeline.css — Dòng thời gian kỷ niệm
   ═══════════════════════════════════════════ */

#timeline {
  position: relative;
  padding: 2rem 1rem 5rem;
  background: transparent;
  z-index: 4;
}

.timeline-wrap {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
}

.timeline-line {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--petal), var(--blush), var(--mauve));
  transform: translateX(-50%);
}
@media (max-width: 620px) {
  .timeline-line { left: 20px; }
}

.timeline-item {
  position: relative;
  display: flex;
  width: 100%;
  margin-bottom: 4rem;
  align-items: flex-start;
}

.timeline-item:nth-child(odd)  { flex-direction: row; }
.timeline-item:nth-child(even) { flex-direction: row-reverse; }

.timeline-card {
  width: calc(50% - 40px);
  background: white;
  border-radius: 20px;
  padding: 1.6rem 1.8rem;
  box-shadow: 0 6px 32px rgba(201,132,142,0.12);
  border: 1px solid rgba(255,192,203,0.3);
  position: relative;
  transition: transform 0.3s, box-shadow 0.3s;
}
.timeline-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(201,132,142,0.22);
}

.timeline-dot {
  position: absolute;
  left: 50%;
  top: 1.6rem;
  transform: translateX(-50%);
  width: 16px; height: 16px;
  background: white;
  border: 3px solid var(--blush);
  border-radius: 50%;
  z-index: 2;
}
.timeline-dot::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--blush);
  border-radius: 50%;
}

.tl-date {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--rose-gold);
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.tl-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.tl-desc-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Scrollable text area */
.tl-desc {
  font-size: 0.9rem;
  color: var(--soft-ink);
  line-height: 1.7;
  /* Collapsed: clip, no scroll, no scrollbar */
  max-height: 6.8em;
  overflow: hidden;
  scrollbar-width: none;
  transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
  padding-right: 4px;
}
.tl-desc::-webkit-scrollbar { width: 0; }

/* Expanded: enable scroll + show scrollbar */
.tl-desc.expanded {
  max-height: 14em;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--petal) transparent;
  cursor: grab;
}
.tl-desc.expanded:active { cursor: grabbing; }
.tl-desc.expanded::-webkit-scrollbar { width: 4px; }
.tl-desc.expanded::-webkit-scrollbar-track { background: transparent; }
.tl-desc.expanded::-webkit-scrollbar-thumb {
  background: var(--petal);
  border-radius: 4px;
}
.tl-desc.expanded::-webkit-scrollbar-thumb:hover { background: var(--blush); }

/* Expand button — sits BELOW the scroll area, never overlaps */
.tl-expand-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.6rem;
  align-self: flex-start;
  padding: 0.28rem 0.85rem;
  background: rgba(255,192,203,0.15);
  border: 1px solid rgba(255,192,203,0.4);
  border-radius: 50px;
  font-family: 'Lora', serif;
  font-size: 0.75rem;
  color: var(--rose-gold);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, border-color 0.2s;
  user-select: none;
  flex-shrink: 0;
}
.tl-expand-btn:hover {
  background: rgba(255,192,203,0.28);
  border-color: var(--blush);
  transform: translateY(-1px);
}
.tl-expand-icon {
  display: inline-block;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 0.85rem;
  line-height: 1;
}
.tl-expand-btn.open .tl-expand-icon {
  transform: rotate(180deg);
}

html.dark .tl-expand-btn {
  background: rgba(242,167,187,0.08);
  border-color: rgba(242,167,187,0.2);
}
html.dark .tl-expand-btn:hover {
  background: rgba(242,167,187,0.15);
  border-color: var(--blush);
}
html.dark .tl-desc.expanded::-webkit-scrollbar-thumb {
  background: var(--blush);
}
.tl-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.6rem;
}

.tl-photo {
  width: 100%;
  height: 140px;
  border-radius: 12px;
  background: linear-gradient(135deg, #FFE4EC, #FFF0F5);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  border: 1.5px dashed var(--petal);
  overflow: hidden;
}
.tl-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }

@media (max-width: 620px) {
  .timeline-item { flex-direction: column !important; padding-left: 50px; }
  .timeline-card { width: 100%; }
  .timeline-dot  { left: 20px; }
}

/* ─── Icon mở rộng (nằm cạnh nút Bình luận) ─── */
.tl-expand-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(255,192,203,0.12);
  border: 1px solid rgba(255,192,203,0.35);
  border-radius: 50%;
  color: var(--rose-gold);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.tl-expand-icon-btn:hover {
  background: rgba(255,192,203,0.28);
  transform: scale(1.1);
}
html.dark .tl-expand-icon-btn {
  background: rgba(242,167,187,0.08);
  border-color: rgba(242,167,187,0.2);
}
html.dark .tl-expand-icon-btn:hover {
  background: rgba(242,167,187,0.18);
}

/* ─── TIMELINE ENDING NOTE ─── */
.tl-ending {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1rem;
  padding-bottom: 2rem;
}

.tl-ending-line {
  width: 2px;
  height: 48px;
  background: linear-gradient(180deg, var(--blush), transparent);
  margin-bottom: 1.2rem;
}

.tl-ending-card {
  text-align: center;
  padding: 2rem 2.5rem;
  background: white;
  border-radius: 24px;
  border: 1.5px dashed var(--petal);
  box-shadow: 0 6px 32px rgba(201,132,142,0.1);
  max-width: 360px;
  position: relative;
  animation: fadeUp 0.8s ease both;
  transition: transform 0.3s, box-shadow 0.3s;
}
.tl-ending-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(201,132,142,0.18);
}

.tl-ending-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.tl-ending-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  color: var(--soft-ink);
  line-height: 1.75;
  letter-spacing: 0.01em;
}
.tl-ending-text em {
  font-style: italic;
  color: var(--mauve);
  display: block;
  margin-top: 0.25rem;
}

.tl-ending-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 1.2rem;
}
.tl-ending-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--petal);
  animation: dot-pulse 1.5s ease-in-out infinite;
}
.tl-ending-dots span:nth-child(1) { animation-delay: 0s; }
.tl-ending-dots span:nth-child(2) { animation-delay: 0.25s; }
.tl-ending-dots span:nth-child(3) { animation-delay: 0.5s; }
@keyframes dot-pulse {
  0%, 100% { transform: scale(1);   opacity: 0.5; }
  50%       { transform: scale(1.5); opacity: 1; }
}

/* ─── DARK MODE ─── */
html.dark #timeline {
  background: linear-gradient(180deg, #0D0D0D 0%, #130A0D 100%);
}
html.dark .timeline-card {
  background: var(--bg-card);
  border-color: var(--border-card);
  box-shadow: 0 6px 32px var(--shadow-card);
}
html.dark .timeline-card:hover {
  box-shadow: 0 12px 40px rgba(242,167,187,0.15);
}
html.dark .timeline-dot {
  background: #1A1015;
}
html.dark .tl-photo {
  background: linear-gradient(135deg, #2A1520, #1A0D12);
  border-color: rgba(242,167,187,0.2);
}
html.dark .tl-ending-card {
  background: var(--bg-card);
  border-color: rgba(242,167,187,0.2);
}
html.dark .tl-ending-text { color: var(--soft-ink); }
html.dark .tl-ending-text em { color: var(--mauve); }

/* ─── Backdrop mờ để chữ dễ đọc trên nền động ─── */
#timeline {
  position: relative;
}
#timeline::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,250,247,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 0;
  transition: background 0.4s ease;
}
html.dark #timeline::before {
  background: rgba(10,6,8,0.62);
}
#timeline > * { position: relative; z-index: 1; }
