/* === GOOGLE FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Montserrat:wght@700;800&display=swap');

/* ================= VARIABLES ================= */
:root {
  --header-height: 5rem;

  /* === Colors (Light Mode) === */
  --bg-color: #f8f9fa;
  --bg-color-alt: #ffffff;
  --text-color: #212529;
  --text-color-muted: #6c757d;
  --primary-color: #4361ee;
  --primary-color-rgb: 67, 97, 238;
  --primary-color-alt: #3a0ca3;
  --secondary-color: #f72585;
  --accent-color: #4cc9f0;
  --success-color: #2ec4b6;
  --warning-color: #ff9f1c;
  --danger-color: #e63946;
  --border-color: #dee2e6;
  --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.08);
  --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--primary-color-alt));
  --gradient-accent: linear-gradient(135deg, var(--accent-color), var(--secondary-color));

  /* === Font & Typography === */
  --body-font: 'Poppins', sans-serif;
  --heading-font: 'Montserrat', sans-serif;
  --h1-font-size: 2.5rem;
  --h2-font-size: 2rem;
  --h3-font-size: 1.5rem;
  --h4-font-size: 1.25rem;
  --normal-font-size: 1rem;
  --small-font-size: 0.875rem;
  --smaller-font-size: 0.75rem;

  /* === Font Weight === */
  --font-light: 300;
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* === Margins & Paddings === */
  --mb-0-5: 0.5rem;
  --mb-1: 1rem;
  --mb-1-5: 1.5rem;
  --mb-2: 2rem;
  --mb-3: 3rem;

  /* === Border Radius === */
  --border-radius-sm: 0.25rem;
  --border-radius: 0.5rem;
  --border-radius-lg: 1rem;
  --border-radius-xl: 1.5rem;

  /* === z-index === */
  --z-tooltip: 10;
  --z-fixed: 100;
  --z-modal: 1000;
}

/* ================= DARK MODE VARIABLES ================= */
body.dark {
  --bg-color: #121212;
  --bg-color-alt: #1e1e1e;
  --text-color: #f8f9fa;
  --text-color-muted: #adb5bd;
  --primary-color: #4cc9f0;
  --primary-color-alt: #4361ee;
  --secondary-color: #f72585;
  --accent-color: #7209b7;
  --success-color: #2ec4b6;
  --warning-color: #ff9f1c;
  --danger-color: #e63946;
  --border-color: #343a40;
  --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  --card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ================= ACCESSIBILITY ================= */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: white;
  padding: 8px 12px;
  text-decoration: none;
  border-radius: var(--border-radius-sm);
  z-index: var(--z-modal);
  font-weight: var(--font-semibold);
  transition: top 0.3s ease;
}

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

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ================= LOADING STATES ================= */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--mb-2);
  gap: var(--mb-1);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.search-loading p {
  color: var(--text-color-muted);
  font-size: var(--small-font-size);
}

/* ================= PERFORMANCE OPTIMIZATIONS ================= */
img {
  max-width: 100%;
  height: auto;
  /* Improve image loading performance */
  content-visibility: auto;
  contain-intrinsic-size: 100px 100px;
}

picture {
  display: block;
}

/* ================= BREADCRUMB NAVIGATION ================= */
.breadcrumb {
  display: flex;
  list-style: none;
  padding: 0;
  margin: var(--mb-1) 0;
  font-size: var(--small-font-size);
  background: var(--bg-color-alt);
  padding: var(--mb-0-5) var(--mb-1);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--card-shadow);
  flex-wrap: wrap;
  gap: 0.25rem;
}

.breadcrumb li {
  display: flex;
  align-items: center;
}

.breadcrumb li:not(:last-child)::after {
  content: "→";
  margin: 0 0.5rem;
  color: var(--text-color-muted);
  font-weight: var(--font-regular);
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s ease;
}

.breadcrumb a:hover {
  background: rgba(var(--primary-color-rgb), 0.1);
  color: var(--primary-color-alt);
}

.breadcrumb li[aria-current="page"] {
  color: var(--text-color);
  font-weight: var(--font-medium);
}

/* Optimize animations for performance */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .spinner {
    animation: none;
  }
  
  .breadcrumb a {
    transition: none;
  }
}

/* ================= BASE ================= */
* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

/* Description Section Styling */
.description-section {
  background-color: var(--bg-color-alt);
  border-radius: var(--border-radius);
  padding: var(--mb-2);
  margin-bottom: var(--mb-3);
  box-shadow: var(--card-shadow);
}

.description-section h2 {
  color: var(--primary-color);
  margin-bottom: var(--mb-1);
  font-family: var(--heading-font);
}

.description-section p {
  margin-bottom: var(--mb-1);
  line-height: 1.6;
}

body {
  font-family: var(--body-font);
  font-size: var(--normal-font-size);
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  color: var(--text-color);
  font-weight: var(--font-semibold);
}

