/* ============================================================
   Luna — USGS Geologic Atlas of the Moon
   Space theme — Lila (Chief Web Designer) + Terry (Assistant)
   ============================================================ */

/* --- Variables --- */
:root {
  --space-black:    #03030f;
  --space-deep:     #07071a;
  --space-blue:     #0d1b3e;
  --lunar-silver:   #c8d0e0;
  --lunar-gold:     #d4a843;
  --glow-blue:      #4a9eff;
  --glow-cyan:      #00d4ff;
  --text-primary:   #e8eaf0;
  --text-secondary: #8a9ab5;
  --text-dim:       #424860;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--space-black);
  color: var(--text-primary);
  font-family: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Starfield canvas (fixed background layer) --- */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* --- Header --- */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3.5rem 2rem 2.5rem;
  border-bottom: 1px solid rgba(74, 158, 255, 0.12);
  background: linear-gradient(
    to bottom,
    rgba(13, 27, 62, 0.5) 0%,
    transparent 100%
  );
}

.header-content {
  max-width: 700px;
  margin: 0 auto;
}

.header-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lunar-gold);
  border: 1px solid rgba(212, 168, 67, 0.35);
  padding: 0.3rem 0.9rem;
  border-radius: 2px;
  margin-bottom: 1.4rem;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 0.9rem;
}

h1 span {
  color: var(--glow-cyan);
  font-weight: 400;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  font-weight: 400;
  text-transform: uppercase;
}

/* --- Main --- */
main {
  position: relative;
  z-index: 1;
}

/* --- Map section --- */
.map-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1rem 2rem;
  gap: 0;
}

.map-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map-wrapper {
  position: relative;
  display: inline-block;
  /* Outer glow suggesting the Moon floating in space */
  filter: drop-shadow(0 0 40px rgba(74, 158, 255, 0.12))
          drop-shadow(0 0 80px rgba(74, 158, 255, 0.06));
}

#moon-map {
  display: block;
  max-width: min(88vw, 820px);
  height: auto;
  cursor: crosshair;
}

/* Canvas sits exactly over the moon image */
#map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Quadrangle name label below the map */
.quad-label {
  margin-top: 1.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--glow-cyan);
  text-shadow: 0 0 12px rgba(0, 212, 255, 0.45);
  min-height: 1.5em;
  text-align: center;
  transition: opacity 0.15s ease;
}

.map-instructions {
  margin-top: 1rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 3rem;
}

/* --- Footer --- */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 2rem 2.5rem;
  border-top: 1px solid rgba(74, 158, 255, 0.1);
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.8;
}

footer a {
  color: var(--lunar-gold);
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover,
footer a:focus {
  color: var(--glow-cyan);
  outline: none;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 15, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--space-deep);
  border: 1px solid rgba(74, 158, 255, 0.25);
  border-radius: 3px;
  max-width: min(95vw, 1050px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    0 0 0 1px rgba(74, 158, 255, 0.08),
    0 0 40px rgba(74, 158, 255, 0.15),
    0 24px 80px rgba(0, 0, 0, 0.9);
  padding: 2.5rem 2rem 2rem;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

#modal-title {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--text-primary);
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  padding-right: 2rem; /* clear the close button */
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 1px solid rgba(74, 158, 255, 0.25);
  color: var(--text-secondary);
  width: 2rem;
  height: 2rem;
  border-radius: 2px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.modal-close:hover,
.modal-close:focus {
  background: rgba(74, 158, 255, 0.12);
  color: var(--text-primary);
  border-color: rgba(74, 158, 255, 0.5);
  outline: none;
}

.modal-image-wrap {
  text-align: center;
}

#modal-img {
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  display: block;
  margin: 0 auto;
}

/* --- Focus styles (accessibility) --- */
:focus-visible {
  outline: 2px solid var(--glow-cyan);
  outline-offset: 3px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  header {
    padding: 2.5rem 1rem 2rem;
  }

  .map-section {
    padding: 2rem 0.25rem 1.5rem;
  }

  .modal-content {
    padding: 2rem 1rem 1.5rem;
  }
}
