/* ================= 1. THEME DEFINITIONS (CSS Variables) ================= */
:root {
  --bg-color: #000;
  --text-color: #fff;
  --text-secondary-color: #aaa;
  --text-tertiary-color: #ccc;
  --box-bg-color: rgba(255, 255, 255, 0.08);
  --box-shadow-color: rgba(255, 255, 255, 0.2);
  --star-color: #FFF;
  --sidebar-bg-color: rgba(10, 10, 10, 0.9);
  --sidebar-border-color: #333;
}

body.light-theme {
  --bg-color: #f0f2f5;
  --text-color: #1c1e21;
  --text-secondary-color: #65676b;
  --text-tertiary-color: #333;
  --box-bg-color: rgba(0, 0, 0, 0.05);
  --box-shadow-color: rgba(0, 0, 0, 0.1);
  --star-color: #333;
  --sidebar-bg-color: rgba(255, 255, 255, 0.9);
  --sidebar-border-color: #ddd;
}

/* ================= 2. Animated Starfield Background ================= */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  animation: animStar 50s linear infinite;
  background-image: radial-gradient(1px 1px at 20px 30px, var(--star-color), transparent), radial-gradient(1px 1px at 90px 60px, var(--star-color), transparent), radial-gradient(1.5px 1.5px at 150px 120px, var(--star-color), transparent);
}

#stars1 {
  background-size: 200px 200px;
  animation-duration: 100s;
}

#stars2 {
  background-image: radial-gradient(1.5px 1.5px at 40px 80px, var(--star-color), transparent), radial-gradient(2px 2px at 160px 20px, var(--star-color), transparent), radial-gradient(1.5px 1.5px at 250px 180px, var(--star-color), transparent);
  background-size: 300px 300px;
  animation-duration: 150s;
}

#stars3 {
  background-image: radial-gradient(2.5px 2.5px at 100px 100px, var(--star-color), transparent), radial-gradient(3px 3px at 250px 320px, var(--star-color), transparent);
  background-size: 450px 450px;
  animation-duration: 200s;
}

@keyframes animStar {
  from { transform: translate(0, 0); }
  to { transform: translate(-100%, -100%); }
}

/* ================= 3. Define the custom font ================= */
@font-face {
  font-family: 'Mojangles';
  src: url('Minecraft.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap; /* ADDED: This prevents invisible text while loading */
}

/* ================= 4. General Body & Layout ================= */
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-text-size-adjust: none;
  text-rendering: optimizeLegibility;
  letter-spacing: 0.3px;
  line-height: 1.6;
  text-align: center;
}

/* ================= 5. Explore Sidebar ================= */
#explore-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 50%;
  max-width: 400px;
  background-color: var(--sidebar-bg-color);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--sidebar-border-color);
  z-index: 1002;
  transform: translateX(-100%);
  transition: transform 0.5s ease-in-out;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

body.sidebar-open #explore-sidebar {
  transform: translateX(0);
}

#explore-sidebar .sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--sidebar-border-color);
}

#sidebar-close-button {
  font-size: 28px;
  color: var(--text-secondary-color);
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

#sidebar-close-button:hover {
  color: var(--text-color);
  transform: rotate(90deg);
}

#explore-sidebar h2 {
  font-family: 'Mojangles', sans-serif;
  font-size: 24px;
  text-align: left;
}

#explore-sidebar nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
#explore-sidebar .nav-link {
  font-family: 'Mojangles', sans-serif; /* This applies the Minecraft font */
  font-size: 18px;
  color: var(--text-color);
  text-decoration: none;
  margin-bottom: 15px;
  transition: color 0.2s ease;
}

#explore-sidebar .nav-link:hover {
  color: var(--text-secondary-color);
}


/* ================= 6. Theme Switcher ================= */
#theme-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  z-index: 1001;
}

.icon-sun, .icon-moon {
  width: 100%;
  height: 100%;
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.icon-sun {
  background-color: #FFD700;
  border-radius: 50%;
  box-shadow: 0 0 10px #FFD700;
}

.icon-moon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 4px -4px 0 0 #f0f0f0;
}

body.light-theme .icon-moon { opacity: 0; transform: scale(0); }
body:not(.light-theme) .icon-sun { opacity: 0; transform: scale(0); }


/* ================= 7. Page Elements ================= */
#video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  cursor: pointer;
}

#intro-video {
  width: 50vw;
  max-width: 600px;
  max-height: 600px;
}

#menu-button {
  position: fixed;
  top: 38px;
  left: 20px;
  width: 18px;
  height: 6px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 2s ease, transform 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#menu-button .bar {
  width: 100%;
  height: 2px;
  background-color: var(--text-color);
  transition: background-color 0.3s ease;
}

#menu-button:hover .bar {
  background-color: var(--text-secondary-color);
}


#logo, #since-logo-text, #since-text {
  position: fixed;
  color: var(--text-color);
  z-index: 1000;
  opacity: 0;
}

#logo {
  top: 25px;
  left: 52px;
  width: 32px;
  height: auto;
  transition: opacity 2s ease;
  cursor: default;
}

#since-logo-text {
  top: 61px;
  left: 52px;
  width: 32px;
  font-size: 7px;
  white-space: nowrap;
  transition: opacity 2s ease;
}

#since-text {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  font-weight: bold;
  transition: opacity 2s ease;
}

#main-content-container {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 1s ease 1s;
}

#knowledge-box {
  position: relative;
  max-width: 700px;
  min-height: 80px;
  padding: 20px 30px;
  border-radius: 20px;
  background-color: var(--box-bg-color);
  color: var(--text-color);
  font-size: 15px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
  cursor: pointer;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