a {
  text-decoration: none;
  color: var(--primary-color);
  transition: color 0.3s;
}

a:hover {
  color: var(--primary-color-alt);
}

img {
  max-width: 100%;
  height: auto;
}

/* ================= LAYOUT ================= */
.container {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 var(--mb-1-5);
}

/* ================= HEADER ================= */
.site-header {
  width: 100%;
  position: sticky;
  top: 0;
  left: 0;
  z-index: var(--z-fixed);
  background-color: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background-color 0.3s, border-color 0.3s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem var(--mb-1-5);
}

body.dark .site-header {
  background-color: rgba(22, 33, 62, 0.8);
}

.logo-title {
  display: flex;
  align-items: center;
  gap: var(--mb-1);
  /* The following ensures it doesn't overlap with controls */
  flex-shrink: 0;
}

.site-logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  transition: transform 0.3s ease;
}

.site-logo:hover {
  transform: scale(1.1) rotate(5deg);
}

.logo-title h1 a {
  font-size: 1.5rem;
  color: var(--text-color);
  font-weight: var(--font-semibold);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--mb-1);
  /* This will push the controls to the far right */
  margin-left: auto;
  padding-left: 1rem; /* Add space between logo and controls */
}

.search-wrapper {
  position: relative;
}

.search-results {
  position: absolute;
  top: 110%;
  left: 0;
  width: 400px;
  max-width: 80vw;
  max-height: 60vh;
  overflow: auto;
  background: var(--bg-color-alt);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  display: none;
  z-index: calc(var(--z-fixed) + 1);
}
.search-results mark {
  background-color: rgba(var(--primary-color-rgb, 67, 97, 238), 0.2);
  color: inherit;
  padding: 0 0.15rem;
  border-radius: 0.15rem;
  font-weight: var(--font-medium);
}

.search-category-header {
  background-color: var(--primary-color);
  color: white;
  padding: 0.5rem 1rem;
  font-weight: var(--font-semibold);
  font-size: var(--small-font-size);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0.5rem 0 0.25rem 0;
  border-radius: 4px;
}

.search-suggestions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.search-suggestions p {
  margin-bottom: 0.5rem;
  font-weight: var(--font-medium);
  color: var(--text-color);
}

.suggestion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.suggestion-tag {
  background-color: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: var(--small-font-size);
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
}

.suggestion-tag:hover {
  background-color: var(--primary-color-alt);
  transform: translateY(-1px);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.result-header h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.result-category {
  color: var(--text-color-muted);
  font-size: var(--small-font-size);
  margin-bottom: 0.25rem;
}

.result-description {
  color: var(--text-color-muted);
  font-size: var(--small-font-size);
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.result-price {
  color: var(--success-color);
  font-weight: var(--font-semibold);
  font-size: var(--small-font-size);
}

.search-results.active {
  display: block;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: var(--bg-color-alt);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--small-font-size);
  color: var(--text-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.close-search {
  background: none;
  border: none;
  color: var(--text-color-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: all 0.2s;
}

.close-search:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-color);
}

.result-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.result-card:last-child {
  border-bottom: none;
}

.result-card:hover,
.result-card.selected {
  background: rgba(0,123,255,0.08);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.result-card:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.result-card img {
  object-fit: cover;
  border-radius: 6px;
  transition: transform 0.3s ease;
}

.result-card:hover img {
  transform: scale(1.05);
}

.result-card .meta h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.result-card .meta p.category-type {
  color: var(--text-color-muted);
  margin-bottom: 0.25rem;
}

.result-card .meta p.description {
  font-size: 0.8rem;
  color: var(--text-color-muted);
  line-height: 1.4;
}

.no-results {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-color-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.no-results p:first-child {
  color: var(--text-color);
  font-weight: var(--font-medium);
  font-size: var(--normal-font-size);
}

#darkModeToggle {
  font-size: 1.2rem;
  cursor: pointer;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
}

#search-box {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  width: 250px;
  transition: all 0.3s;
}

#search-box:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

#darkToggle {
  font-size: 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-color);
  padding: 0.25rem;
}

/* ================= NAVIGATION ================= */
nav {
  background-color: var(--bg-color-alt);
  padding: 0.8rem var(--mb-1-5);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: var(--mb-2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  border-radius: var(--border-radius);
  position: sticky;
  top: calc(var(--header-height) + 5px);
  z-index: var(--z-fixed);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

nav a {
  color: var(--text-color);
  font-weight: var(--font-medium);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
}

nav a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--gradient-accent);
  transition: width 0.3s ease;
}

nav a:hover::before {
  width: 80%;
}

nav a:hover {
  color: var(--primary-color);
  background-color: rgba(67, 97, 238, 0.05);
}

nav a.active {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.4);
  transform: translateY(-2px);
}

