@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@500;700&family=Montserrat:wght@400;500;700&display=swap");

:root {
  --primary-color: #0a1c2e; 
  --secondary-color:  #06121f;
  --text-c-highlight: #3399ff;
  --bg-color: #fff6ec;

  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --bg-color: #fff6ec;
  --bg-secondary: #f3f4f6;
  --bg-tertiary: #e5e7eb;
  --text-color: #333;
  --text-tertiary: #6b7280;
  --highlight: #d4af37;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);

  /* UI Elements */
  --card-bg: #ffffff;
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08);

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;

  /* Layout */
  --container-max: 1280px;
  --container-padding: 1.5rem;
  --section-spacing: 5rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
}

/* Base Styles */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--transition-normal),
    color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
  overflow: hidden;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* Toppers Section */
.toppers-section {
  padding: var(--section-spacing) 0;
}

.tabs-filter-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.tabs {
  display: flex;
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  padding: 0.25rem;
  position: relative;
  overflow: hidden;
}

.tab-button {
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 0.75rem 2rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  position: relative;
  z-index: 1;
  border-radius: var(--radius-md);
}

.tab-button.active {
  color: white;
}

.tab-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: -1;
  border-radius: var(--radius-md);
}

.tab-button.active::before {
  opacity: 1;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.year-select {
  position: relative;
}

.year-dropdown {
  appearance: none;
  padding: 0.75rem 2.5rem 0.75rem 1.25rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition-fast);
  min-width: 140px;
}

.year-dropdown:hover,
.year-dropdown:focus {
  border-color: var(--primary);
  outline: none;
}

.select-arrow {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-tertiary);
}

.pdf-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.pdf-button:hover {
  color: var(--text-c-highlight);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* Toppers Grid */
.toppers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 2rem;
}

.topper-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-normal),
    box-shadow var(--transition-normal);
  position: relative;
}

.topper-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

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

.topper-img-container {
  position: relative;
  width: 100%;
  padding-top: 100%; /* Square aspect ratio */
  overflow: hidden;
}

.topper-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}

.topper-info {
  padding: 1.5rem;
  text-align: center;
}

.topper-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-color);
}

.topper-score {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.topper-rank {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 0;
}

/* PDF Modal */
.pdf-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  z-index: 9999;
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity var(--transition-normal);
  justify-content: center;
  align-items: center;
}

.pdf-modal.open {
  display: flex;
  opacity: 1;
}

.pdf-container {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 900px;
  height: 90%;
  max-height: 700px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  opacity: 0;
  transition: transform var(--transition-normal),
    opacity var(--transition-normal);
}

.pdf-modal.open .pdf-container {
  transform: translateY(0);
  opacity: 1;
}

.pdf-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.pdf-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

.pdf-actions {
  display: flex;
  gap: 0.75rem;
}

.pdf-action-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
}

.pdf-action-button.close {
  background-color: var(--bg-tertiary);
  color: var(--text-color);
}

.pdf-action-button.close:hover {
  background-color: var(--bg-secondary);
}

.pdf-viewer {
  flex: 1;
  width: 100%;
  background-color: var(--bg-secondary);
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Media Queries */
@media (max-width: 768px) {
  .tabs-filter-container {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-controls {
    width: 100%;
    justify-content: space-between;
  }

  .toppers-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .pdf-container {
    width: 95%;
    height: 95%;
  }

  .pdf-actions {
    gap: 0.5rem;
  }

  .pdf-action-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  .pdf-title {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .year-dropdown {
    min-width: 100px;
  }
}

/* Reset CSS for consistent base layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Body and main container fixes */
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden; /* Prevents horizontal scrolling */
}

/* Main content container with consistent spacing from navbar */
.container,
main,
.content-wrapper {
  width: 100%;
  max-width: 1200px; /* Adjust based on your design needs */
  margin: 0 auto; /* Centers the container */
  padding: 0 2rem; /* Consistent padding on left and right */
}

/* Consistent top spacing for all content pages */
.page-content,
main > section:first-child,
.content-wrapper > section:first-child,
.container > section:first-child,
.page-content > section:first-child,
main > .section-title:first-child,
.content-wrapper > .section-title:first-child,
.container > .section-title:first-child,
.page-content > .section-title:first-child,
main > h1:first-child,
main > h2:first-child,
.content-wrapper > h1:first-child,
.content-wrapper > h2:first-child {
  margin-top: 0px; /* Fixed distance from navbar - adjust to your preferred spacing */
}

/* Section styling with consistent spacing */
section {
  padding: 2rem 0;
  width: 100%;
}

/* CSS for section title with consistent centering */
.section-title {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
  color: var(--primary-color);
  position: relative;
  padding-bottom: 1rem;
  font-weight: 600;
  /* Ensure consistent margins for centering */
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;
  padding-right: 0;
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(to right, var(--primary-color), var(--highlight));
  border-radius: 2px;
}

/* Ensure consistent heading alignment across all pages */
h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.heading {
  text-align: center;
  padding-left: 0;
  padding-right: 0;
  margin-left: auto;
  margin-right: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container,
  main,
  .content-wrapper {
    padding: 0 1rem; /* Slightly reduced padding on smaller screens */
  }

  /* Adjust top spacing for mobile */
  .page-content,
  main > section:first-child,
  .content-wrapper > section:first-child,
  .container > section:first-child,
  .page-content > section:first-child,
  main > .section-title:first-child,
  .content-wrapper > .section-title:first-child,
  .container > .section-title:first-child,
  .page-content > .section-title:first-child,
  main > h1:first-child,
  main > h2:first-child,
  .content-wrapper > h1:first-child,
  .content-wrapper > h2:first-child {
    margin-top: 20px; /* Adjusted for mobile navbar height */
  }
}

@media (max-width: 600px) {
  /* Further adjust for even smaller screens */
  .page-content,
  main > section:first-child,
  .content-wrapper > section:first-child,
  .container > section:first-child,
  .page-content > section:first-child,
  main > .section-title:first-child,
  .content-wrapper > .section-title:first-child,
  .container > .section-title:first-child,
  .page-content > .section-title:first-child,
  main > h1:first-child,
  main > h2:first-child,
  .content-wrapper > h1:first-child,
  .content-wrapper > h2:first-child {
    margin-top: 20px; /* Adjusted for smaller mobile navbar height */
  }
}

/* Scroll Animation for reveal effect */
.reveal {
  position: relative;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}
