/* ============================================
   IMMAGINI NASA - CSS
   Tema: Celestiale / Astronomico
   Pagina: Foto dallo Spazio / Immagini da Marte
   ============================================ */

/* ============================================
   1. DATA E ORA DISPLAY
   ============================================ */
.container.d-block > .row > .col-sm-12 > p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--gradient-card);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--color-aurora-cyan);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
}

/* Icone per data e ora */
.container.d-block > .row > .col-sm-12 > p::before {
  content: '📅';
  font-size: 1.2rem;
}

/* ============================================
   2. TITOLI SEZIONI
   ============================================ */
h3 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--color-moon-white);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

h3::before {
  content: '🚀';
  font-size: 1.5rem;
  animation: rocketFloat 3s ease-in-out infinite;
}

@keyframes rocketFloat {
  0%, 100% { transform: translateY(0) rotate(-45deg); }
  50% { transform: translateY(-5px) rotate(-45deg); }
}

h3::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, 
    var(--color-aurora-cyan) 0%, 
    var(--color-aurora-purple) 50%, 
    transparent 100%);
  border-radius: var(--radius-full);
}

/* Titolo specifico per Marte */
.col-sm-12 > h3:nth-of-type(2)::before,
h3:contains("Marte")::before {
  content: '🔴';
  animation: marsPulse 2s ease-in-out infinite;
}

@keyframes marsPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.1); filter: brightness(1.2); }
}

/* ============================================
   3. CARD IMMAGINE DEL GIORNO (APOD)
   ============================================ */
.container.mb-2.border-bottom.pb-2 {
  background: linear-gradient(145deg, 
    rgba(26, 31, 60, 0.8) 0%, 
    rgba(45, 43, 85, 0.6) 100%);
  border: 1px solid rgba(168, 85, 247, 0.3) !important;
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-2xl) !important;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(168, 85, 247, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  position: relative;
  overflow: hidden;
}

/* Effetto stelle nel background */
.container.mb-2.border-bottom.pb-2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 70% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.3), transparent);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.container.mb-2.border-bottom.pb-2 > * {
  position: relative;
  z-index: 1;
}

/* Titolo immagine del giorno */
.container.mb-2.border-bottom.pb-2 h3 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  background: var(--gradient-aurora);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: var(--space-lg);
}

.container.mb-2.border-bottom.pb-2 h3::before,
.container.mb-2.border-bottom.pb-2 h3::after {
  display: none;
}

/* ============================================
   4. IMMAGINI THUMBNAIL
   ============================================ */
.img-thumbnail {
  background: transparent !important;
  border: 3px solid rgba(168, 85, 247, 0.4) !important;
  border-radius: var(--radius-lg) !important;
  padding: 0 !important;
  max-width: 100%;
  height: auto;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(168, 85, 247, 0.2);
  cursor: pointer;
  position: relative;
}

.img-thumbnail:hover {
  transform: scale(1.03);
  border-color: var(--color-aurora-cyan) !important;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(0, 217, 255, 0.3),
    0 0 60px rgba(168, 85, 247, 0.2);
}

/* Link wrapper per immagini */
a[onclick*="showImage"] {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

a[onclick*="showImage"]::before {
  content: '🔍 Clicca per ingrandire';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
  color: white;
  font-size: 0.85rem;
  text-align: center;
  opacity: 0;
  transform: translateY(100%);
  transition: all 0.3s ease;
  z-index: 10;
}

a[onclick*="showImage"]:hover::before {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   5. CARD BODY (Descrizioni)
   ============================================ */
.card-body {
  padding: var(--space-lg) 0;
}

.card-text {
  color: var(--color-moon-glow);
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: var(--space-md);
}

/* Data */
.card-text:first-of-type {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: rgba(0, 217, 255, 0.1);
  border: 1px solid rgba(0, 217, 255, 0.3);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--color-aurora-cyan);
  margin-bottom: var(--space-lg);
}

.card-text:first-of-type::before {
  content: '📆';
}

/* Descrizione/Explanation */
.card-text:last-of-type {
  text-align: justify;
  color: rgba(240, 240, 245, 0.85);
  font-size: 0.95rem;
  line-height: 1.9;
  padding: var(--space-lg);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-aurora-purple);
}