nav a.active:hover {
  background-color: var(--primary-color-alt);
  color: white;
  box-shadow: 0 3px 10px rgba(var(--primary-color-rgb), 0.5);
}

nav a.active::before {
  width: 0;
}

/* ================= DROPDOWN NAVIGATION ================= */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.dropdown-arrow {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.nav-dropdown:hover .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background-color: var(--bg-color-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow-hover);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: calc(var(--z-fixed) + 1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.nav-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-color);
  text-decoration: none;
  border-radius: 0;
  transition: all 0.3s ease;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.dropdown-menu a:last-child {
  border-bottom: none;
}

.dropdown-menu a:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateX(5px);
}

.dropdown-menu a::before {
  display: none;
}

/* ================= FRUIT CATEGORY DROPDOWNS ================= */
.fruit-category-dropdown {
  position: relative;
  margin-bottom: 1rem;
}

.fruit-category-dropdown .dropdown-toggle {
  width: 100%;
  justify-content: space-between;
  background-color: var(--bg-color-alt);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  font-weight: var(--font-medium);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fruit-category-dropdown .dropdown-toggle:hover {
  background-color: var(--primary-color);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.fruit-category-dropdown .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg-color-alt);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: var(--z-tooltip);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  max-height: 300px;
  overflow-y: auto;
}

.fruit-category-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.fruit-category-dropdown .dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.fruit-category-dropdown .dropdown-menu a:last-child {
  border-bottom: none;
}

.fruit-category-dropdown .dropdown-menu a:hover {
  background-color: var(--primary-color);
  color: var(--white);
  padding-left: 1.5rem;
}

.fruit-category-dropdown .dropdown-arrow {
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}

.fruit-category-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

/* ================= INFORMATION PROFILE BOX ================= */
.info-profile-box {
  background-color: var(--bg-color-alt);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem;
  overflow: hidden;
  position: relative;
}

.profile-header {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #000;
  padding: 1rem 1.5rem;
  text-align: center;
  position: relative;
}

.profile-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: var(--font-bold);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.profile-image {
  padding: 1.5rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.1), rgba(58, 12, 163, 0.1));
}

.profile-main-image {
  max-width: 200px;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease;
}

.profile-main-image:hover {
  transform: scale(1.05);
}

.profile-details {
  padding: 1.5rem;
  background-color: var(--bg-color-alt);
}

.profile-detail-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-detail-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.detail-label {
  font-weight: var(--font-semibold);
  color: var(--text-color);
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.detail-value {
  color: #ffd700;
  font-weight: var(--font-medium);
  font-size: 1rem;
}

.detail-list ul {
  margin: 0;
  padding-left: 1rem;
  list-style-type: disc;
}

.detail-list li {
  color: #ffd700;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

/* Responsive design for profile box */
@media screen and (max-width: 768px) {
  .info-profile-box {
    margin: 1rem 0;
  }
  
  .profile-header {
    padding: 0.75rem 1rem;
  }
  
  .profile-header h2 {
    font-size: 1.25rem;
  }
  
  .profile-image {
    padding: 1rem;
  }
  
  .profile-main-image {
    max-width: 150px;
  }
  
  .profile-details {
    padding: 1rem;
  }
  
  .profile-detail-item {
    margin-bottom: 0.75rem;
  }
}

/* Mobile dropdown adjustments */
@media screen and (max-width: 768px) {
  .nav-dropdown {
    width: 100%;
  }
  
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background-color: transparent;
    margin-top: 0.5rem;
    padding-left: 1rem;
  }
  
  .dropdown-menu a {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
  }
  
  .dropdown-arrow {
    display: none;
  }
}

/* ================= MAIN CONTENT ================= */
main {
  padding: var(--mb-2) var(--mb-1-5);
}

.main-layout {
  display: flex;
  gap: var(--mb-2);
  max-width: 1400px;
  margin: 0 auto;
}

.main-content {
  flex: 1;
  min-width: 0; /* Prevents flex item from overflowing */
}

/* ================= HERO SECTION ================= */
.hero {
  background: var(--gradient-primary);
  color: white;
  text-align: center;
  padding: 4rem 2rem;
  margin-bottom: var(--mb-3);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.1"/><circle cx="10" cy="60" r="0.5" fill="white" opacity="0.1"/><circle cx="90" cy="40" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero h2 {
  font-family: var(--heading-font);
  font-size: calc(var(--h1-font-size) * 1.2);
  font-weight: var(--font-extrabold);
  margin-bottom: var(--mb-1);
  color: white;
}

.hero p {
  font-size: var(--h3-font-size);
  max-width: 800px;
  margin: 0 auto 2rem auto;
  opacity: 0.9;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 2rem;
}

.hero-stats .stat-item {
  text-align: center;
}

.hero-stats .stat-number {
  display: block;
  font-size: 2.5rem;
  font-weight: var(--font-bold);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.hero-stats .stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ================= FEATURED SECTION ================= */
.featured-section {
  padding: 3rem 0;
  background-color: var(--bg-color-alt);
  margin-bottom: 2rem;
}

.featured-section h2 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
  color: var(--text-color);
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.featured-item {
  background-color: var(--bg-color);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.featured-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.featured-item:hover::before {
  transform: scaleX(1);
}

.featured-item:hover {
  transform: translateY(-8px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--primary-color);
}

.featured-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background-color: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.featured-item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 1rem;
  border-radius: 8px;
}

.featured-item h3 {
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.featured-item p {
  color: var(--text-color-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}

/* ================= CATEGORY CARDS ================= */
.categories {
  display: flex;
  flex-direction: column;
  gap: var(--mb-1-5);
  margin-bottom: var(--mb-2);
}

.category-grid, .item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--mb-1-5);
  margin-top: 2rem;
}

.category-card {
  background-color: var(--bg-color-alt);
  padding: var(--mb-1-5);
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-height: 280px;
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.category-card:hover::before {
  transform: scaleX(1);
}

.category-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--primary-color);
}

.category-card img {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--mb-1);
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--border-color);
  transition: all 0.3s ease;
  background-color: rgba(var(--primary-color-rgb, 67, 97, 238), 0.05);
}

