/* --- Global Styles & Variables --- */
:root {
  --background-color: #f9fafb;
  --card-background-color: #ffffff;
  --border-color: #e5e7eb;
  --text-color: #1f2937;
  --text-color-light: #6b7280;
  --primary-color: #111827;
  --primary-color-hover: #374151;
  --accent-color: #3b82f6;
  --error-color: #ef4444;
  --info-text-color: #1e40af;
  --info-bg-color: #eff6ff;
  --info-border-color: #dbeafe;
  --border-radius: 6px;
  --box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

body {
  background-color: var(--background-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 20px;
  color: var(--text-color);
  margin: 0;
  padding: 2rem;
}

/* --- Typography --- */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 0;
}

button {
  font-size: 20px;
}

#message {
  position: fixed; /* Makes the element stay in one place even when scrolling */
  top: 0;          /* Aligns it to the top of the viewport */
  left: 0;         /* Aligns it to the left of the viewport */
  width: 100%;     /* Makes it span the full width of the viewport */
  z-index: 1000;   /* Ensures it sits on top of all other content */
  box-sizing: border-box; /* Ensures padding is included in the element's total width */

  padding: 1rem;
  margin-bottom: 0;

  background: var(--card-background-color);
  border: 1px solid var(--border-color);
  text-align: center;
}

#message .error {
  color: var(--error-color);
  background-color: #fef2f2;
  border-color: #fecaca;
}

#message .info { /* NEW: Informational message style */
  color: var(--info-text-color);
  background-color: var(--info-bg-color);
  border-color: var(--info-border-color);
}

#message:not(:empty) {
   display: block;
}

#message:empty {
   display: none;
}


/* --- Loader Animation --- */
#loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: 120px;
  height: 120px;
  pointer-events: none;
}

/* The main pulsating core - like a beating heart or bleeding wound */
#loader::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, #8b0000 0%, #4a0000 40%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: heartbeat 2.5s ease-in-out infinite, bleed 4s linear infinite;
  box-shadow: 
    0 0 20px rgba(139, 0, 0, 0.3),
    inset 0 0 10px rgba(139, 0, 0, 0.5);
}

/* Ink drops that fall and dissolve */
#loader::after {
  content: '';
  position: absolute;
  top: 60%;
  left: 50%;
  width: 3px;
  height: 40px;
  background: linear-gradient(to bottom, 
    rgba(139, 0, 0, 0.8) 0%, 
    rgba(139, 0, 0, 0.4) 50%, 
    transparent 100%);
  transform: translateX(-50%);
  animation: drip 3s ease-in-out infinite;
  border-radius: 0 0 50% 50%;
}

/* Floating fragments - like scattered words or memories */
.loader-fragment {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(139, 0, 0, 0.6);
  border-radius: 50%;
  animation: float 6s linear infinite;
}

/* Animation keyframes */
@keyframes heartbeat {
  0%, 100% { 
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.7;
  }
  50% { 
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 1;
  }
}

@keyframes bleed {
  0%, 100% {
    box-shadow: 
      0 0 20px rgba(139, 0, 0, 0.3),
      inset 0 0 10px rgba(139, 0, 0, 0.5);
  }
  50% {
    box-shadow: 
      0 0 40px rgba(139, 0, 0, 0.6),
      0 0 60px rgba(139, 0, 0, 0.2),
      inset 0 0 15px rgba(139, 0, 0, 0.8);
  }
}

@keyframes drip {
  0% {
    opacity: 0;
    transform: translateX(-50%) scaleY(0);
  }
  20% {
    opacity: 0.8;
    transform: translateX(-50%) scaleY(1);
  }
  80% {
    opacity: 0.8;
    transform: translateX(-50%) scaleY(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scaleY(0.5) translateY(10px);
  }
}

@keyframes float {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.2;
  }
  100% {
    transform: translateY(-60px) rotate(360deg);
    opacity: 0;
  }
}

#body.loading {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(0.6) contrast(0.8);
  transition: all 0.8s ease;
}

#loader.notloading {
  visibility: hidden;
  transition: visibility 0.5s ease;
}

#body.notloading {
  opacity: 1.0;
  filter: none;
  transition: all 0.8s ease;
}

#next.loading {
  visibility: hidden;
}

/* Add atmospheric backdrop during loading */
body.loading-atmosphere {
  background: linear-gradient(135deg, 
    #f9fafb 0%, 
    #f3f3f3 50%, 
    #ebebeb 100%);
  transition: background 1.2s ease;
}

body.loading-atmosphere::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, 
    transparent 0%, 
    rgba(139, 0, 0, 0.02) 70%, 
    rgba(139, 0, 0, 0.05) 100%);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  animation: atmosphere-pulse 4s ease-in-out infinite;
}

@keyframes atmosphere-pulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}
