:root {
  /* Dark theme - softened charcoal grey backdrop */
  --background: #2C2C2C;
  --text: #FFFFFF;
  --navbar-bg: #2C2C2C;
  --navbar-text: #FFFFFF;
  /* Primary accent updated to match lighter hero orange */
  --card-bg: #FFB74D;
  --card-text: #FFFFFF;
  --card-max-width: 420px;
  --panel-max-width: 560px;
  /* Buttons: white background, accent-colored text */
  --button-bg: #FFFFFF;
  --button-text: #FFB74D;
  --section-bg: #2C2C2C;
}

.theme-light {
  --background: #FFFFFF;
  --text: #333333;
  --navbar-bg: #FFFFFF;
  --navbar-text: #333333;
  /* Light theme accent UPDATED to match hero orange */
  --card-bg: #FFB74D;
  --card-text: #FFFFFF;
  /* Buttons: switch accent/white for visibility */
  --button-bg: #FFB74D;
  --button-text: #FFFFFF;
  --section-bg: #FFFFFF;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Montserrat', sans-serif;
  background-color: var(--background);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1 0 auto;
}

footer {
  flex-shrink: 0;
}

.logo-text {
  font-weight: 800;
  font-size: 2.5rem;
}

.primary-bg {
  /* Primary section background uses theme variable */
  background-color: var(--card-bg);
  /* Use medium grey for text on orange backgrounds */
  color: #333333;
}

/* Override any explicit white text classes inside primary-bg */
.primary-bg .text-white {
  color: #333333 !important;
}

/* Lighten hero background so network nodes/droplets show up against it */
#home.primary-bg {
  background-color: #FFB74D;
}

.primary-text {
  /* Primary accent text color */
  color: var(--card-bg);
}

.primary-border {
  /* Primary accent border color */
  border-color: var(--card-bg);
}

.navbar {
  background-color: var(--navbar-bg);
  color: var(--navbar-text);
}

.section-padding {
  padding: 5rem 1.5rem;
}

.container-tight {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.card {
  background-color: var(--card-bg);
  color: var(--card-text);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  width: 100%;
  max-width: var(--card-max-width);
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* White panels used in app pages (filters, quizzes, study cards) */
.panel {
  width: 100%;
  max-width: var(--panel-max-width);
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* Center action buttons inside cards/panels */
.card .card-button,
.panel .card-button {
  margin-left: auto;
  margin-right: auto;
  display: inline-block;
}

/* Center table text inside app panels/cards */
.table-center th,
.table-center td {
  text-align: center;
  vertical-align: middle;
}

/* Badge styling */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  background-color: #ffffff;
  color: #333333;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.badge-earned {
  background-color: var(--card-bg);
  color: #333333;
  border-color: var(--card-bg);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 20px rgba(244, 124, 0, 0.4);
}

.aligned-list {
  list-style: none;
  padding-left: 0;
}

.aligned-list li {
  text-align: center;
}

.custom-button {
  background-color: var(--button-bg);
  color: var(--button-text) !important;
  padding: 0.75rem 2rem;
  border-radius: 9999px;
  font-size: 1.125rem;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: inline-block;
}

.custom-button:hover {
  /* Pause auto-pulse animation on hover */
  animation: none !important;
  opacity: 0.9;
  /* Increase hover scale for stronger emphasis */
  transform: scale(1.2) !important;
  /* Glow effect to attract clicks */
  box-shadow: 0 0 10px rgba(244, 124, 0, 0.85), 0 0 20px rgba(244, 124, 0, 0.6);
}

.card-button {
  background-color: var(--button-bg);
  color: var(--button-text) !important;
  padding: 0.5rem 1.5rem;
  border-radius: 9999px;
  font-size: 1rem;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: inline-block;
}

.card-button:hover {
  /* Pause auto-pulse animation on hover */
  animation: none !important;
  opacity: 0.9;
  /* Increase hover scale for card buttons */
  transform: scale(1.15) !important;
  /* Glow effect for card buttons */
  box-shadow: 0 0 8px rgba(244, 124, 0, 0.8), 0 0 16px rgba(244, 124, 0, 0.6);
}

/* Auto-pulse animation on all buttons to draw attention */
@keyframes autoPulse {

  0%,
  100% {
    /* base state: no scale, subtle glow */
    transform: scale(1);
    box-shadow: 0 0 4px rgba(244, 124, 0, 0.5);
  }

  50% {
    /* mid-pulse: slight scale up, stronger glow */
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(244, 124, 0, 0.9);
  }
}

.custom-button,
.card-button {
  /* shorter cycle for more noticeable pulsing */
  animation: autoPulse 2.5s ease-in-out infinite;
  transform-origin: center center;
}

/* Override card button colors inside orange sections for better contrast */
/* Cards (product cards) and token section buttons */
.card .card-button,
.primary-bg .card-button {
  background-color: #FFFFFF !important;
  /* Use primary accent orange (same as slider) for highest visibility */
  color: #F47C00 !important;
}

/* Hamburger Menu Styles */
#menu-toggle {
  z-index: 20;
}

#mobile-menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  z-index: 10;
  background-color: var(--navbar-bg);
  color: var(--navbar-text);
}

#mobile-menu.show {
  display: block;
}