.category-card:hover img {
  transform: scale(1.1);
  border-color: var(--primary-color);
}

.category-card h3 {
  font-size: var(--normal-font-size);
  font-weight: var(--font-semibold);
  margin: var(--mb-0-5) 0;
  line-height: 1.3;
  color: var(--text-color);
}

.category-card h3 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

.category-card h3 a:hover {
  color: var(--primary-color);
}

.category-card p {
  font-size: var(--small-font-size);
  color: var(--text-color-muted);
  line-height: 1.4;
  margin: var(--mb-0-5) 0;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Rarity badges */
.rarity-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: var(--smaller-font-size);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: var(--mb-0-5);
}

.rarity-badge.common {
  background-color: #6c757d;
  color: white;
}

.rarity-badge.uncommon {
  background-color: #28a745;
  color: white;
}

.rarity-badge.rare {
  background-color: #007bff;
  color: white;
}

.rarity-badge.epic {
  background-color: #6f42c1;
  color: white;
}

.rarity-badge.legendary {
  background-color: #fd7e14;
  color: white;
}

.rarity-badge.mythical {
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
  color: white;
}

/* New/Updated badges */
.new-badge, .updated-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-size: var(--smaller-font-size);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 2;
}

.new-badge {
  background-color: var(--success-color);
  color: white;
  animation: pulse 2s infinite;
}

.updated-badge {
  background-color: var(--warning-color);
  color: white;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ================= NEW SECTIONS ================= */
.featured-content, .did-you-know, .quick-links, .community-spotlight {
  margin-bottom: var(--mb-2);
  padding: var(--mb-2);
  background-color: var(--bg-color-alt);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.featured-content h2, .did-you-know h2, .quick-links h2, .community-spotlight h2 {
  font-size: var(--h2-font-size);
  color: var(--primary-color);
  margin-bottom: var(--mb-1-5);
  text-align: center;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--mb-1-5);
}

.featured-card {
  background-color: var(--bg-color);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}

.featured-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--card-shadow-hover);
}

.featured-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.featured-info {
  padding: var(--mb-1);
}

.featured-info h3 {
  font-size: var(--h3-font-size);
  margin-bottom: var(--mb-0-5);
}

.featured-info p {
  color: var(--text-color-muted);
  margin-bottom: var(--mb-1);
}

.btn {
  display: inline-block;
  background-color: var(--primary-color);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: var(--font-medium);
  transition: background-color 0.3s;
}

.btn:hover {
  background-color: var(--primary-color-alt);
  color: #fff;
}

.did-you-know {
  text-align: center;
  font-style: italic;
  color: var(--text-color-muted);
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--mb-1);
}

.link-card {
  background-color: var(--bg-color);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  transition: background-color 0.3s, color 0.3s;
}

.link-card:hover {
  background-color: var(--primary-color);
  color: #fff;
}

.spotlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--mb-1-5);
}

.spotlight-card {
  text-align: center;
}

.spotlight-card img {
  width: 100%;
  height: 240px; /* make images a bit bigger and uniform */
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: var(--mb-0-5);
}

.spotlight-card p {
  color: var(--text-color-muted);
  font-size: var(--small-font-size);
}

/* ================= INFO & CONTENTS SECTION ================= */
.intro, .blox-fruits-info, .blox-contents {
  background: linear-gradient(145deg, var(--bg-color-alt), var(--bg-color));
  padding: var(--mb-2);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: var(--mb-2);
  text-align: center;
  box-shadow: var(--card-shadow);
  border-left: 5px solid var(--primary-color);
}

