/* Timeline Main Styles */

:root {
  --header-bg: #1A1A2E;
  --header-text: #EAEAEA;
  --accent-gold: #D4AF37;
  --timeline-bg: #F5F5F0;
  --period-label: #8B7355;
  --work-border: #2C3E50;
  --work-period-bar: rgba(212, 175, 55, 0.2);
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  background: #D4AF37;
  color: #1A1A2E;
  padding: 8px 16px;
  z-index: 1001;
  text-decoration: none;
  font-weight: bold;
}

.skip-link:focus {
  left: 0;
  top: 0;
  outline: 3px solid #1A1A2E;
  outline-offset: 2px;
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #E5E5E0;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-gold) 0%, #C9A961 100%);
  border-radius: 10px;
  border: 2px solid #E5E5E0;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #F4D03F 0%, var(--accent-gold) 100%);
}

/* Firefox Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold) #E5E5E0;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--header-bg) 0%, #16213E 100%);
  color: var(--header-text);
  padding: 2rem 1.5rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 200; /* Above all content including work items */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.site-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  color: var(--accent-gold);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.site-subtitle {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  opacity: 0.9;
}

/* Main Content */
.main-content {
  min-height: calc(100vh - 200px);
  background: var(--timeline-bg);
  overflow-x: auto; /* Allow horizontal scroll when timeline is wider */
  overflow-y: visible;
}

.timeline-container {
  position: relative;
  width: 100%;
  min-height: 5000px;
  padding: 3rem 0 2rem 0; /* Only top and bottom padding to avoid width issues */
  overflow: visible; /* Let parent handle overflow */
}

/* Loading State */
.timeline-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--accent-gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text,
.loading-message {
  font-family: inherit;
  font-size: 1.2rem;
  color: var(--period-label);
}

/* Error State */
.timeline-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 3rem;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  max-width: 400px;
}

.error-icon {
  font-size: 4rem;
  line-height: 1;
}

.error-title {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  color: #DC2626;
  margin: 0;
}

.error-message {
  font-family: inherit;
  font-size: 1rem;
  color: #6B7280;
  line-height: 1.6;
  margin: 0;
}

.error-retry-button {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #F4D03F 100%);
  color: #1A1A2E;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.error-retry-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

/* Year Markers (Century Grid) */
.year-marker-line {
  position: absolute;
  width: 100%;
  height: 0;
  border-top: 2px solid rgba(26, 26, 46, 0.15);
  z-index: 1;
  pointer-events: none;
}

.year-marker-label {
  position: fixed;
  right: 1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #4A5568;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  z-index: 5; /* Below work items (z-index: 100) */
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  will-change: transform; /* GPU acceleration for smooth scroll */
  backface-visibility: hidden; /* Prevent flickering */
}

/* Period Backgrounds */
.period-background {
  position: absolute;
  left: 0;
  width: 100%;
  border-top: 1px dashed var(--period-label);
  border-bottom: 1px dashed var(--period-label);
  z-index: 3;
}

.period-background:hover {
  filter: brightness(1.2);
}

.period-label {
  position: fixed;
  left: 1rem;
  /* top is set by JavaScript */
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  color: #2C3E50; /* Much darker for readability */
  opacity: 0.95; /* More visible */
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8); /* Enhanced outline for contrast */
  background: rgba(255, 255, 255, 0.7); /* Background for better readability */
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  z-index: 5; /* Below work items (z-index: 100), same as year markers */
  will-change: transform; /* GPU acceleration for smooth scroll */
  backface-visibility: hidden; /* Prevent flickering */
}

/* Work Elements */
.work-item {
  position: absolute;
  cursor: pointer;
  z-index: 100; /* Above year/period labels (z-index: 5) */
  pointer-events: auto; /* Ensure clickable */
  overflow: visible; /* Allow cover to extend beyond band boundaries */
}

.work-item:hover {
  z-index: 150; /* Even higher on hover */
}

.work-cover {
  position: absolute; /* Position within work-item using coverOffset */
  left: 50%;
  transform: translateX(-50%); /* Center horizontally */
  width: 100px;
  max-width: 100px; /* Override reset.css max-width: 100% */
  height: 140px; /* Fixed height for consistent layout */
  object-fit: cover; /* Crop/fit image to maintain aspect ratio */
  border: 3px solid var(--work-border);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 10; /* Above period bar */
}

.work-item:hover .work-cover {
  transform: translateX(-50%) scale(1.05); /* Scale only the cover, not the band */
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Focus indicator for keyboard navigation (WCAG 2.1.1) */
.work-item:focus {
  outline: 3px solid #D4AF37;
  outline-offset: 2px;
}

.work-item:focus .work-cover {
  transform: translateX(-50%) scale(1.05);
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.2);
}

.work-period-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  /* Gradient from light to dark to light */
  background: linear-gradient(
    to bottom,
    rgba(40, 40, 40, 0.1),
    rgba(40, 40, 40, 0.4) 50%,
    rgba(40, 40, 40, 0.1)
  );
  border-radius: 6px;
  pointer-events: none;
  z-index: 5; /* Behind cover, but above period backgrounds */
}

.work-title-tooltip {
  position: absolute;
  /* top is set by JavaScript to be below the cover image */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 26, 46, 0.9);
  color: var(--header-text);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 60;
}

.work-item:hover .work-title-tooltip {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .site-title {
    font-size: 2rem;
  }

  .site-subtitle {
    font-size: 0.9rem;
  }

  .site-header {
    padding: 2rem 1rem;
  }

  .year-marker-label {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    right: 0.5rem;
  }

  .period-label {
    font-size: 0.9rem;
    padding: 0.15rem 0.5rem;
  }
}

/* Scroll Hint */
.scroll-hint {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250; /* Above header and content */
  background: rgba(26, 26, 46, 0.95);
  color: var(--accent-gold);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: none; /* Hidden by default, shown by JavaScript when needed */
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  white-space: nowrap; /* Prevent text wrapping */
}

.scroll-hint.visible {
  opacity: 1;
}

.scroll-hint.fade-out {
  opacity: 0;
}

.scroll-hint-icon {
  font-size: 1.25rem;
  animation: scroll-hint-wiggle 2s ease-in-out infinite;
}

.scroll-hint-text {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
}

@keyframes scroll-hint-wiggle {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

@media (max-width: 768px) {
  .scroll-hint {
    bottom: 1rem;
    padding: 0.6rem 1.2rem;
  }

  .scroll-hint-icon {
    font-size: 1.1rem;
  }

  .scroll-hint-text {
    font-size: 0.8rem;
  }
}

/* Footer */
.site-footer {
  background: linear-gradient(135deg, #1A1A2E 0%, #16213E 100%);
  color: var(--header-text);
  padding: 2rem 1rem;
  border-top: 2px solid var(--accent-gold);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.footer-link {
  color: #D4AF37;
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

.footer-link:hover {
  color: #F4D03F;
  background: rgba(212, 175, 55, 0.1);
  transform: translateY(-2px);
}

.footer-link:focus {
  outline: 3px solid #D4AF37;
  outline-offset: 2px;
}

.footer-note {
  font-size: 0.85rem;
  color: rgba(234, 234, 234, 0.7);
  margin-top: 1rem;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .footer-nav {
    flex-direction: column;
    gap: 0.75rem;
  }

  .footer-link {
    display: block;
    width: 100%;
  }
}
