* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --space-black: #05070f;
  --deep-navy: #071426;
  --panel-navy: #0d1f3a;
  --nasa-blue: #2f80ed;
  --nasa-red: #fc3d21;
  --star-white: #ffffff;
  --moon-gray: #c8d2e0;
  --muted-blue: #88a5c9;
  --focus: #79b8ff;
}

body {
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--star-white);
  background:
    radial-gradient(circle at 20% 10%, rgba(47, 128, 237, 0.2), transparent 26rem),
    linear-gradient(180deg, var(--deep-navy), var(--space-black) 55%);
  padding: 20px;
}

body.modal-open {
  overflow: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0 24px;
  text-align: center;
}

h1 {
  font-family: Verdana, Arial, sans-serif;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 700;
  color: var(--star-white);
  letter-spacing: 0;
}

.logo {
  width: 140px;
  height: auto;
  flex: 0 0 auto;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  margin-bottom: 18px;
}

input[type="date"],
button {
  min-height: 48px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  border-radius: 6px;
}

input[type="date"] {
  width: 100%;
  color: var(--star-white);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 10px 14px;
}

button,
#getImagesButton {
  color: var(--star-white);
  background: var(--nasa-blue);
  border: 1px solid var(--nasa-blue);
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
#getImagesButton:hover {
  background: #1d66c5;
  border-color: #1d66c5;
}

button:disabled,
#getImagesButton:disabled {
  cursor: wait;
  opacity: 0.65;
}

input[type="date"]:focus-visible,
button:focus-visible,
.gallery-item:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.space-fact,
.status-message {
  width: 100%;
  margin: 0 auto 18px;
  border-radius: 8px;
  text-align: center;
}

.space-fact {
  border: 1px solid rgba(47, 128, 237, 0.45);
  background: rgba(13, 31, 58, 0.8);
  color: var(--moon-gray);
  padding: 16px 18px;
}

.status-message {
  min-height: 24px;
  color: var(--moon-gray);
}

.status-message.is-loading,
.status-message.is-error {
  padding: 14px 16px;
}

.status-message.is-loading {
  background: rgba(47, 128, 237, 0.16);
}

.status-message.is-error {
  background: rgba(252, 61, 33, 0.16);
  color: #ffd7d0;
  border: 1px solid rgba(252, 61, 33, 0.55);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  padding: 10px 0 32px;
}

.gallery-item {
  min-height: 340px;
  color: var(--star-white);
  background: rgba(13, 31, 58, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.gallery-item:hover {
  border-color: rgba(47, 128, 237, 0.75);
}

.gallery-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #000;
}

.gallery-media img,
.video-preview {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  object-fit: cover;
  transition: transform 220ms ease;
}

.gallery-item:hover .gallery-media img,
.gallery-item:hover .video-preview {
  transform: scale(1.04);
}

.video-preview {
  color: var(--star-white);
  background:
    linear-gradient(rgba(5, 7, 15, 0.5), rgba(5, 7, 15, 0.9)),
    linear-gradient(135deg, #102b54, #111827);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  pointer-events: none;
}

.video-preview span {
  color: var(--star-white);
  background: var(--nasa-red);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.video-preview p {
  color: var(--star-white);
  font-weight: 700;
}

.gallery-item h2 {
  font-size: 1.05rem;
  line-height: 1.35;
  padding: 16px 16px 8px;
}

.gallery-date {
  margin-top: auto;
  color: var(--muted-blue);
  padding: 0 16px 16px;
  font-size: 0.95rem;
}

.placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 44px 20px;
  color: var(--moon-gray);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.78);
  padding: 18px;
}

.modal-content {
  width: min(960px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  color: var(--star-white);
  background: var(--deep-navy);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  padding: 18px;
}

.modal-close {
  display: block;
  margin-left: auto;
  margin-bottom: 14px;
  background: var(--nasa-red);
  border-color: var(--nasa-red);
}

.modal-close:hover {
  background: #c92d18;
  border-color: #c92d18;
}

.modal-media {
  width: 100%;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}

.modal-media img,
.modal-media iframe {
  width: 100%;
  max-height: 68vh;
  border: 0;
  display: block;
}

.modal-media img {
  object-fit: contain;
}

.modal-media iframe {
  aspect-ratio: 16 / 9;
  height: auto;
}

.modal-content h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1.25;
  margin-bottom: 8px;
}

.modal-date {
  color: var(--muted-blue);
  margin-bottom: 14px;
}

.modal-explanation {
  color: var(--moon-gray);
  line-height: 1.65;
}

.video-link {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  color: var(--star-white);
  background: var(--nasa-blue);
  font-weight: 700;
  text-decoration: none;
}

.video-link:hover {
  background: #1d66c5;
}

@media (min-width: 600px) {
  .filters {
    flex-direction: row;
  }

  input[type="date"],
  #getImagesButton {
    width: auto;
  }
}

@media (max-width: 520px) {
  body {
    padding: 14px;
  }

  .site-header {
    flex-direction: column;
  }

  .logo {
    width: 120px;
  }

  .gallery {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-media img,
  .video-preview {
    transition: none;
  }

  .gallery-item:hover .gallery-media img,
  .gallery-item:hover .video-preview {
    transform: none;
  }
}
