/* ===================================
   subject.css - EXACTLY LIKE MATHS PAGE (COSMIC PREMIUM DESIGN)
   =================================== */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  background: #0f0c29;
  color: #e0e7ff;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.8s ease;
}

body.dark {
  background: #0a0719;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
}

/* Hero Background Animation */
.page-hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: clamp(100px, 15vw, 180px) 5% 80px;
  margin-top: 80px;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: 
    radial-gradient(circle at 20% 80%, #7c3aed 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, #ec4899 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #3b82f6 0%, transparent 40%);
  opacity: 0.6;
  animation: smoothFloat 28s ease-in-out infinite;
  will-change: transform;
}

.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, #1e1b4b 0%, #2d1b69 60%, #4c1d95 100%);
  opacity: 0.95;
}

@keyframes smoothFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(4%, -4%) scale(1.03); }
  66% { transform: translate(-3%, 3%) scale(1.02); }
}

@media (prefers-reduced-motion: reduce) {
  .page-hero::before { animation: none; }
}

/* Header */
header {
  position: fixed;
  top: 0;
  width: 100%;
  padding: clamp(1.2rem, 3vw, 2rem) 5% clamp(1.5rem, 4vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 12, 41, 0.4);
  backdrop-filter: blur(30px);
  border-bottom: 1px solid rgba(124, 58, 237, 0.2);
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  transition: all 0.4s ease;
}

.logo {
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 900;
  background: linear-gradient(135deg, #a78bfa, #ec4899, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: transform 0.4s ease;
  cursor: pointer;
}

.logo:hover {
  transform: scale(1.05) rotate(2deg);
}

nav {
  display: flex;
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
}

nav a {
  font-weight: 600;
  font-size: clamp(1.1rem, 2.5vw, 1.3rem);
  position: relative;
  transition: all 0.4s ease;
  padding: 0.5rem 0;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  border-radius: 4px;
  transition: all 0.5s ease;
  transform: translateX(-50%);
}

nav a:hover::after, nav a.active::after { width: 100%; }
nav a:hover, nav a.active { color: #fbbf24; transform: translateY(-4px); }

.login-btn {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: white;
  padding: 0.9rem 2.2rem;
  border-radius: 60px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(124,58,237,0.5);
  transition: all 0.5s ease;
}

.login-btn:hover {
  transform: translateY(-8px) scale(1.1);
  box-shadow: 0 25px 50px rgba(124,58,237,0.7);
}

.toggle-dark {
  font-size: 2.2rem;
  background: none;
  margin-left: 1.5rem;
  transition: transform 0.3s;
}

.toggle-dark:hover {
  transform: rotate(20deg);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  z-index: 1001;
}

.hamburger div {
  width: 40px;
  height: 5px;
  background: #c4b5fd;
  border-radius: 3px;
  transition: all 0.4s ease;
}

/* Page Hero Text */
.page-hero h1 {
  font-size: clamp(3.5rem, 9vw, 6rem);
  font-weight: 900;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #c4b5fd, #fbbf24, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-hero p {
  font-size: clamp(1.4rem, 4vw, 2rem);
  max-width: 800px;
  opacity: 0.9;
}

/* Fixed Search Bar */
.search-container {
  position: fixed;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  z-index: 50;
  transition: top 0.4s ease;
}

.search-container input {
  width: 100%;
  padding: clamp(1rem, 3vw, 1.5rem) clamp(2rem, 5vw, 3rem);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  border: none;
  border-radius: 60px;
  background: rgba(30, 27, 75, 0.7);
  backdrop-filter: blur(20px);
  color: white;
  outline: none;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  transition: all 0.4s ease;
}

.search-container input::placeholder {
  color: rgba(255,255,255,0.7);
}

.search-container input:focus {
  transform: scale(1.03);
  box-shadow: 0 30px 70px rgba(124,58,237,0.5);
}

/* Subject Grid */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: clamp(2rem, 5vw, 3rem);
  width: 90%;
  max-width: 1400px;
  margin: 200px auto 6rem;
  padding: 0 5%;
}

.subject-card {
  background: rgba(30, 27, 75, 0.4);
  backdrop-filter: blur(30px);
  border-radius: 40px;
  padding: clamp(2rem, 5vw, 3rem);
  text-align: center;
  box-shadow: 0 30px 80px rgba(124, 58, 237, 0.3);
  border: 1px solid rgba(167, 139, 250, 0.2);
  transition: all 0.8s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(236,72,153,0.2));
  opacity: 0;
  transition: opacity 0.6s ease;
}

.subject-card:hover::before {
  opacity: 1;
}

.subject-card:hover {
  transform: translateY(-20px) scale(1.05);
  box-shadow: 0 50px 100px rgba(124, 58, 237, 0.5);
}

.subject-card h2 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #c4b5fd, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.subject-card p {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

/* Loader */
.loader {
  border: 5px solid rgba(255,255,255,0.2);
  border-top: 5px solid #fbbf24;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
  margin: 40px auto;
}

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

.loading-text {
  text-align: center;
  font-size: 1.4rem;
  margin-top: 20px;
  opacity: 0.8;
}

/* Footer */
footer {
  background: linear-gradient(135deg, #1e1b4b, #0f0c29);
  padding: clamp(4rem, 8vw, 6rem) 5%;
  text-align: center;
  border-top: 1px solid rgba(124, 58, 237, 0.3);
}

footer p {
  font-size: clamp(1rem, 2vw, 1.3rem);
  opacity: 0.9;
}

footer span {
  background: linear-gradient(135deg, #a78bfa, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  nav {
    position: fixed;
    top: 100%;
    left: -100%;
    width: 100%;
    background: rgba(15, 12, 41, 0.95);
    flex-direction: column;
    padding: 4rem 0;
    transition: left 0.6s ease;
    gap: 2.5rem;
    align-items: center;
    backdrop-filter: blur(30px);
  }
  nav.active { left: 0; }
  .search-container { top: 110px; width: 92%; }
  .subject-grid { margin-top: 180px; }
}

@media (max-width: 480px) {
  .search-container { top: 100px; }
  .subject-grid { margin-top: 160px; }
}