/* ==========================================================================
   IIT PATNA - CENTRE FOR EDUCATIONAL TECHNOLOGY (CET) REPLICA
   Global Stylesheet: Design Tokens, CSS Reset, Typography, Utilities
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --color-brand-primary: #003360;       /* Header bar & deep contrast */
  --color-brand-navy-dark: #042c53;     /* Headings, text accents, hero base */
  --color-brand-secondary: #095aa3;     /* Dropdowns, submenus, footer bg */
  --color-brand-accent: #185fa5;        /* Counter numbers, links */
  --color-accent-orange: #fb7906;       /* Active "Home" pill, Back-to-Top */
  --color-accent-yellow: #f9c74f;       /* Nav link hover gold */
  --color-alert-maroon: #8B0000;        /* Announcement marquee bar */
  --color-alert-red: #dc2626;           /* Blinking "NEW" badge */

  /* Surface & Background */
  --color-bg-body: #ffffff;
  --color-surface-light: #F4F6FB;       /* Stat cards & light boxes */
  --color-surface-card: #ffffff;
  --color-surface-subtle: #f8fafc;
  --color-border-soft: #e2e8f0;
  --color-border-dark: #cbd5e1;

  /* Text Colors */
  --color-text-primary: #212529;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-text-white: #ffffff;

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --gradient-overlay: linear-gradient(180deg, rgba(0, 32, 60, 0.75) 0%, rgba(4, 44, 83, 0.88) 100%);

  /* Typography */
  --font-family-base: 'Source Sans Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-family-heading: 'Source Sans Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Font Sizes */
  --font-size-xs: 0.75rem;     /* 12px */
  --font-size-sm: 0.8125rem;   /* 13px */
  --font-size-base: 0.9375rem; /* 15px */
  --font-size-md: 1rem;        /* 16px */
  --font-size-lg: 1.125rem;    /* 18px */
  --font-size-xl: 1.375rem;    /* 22px */
  --font-size-2xl: 1.75rem;    /* 28px */
  --font-size-3xl: 2.25rem;    /* 36px */

  /* Spacing */
  --space-2xs: 0.125rem; /* 2px */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2.25rem;   /* 36px */
  --space-2xl: 3.5rem;   /* 56px */

  /* Container & Layout */
  --container-max-width: 1320px;
  --container-padding: 1.25rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.2);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Z-Index Scale */
  --z-disclaimer: 1000;
  --z-header: 900;
  --z-dropdown: 950;
  --z-drawer: 1050;
  --z-backdrop: 1040;
  --z-backtotop: 800;
  --z-preloader: 9999;
}

/* --------------------------------------------------------------------------
   2. Reset & Base Elements
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: 1.65;
  color: var(--color-text-primary);
  background-color: var(--color-bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-brand-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-brand-secondary);
  text-decoration: underline;
}

ul,
ol {
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

/* Accessible Skip to Content Link (WCAG 2.4.1 & WCAG 1.4.3 High Contrast) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background-color: var(--color-accent-orange);
  color: #002147 !important;
  font-weight: 700;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  z-index: 10000;
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid #002147;
  outline-offset: 2px;
}

/* Visible Focus Indicator for Keyboard Navigation (WCAG 2.4.7 & 2.4.11) */
:focus-visible {
  outline: 2px solid var(--color-accent-orange);
  outline-offset: 2px;
}

/* Reduced Motion Mode for Accessibility (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ticker-track {
    animation: none !important;
  }
}

/* --------------------------------------------------------------------------
   3. Typography Rules
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-heading);
  color: var(--color-brand-navy-dark);
  line-height: 1.25;
  font-weight: 700;
}

h1 {
  font-size: var(--font-size-3xl);
  font-weight: 800;
}

h2 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-md);
}

h3 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-sm);
}

h4 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

p {
  margin-bottom: var(--space-md);
}

p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   4. Site-Wide Disclaimer Banner (Educational Replica Notice)
   -------------------------------------------------------------------------- */
.replica-disclaimer {
  position: relative;
  z-index: var(--z-disclaimer);
  background: #fffbeb;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  padding: 0.45rem var(--container-padding);
  font-size: var(--font-size-xs);
  text-align: center;
  line-height: 1.4;
  font-weight: 500;
}

.replica-disclaimer a {
  color: #b45309;
  font-weight: 700;
  text-decoration: underline;
}

.replica-disclaimer strong {
  color: #78350f;
}

/* --------------------------------------------------------------------------
   5. Reusable Layout Utilities
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.container-fluid {
  width: 100%;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.flex-1 { flex: 1 1 0%; }

.grid {
  display: grid;
  gap: var(--space-lg);
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--color-text-muted); }
.text-white { color: var(--color-text-white); }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-normal { font-weight: 400; }

.section-padding {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
}

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

/* --------------------------------------------------------------------------
   6. Preloader
   -------------------------------------------------------------------------- */
#astroid-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-preloader);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#astroid-preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.preloader-spinner {
  width: 80px;
  height: 80px;
  animation: rotatePreloader 3s linear infinite;
}

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

.preloader-text {
  margin-top: 1rem;
  font-size: var(--font-size-sm);
  color: var(--color-brand-primary);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   7. Back-to-Top Floating Button
   -------------------------------------------------------------------------- */
#astroid-backtotop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background-color: var(--color-accent-orange);
  color: #002147;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: var(--z-backtotop);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--transition-normal), transform var(--transition-normal), background-color var(--transition-fast);
}

#astroid-backtotop.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#astroid-backtotop:hover {
  background-color: #e06c00;
  color: #002147;
}

#astroid-backtotop svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
