/* === Global Styles === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100vh;
  overflow: hidden;
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  line-height: 1.8;
  background-image: url('../Images/khi_background.jpg');
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
}

/* === Keyframes for Animations === */
@keyframes pulseOpacity {
  0%   { background: rgba(0, 0, 0, 0.85); }
  50%  { background: rgba(5, 0, 0, 0.95); }
  100% { background: rgba(0, 0, 0, 0.85); }
}

/* === Theme-specific styles === */
body.dark {
  color: #fff;
}

body.dark::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 1);
  z-index: -1;
  animation: pulseOpacity 30s ease-in-out infinite;
}

body.light {
  color: #000;
}

body.light::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('../Images/khi_background.jpg');
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  filter: invert(1) hue-rotate(180deg) brightness(0.85);
  background: rgba(0, 0, 0, 1);
  z-index: -1;
  animation: pulseOpacity 30s ease-in-out infinite;
}

/* Current problematic rule */
body.light,
body.light * {
  color: #000 !important;
}

/* Exceptions for elements that should keep their color in light mode */
body.light .main-content a,
body.light .section-title {
  color: rgba(0, 0, 192, 1.0) !important; /* Complement of blue for hyperlinks, if needed: #b35200 */
}

body.light .section-title {
  color: rgba(179, 82, 0, 1.0) !important; /* Complement of orange for section titles, if needed rgba(0, 90, 255, 0.8) */
}

/* Light mode overrides for map components */
body.light #map-overlay {
  background: rgba(255, 255, 255, 0.95);
  filter: brightness(0.85);
}

body.dark #map-container {
  border: 2px solid white;
}

body.light #map-container {
  background: #f5f5f5;
  border: 2px solid #333;
}

body.light #close-map,
body.light #map-title,
body.light #map-error,
body.light #map-loading {
  color: #000 !important;
}

body.light .colorbar-gradient {
  border: 2px solid #000;
}

body.light .colorbar-labels {
  color: #000;
}

body.light #map-container,
body.light #map-container * {
  color: inherit !important;
}

body.light .leaflet-control-zoom-in,
body.light .leaflet-control-zoom-out {
  background-color: white !important;
  color: #333 !important;
  border: 1px solid #ccc !important;
}

body.light .leaflet-control-zoom-in.leaflet-disabled,
body.light .leaflet-control-zoom-out.leaflet-disabled {
  background-color: rgba(255, 255, 255, 0.3) !important;
  color: rgba(51, 51, 51, 0.3) !important;
}

/* === Light Mode Overrides: Fullscreen Modal === */
body.light .fullscreen-modal {
  background-color: rgba(255, 255, 255, 0.95);
}

body.light .fullscreen-modal img {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

body.light .close-fullscreen {
  color: #000;
}

/* === Navigation === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100px;
  width: 100%;
  z-index: 1000;
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 5px solid white;
}

.navbar nav {
  width: 85%;
  max-width: 1200px;
  display: flex;
  justify-content: space-evenly;
}

.navbar nav a {
  color: #ccc;
  text-decoration: none;
  font-size: 1.8rem;
  transition: color 0.2s;
  font-weight: normal;
  border-bottom: 3px solid transparent;
}

.navbar nav a:hover,
.navbar nav a.active {
  color: #fff;
  font-weight: normal;
  border-bottom-color: white;
}

/* Light mode navbar overrides */
body.light .navbar {
  border-bottom: 5px solid black;
}

body.light .navbar nav a {
  color: #333 !important;
}

body.light .navbar nav a:hover,
body.light .navbar nav a.active {
  color: #000 !important;
  border-bottom-color: black;
}

/* === Content Layout === */
.content-scroll {
  position: absolute;
  top: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 2rem 0;
}

.main-content {
  width: 85%;
  max-width: 1200px;
  margin: 0 auto;
}

.main-content a {
  color: #2997ff;
  text-decoration: none;
}

.main-content a:hover {
  text-decoration: underline;
}

.intro-flex {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 2rem;
}

.intro-text {
  flex: 1;
  min-width: 300px;
}

.intro-text p {
  margin-bottom: 1.5em;
}

.profile-photo {
  height: 200px;
  width: auto;
  border-radius: 8px;
  flex-shrink: 0;
}

/* === Section Styling === */
.section-title {
  position: absolute;
  top: 0;
  left: 7rem;
  font-size: 8rem;
  color: rgba(255, 165, 0, 1.0);
  font-weight: bold;
  z-index: 1;
}

.section-wrapper {
  position: relative;
  padding-top: 20rem;
}

.section-divider {
  border: none;
  border-top: 0px solid white;
  margin: 3rem 0;
}

.privacy-note {
  font-family: inherit;
  font-size: 0.7rem;
  color: #ccc;
  text-align: center;
  margin-top: 4rem;
  margin-bottom: 2rem;
}

/* === Animations === */
.fade-in {
  opacity: 0;
  filter: blur(5px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-in.visible {
  opacity: 1;
  filter: blur(0);
}

/* === Modal Components === */
.fullscreen-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.fullscreen-modal.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.fullscreen-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.close-fullscreen {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 2rem;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

/* === Project Images === */
.project-image-wrapper {
  position: relative;
  display: inline-block;
  float: right;
  margin-left: 10px;
  margin-bottom: 1rem;
}

.project-image {
  display: block;
  width: 400px;
  height: 400px;
  border-radius: 8px;
}

.fullscreen-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 0.3rem;
  background-color: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Smoothly scale the entire button */
  transition: transform 0.2s ease, background-color 0.2s ease;
  will-change: transform;
}

.fullscreen-btn:hover {
  transform: scale(1.25);
  background-color: white;
}

/* Icon stability fix */
.fullscreen-icon {
  width: 32px;
  height: 32px;
  stroke: black;
  transition: stroke 0.2s ease;
  transform: translateZ(0); /* GPU acceleration for smoother rendering */
}

/* === Toggle Buttons === */
#theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  z-index: 9999;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#theme-toggle:hover {
  background: #555;
  transform: scale(1.25);
}

/* === Map Components === */
#map-toggle {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 50px;
  height: 50px;
  cursor: pointer;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.2s ease;
}

#map-toggle:hover {
  transform: scale(1.25);
}