#mobile-menu nav {
  background-color: var(--navbar-bg);
  color: var(--navbar-text);
}

#mobile-menu nav a {
  text-align: center;
  color: var(--navbar-text);
}

#mobile-menu {
  transition: all 0.3s ease-in-out;
}

#mobile-menu nav {
  padding: 2rem;
}

/* Accessibility for hamburger button */
#menu-toggle:focus {
  outline: 2px solid var(--card-bg);
  outline-offset: 2px;
}

/* Theme Toggle Slider */
.theme-toggle {
  display: flex;
  align-items: center;
}

/* Token section metadata cards: override .card colors for visibility */
#token-cards .card {
  background-color: #ffffff !important;
  color: #333333 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
#token-cards .card-button {
  background-color: var(--button-bg) !important;
  color: var(--button-text) !important;
}

/* Active navigation link highlight */
.navbar nav a.active,
#mobile-menu nav a.active {
  /* Use accent color to indicate active section */
  color: var(--card-bg) !important;
  /* Optional underline for clearer indication */
  border-bottom: 2px solid var(--card-bg);
  padding-bottom: 0.25rem;
}

.theme-toggle input[type="checkbox"] {
  display: none;
}

.theme-toggle-label {
  position: relative;
  /* Bigger track for more visibility */
  width: 64px;
  height: 32px;
  background-color: #F47C00;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  /* Border and shadow for depth */
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.theme-toggle-label::after {
  content: '';
  position: absolute;
  /* Center thumb vertically with small padding */
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.3s ease, background-color 0.3s ease;
  /* Thumb shadow for lift effect */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.theme-toggle input[type="checkbox"]:checked+.theme-toggle-label {
  background-color: #F47C00;
}

.theme-toggle input[type="checkbox"]:checked+.theme-toggle-label::after {
  /* Move thumb to other end: track width (64) minus thumb width (28) minus padding */
  transform: translateX(34px);
}

/* Particle animation on canvas */
#hero-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* under static network overlay */
  z-index: 0;
  pointer-events: none;
}

/* Static blockchain network overlay */
#hero-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* over canvas, under content */
  z-index: 1;
  pointer-events: none;
}

/* Ensure hero content (text/buttons) stays above animations */
#home .container-tight {
  position: relative;
  z-index: 2;
}

#home {
  position: relative;
  overflow: hidden;
  /* Make hero section fill viewport height and center content */
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 0;
}

/* Ensure each main section fills the viewport height and centers content vertically */
#products,
#about,
#token,
#contact {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}

@media (max-width: 768px) {
  .navbar {
    padding: 1rem 1.5rem;
  }

  .navbar img {
    height: 3rem;
    width: 3rem;
  }

  .logo-text {
    font-size: 1.5rem;
  }

  .text-5xl {
    font-size: 2.5rem;
  }

  .text-4xl {
    font-size: 2rem;
  }

  .text-2xl {
    font-size: 1.5rem;
  }

  .theme-toggle {
    margin-left: 1rem;
  }
}

/* Light theme override for buttons on primary-bg sections */
.theme-light .primary-bg .custom-button,
.theme-light .primary-bg .card-button,
.theme-light .card .card-button {
  background-color: #FFFFFF;
  /* Use slider-track orange for highest contrast */
  color: #F47C00 !important;
}

/* Auth cards: keep inputs readable on orange card backgrounds */
.auth-card input,
.auth-card select,
.auth-card textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background-color: #FFFFFF;
  color: #333333;
}
.auth-card .errorlist {
  margin-top: 0.25rem;
  color: #7f1d1d;
  font-size: 0.875rem;
}

/* Navbar link hover effect: slide-in underline and orange text */
.navbar nav a {
  position: relative;
  transition: color 0.3s ease;
}

.navbar nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0%;
  height: 2px;
  background-color: var(--card-bg);
  transition: width 0.3s ease;
}


/* Highlight current section link (desktop & mobile) */
.navbar nav a:hover,
.navbar nav a.active,
#mobile-menu nav a:hover,
#mobile-menu nav a.active {
  color: var(--card-bg) !important;
}

.navbar nav a:hover::after,
.navbar nav a.active::after,
#mobile-menu nav a:hover::after,
#mobile-menu nav a.active::after {
  width: 100% !important;
}

/* Mobile menu underline fix: position underline at bottom of each link */
#mobile-menu nav a {
  position: relative;
}
#mobile-menu nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background-color: var(--card-bg);
  transition: width 0.3s ease;
}
#mobile-menu nav a:hover,
#mobile-menu nav a.active {
  color: var(--card-bg) !important;
}
#mobile-menu nav a:hover::after,
#mobile-menu nav a.active::after {
  width: 100%;
}

/* Mobile menu underline and active link highlight */
#mobile-menu nav a {
  position: relative;
  transition: color 0.3s ease;
}
#mobile-menu nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background-color: var(--card-bg);
  transition: width 0.3s ease;
}
#mobile-menu nav a:hover,
#mobile-menu nav a.active {
  color: var(--card-bg) !important;
}
#mobile-menu nav a:hover::after,
#mobile-menu nav a.active::after {
  width: 100% !important;
}
/* Ensure Scroll-spy works with Jinja2 templates (no changes needed) */