/* ===================================
   Love Letters Timeline - Luxury Pink Theme
   Design System: Liquid Glass Style
   =================================== */

/* === CSS Variables === */
:root {
  /* Colors - Romantic Pink Palette */
  --color-primary: #db2777;
  --color-secondary: #f472b6;
  --color-gold: #ca8a04;
  --color-background: #fdf2f8;
  --color-text: #831843;
  --color-text-light: #9f1239;
  --color-text-muted: #be185d;

  /* Glass Effects */
  --glass-bg-light: rgba(255, 255, 255, 0.85);
  --glass-bg-medium: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(219, 39, 119, 0.2);
  --glass-shadow: 0 8px 32px rgba(219, 39, 119, 0.15);

  /* Typography */
  --font-heading: "Playfair Display", serif;
  --font-body: "Inter", sans-serif;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Transitions - Genshin Style Curves */
  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-medium: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 600ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Timeline */
  --timeline-width: 120px;
}

/* === Reset & Base Styles === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-background);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* === Genshin-Style Custom Scrollbar === */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: linear-gradient(
    to bottom,
    rgba(219, 39, 119, 0.05),
    rgba(244, 114, 182, 0.05)
  );
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(
    to bottom,
    var(--color-primary),
    var(--color-secondary)
  );
  border-radius: 10px;
  border: 2px solid var(--color-background);
  transition: var(--transition-medium);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    to bottom,
    var(--color-gold),
    var(--color-primary)
  );
  box-shadow: 0 0 10px rgba(202, 138, 4, 0.5);
}

/* === Header === */
.header {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  background: linear-gradient(
    135deg,
    rgba(219, 39, 119, 0.1),
    rgba(244, 114, 182, 0.1)
  );
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 10;
}

.header-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeInDown var(--transition-slow);
}

.header-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--color-text-muted);
  font-weight: 300;
  animation: fadeInUp var(--transition-slow);
}

/* === Timeline Navigation === */
.timeline-nav {
  position: fixed;
  left: var(--spacing-lg);
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.85); /* Solid fallback */
  backdrop-filter: blur(8px); /* Reduced from 20px for performance */
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* Simple circle dots - Genshin style */
.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-secondary);
  border: 2px solid var(--color-primary);
  cursor: pointer;
  transition: all var(--transition-medium);
  position: relative;
}

/* Anniversary - Larger gold circle */
.timeline-dot.type-anniversary {
  width: 20px;
  height: 20px;
  background: var(--color-gold);
  border-color: var(--color-gold);
  box-shadow: 0 0 12px rgba(202, 138, 4, 0.5);
}