/* ============================================
   6. CARD IMMAGINI DA MARTE
   ============================================ */
.card {
  background: linear-gradient(145deg, 
    rgba(26, 31, 60, 0.9) 0%, 
    rgba(45, 43, 85, 0.7) 100%) !important;
  border: 1px solid rgba(255, 107, 107, 0.3) !important;
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 0 15px rgba(255, 107, 107, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  height: 100%;
  opacity: 1 !important;
}

.card:hover {
  transform: translateY(-10px) scale(1.02);
  border-color: rgba(255, 107, 107, 0.6) !important;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.4),
    0 0 30px rgba(255, 107, 107, 0.2),
    0 0 50px rgba(255, 107, 107, 0.1);
}

/* Mars card specific styling */
.card .img-thumbnail {
  border: none !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  box-shadow: none;
  margin: 0 !important;
}

.card .card-body {
  padding: var(--space-md);
  background: rgba(0, 0, 0, 0.2);
}

.card .card-body .card-text {
  margin-bottom: var(--space-xs);
  font-size: 0.85rem;
}

.card .card-body .card-text:first-child {
  color: var(--color-aurora-cyan);
  font-weight: 600;
  background: transparent;
  border: none;
  padding: 0;
  display: block;
}

.card .card-body .card-text:first-child::before {
  content: '📷 ';
}

.card .card-body .card-text:last-child {
  color: rgba(255, 107, 107, 0.8);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: transparent;
  border: none;
  padding: 0;
}

.card .card-body .card-text:last-child::before {
  content: '🗓 ';
}

/* ============================================
   7. GRID LAYOUT IMMAGINI MARTE
   ============================================ */
.col-sm-6.col-md-4.col-lg-3.mb-4 {
  padding: var(--space-sm);
}

/* Animazione staggered per le card */
.col-sm-6.col-md-4.col-lg-3.mb-4 {
  animation: cardFadeIn 0.6s ease backwards;
}

