@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');

/* Starfield background layers */
@keyframes move-stars {
  from { background-position: 0 0; }
  to   { background-position: -10000px 5000px; }
}

/* General body styling */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  /* A deep space blue background */
  background-color: #0d1117;
  /* Multiple layers of radial gradients create a starfield effect */
  background-image:
    radial-gradient(1px 1px at 10% 20%, white, transparent),
    radial-gradient(1px 1px at 80% 40%, white, transparent),
    radial-gradient(1px 1px at 50% 70%, #ccc, transparent),
    radial-gradient(1px 1px at 25% 90%, #ccc, transparent),
    radial-gradient(2px 2px at 90% 10%, #fff, transparent),
    radial-gradient(2px 2px at 40% 50%, #fff, transparent);
  color: #e6edf3;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  min-height: 100vh;
  /* Optional: uncomment the line below for a slow-moving starfield */
  /* animation: move-stars 300s linear infinite; */
}

/* Navigation styling */
nav {
  background-color: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(5px);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  margin-bottom: 2rem;
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
  text-align: center;
}

nav a {
  margin: 0 15px;  
  color: #58a6ff;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  transition: color 0.2s;
}

nav a:hover, nav a.active {
  color: #9ecbff;
  text-decoration: underline;
}

/* Dropdown Navigation Styling */
.dropdown {
  position: relative;
  display: inline-block;
  padding-bottom: 8px; /* Creates a hoverable bridge to the dropdown menu */
  margin-bottom: -8px; /* Prevents the padding from pushing down other nav items */
}

.dropbtn {
  /* This makes the dropdown trigger look like a regular nav link */
  color: #58a6ff;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  margin: 0 15px; /* Match the margin of other nav links */
}

.dropdown:hover .dropbtn, .dropbtn.active {
  color: #9ecbff;
  text-decoration: underline;
}

.dropdown-content {
  /* Use opacity and visibility for a fade effect instead of display: none */
  display: block; /* Keep the element in the layout */
  opacity: 0; /* Make it fully transparent */
  visibility: hidden; /* Hide it from screen readers and mouse events */
  transform: translateY(-10px); /* Start slightly higher for a slide-down effect */
  pointer-events: none; /* Prevent any mouse interaction when hidden */
  /* Add the transition for a smooth fade, slide, and visibility change */
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  position: absolute;
  background-color: rgba(22, 27, 34, 0.9);
  backdrop-filter: blur(5px);
  min-width: 160px;
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.4);
  z-index: 1;
  border-radius: 8px;
  border: 1px solid #30363d;
  margin-top: 8px;
  text-align: left;
}

.dropdown-content a {
  color: #c9d1d9;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  margin: 0;
  font-size: 1em;
}

.dropdown-content a:hover {
  background-color: rgba(56, 139, 253, 0.2);
  color: #f0f6fc;
  text-decoration: none;
}

.dropdown:hover .dropdown-content,
.dropdown.is-active .dropdown-content {
  /* This makes the dropdown visible on EITHER hover OR click */
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Main content container */
main {
  text-align: center;
  width: 100%;
  max-width: 800px;
}

/* Specific style for the homepage's main content to make it narrower */
.main-homepage {
    max-width: 650px;
}

/* Heading style */
h1 {
  color: #f0f6fc;
  margin-bottom: 16px;
}

main h2 {
  color: #c9d1d9;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

/* General paragraph style */
p {
  font-size: 1.1em;
  color: #c9d1d9;
  line-height: 1.5;
}

.video-section {
  width: 100%;
  margin-bottom: 2.5rem;
}

/* Responsive video container */
.video-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border-radius: 8px;
  background-color: #010409; /* Dark background while video loads */
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Politics page grid */
.politics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  width: 100%;
}

/* Fixed image on the politics page */
.fixed-left-image {
  position: fixed;
  top: 6rem; /* Position below the nav bar */
  left: 1rem;
  width: 250px; /* A reasonable small size */
  z-index: 998; /* Below other fixed widgets but above main content */
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.fixed-left-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

/* On smaller screens, stack the politics videos */
@media (max-width: 768px) {
  .politics-grid {
    grid-template-columns: 1fr;
  }
}

/* Game grid styling */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  width: 100%;
  margin-top: 2rem;
}

.game-card {
  background-color: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(5px);
  border: 1px solid #30363d;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  overflow: hidden; /* Ensures iframe corners are rounded */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: block; /* Allows the whole card to be a link */
  text-decoration: none;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.game-card iframe {
  display: block; /* Removes bottom space under iframe */
  width: 100%;
  height: 167px; /* Keep the original height */
  border: none;
}

/* Section for additional game links */
.more-games-section {
  width: 100%;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #30363d;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.link-item {
  background-color: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(5px);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  text-align: left;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.link-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border-color: #8b949e;
}

.link-item h3 {
  margin: 0 0 0.25rem 0;
  color: #f0f6fc;
  font-size: 1.2em;
}

.link-item p {
  margin: 0;
  color: #c9d1d9;
  font-size: 1em;
  line-height: 1.4;
}

.link-item a {
  font-weight: bold;
  white-space: nowrap; /* Prevents the link from wrapping */
  color: #58a6ff;
}

/* Constitution Section Styling */
.constitution-section {
  width: 100%;
  max-width: 800px;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid #30363d;
}

.constitution-text {
  background-color: rgba(13, 17, 23, 0.8);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1rem 2rem;
  text-align: left;
  max-height: 500px;
  overflow-y: auto;
  line-height: 1.7;
  margin-bottom: 2rem;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.4);
}

.constitution-text h3 {
  color: #58a6ff;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #30363d;
  padding-bottom: 0.25rem;
}

.constitution-text h4 {
  color: #c9d1d9;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.constitution-text p {
  font-size: 1em;
}

/* Container for Earth and Music Button */
.earth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 3rem; /* Adds space above the group */
}
 
/* Rotating Earth GIF */
.rotating-earth-gif {
  width: 128px; /* Set a good size */
  height: 128px;
  /* Keep the pixel art sharp and not blurry */
  image-rendering: pixelated; /* For Chrome/Firefox */
  image-rendering: crisp-edges; /* For older browsers */
}

/* SoundCloud Embed */
.soundcloud-embed {
  border: none;
  border-radius: 8px;
  width: 100%;
}

.soundcloud-attribution {
  font-size: 10px;
  color: #8b949e; /* A grey that fits the theme */
  line-break: anywhere;
  word-break: normal;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: Interstate, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Garuda, Verdana, Tahoma, sans-serif;
  font-weight: 100;
  width: 100%;
  margin-top: 5px;
  text-align: left;
}

.soundcloud-attribution a {
  color: #8b949e;
  text-decoration: none;
}

/* Puzzle Section on Admin Page */
.puzzle-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid #30363d;
}

.word-haystack {
  line-height: 1.8;
  color: #8b949e;
  text-align: justify;
  font-family: monospace;
}

/* Admin Page Section */
.admin-section {
  width: 100%;
  max-width: 800px;
  margin-top: 2rem;
  padding: 2rem;
  border-top: 1px solid #30363d;
  text-align: left;
}

.admin-textarea {
  width: 100%;
  background-color: #010409;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.75rem;
  color: #e6edf3;
  font-size: 1em;
  font-family: monospace;
  line-height: 1.5;
  margin-top: 1rem;
  box-sizing: border-box;
}

.admin-button {
  background-color: #58a6ff;
  color: #0d1117;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-top: 1rem;
}

.admin-button:hover {
  background-color: #9ecbff;
}

.save-confirm {
  color: #4caf50; /* Green for success */
  font-weight: bold;
  margin-top: 1rem;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.save-confirm.fade-out {
  opacity: 1;
}

/* Sign-in Form Styling */
.signin-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
  width: 100%;
  margin: 2rem auto 0;
  padding: 2rem;
  background-color: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(5px);
  border: 1px solid #30363d;
  border-radius: 8px;
}

.signin-form .form-group {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.signin-form label {
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #c9d1d9;
}

.signin-form input {
  background-color: #010409;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.75rem;
  color: #e6edf3;
  font-size: 1em;
}

.signin-form input:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}

.signin-form button {
  background-color: #58a6ff;
  color: #0d1117;
  border: none;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.signin-form button:hover {
  background-color: #9ecbff;
}

.signin-error {
  color: #f85149; /* Red for errors */
  text-align: center;
  margin-top: 1rem;
  min-height: 1.2em; /* Prevents layout shift */
  display: none; /* Hidden by default */
}

/* --- Settings Dropdown --- */
.settings-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000; /* Make sure it's on top of everything */
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.settings-dropdown {
  position: relative;
  padding-bottom: 8px; /* Creates a hoverable bridge to the dropdown menu */
  margin-bottom: -8px; /* Prevents the padding from pushing down other nav items */
}
.signin-btn {
  background-color: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(5px);
  border: 1px solid #30363d;
  color: #c9d1d9;
  height: 40px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0 1rem;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.9em;
}

.signin-btn:hover {
  color: #58a6ff;
  border-color: #58a6ff;
}

.settings-btn {
  background-color: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(5px);
  border: 1px solid #30363d;
  color: #c9d1d9;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.settings-btn:hover {
  color: #58a6ff;
  border-color: #58a6ff;
}

.settings-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.settings-dropdown-content {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background-color: rgba(22, 27, 34, 0.9);
  backdrop-filter: blur(5px);
  min-width: 180px;
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.4);
  z-index: 1;
  border-radius: 8px;
  border: 1px solid #30363d;
  padding: 0.5rem 0;
}

.settings-dropdown-content a {
  color: #c9d1d9;
  padding: 10px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
  font-size: 0.9em;
}

.settings-dropdown-content a:hover {
  background-color: rgba(56, 139, 253, 0.2);
  color: #f0f6fc;
}

.settings-dropdown:hover .settings-dropdown-content,
.settings-dropdown.is-active .settings-dropdown-content {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* --- THEME STYLES --- */

/* Psychedelic Theme */
@keyframes psychedelic-bg {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
body[data-theme="psychedelic"] {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: psychedelic-bg 15s ease infinite;
    color: #fff;
}
body[data-theme="psychedelic"] h1, body[data-theme="psychedelic"] h2, body[data-theme="psychedelic"] h3 {
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
body[data-theme="psychedelic"] nav, body[data-theme="psychedelic"] .game-card, body[data-theme="psychedelic"] .link-item, body[data-theme="psychedelic"] .constitution-text, body[data-theme="psychedelic"] .settings-btn, body[data-theme="psychedelic"] .settings-dropdown-content {
    background-color: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}
body[data-theme="psychedelic"] nav a, body[data-theme="psychedelic"] .link-item a, body[data-theme="psychedelic"] .dropbtn {
    color: #fff;
}

/* Obsidian Black Theme */
body[data-theme="black"] {
    background: #000;
    color: #e0e0e0;
}
body[data-theme="black"] h1, body[data-theme="black"] h2, body[data-theme="black"] h3 {
    color: #fff;
}
body[data-theme="black"] nav, body[data-theme="black"] .game-card, body[data-theme="black"] .link-item, body[data-theme="black"] .constitution-text, body[data-theme="black"] .settings-btn, body[data-theme="black"] .settings-dropdown-content {
    background-color: #111;
    border-color: #333;
}
body[data-theme="black"] nav a, body[data-theme="black"] .link-item a, body[data-theme="black"] .dropbtn {
    color: #bbb;
}
body[data-theme="black"] nav a:hover, body[data-theme="black"] nav a.active, body[data-theme="black"] .dropdown:hover .dropbtn {
    color: #fff;
}

/* Graffiti Theme */
body[data-theme="graffiti"] {
    background-color: #4a4a4a;
    background-image: url('https://www.transparenttextures.com/patterns/brick-wall.png');
    color: #fff;
}
body[data-theme="graffiti"] h1, body[data-theme="graffiti"] h2, body[data-theme="graffiti"] .link-item h3 {
    font-family: 'Permanent Marker', cursive;
    color: #fef200; /* Bright yellow */
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}
body[data-theme="graffiti"] nav, body[data-theme="graffiti"] .game-card, body[data-theme="graffiti"] .link-item, body[data-theme="graffiti"] .constitution-text, body[data-theme="graffiti"] .settings-btn, body[data-theme="graffiti"] .settings-dropdown-content {
    background-color: rgba(10, 10, 10, 0.7);
    border: 2px solid #fff;
    border-radius: 0;
}

/* Mental Health Awareness Theme */
body[data-theme="mental-health"] {
    background-color: #f0f4f0; /* Very light green/grey */
    color: #37474f; /* Dark grey-blue */
}
body[data-theme="mental-health"] h1, body[data-theme="mental-health"] h2, body[data-theme="mental-health"] h3 {
    color: #2e7d32; /* Darker green */
}
body[data-theme="mental-health"] nav, body[data-theme="mental-health"] .game-card, body[data-theme="mental-health"] .link-item, body[data-theme="mental-health"] .constitution-text, body[data-theme="mental-health"] .settings-btn, body[data-theme="mental-health"] .settings-dropdown-content {
    background-color: #fff;
    border-color: #c8e6c9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
body[data-theme="mental-health"] nav a, body[data-theme="mental-health"] .link-item a, body[data-theme="mental-health"] .dropbtn {
    color: #1b5e20; /* Even darker green */
}
body[data-theme="mental-health"] nav a:hover, body[data-theme="mental-health"] nav a.active, body[data-theme="mental-health"] .dropdown:hover .dropbtn {
    color: #4caf50; /* Medium green */
}

/* Random Video Player on Homepage */
.random-video-player {
  width: 320px; /* Increased size for better controls */
  height: 180px; /* 16:9 aspect ratio */
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  background-color: #010409;
}

/* New container for fixed widgets in the top-left */
#top-left-widgets {
  position: fixed;
  top: 6rem; /* Lowered to not cover the nav bar */
  left: 1rem;
  z-index: 999; /* Below settings menu */
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

/* Adjust player dimensions for vertical YouTube Shorts */
.random-video-player.is-short {
  width: 180px; /* Increased size for better controls */
  height: 320px;
}

.random-video-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.soundcloud-container {
  width: 320px; /* Match the width of the video player */
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* Sisyphus Game Canvas */
#gameCanvas {
    margin-top: 1rem;
    background-color: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
}