.blox-fruits-info h2, .blox-contents h3, .intro h2 {
  margin-bottom: var(--mb-1-5);
  font-size: var(--h2-font-size);
  color: var(--primary-color);
  font-family: var(--heading-font);
  font-weight: var(--font-bold);
}

.intro h3 {
  margin: var(--mb-1-5) 0 var(--mb-1);
  color: var(--text-color);
  font-weight: var(--font-semibold);
}

.blox-fruits-info p, .blox-contents ul, .intro p, .intro ul {
  color: var(--text-color-muted);
  line-height: 1.7;
  text-align: left;
  font-size: 1.05rem;
}

.intro ul {
  display: inline-block;
  text-align: left;
  margin-top: var(--mb-1);
  padding-left: var(--mb-1);
  list-style-position: outside;
  margin-bottom: 1rem;
  list-style-type: none;
}

/* Ensure lists inside overview sections align correctly */
.blox-fruits-info ul {
  text-align: left;
  list-style-position: inside;
  margin: var(--mb-1) auto 1rem;
  padding-left: var(--mb-1);
  max-width: 900px;
}

.blox-fruits-info ul li {
  margin-bottom: var(--mb-0-5);
}

.intro ul li {
  margin-bottom: 0.75rem;
  position: relative;
  padding-left: 1.5rem;
}

.intro ul li::before {
  content: "✦";
  color: var(--secondary-color);
  position: absolute;
  left: 0;
  font-weight: var(--font-bold);
}

.intro p:last-of-type {
  margin-top: var(--mb-1-5);
  font-size: var(--small-font-size);
  opacity: 0.8;
}

.blox-contents ul {
  list-style-position: inside;
}

/* ================= TABLES ================= */
.dataTable {
  width: 100%;
  border-collapse: collapse;
  margin: var(--mb-2) 0;
  background-color: var(--bg-color-alt);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.dataTable th, .dataTable td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.dataTable th {
  background-color: var(--primary-color);
  color: #fff;
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  font-size: var(--small-font-size);
}

.dataTable tr {
  transition: background-color 0.3s;
}

.dataTable tr:nth-child(even) {
  background-color: var(--bg-color);
}

.dataTable tr:last-child td {
  border-bottom: none;
}

.dataTable tr:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

body.dark .dataTable tr:nth-child(even) {
  background-color: #2c3e50;
}

body.dark .dataTable tr:hover {
  background-color: #34495e;
}

/* ================= COLLAPSIBLE SECTIONS ================= */
.collapsible-section {
  margin-bottom: var(--mb-2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.3s ease;
}

.collapsible-section:hover {
  box-shadow: var(--card-shadow-hover);
}

.collapsible-header {
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  cursor: pointer;
  padding: 1rem;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: var(--h3-font-size);
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: var(--font-semibold);
  position: relative;
  user-select: none;
}

.collapsible-header:hover {
  background-color: var(--primary-color);
  color: #fff;
  transform: translateY(-1px);
}

.collapsible-header.active {
  background-color: var(--primary-color);
  color: #fff;
}

.collapsible-header::after {
  content: "▼";
  transition: transform 0.3s ease;
  font-size: 0.8rem;
  opacity: 0.7;
}

.collapsible-header.active::after {
  transform: rotate(180deg);
  opacity: 1;
}

.collapsible-header:focus {
  outline: 2px solid var(--primary-color-alt);
  outline-offset: -2px;
}

.collapsible-content {
  padding: 0;
  background-color: var(--bg-color);
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  border-top: 1px solid var(--border-color);
}

.collapsible-content.active {
  padding: 1.5rem;
}

.collapsible-content p {
  margin-bottom: var(--mb-1);
  line-height: 1.6;
}

.collapsible-content ul, .collapsible-content ol {
  margin-bottom: var(--mb-1);
  padding-left: var(--mb-1-5);
}

.collapsible-content li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.collapsible-content strong {
  color: var(--primary-color);
  font-weight: var(--font-semibold);
}

.collapsible-content code {
  background-color: var(--bg-color-alt);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: var(--text-color);
}

.collapsible-content pre {
  background-color: var(--bg-color-alt);
  padding: var(--mb-1);
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: var(--mb-1);
}

.collapsible-content pre code {
  background: none;
  padding: 0;
}

/* ================= FOOTER ================= */
footer {
  text-align: center;
  padding: var(--mb-2) 0;
  margin-top: var(--mb-2);
  background-color: var(--bg-color-alt);
  border-top: 1px solid var(--border-color);
  color: var(--text-color-muted);
  font-size: var(--small-font-size);
}

/* ================= SCROLL TOP BUTTON ================= */
#scrollTopBtn {
  position: fixed;
  bottom: -20%;
  right: 1rem;
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  padding: 0.8rem 1rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  transition: bottom 0.4s, transform 0.3s;
  z-index: var(--z-fixed);
}

#scrollTopBtn:hover {
  background-color: var(--primary-color-alt);
  transform: scale(1.1);
}

