/* Global layout */
body {
  background-color: #111;
  color: #ddd;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

header {
  background-color: #000;
  padding: 20px;
  text-align: center;
}

/* Header layout */
.header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.lab-icon {
  width: 60px;
  height: 60px;
  margin-left: 15px;
}

main {
  max-width: 1000px;
  margin: 20px auto;
  padding: 0 20px;
}

section {
  margin-bottom: 30px;
}

/* Headings */
h2 {
  color: #fff;
  cursor: pointer;
  margin-bottom: 10px;
}

h3 {
  color: #fff;
}

/* ========================= */
/* BIO SECTION – DESKTOP     */
/* ========================= */

.bio-content {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  flex-wrap: nowrap;        /* keep a single row on desktop */
  position: relative;       /* so we can absolutely position the planet inside */
  padding-right: 180px;     /* reserve space for 150px planet + a bit of gap */
}

/* Text should fill the space between profile and planet */
.bio-content p {
  flex: 1;
  margin: 0;
}

/* Profile picture on the left */
.profile-pic {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Planet – pinned in the right corner on desktop */
#planet-container {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;          /* mask content to circle */
  flex-shrink: 0;

  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);  /* vertical center in the bio row */
}

/* Ensure the Three.js canvas fills the circle */
#planet-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ========================= */
/* EXOPLANET GAME            */
/* ========================= */

#explorer-game {
  margin-top: 30px;
  background-color: #222;
  padding: 15px;
  border-radius: 8px;
}

#explorer-wrapper {
  position: relative;
}

#explorer-canvas {
  width: 100%;
  height: 350px;
  display: block;
  background-color: #000;
  border: 1px solid #333;
  border-radius: 4px;
  margin-top: 10px;
}

.game-instructions {
  text-align: center;
  font-size: 0.9em;
  color: #ccc;
  margin-bottom: 5px;
}

.game-score {
  text-align: center;
  margin-top: 10px;
  color: #ccc;
  font-size: 0.9em;
}

/* Popup with planet info */
.info-popup {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 10px;
  background-color: rgba(0, 0, 0, 0.85);
  color: #eee;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #444;
  max-width: min(300px, 90vw);  /* avoid being cut off on mobile */
  z-index: 10;
}

.info-popup.hidden {
  display: none;
}

/* ========================= */
/* CONTENT SECTIONS          */
/* ========================= */

.content {
  background-color: #222;
  padding: 15px;
  border-radius: 5px;
  color: #ccc;
}

/* Research images layout */
.image-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}

.research-img {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
}

figure {
  margin: 0 0 15px 0;
  text-align: center;
  color: #ccc;
}

figcaption {
  font-size: 0.9em;
  margin-top: 5px;
  color: #eee;
}

/* Improve readability of captions by adding a semi-transparent background */
figure figcaption {
  background-color: rgba(0, 0, 0, 0.6);
  padding: 5px 8px;
  border-radius: 4px;
  display: inline-block;
}

/* Links */
a {
  color: #00bfff;
  text-decoration: underline;
}

/* Utility */
.hidden {
  display: none;
}

/* Footer */
footer {
  background-color: #000;
  color: #777;
  text-align: center;
  padding: 20px 0;
}

/* ========================= */
/* MOBILE CONTROLS FOR GAME  */
/* ========================= */

.mobile-controls {
  display: none;  /* hidden on desktop */
}

/* ========================= */
/* MOBILE LAYOUT             */
/* ========================= */

@media (max-width: 700px) {
  /* In bio: allow wrapping and align items nicely */
  .bio-content {
    flex-wrap: wrap;
    align-items: center;
    padding-right: 0;           /* no reserved right space on mobile */
  }

  /* On mobile: profile (1), planet (2) on first row, text (3) below */
  .bio-content .profile-pic {
    order: 1;
    width: 130px;
    height: 130px;
  }

  #planet-container {
    order: 2;
    position: static;           /* back into normal flex flow */
    width: 130px;
    height: 130px;
    transform: none;
    margin-top: 0;
  }

  .bio-content p {
    order: 3;
    width: 100%;
    margin-top: 10px;
  }

  #explorer-canvas {
    height: 250px;
  }

  .mobile-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
  }

  .mobile-controls .middle-row {
    display: flex;
    gap: 6px;
  }

  .mobile-controls button {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 1px solid #555;
    background: #333;
    color: #fff;
    font-size: 22px;
    padding: 0;
    cursor: pointer;
  }

  .mobile-controls button:active {
    background: #555;
  }
}
