/* CSS Custom Properties for better maintainability */
:root {
  --primary-bg: #000;
  --text-color: white;
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --overlay-bg-light: rgba(255, 255, 255, 0.9);
  --gradient-bg: linear-gradient(135deg, #87ceeb 0%, #e0f6ff 50%, #b0e0e6 100%);
  --border-radius: 10px;
  --transition-speed: 0.3s;
  --animation-duration: 0.3s;
  --font-family-primary: "Arial", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  --font-family-serif: "Georgia", "Times New Roman", serif;
  --shadow-subtle: 0 4px 15px rgba(0, 0, 0, 0.1);
  --focus-outline: 2px solid #4caf50;
  --focus-outline-offset: 2px;
}

/* Support for reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  :root {
    --animation-duration: 0s;
    --transition-speed: 0s;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* General Reset and Base Styles */
body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--primary-bg);
  overflow: hidden;
  font-family: var(--font-family-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-bg);
  color: var(--text-color);
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  font-weight: bold;
  transition: top var(--transition-speed) ease;
}

.skip-link:focus {
  top: 6px;
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Gradient background for fallback/non-image periods */
body.gradient-background {
  background: var(--gradient-bg);
}

/* Container for the image and text */
#container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Background Image */
#background-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  transition: opacity var(--transition-speed) ease;
  will-change: opacity; /* Optimize for animations */
}

/* Countdown Text Container (with background) */
#countdown-text-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--overlay-bg);
  padding: 20px;
  border-radius: var(--border-radius);
  box-sizing: border-box;
  z-index: 1;
  max-width: 90%;
  text-align: center;
  min-height: auto;
  backdrop-filter: blur(10px); /* Modern backdrop blur effect */
  -webkit-backdrop-filter: blur(10px);
}

/* Focus management for accessibility */
#countdown-text-container:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Text container styling for gradient background */
body.gradient-background #countdown-text-container {
  background: var(--overlay-bg-light);
  box-shadow: var(--shadow-subtle);
}

/* Countdown text color adjustment for gradient background */
body.gradient-background #countdown-text {
  color: #2c3e50; /* WCAG AA compliant contrast ratio */
}

/* Countdown Text (now h1) */
#countdown-text {
  color: var(--text-color);
  font-size: clamp(2rem, 5vw, 6rem); /* Fluid typography with constraints */
  margin: 0;
  word-wrap: break-word;
  font-weight: bold;
  line-height: 1.2;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7); /* Better text readability */
}

/* Responsive Design for Smaller Screens */
@media (max-width: 768px) {
  #countdown-text {
    font-size: 10vw; /* Larger text for small screens */
  }
}

@media (max-width: 480px) {
  #countdown-text {
    font-size: 12vw; /* Even larger text for very small screens */
  }

  #background-image {
    object-position: center; /* Keep the focus on the center of the image */
  }
}

#daily-quote {
  color: var(--text-color);
  font-size: clamp(1rem, 2vw, 1.5rem); /* Fluid typography */
  font-family: var(--font-family-serif);
  margin-top: 20px;
  text-align: center;
  max-width: 90%;
  line-height: 1.6; /* Better readability */
  display: block;
  font-style: italic;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

#daily-quote:empty {
  display: none;
}

/* Enhanced responsive design with better breakpoints */
@media (max-width: 768px) {
  #countdown-text-container {
    padding: 15px;
    max-width: 95%;
  }

  #daily-quote {
    margin-top: 15px;
  }
}

@media (max-width: 480px) {
  #countdown-text-container {
    padding: 12px;
    margin: 0 10px;
  }

  #background-image {
    object-position: center;
  }

  #daily-quote {
    margin-top: 12px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #countdown-text-container {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--text-color);
  }

  #countdown-text,
  #daily-quote {
    text-shadow: none;
    font-weight: bold;
  }
}

/* Footer Link */
#footer-link {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

#footer-link a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 14px;
  background: var(--overlay-bg);
  padding: 8px 12px;
  border-radius: 5px;
  transition: all var(--transition-speed) ease;
  display: inline-block;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

#footer-link a:hover,
#footer-link a:focus {
  background: rgba(0, 0, 0, 0.8);
  text-decoration: underline;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#footer-link a:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body.gradient-background #countdown-text-container {
    background: rgba(0, 0, 0, 0.8);
  }

  body.gradient-background #countdown-text {
    color: var(--text-color);
  }
}

/* Print styles for accessibility */
@media print {
  #background-image {
    display: none;
  }

  #countdown-text-container {
    background: white;
    color: black;
    position: static;
    transform: none;
    box-shadow: none;
  }

  #countdown-text,
  #daily-quote {
    color: black;
    text-shadow: none;
  }

  #footer-link {
    position: static;
    margin-top: 20px;
    text-align: center;
    transform: none;
  }
}

/* Footer link styling for gradient background */
body.gradient-background #footer-link a {
  color: #2c3e50;
  background: rgba(255, 255, 255, 0.8);
}

body.gradient-background #footer-link a:hover {
  background: rgba(255, 255, 255, 0.95);
}

@media (max-width: 480px) {
  #footer-link {
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
  }

  #footer-link a {
    font-size: 12px;
    padding: 6px 10px;
  }
}