#scrollTopBtn.show {
  bottom: 1rem;
}

/* ================= ACCESSIBILITY ================= */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ================= FILTERING & PAGINATION ================= */
.item-filter-toolbar {
  background-color: var(--bg-color-alt);
  padding: var(--mb-1-5);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: var(--mb-2);
  box-shadow: var(--card-shadow);
}

.filter-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--mb-1);
  flex-wrap: wrap;
}

.item-filter-input {
  flex: 1;
  min-width: 250px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: var(--normal-font-size);
  transition: all 0.3s ease;
}

.item-filter-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.1);
}

.item-count {
  font-size: var(--small-font-size);
  color: var(--text-color-muted);
  white-space: nowrap;
}

.item-count-display {
  font-weight: var(--font-semibold);
  color: var(--primary-color);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: var(--mb-2) 0;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: var(--small-font-size);
}

.pagination button:hover:not(:disabled) {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination button.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination .page-info {
  margin: 0 var(--mb-1);
  font-size: var(--small-font-size);
  color: var(--text-color-muted);
}

/* Sticky Sidebar */
.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 80px); /* stays below header/nav */
  width: 260px;
  background-color: var(--bg-color-alt);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  padding: var(--mb-1-5);
  margin-right: var(--mb-2);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.sidebar h3 {
  font-size: var(--h4-font-size);
  color: var(--primary-color);
  margin-bottom: var(--mb-1);
  padding-bottom: var(--mb-0-5);
  border-bottom: 1px solid var(--border-color);
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  margin-bottom: var(--mb-0-5);
}

.sidebar a {
  display: block;
  padding: 0.45rem 0.65rem;
  color: var(--text-color);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: var(--small-font-size);
  border: 1px solid transparent;
}

.sidebar a:hover {
  background-color: rgba(var(--primary-color-rgb, 67, 97, 238), 0.08);
  color: var(--primary-color);
  transform: translateX(2px);
  border-color: rgba(var(--primary-color-rgb, 67, 97, 238), 0.25);
}

.sidebar a.active {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px rgba(var(--primary-color-rgb, 67, 97, 238), 0.3);
}

/* Breadcrumb Navigation (integrated inside nav) */
/* Breadcrumbs - styled as subtle chips similar to quiz visuals */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0; /* inside nav */
  padding: 0.25rem 0.25rem;
  background: transparent;
  font-size: var(--smaller-font-size);
}

.breadcrumb a,
.breadcrumb .current {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-color-alt);
  color: var(--text-color);
  box-shadow: var(--card-shadow);
}

.breadcrumb a {
  text-decoration: none;
  transition: all 0.2s ease;
}

.breadcrumb a:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.breadcrumb .current {
  color: var(--primary-color);
  font-weight: var(--font-semibold);
  border-color: rgba(var(--primary-color-rgb, 67, 97, 238), 0.35);
}

.breadcrumb .separator {
  color: var(--text-color-muted);
  margin: 0 0.25rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal);
  cursor: pointer;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox .close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  z-index: calc(var(--z-modal) + 1);
}

/* Tooltips */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  text-align: center;
  border-radius: 6px;
  padding: 0.5rem;
  position: absolute;
  z-index: var(--z-tooltip);
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  font-size: var(--small-font-size);
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--bg-color-alt) transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Comparison Tool */
.comparison-tool {
  background-color: var(--bg-color-alt);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: var(--mb-2);
  margin: var(--mb-2) 0;
  box-shadow: var(--card-shadow);
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--mb-2);
}

.comparison-item {
  text-align: center;
  padding: var(--mb-1);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.comparison-item.selected {
  border-color: var(--primary-color);
  background-color: rgba(var(--primary-color-rgb), 0.05);
}

.comparison-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--mb-1);
  margin-top: var(--mb-1);
}

