/* --- Base Setup --- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: radial-gradient(circle, #fffbeb 0%, #FFD700 100%);
  display: grid;
  place-items: center;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
}

/* --- Logo Container & SVG --- */
.logo-container {
  width: 90%;
  max-width: 600px;
  position: relative;
  z-index: 10; 
  /* Added for smooth hide/show */
  transition: opacity 0.4s ease-out;
}
.logo-container.hidden {
  opacity: 0;
  pointer-events: none;
}

svg {
  width: 100%;
  height: auto;
  z-index: 1000;
  overflow: visible;
}

/* --- 0. Magical Shimmer Particles --- */
.particle-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  overflow: hidden;
  z-index: 1; 
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0;
  z-index: 1;
  will-change: transform, opacity;
}

/* Particle Keyframes */
@keyframes burst {
  0% { transform: translate(0,0) scale(0.5); opacity: 1; }
  40% { transform: translate(var(--x-move), var(--y-move)) scale(1.5); opacity: 0.9; filter: brightness(1.6); }
  70% { transform: translate(calc(var(--x-move) * 1.2), calc(var(--y-move) * 1.2)) scale(0.7); opacity: 0.6; }
  100% { transform: translate(0,0) scale(0.3); opacity: 0; }
}

/* --- Initial Animation States (Hidden) --- */
#logo-triangles,
#logo-circles > *,
#logo-text > *,
#theline {
  opacity: 0;
  filter: blur(5px);
}
.ray-part path {
  opacity: 0;
  filter: blur(5px);
  --ray-scale: 0; /* JS will animate this */
}


/* --- 1. Triangles --- */
.logo-container.animate #logo-triangles {
  animation: blur-in 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 1.0s 1 forwards;
}

/* --- 2. Circles --- */
#logo-circles > * {
  transform: scale(0);
  transform-origin: 50.4px 37.0px; 
}
.logo-container.animate #midcircle1 {
  animation: pop-in 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) 1.5s 1 forwards;
}
.logo-container.animate #midcircle2 {
  animation: pop-in 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) 1.6s 1 forwards;
}
.logo-container.animate #midcircle3 {
  animation: pop-in 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) 1.7s 1 forwards;
}
.logo-container.animate #midcircle4 {
  animation: pop-in 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) 1.8s 1 forwards;
}

/* --- 3. The Red Rays --- */
.ray-part path {
  fill: #dc0000;
  transform: scale(var(--ray-scale));
  transform-origin: center center;
  transform-box: fill-box;
}

/* --- 4. The "KAPNOX" Text (Staggered) --- */
.logo-container.animate #logoname1 {
  animation: blur-in 0.5s ease-out 3.0s 1 forwards;
}
.logo-container.animate #logoname2 {
  animation: blur-in 0.5s ease-out 3.1s 1 forwards;
}
.logo-container.animate #logoname3 {
  animation: blur-in 0.5s ease-out 3.2s 1 forwards;
}
.logo-container.animate #logoname4, .logo-container.animate #logoname4a {
  animation: blur-in 0.5s ease-out 3.3s 1 forwards;
}
.logo-container.animate #logoname5 {
  animation: blur-in 0.5s ease-out 3.4s 1 forwards;
}
.logo-container.animate #logoname6, .logo-container.animate #logoname6a {
  animation: blur-in 0.5s ease-out 3.5s 1 forwards;
}

/* --- 5. The Line --- */
#theline {
  stroke-dasharray: 87;
  stroke-dashoffset: 87;
}
.logo-container.animate #theline {
  animation: draw-line 0.5s ease-out 3.6s 1 forwards,
             blur-in 0.5s ease-out 3.6s 1 forwards;
}

/* --- 6. Final Highlight --- */
.logo-container.animate #KapnoxLogo {
  animation: final-highlight 0.8s ease-in-out 4.2s 1;
}

/* --- Keyframes --- */
@keyframes blur-in {
  from { opacity: 0; filter: blur(8px); }
  to { opacity: 1; filter: blur(0px); }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0); filter: blur(5px); }
  to { opacity: 1; transform: scale(1); filter: blur(0px); }
}
@keyframes draw-line {
  to { stroke-dashoffset: 0; }
}
@keyframes final-highlight {
  0% { filter: none; }
  50% { filter: brightness(1.5) drop-shadow(0 0 15px #FFD700); }
  100% { filter: none; }
}

/* --- Page fade helpers for load --- */
.page-fade { 
  transition: opacity 420ms cubic-bezier(.2,.9,.2,1); 
}
.page-hidden { 
  opacity: 0; 
  pointer-events: none; 
}

/* --- Reduced Motion Accessibility --- */
@media (prefers-reduced-motion: reduce) {
  /* ... (styles) ... */
}

/* ===============================================
RAY LABEL STYLES
===============================================
*/
.ray-label {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
font-weight: 700;
text-transform: uppercase;
fill: url(#text-gradient);
stroke: rgba(0,0,0,0.4);
stroke-width: 0.2px;
opacity: 0; 
pointer-events: none; 
transition: opacity 0.3s ease-out;
}

/* ===============================================
BOTTOM LEFT CONTROLS
===============================================
*/
.bottom-left-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Added for smooth hide/show */
  transition: opacity 0.4s ease-out;
}
/* Added */
.bottom-left-controls.hidden {
  opacity: 0;
  pointer-events: none;
}

/* --- Replay Button --- */
.replay-button {
  background-color: #06005e;
  color: #FFD700;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease-out;
}
.replay-button:hover {
  background-color: #1a1a6e;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* --- Mute Button --- */
.control-button {
  background-color: #06005e;
  border: none;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease-out;
  width: 50px;
  height: 50px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
}
.control-button:hover {
  background-color: #1a1a6e;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.control-button img {
  width: 24px;
  height: 24px;
  filter: invert(84%) sepia(90%) saturate(857%) hue-rotate(320deg) brightness(104%) contrast(102%);
}

/* ===============================================
SPA CONTENT STYLES (Added)
===============================================
*/
.main-content {
  position: fixed;
  inset: 0;
  z-index: 2000; /* On top of everything */
  background: rgba(6,0,94,0.98); /* Dark blue overlay */
  color: #fff;
  padding: 40px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}

.main-content.visible {
  opacity: 1;
  visibility: visible;
}

/* "Home" button inside the SPA content */
#main #homeButton {
  position: fixed;
  left: 20px;
  top: 20px;
  z-index: 2100; /* Above main content */
  background: #FFD700;
  color: #06005e;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
  transition: all 0.2s ease-out;
}
#main #homeButton:hover {
  transform: translateY(-2px);
}