/* Monthly holiday - Pink circle */
.timeline-dot.type-monthly_holiday {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* Hover effects */
.timeline-dot:hover {
  transform: scale(1.4);
  box-shadow: 0 0 20px rgba(219, 39, 119, 0.6);
}

.timeline-dot.type-anniversary:hover {
  box-shadow: 0 0 25px rgba(202, 138, 4, 0.8);
}

/* Timeline Tooltip */
.timeline-tooltip {
  position: absolute;
  left: calc(100% + 15px);
  top: 50%;
  transform: translateY(-50%) translateX(-10px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}

.timeline-tooltip strong {
  color: var(--color-primary);
  display: block;
  margin-bottom: 2px;
}

.timeline-dot.type-anniversary .timeline-tooltip strong {
  color: var(--color-gold);
}

/* Show tooltip on hover */
.timeline-dot:hover .timeline-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* ========================================
   ACTIVE STATE - App-style selection
   ======================================== */
.timeline-dot.active {
  transform: scale(1.8);
  background: var(--color-primary);
  border: 3px solid white;
  box-shadow: 
    0 0 0 3px var(--color-primary),
    0 0 25px rgba(219, 39, 119, 0.8);
  z-index: 110;
  /* Removed infinite animation to prevent GPU strain */
}

.timeline-dot.type-anniversary.active {
  background: var(--color-gold);
  box-shadow: 
    0 0 0 3px var(--color-gold),
    0 0 25px rgba(202, 138, 4, 0.9);
}

/* === SVG Connection Curve Line === */
.connection-line {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 95;
}

.connection-line path {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.3s ease;
  /* Static drop-shadow - no animation to prevent GPU strain */
  filter: drop-shadow(0 0 6px rgba(219, 39, 119, 0.5));
}

.connection-line path.visible {
  opacity: 1;
  /* Removed infinite curvePulse animation */
}

/* === Main Content === */
.main-content {
  margin-left: 180px;
  padding: var(--spacing-xl) var(--spacing-lg);
  min-height: 100vh;
}

.letters-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

/* === Letter Cards === */
.letter-card {
  background: rgba(255, 255, 255, 0.95); /* Solid background - NO backdrop-filter for performance */
  border-radius: 24px;
  padding: var(--spacing-lg);
  border: 2px solid transparent;
  box-shadow: 0 4px 20px rgba(219, 39, 119, 0.1);
  cursor: pointer;
  transition: 
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  position: relative;
  overflow: visible;
  scroll-margin-top: var(--spacing-xl);
}

/* Active state - simple border highlight, NO transform */
.letter-card.active {
  border-color: var(--color-primary);
  box-shadow: 0 4px 24px rgba(219, 39, 119, 0.3);
  background: white;
}

.letter-card.active.type-anniversary {
  border-color: var(--color-gold);
  box-shadow: 0 4px 24px rgba(202, 138, 4, 0.3);
}

/* Chevron arrow - HIDDEN to prevent glitches */
.letter-card::after {
  display: none; /* Completely removed to prevent any conflicts */
}

/* Letter card hover - simple border only, NO transform */
.letter-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 28px rgba(219, 39, 119, 0.25);
}

.letter-card.type-anniversary:hover {
  border-color: var(--color-gold);
  box-shadow: 0 4px 28px rgba(202, 138, 4, 0.25);
}

.letter-card.type-anniversary .letter-event {
  color: var(--color-gold);
}

.letter-card.type-anniversary .letter-heading {
  background: linear-gradient(135deg, var(--color-gold), var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Monthly holiday type - Pink theme */
.letter-card.type-monthly_holiday::before {
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
}

.letter-card.type-monthly_holiday .letter-event {
  color: var(--color-primary);
}

.letter-card.type-monthly_holiday .letter-heading {
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Letter card content - flex layout */
.letter-preview {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.letter-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.letter-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-primary);
  box-shadow: 0 4px 12px rgba(219, 39, 119, 0.3);
  flex-shrink: 0;
}

/* Default avatar with initial letter */
.letter-avatar-initial {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border: 3px solid var(--color-primary);
  box-shadow: 0 4px 16px rgba(219, 39, 119, 0.4);
  flex-shrink: 0;
}

/* Anniversary type avatar initial - gold gradient */
.type-anniversary .letter-avatar-initial {
  background: linear-gradient(135deg, var(--color-gold), #e5a00d);
  border-color: var(--color-gold);
  box-shadow: 0 4px 16px rgba(202, 138, 4, 0.5);
}

/* Monthly holiday type avatar initial */
.type-monthly_holiday .letter-avatar-initial {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-color: var(--color-primary);
}

.letter-avatar.default-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  color: white;
}

.letter-avatar.default-avatar.type-anniversary {
  background: linear-gradient(135deg, var(--color-gold), var(--color-primary));
}

.letter-info {
  flex: 1;
}

.letter-date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-xs);
}

.letter-event {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-xs);
}

.letter-heading {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  line-height: 1.2;
}

.letter-title {
  font-size: 1.125rem;
  color: var(--color-text-light);
  font-weight: 500;
}

/* === Modal === */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
}

.modal.active {
  display: flex;
  animation: fadeIn var(--transition-medium);
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(131, 24, 67, 0.8);
  backdrop-filter: blur(10px);
  animation: fadeIn var(--transition-medium);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  background: #faf8f3;
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(219, 39, 119, 0.02) 2px, rgba(219, 39, 119, 0.02) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(219, 39, 119, 0.02) 2px, rgba(219, 39, 119, 0.02) 4px),
    linear-gradient(135deg, #faf8f3 0%, #f5f0e8 100%);
  backdrop-filter: blur(30px);
  border-radius: 32px;
  overflow: hidden;
  box-shadow: 
    0 24px 64px rgba(219, 39, 119, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  border: 3px solid;
  border-image: linear-gradient(135deg, var(--color-gold), var(--color-primary)) 1;
  animation: letterUnfold var(--transition-slow);
  z-index: 1;
}

/* Paper texture overlay */
.modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(219, 39, 119, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(202, 138, 4, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Decorative wax seal effect - elegant letter seal */
.modal-content::after {
  content: 'L';
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 45px;
  height: 45px;
  background: radial-gradient(circle at 30% 30%, #d44a7a, var(--color-primary), #8b1c4a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  font-style: italic;
  color: #ffd700;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  box-shadow: 
    0 4px 15px rgba(139, 28, 74, 0.5),
    inset 0 -2px 5px rgba(0,0,0,0.2),
    inset 0 2px 5px rgba(255,255,255,0.2);
  z-index: 10;
  line-height: 45px;
  text-align: center;
}

.modal-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  opacity: 0.2;
  z-index: 0;
}

.modal-background.has-image {
  opacity: 1;
  background-size: cover;
  background-position: center;
}

.modal-background.has-image::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(253, 242, 248, 0.3),
    rgba(253, 242, 248, 0.95)
  );
}

.modal-close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass-bg-light);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  transition: var(--transition-fast);
  z-index: 2;
}