.stat-item {
  text-align: center;
  padding: var(--mb-0-5);
  background-color: var(--bg-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.stat-label {
  font-size: var(--smaller-font-size);
  color: var(--text-color-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: var(--normal-font-size);
  font-weight: var(--font-semibold);
  color: var(--text-color);
}

/* Rating System */
.rating-system {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: var(--mb-1) 0;
}

.star-rating {
  display: flex;
  gap: 0.25rem;
}

.star {
  font-size: 1.2rem;
  color: #ddd;
  cursor: pointer;
  transition: color 0.2s ease;
}

.star:hover,
.star.active {
  color: #ffc107;
}

.rating-count {
  font-size: var(--small-font-size);
  color: var(--text-color-muted);
}

/* Animated Stats */
.animated-stat {
  position: relative;
  background-color: var(--bg-color);
  border-radius: 8px;
  padding: var(--mb-1);
  margin: var(--mb-0-5) 0;
  border: 1px solid var(--border-color);
}

.stat-bar {
  height: 8px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.stat-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 4px;
  transition: width 1s ease-in-out;
  width: 0%;
}

.stat-fill.animate {
  animation: fillBar 1.5s ease-out forwards;
}

@keyframes fillBar {
  from { width: 0%; }
  to { width: var(--target-width, 0%); }
}

/* Loading States */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================= BACK TO TOP BUTTON ================= */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: var(--z-fixed);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top:hover {
  background-color: var(--primary-color-alt);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:focus {
  outline: 2px solid var(--primary-color-alt);
  outline-offset: 2px;
}

/* ================= SORTABLE TABLES ================= */
.stats-table-container {
  margin: 2rem 0;
  background-color: var(--bg-color);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
}

.stats-table-container h3 {
  margin-bottom: 1.5rem;
  color: var(--text-color);
  font-size: 1.5rem;
}

.table-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.table-filter, .table-search {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  font-size: 0.9rem;
  transition: border-color 0.3s ease;
}

.table-filter:focus, .table-search:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb, 67, 97, 238), 0.2);
}

.table-search {
  flex: 1;
  min-width: 200px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-color);
  font-size: 0.9rem;
}

.stats-table th {
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  font-weight: var(--font-semibold);
  padding: 1rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.stats-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s ease;
  position: relative;
}

.stats-table th.sortable:hover {
  background-color: var(--primary-color);
  color: white;
}

.sort-indicator {
  margin-left: 0.5rem;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.stats-table th.sortable:hover .sort-indicator {
  opacity: 1;
}

.stats-table th.sort-asc .sort-indicator::after {
  content: " ↑";
  opacity: 1;
}

.stats-table th.sort-desc .sort-indicator::after {
  content: " ↓";
  opacity: 1;
}

.stats-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

.stats-table tbody tr {
  transition: background-color 0.3s ease;
}

.stats-table tbody tr:hover {
  background-color: var(--bg-color-alt);
}

.stats-table tbody tr:nth-child(even) {
  background-color: rgba(var(--primary-color-rgb, 67, 97, 238), 0.02);
}

.stats-table tbody tr:nth-child(even):hover {
  background-color: var(--bg-color-alt);
}

.rarity-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rarity-badge.common {
  background-color: #6b7280;
  color: white;
}

.rarity-badge.uncommon {
  background-color: #10b981;
  color: white;
}

.rarity-badge.rare {
  background-color: #3b82f6;
  color: white;
}

.rarity-badge.epic {
  background-color: #8b5cf6;
  color: white;
}

.rarity-badge.legendary {
  background-color: #f59e0b;
  color: white;
}

.rarity-badge.mythical {
  background-color: #ef4444;
  color: white;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.table-actions button {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color-alt);
  color: var(--text-color);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.table-actions button:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* ================= COMPARISON TOOL ================= */
.compare-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s ease;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-btn:hover {
  background-color: var(--primary-color-alt);
  transform: scale(1.1);
}

.category-card.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb, 67, 97, 238), 0.3);
}

.comparison-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 2rem;
}

.comparison-modal-content {
  background-color: var(--bg-color);
  border-radius: 12px;
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--card-shadow-hover);
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-color-alt);
  border-radius: 12px 12px 0 0;
}

.comparison-header h3 {
  margin: 0;
  color: var(--text-color);
}

.close-comparison {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-color-muted);
  transition: color 0.3s ease;
}

.close-comparison:hover {
  color: var(--text-color);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
}

.comparison-item {
  background-color: var(--bg-color-alt);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border-color);
  position: relative;
  transition: transform 0.3s ease;
}

.comparison-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow);
}

.comparison-item-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  position: relative;
}

.comparison-item-header img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 6px;
}

.comparison-item-header h4 {
  margin: 0;
  color: var(--text-color);
  flex: 1;
}