#knowledge-bit-text {
  font-family: 'Mojangles', sans-serif;
  text-transform: uppercase;
}

#knowledge-explanation {
  margin-top: 15px;
  font-size: 14px;
  color: var(--text-tertiary-color);
  line-height: 1.4;
  font-family: 'Fedorka', sans-serif;
  text-transform: none;
}

.typing::after {
  content: '▋';
  margin-left: 3px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  from, to { opacity: 0; }
  50% { opacity: 1; }
}

/* ================= 8. AI Chat Interface ================= */
#ask-carlos-trigger {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-style: italic;
  color: var(--text-secondary-color);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.5s ease;
  visibility: hidden;
}

/* EDITED: Added this rule to apply the Mojangles font to the 'CARLOSai' text */
.carlos-ai-font {
  font-family: 'Mojangles', sans-serif;
  text-transform: uppercase;
  font-style: normal;
}

.carlos-ai-font sup {
  text-transform: lowercase;
}

#ai-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 600px;
  padding: 20px;
  border-radius: 20px;
  background-color: var(--box-bg-color);
  backdrop-filter: blur(10px);
  z-index: 1003;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

body.ai-modal-open #ai-modal {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

#ai-modal-close-button {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  color: var(--text-secondary-color);
  cursor: pointer;
}

#ai-chat-form {
  display: flex;
  align-items: center;
}

#ai-chat-input {
  flex-grow: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--text-secondary-color);
  color: var(--text-color);
  font-size: 14px;
  padding: 5px;
}
#ai-chat-input:focus {
  outline: none;
  border-bottom-color: var(--text-color);
}

#ai-chat-form button {
  background: none;
  border: none;
  color: var(--text-secondary-color);
  font-size: 20px;
  cursor: pointer;
  margin-left: 10px;
  transform: rotate(-20deg);
  transition: transform 0.3s ease, color 0.3s ease;
}
#ai-chat-form button:hover {
  color: var(--text-color);
  transform: scale(1.2) rotate(0deg);
}

#ai-response-area {
  margin-top: 15px;
  text-align: left;
  font-style: italic;
  color: var(--text-tertiary-color);
  min-height: 80px;
  position: relative;
  line-height: 1.5;
  font-size: 14px;
}

.flying-star {
  position: fixed;
  background-color: var(--star-color);
  border-radius: 50%;
  z-index: 1004;
  pointer-events: none;
}


/* ================= 9. Action Buttons & Footer ================= */
#refresh-button, #share-button {
  color: var(--text-secondary-color);
  cursor: pointer;
  transition: transform 0.3s ease, color 0.3s ease;
}
#refresh-button {
  font-size: 28px;
  margin-left: 20px;
}
#share-button {
  font-size: 24px;
  margin-left: 15px;
  transform: rotate(-20deg);
}
#refresh-button:hover, #share-button:hover {
  color: var(--text-color);
}
#refresh-button:hover { transform: rotate(360deg); }
#share-button:hover { transform: scale(1.2) rotate(0deg); }


#knowledge-box:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--box-shadow-color);
}

#live-clock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  font-family: 'Fedorka', sans-serif;
  font-weight: 500;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 2s ease;
  font-size: 18px;
  color: var(--text-color);
}

.time-group {
  display: flex;
}

.separator {
  margin: 0 5px;
  line-height: 1.2em;
}

.digit-box {
  position: relative;
  width: 0.8em;
  height: 1.2em;
  margin: 0 1px;
  overflow: hidden;
}

.digit-box span {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.4s ease-in-out;
}

.digit-box .digit-top {
  transform: translateY(0);
}

.digit-box .digit-bottom {
  transform: translateY(100%);
}

.digit-box.drop .digit-top {
  transform: translateY(-100%);
}

.digit-box.drop .digit-bottom {
  transform: translateY(0);
}

#footer-text {
  position: fixed;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-secondary-color);
  opacity: 0;
  transition: opacity 2s ease;
}

#tap-to-enter {
  position: absolute;
  color: var(--text-secondary-color);
  font-size: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease;
  cursor: pointer;
  z-index: 1000;
}


/* ================= 10. Media Queries ================= */
@media (max-width: 768px) {
  #since-text { font-size: 18px; }
  #main-content-container { width: 90%; }
  #knowledge-box { font-size: 16px; padding: 15px 20px; line-height: 1.3; }
  #knowledge-explanation { font-size: 13px; }
  #ai-response-area { font-size: 13px; }
  #refresh-button { font-size: 24px; margin-left: 15px; }
  #share-button { font-size: 22px; }
  #live-clock { font-size: 16px; }
  
  #logo { width: 32px; left: 52px; top: 25px; } 
  #since-logo-text { width: 32px; top: 61px; font-size: 7px; left: 52px; }
  #menu-button { top: 38px; width: 18px; height: 6px; }
}

@media (max-width: 480px) {
  #since-text { font-size: 14px; }
  #knowledge-box { font-size: 14px; line-height: 1.2; padding: 10px 15px; }
  #knowledge-explanation { font-size: 12px; }
  #ai-response-area { font-size: 12px; }
  #explore-sidebar { width: 80%; }
  #live-clock { font-size: 10px; }
  #logo { width: 32px; left: 52px; top: 25px; }
  #since-logo-text { width: 32px; top: 61px; font-size: 7px; left: 52px; }
  #menu-button { top: 38px; width: 18px; height: 6px; }
}

@media (max-width: 600px) {
  #live-clock { bottom: 40px; }
  #footer-text { bottom: 8px; font-size: 10px; }
}