.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(1) { animation-delay: 0.05s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(2) { animation-delay: 0.1s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(3) { animation-delay: 0.15s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(4) { animation-delay: 0.2s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(5) { animation-delay: 0.25s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(6) { animation-delay: 0.3s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(7) { animation-delay: 0.35s; }
.col-sm-6.col-md-4.col-lg-3.mb-4:nth-child(8) { animation-delay: 0.4s; }

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

/* ============================================
   8. MODAL LIGHTBOX
   ============================================ */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: modalFadeIn 0.3s ease;
  overflow: auto;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  display: block;
  max-width: 90%;
  max-height: 90vh;
  margin: 5vh auto;
  border-radius: var(--radius-xl);
  box-shadow: 
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(168, 85, 247, 0.2),
    0 0 100px rgba(0, 217, 255, 0.1);
  animation: modalImageZoom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid rgba(168, 85, 247, 0.4);
}

@keyframes modalImageZoom {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Close button */
.close {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 300;
  color: var(--color-moon-white);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10001;
}

.close:hover {
  background: rgba(255, 107, 107, 0.3);
  border-color: rgba(255, 107, 107, 0.5);
  transform: rotate(90deg) scale(1.1);
  color: #ff6b6b;
}

/* ============================================
   9. SEZIONE TITOLO MARTE
   ============================================ */
.container.d-block.mt-3 h3 {
  color: #ff6b6b;
}

.container.d-block.mt-3 h3::before {
  content: '🔴';
  animation: marsPulse 2s ease-in-out infinite;
}

.container.d-block.mt-3 h3::after {
  background: linear-gradient(90deg, 
    #ff6b6b 0%, 
    #ff8e53 50%, 
    transparent 100%);
}

/* ============================================
   10. LOADING STATES
   ============================================ */
.img-thumbnail[src=""],
.img-thumbnail:not([src]) {
  background: linear-gradient(90deg, 
    rgba(255,255,255,0.05) 25%, 
    rgba(255,255,255,0.1) 50%, 
    rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 200px;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   11. EMPTY STATE
   ============================================ */
.container:empty::before {
  content: '🔭 Caricamento immagini in corso...';
  display: block;
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-aurora-cyan);
  font-size: 1.2rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   12. RESPONSIVE
   ============================================ */
@media (max-width: 991px) {
  .col-sm-6.col-md-4.col-lg-3.mb-4 {
    flex: 0 0 50%;
    max-width: 50%;
  }
  
  .modal-content {
    max-width: 95%;
    border-radius: var(--radius-lg);
  }
  
  .close {
    top: var(--space-md);
    right: var(--space-md);
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }
}

@media (max-width: 767px) {
  .col-sm-6.col-md-4.col-lg-3.mb-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  h3 {
    font-size: 1.3rem;
  }
  
  h3::before {
    font-size: 1.2rem;
  }
  
  .container.mb-2.border-bottom.pb-2 {
    padding: var(--space-md);
  }
  
  .card-text:last-of-type {
    font-size: 0.9rem;
    padding: var(--space-md);
  }
  
  .container.d-block > .row > .col-sm-12 > p {
    flex-direction: column;
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .close {
    top: var(--space-sm);
    right: var(--space-sm);
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
  }
  
  a[onclick*="showImage"]::before {
    font-size: 0.75rem;
    padding: var(--space-sm);
  }
}

/* ============================================
   13. ACCESSIBILITÀ
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .col-sm-6.col-md-4.col-lg-3.mb-4,
  .modal,
  .modal-content,
  .img-thumbnail,
  .card,
  h3::before {
    animation: none;
  }
  
  .img-thumbnail:hover,
  .card:hover {
    transform: none;
  }
}

/* Focus states */
a[onclick*="showImage"]:focus-visible {
  outline: 3px solid var(--color-aurora-cyan);
  outline-offset: 3px;
}

.close:focus-visible {
  outline: 3px solid var(--color-aurora-cyan);
  outline-offset: 3px;
}

/* High contrast */
@media (prefers-contrast: high) {
  .card,
  .container.mb-2.border-bottom.pb-2 {
    border-color: white !important;
  }
  
  .img-thumbnail {
    border-color: white !important;
  }
}

/* ============================================
   14. PRINT STYLES
   ============================================ */
@media print {
  .modal {
    display: none !important;
  }
  
  .card,
  .container.mb-2.border-bottom.pb-2 {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
  
  h3 {
    color: black !important;
    -webkit-text-fill-color: black !important;
  }
  
  h3::before,
  h3::after {
    display: none;
  }
  
  .card-text {
    color: black !important;
  }
}

/* ============================================
   15. EFFETTI EXTRA
   ============================================ */
/* Parallax effect on APOD image */
.container.mb-2.border-bottom.pb-2 .img-thumbnail {
  transition: transform 0.1s ease-out;
}

/* Glow effect on hover for Mars cards */
.card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, 
    #ff6b6b, 
    #ff8e53, 
    #ff6b6b);
  border-radius: var(--radius-lg);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: blur(10px);
}

.card:hover::before {
  opacity: 0.5;
}

/* Badge "NASA" sulle card */
.card::after {
  content: 'NASA';
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 0, 0, 0.7);
  color: var(--color-aurora-cyan);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 217, 255, 0.3);
  z-index: 10;
}

/* Hover info overlay per APOD */
.container.mb-2.border-bottom.pb-2 .col-sm-12 > a {
  position: relative;
}

.container.mb-2.border-bottom.pb-2 .col-sm-12 > a::after {
  content: '✨ Immagine Astronomica del Giorno';
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  padding: var(--space-xs) var(--space-md);
  background: var(--gradient-aurora);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.container.mb-2.border-bottom.pb-2 .col-sm-12 > a:hover::after {
  opacity: 1;
  transform: translateY(0);
}