/* Apple-inspired Archives Styles */
:root {
  --primary-color-ar: #007AFF;
  --secondary-color-ar: #5856D6;
  --text-primary: #1D1D1F;
  --text-secondary: #86868B;
  --background-primary: #FBFBFD;
  --background-secondary: #F5F5F7;
  --surface-color: #FFFFFF;
  --border-color: #D2D2D7;
  --shadow-light: 0 2px 16px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 32px rgba(0, 0, 0, 0.15);
  --shadow-heavy: 0 8px 64px rgba(0, 0, 0, 0.2);
  --border-radius: 12px;
  --border-radius-large: 20px;
  --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Hero Section */
.archives-main {
  padding-top: 120px;
  min-height: 100vh;
}

.archives-hero {
  padding: 60px 0 80px;
  background: linear-gradient(135deg, var(--background-primary) 0%, var(--background-secondary) 100%);
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 0;
}

/* Loading States */
.loading-container, .error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color-ar);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin: 0;
}

.error-container {
  color: var(--text-secondary);
}

.error-icon {
  font-size: 3rem;
  color: #FF3B30;
  margin-bottom: 1rem;
}

.error-content h3 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Archives Container */
.archives-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Month Section */
.archive-month {
  margin-bottom: 80px;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.6s ease-out forwards;
}

.archive-month:nth-child(even) {
  animation-delay: 0.1s;
}

.archive-month:nth-child(odd) {
  animation-delay: 0.2s;
}

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

.month-header {
  text-align: center;
  margin-bottom: 40px;
}

.month-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.month-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin: 0;
}

/* Archive Grid */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

@media (min-width: 768px) {
  .archive-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 32px;
  }
}

/* Archive Cards */
.archive-card {
  background: var(--surface-color);
  border-radius: var(--border-radius-large);
  overflow: hidden;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.archive-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-medium);
}

.archive-card:active {
  transform: translateY(-4px);
}

.card-image-container {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  background: var(--background-secondary);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.archive-card:hover .card-image {
  transform: scale(1.05);
}

.card-image.loading {
  opacity: 0;
}

.card-image.loaded {
  opacity: 1;
}

.image-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-secondary);
  font-size: 2rem;
}

/* Card Content */
.card-content {
  padding: 20px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-date {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.card-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-category {
  display: inline-block;
  background: var(--primary-color-ar);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Load More Button */
.load-more-container {
  text-align: center;
  padding: 40px 0;
}

.load-more-btn {
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  padding: 16px 32px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 140px;
  justify-content: center;
}

.load-more-btn:hover {
  background: var(--primary-color-ar);
  color: white;
  border-color: var(--primary-color-ar);
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

.load-more-btn:active {
  transform: translateY(0);
}

.load-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.load-more-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--surface-color);
  border-radius: var(--border-radius-large);
  overflow: hidden;
  box-shadow: var(--shadow-heavy);
  transform: scale(0.9);
  transition: var(--transition);
}

.lightbox-overlay.active .lightbox-container {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

@media (min-width: 768px) {
  .lightbox-content {
    flex-direction: row;
  }
}

.lightbox-image-container {
  position: relative;
  flex: 1;
  min-height: 300px;
  background: var(--background-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: var(--transition);
}

.lightbox-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.lightbox-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color-ar);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.lightbox-info {
  padding: 30px;
  max-width: 400px;
  background: var(--surface-color);
}

@media (max-width: 767px) {
  .lightbox-info {
    max-width: 100%;
  }
}

.lightbox-info h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.lightbox-info p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.lightbox-info p:last-child {
  margin-bottom: 0;
}

/* Lightbox Navigation */
.lightbox-navigation {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
}

.lightbox-nav {
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  pointer-events: auto;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

.lightbox-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .archives-main {
    padding-top: 100px;
  }
  
  .archives-hero {
    padding: 40px 0 60px;
  }
  
  .hero-title {
    font-size: 2.5rem;
  }
  
  .hero-subtitle {
    font-size: 1.1rem;
  }
  
  .archive-month {
    margin-bottom: 60px;
  }
  
  .month-title {
    font-size: 2rem;
  }
  
  .archive-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .card-image-container {
    height: 200px;
  }
  
  .lightbox-container {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .lightbox-info {
    padding: 20px;
  }
  
  .lightbox-navigation {
    padding: 0 10px;
  }
  
  .lightbox-nav {
    width: 40px;
    height: 40px;
  }
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles */
.archive-card:focus,
.load-more-btn:focus,
.lightbox-close:focus,
.lightbox-nav:focus {
  outline: 2px solid var(--primary-color-ar);
  outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #F2F2F7;
    --text-secondary: #8E8E93;
    --background-primary: #000000;
    --background-secondary: #1C1C1E;
    --surface-color: #2C2C2E;
    --border-color: #38383A;
  }
}

/* Skeleton loading animation */
@keyframes skeleton-loading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--background-secondary) 25%, var(--border-color) 50%, var(--background-secondary) 75%);
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s infinite;
}