#map-toggle.hidden {
  opacity: 0;
  display: none;
  pointer-events: none;
}

#map-toggle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  padding: 2rem 1rem;
  box-sizing: border-box;
}

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

#map-overlay, 
#map-overlay * {
  font-family: 'JetBrains Mono', monospace;
}

#map-container {
  width: 100%;
  height: 75vh;
  background: #222;
  border-radius: 12px;
}

#close-map {
  position: absolute;
  top: 1rem;
  right: 2rem;
  font-size: 2rem;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10000;
}

#map-title {
  margin-bottom: 0.5rem;
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  z-index: 10000;
  text-align: center;
}

#map-error {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  font-weight: 500;
  color: white;
  max-width: 90%;
  text-align: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}

#map-error.show {
  display: block;
  opacity: 1;
}

#map-loading {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  font-weight: 500;
  color: white;
  max-width: 90%;
  text-align: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#map-loading.show {
  display: block;
  opacity: 1;
}

#map-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 85vw;
  max-width: 1100px;
}

#colorbar {
  margin-top: 0.5rem;
  width: 100%;
  max-width: 100%;
  display: none;
}

.colorbar-gradient {
  width: 100%;
  height: 1rem;
  border: 2px solid white;
  box-sizing: border-box;
  border-radius: 6px;
  background: linear-gradient(to left,
  #000000, #040000, #080000, #0c0000, #100000,
  #140000, #180000, #1c0000, #200000, #240000,
  #280000, #2c0000, #300000, #340000, #380000,
  #3c0000, #400000, #440000, #480000, #4c0000,
  #500000, #540000, #580000, #5c0000, #600000,
  #640000, #680000, #6c0000, #700000, #740000,
  #780000, #7c0000, #800000, #840000, #880000,
  #8c0000, #900000, #940000, #980000, #9c0000,
  #a00000, #a40000, #a80000, #ac0000, #b00000,
  #b40000, #b80000, #bc0000, #c00000, #c40000,
  #c80000, #cc0000, #d00000, #d40000, #d80000,
  #dc0000, #e00000, #e40000, #e80000, #ec0000,
  #f00000, #f40000, #f80000, #fc0000, #ff0400,
  #ff1800, #ff2c00, #ff4000, #ff5400, #ff6800,
  #ff7c00, #ff9000, #ffa400, #ffb800, #ffcc00,
  #ffe000
  );
}

.colorbar-labels {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: white;
  font-size: 0.8rem;
  font-weight: 400;
  padding: 0 0.25rem;
}

/* === Responsive Design === */
@media (max-width: 768px) {
  .navbar {
    height: 110px;
  }

  .content-scroll {
    top: 110px;
  }

  .main-content {
    width: 90%;
    font-size: 20px;
  }

  .intro-flex {
    flex-direction: column;
    align-items: center;
  }

  .profile-photo {
    width: 60%;
    height: auto;
    margin-top: 1rem;
  }

  .navbar nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .navbar nav a {
    margin: 0.5rem 1rem;
  }

  .section-title {
    left: 1rem !important;
    font-size: 3rem !important;
  }

  .section-wrapper {
    padding-top: 10rem !important;
  }
}

/* Grid layout */
.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 2rem;
}

.media-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Play button overlay */
.play-button-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: white;
  z-index: 10;
  pointer-events: auto;
}

/* Description text */
.description {
  margin-top: 10px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-subtle, #aaa); /* fallback */
  max-width: 90%;
}

/* Shared sizing + aspect */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background-color: black;
}

/* Thumbnail image container */
.video-thumb-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
  background-color: #333;
}

/* Video container */
.inline-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.inline-video.hidden {
  display: none;
}

/* Actual video element */
.inline-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: none;
  border-radius: inherit;
  background-color: black;
}

/* Light mode adjustments */
body.light .video-wrapper {
  background-color: white;
}

video:fullscreen,
video:-webkit-full-screen {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  border-radius: 0 !important;
  background-color: black !important;
}