.modal-close:hover {
  background: var(--color-primary);
  color: white;
  transform: rotate(90deg);
}

.modal-close svg {
  width: 24px;
  height: 24px;
}

.modal-body {
  position: relative;
  padding: var(--spacing-xl);
  overflow-y: auto;
  max-height: 90vh;
  z-index: 1;
}

.modal-header {
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

.modal-date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-xs);
}

.modal-event {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: var(--spacing-sm);
}

.modal-heading {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-sm);
  line-height: 1.2;
}

.modal-title {
  font-size: 1.5rem;
  color: var(--color-text-light);
  font-weight: 500;
  margin-bottom: var(--spacing-lg);
}

.modal-content-text {
  font-size: 1.125rem;
  line-height: 2;
  color: var(--color-text);
  white-space: pre-line;
  text-align: left;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  padding: var(--spacing-lg);
  background: rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  border-left: 4px solid var(--color-primary);
  position: relative;
  margin-top: var(--spacing-md);
}

/* Handwritten letter decorative quotes */
.modal-content-text::before {
  content: '"';
  position: absolute;
  top: -10px;
  left: 10px;
  font-size: 4rem;
  color: var(--color-secondary);
  opacity: 0.3;
  font-family: 'Playfair Display', serif;
  line-height: 1;
}

.modal-content-text::after {
  content: '"';
  position: absolute;
  bottom: -30px;
  right: 20px;
  font-size: 4rem;
  color: var(--color-secondary);
  opacity: 0.3;
  font-family: 'Playfair Display', serif;
  line-height: 1;
}

/* Anniversary modal styling */
.modal.type-anniversary .modal-event {
  color: var(--color-gold);
}

.modal.type-anniversary .modal-heading {
  background: linear-gradient(135deg, var(--color-gold), var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal.type-anniversary .modal-background {
  background: linear-gradient(135deg, var(--color-gold), var(--color-primary));
}

/* === Animations === */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Letter unfold animation */
@keyframes letterUnfold {
  0% {
    opacity: 0;
    transform: perspective(1000px) rotateX(-90deg) scale(0.8);
    transform-origin: top center;
  }
  50% {
    transform: perspective(1000px) rotateX(-45deg) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: perspective(1000px) rotateX(0deg) scale(1);
  }
}

/* === Responsive Design === */

/* Tablet */
@media (max-width: 1024px) {
  :root {
    --timeline-width: 80px;
  }

  .main-content {
    margin-left: calc(var(--timeline-width) + var(--spacing-md));
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .timeline-nav {
    left: var(--spacing-md);
  }

  /* Hide chevron on tablet for cleaner look */
  .letter-card::after {
    display: none;
  }

  /* Reduce active card shift */
  .letter-card.active {
    transform: translateX(5px);
  }
}

/* Mobile */
@media (max-width: 768px) {
  .header {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  /* Hide connection curve on mobile - horizontal timeline breaks curve logic */
  .connection-line {
    display: none;
  }

  /* Hide chevron arrows on mobile - no space for them */
  .letter-card::after {
    display: none;
  }

  /* Horizontal timeline at bottom */
  .timeline-nav {
    position: fixed;
    top: auto;
    bottom: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    padding: var(--spacing-sm) var(--spacing-md);
    max-width: calc(100vw - var(--spacing-lg));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Tooltip appears ABOVE dot on mobile */
  .timeline-tooltip {
    left: 50%;
    top: auto;
    bottom: calc(100% + 15px);
    transform: translateX(-50%) translateY(10px);
  }

  .timeline-dot:hover .timeline-tooltip {
    transform: translateX(-50%) translateY(0);
  }

  .main-content {
    margin-left: 0;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-xl) * 3); /* More space for bottom timeline */
  }

  .letters-container {
    gap: var(--spacing-lg);
  }

  .letter-card {
    padding: var(--spacing-md);
    border-radius: 20px;
  }

  /* Remove transform on active to prevent layout shifts */
  .letter-card.active {
    transform: none;
  }

  .letter-preview {
    flex-direction: column;
    text-align: center;
    gap: var(--spacing-sm);
  }

  .letter-avatar,
  .letter-avatar-initial {
    width: 80px;
    height: 80px;
    margin: 0 auto;
  }

  .letter-heading {
    font-size: 1.5rem;
  }

  .modal-body {
    padding: var(--spacing-md);
  }

  .modal-content-text {
    font-size: 1rem;
  }
}

/* Small mobile */
@media (max-width: 375px) {
  .header-title {
    font-size: 1.75rem;
  }

  .letter-heading {
    font-size: 1.5rem;
  }

  .modal-heading {
    font-size: 1.75rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible {
  outline-offset: 4px;
}