.remove-from-comparison {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background-color: var(--error-color, #ef4444);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s ease;
}

.remove-from-comparison:hover {
  background-color: #dc2626;
  transform: scale(1.1);
}

.comparison-stats {
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
}

.stat-label {
  font-weight: var(--font-medium);
  color: var(--text-color-muted);
}

.stat-value {
  font-weight: var(--font-semibold);
  color: var(--text-color);
}

.comparison-description {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.comparison-description p {
  margin: 0;
  color: var(--text-color-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.comparison-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-color-alt);
  border-radius: 0 0 12px 12px;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: var(--font-semibold);
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-color-alt);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-color-alt);
  border-color: var(--primary-color);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ================= RATING SYSTEM ================= */
.rating-system {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.rating-stars {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
  justify-content: center;
}

.star {
  font-size: 1.2rem;
  color: #ddd;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.star:hover {
  transform: scale(1.1);
}

.star.active {
  color: #ffc107;
  text-shadow: 0 0 4px rgba(255, 193, 7, 0.5);
}

.rating-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.rating-average {
  font-weight: var(--font-semibold);
  color: var(--text-color);
}

.rating-count {
  color: var(--text-color-muted);
  font-size: 0.8rem;
}

/* Rating system on category cards */
.category-card .rating-system {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(var(--primary-color-rgb, 67, 97, 238), 0.1);
}

.category-card .rating-stars {
  gap: 0.15rem;
  margin-bottom: 0.25rem;
}

.category-card .star {
  font-size: 1rem;
}

.category-card .rating-info {
  font-size: 0.75rem;
  gap: 0.25rem;
}

/* Rating feedback animation */
@keyframes ratingFeedback {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
}

/* ================= ANIMATED STATS ================= */
.featured-stats {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.featured-stats .stat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.featured-stats .stat-label {
  font-size: 0.8rem;
  color: var(--text-color-muted);
  min-width: 50px;
  font-weight: var(--font-medium);
}

.featured-stats .stat-bar {
  flex: 1;
  height: 6px;
  background-color: var(--bg-color-alt);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.featured-stats .stat-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 1.5s ease-out;
  position: relative;
}

.featured-stats .stat-fill.animate {
  width: var(--target-width, 0%);
}

.featured-stats .stat-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

.featured-stats .stat-value {
  font-size: 0.8rem;
  font-weight: var(--font-semibold);
  color: var(--text-color);
  min-width: 30px;
  text-align: right;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Animated stat bars for general use */
.animated-stat {
  margin-bottom: 1rem;
}

.animated-stat .stat-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-color);
}

.animated-stat .stat-bar {
  height: 8px;
  background-color: var(--bg-color-alt);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.animated-stat .stat-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 4px;
  width: 0%;
  transition: width 2s ease-out;
  position: relative;
}

.animated-stat .stat-fill.animate {
  width: var(--target-width, 0%);
}

.animated-stat .stat-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2.5s infinite;
}

/* Counter animations */
.counter {
  font-weight: var(--font-bold);
  color: var(--primary-color);
}

/* Hero stats animation */
.hero-stats .stat-number {
  transition: all 0.3s ease;
}

.hero-stats .stat-number:hover {
  transform: scale(1.1);
  text-shadow: 0 0 10px rgba(var(--primary-color-rgb, 67, 97, 238), 0.5);
}

/* ================= MEDIA QUERIES ================= */
@media screen and (max-width: 768px) {
  :root {
    --h1-font-size: 1.75rem;
    --h2-font-size: 1.5rem;
    --h3-font-size: 1.125rem;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem;
    position: sticky; /* Keep it sticky on mobile */
  }

  .logo-title h1 a {
    font-size: 1.25rem;
  }

  nav {
    margin-top: 0;
    overflow-x: auto; /* Allow horizontal scrolling */
    white-space: nowrap;
    top: 60px; /* Adjust for smaller mobile header */
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
  }

  nav::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari, and Opera */
  }

  /* Breadcrumb sits within nav on mobile too */
  .breadcrumb {
    top: auto;
    margin-left: 0;
    margin-right: 0;
    overflow-x: auto;
    white-space: nowrap;
  }

  nav a {
    padding: 0.5rem 0.75rem; /* Reduce padding on mobile */
  }
  
  main {
    margin-top: 0; /* Reset margin */
    padding: var(--mb-2) var(--mb-1); /* Adjust padding for mobile */
  }

  .category-grid, .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--mb-1);
  }

  .category-card {
    min-height: 240px;
    padding: var(--mb-1);
  }

  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .item-filter-input {
    min-width: auto;
    width: 100%;
  }

  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    margin-right: 0;
    margin-bottom: var(--mb-2);
    max-height: none;
    order: -1; /* Show sidebar first on mobile */
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .pagination {
    gap: 0.25rem;
  }

  .pagination button {
    padding: 0.4rem 0.6rem;
    font-size: var(--smaller-font-size);
  }

  .lightbox .close {
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
  }

  .tooltip .tooltiptext {
    width: 150px;
    margin-left: -75px;
  }

  .hero-stats {
    gap: 1.5rem;
  }

  .hero-stats .stat-number {
    font-size: 2rem;
  }

  .featured-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 45px;
    height: 45px;
    font-size: 1.25rem;
  }

  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .table-filter, .table-search {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .stats-table th, .stats-table td {
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
  }

  .table-actions {
    flex-direction: column;
    gap: 0.25rem;
  }

  .table-actions button {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }

  .comparison-modal {
    padding: 1rem;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }

  .comparison-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn {
    width: 100%;
  }
}
