/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  --bg-warm: #fdf6e3;
  --bg-grid: rgba(100, 90, 80, 0.15);
  
  --text-main: #2c3e50;
  --text-light: #546b82;
  
  --primary: #3b5998;
  --primary-gradient: linear-gradient(135deg, #3b5998 0%, #4e7ac7 100%);
  --primary-glow: rgba(59, 89, 152, 0.4);
  
  --glass-bg: rgba(255, 255, 255, 0.75); 
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  
  --ease-bounce: cubic-bezier(0.34, 1.15, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.8, 0.25, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; scroll-behavior: smooth; }

body {
  font-family: "Poppins", sans-serif;
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg-warm);
  background-image: 
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, var(--bg-warm), transparent 80%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
  background-attachment: fixed;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.02); }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }


/* =========================================
   2. LAYOUT CONTAINERS
   ========================================= */
.page, .card-container, .module-grid, .applet-grid, .module-layout {
  max-width: 1200px;
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
}

/* HOMEPAGE CONTAINER */
.card-container { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  align-content: center; 
  gap: 2rem; 
  max-width: 1100px; 
  min-height: 60vh; 
  padding-bottom: 4rem;
}

/* APPLET GRID */
.applet-grid { 
  display: grid; 
  gap: 1.5rem; 
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
}

.module-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); }


/* =========================================
   3. HEADER (UPDATED)
   ========================================= */
header {
  position: relative;
  /* Top: 2.5rem | Sides: 1.5rem | Bottom: 2.5rem */
  padding: 2.5rem 1.5rem 2.5rem; 
  text-align: center;
  animation: fadeDown 0.8s var(--ease-smooth);
}

header h1 {
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 4rem); 
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text; 
  color: transparent; 
  filter: drop-shadow(0 4px 20px rgba(59,89,152,0.15));
  line-height: 1.1;
}

header p { margin: 0.5rem auto 0; max-width: 600px; color: var(--text-light); font-size: 1.1rem; }

.header-back {
  position: absolute; left: 2rem; top: 2rem;
  /* Added z-index to fix hitbox issue */
  z-index: 10; 
  background: rgba(255, 255, 255, 0.9); 
  backdrop-filter: blur(4px);
  padding: 0.8rem 1.5rem; border-radius: 99px;
  text-decoration: none; color: var(--primary); font-weight: 600; font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  display: flex; align-items: center; gap: 8px;
  transition: all 0.3s var(--ease-smooth);
}
.header-back:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59,89,152,0.15); }


/* =========================================
   4. CARDS (GLOBAL)
   ========================================= */
.card, .module-content {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 24px;
}

.card {
  display: flex; 
  flex-direction: row; 
  align-items: center; 
  gap: 1.5rem; 
  padding: 1.5rem 2rem; 
  color: var(--text-main); 
  text-decoration: none;
  transition: all 0.4s var(--ease-smooth);
  will-change: transform;
  height: 100%;
  width: 100%;
}

.card-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 72px; height: 72px;
  background: #ebeef1; border-radius: 50%;
  font-size: 2rem;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.5s var(--ease-smooth);
}

.card > div:not(.card-icon) { flex: 1; min-width: 0; }
.card h2 { margin: 0 0 0.25rem; font-size: 1.4rem; color: var(--primary); font-weight: 700; }
.card p { margin: 0; color: var(--text-light); line-height: 1.5; font-size: 0.95rem; }

.card:hover:not(.disabled) { 
  transform: translateY(-4px); 
  background: rgba(255,255,255,0.95);
  border-color: var(--primary); 
  box-shadow: inset 0 0 0 1px var(--primary), 0 15px 35px rgba(59, 89, 152, 0.2); 
}
.card:hover:not(.disabled) .card-icon { transform: scale(1.1) rotate(-5deg); }

.card.disabled {
  opacity: 1; 
  filter: opacity(0.6) grayscale(1); 
  cursor: default;           
  pointer-events: none;      
  background-color: rgba(240, 240, 240, 0.5); 
  box-shadow: none;          
}


/* =========================================
   5. CARD MODIFIERS
   ========================================= */

/* --- HOMEPAGE CARDS (Big) --- */
.card--home {
  min-height: 180px; 
  padding: 2.5rem;     
  border-radius: 32px;
}
.card--home .card-icon {
  width: 88px; height: 88px; font-size: 2.5rem; 
}
.card--home h2 {
  font-size: 1.8rem; margin-bottom: 0.5rem;
}
.card--home p {
  font-size: 1.05rem; 
}


/* --- APPLET CARDS (Uniform Standard) --- */
.card--module {
  min-height: 160px; 
}


/* =========================================
   6. ANIMATIONS
   ========================================= */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

.card, .module-step, .module-content { 
  opacity: 1; 
  animation: fadeUp 0.6s var(--ease-bounce) backwards; 
}
.module-content { animation-delay: 0.1s; }

/* Generated Stagger */
.card:nth-child(1), .module-step:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2), .module-step:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3), .module-step:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4), .module-step:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5), .module-step:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6), .module-step:nth-child(6) { animation-delay: 0.3s; }
.card:nth-child(n+7) { animation-delay: 0.35s; }


/* =========================================
   7. MODULE / APPLET UI
   ========================================= */
.module-layout { display: grid; grid-template-columns: 240px 1fr; gap: 3rem; align-items: start; }

.module-sidebar {
  display: flex; flex-direction: column; gap: 0.75rem;
  position: sticky; top: 40px; padding: 1.5rem;
  background: rgba(255,255,255,0.5); border-radius: 24px; backdrop-filter: blur(8px);
}

.module-step {
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: 0.8rem 1rem; border-radius: 12px;
  color: var(--text-light); text-decoration: none; font-weight: 600;
  transition: all 0.2s var(--ease-bounce);
}
.module-step:hover { background: rgba(59,89,152,0.08); color: var(--primary); transform: translateX(2px); }
.module-step.active { background: var(--primary-gradient); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }

.module-content { padding: 3rem; }
.module-content h2 { margin-top: 0; font-size: 2rem; color: var(--primary); }

.next-button {
  margin-top: 2.5rem; display: inline-flex; align-items: center; justify-content: center;
  padding: 1rem 2.5rem; border-radius: 99px;
  background: var(--primary-gradient); color: #fff; text-decoration: none; font-weight: 600; letter-spacing: 0.02em;
  box-shadow: 0 4px 12px var(--primary-glow); border: 2px solid transparent;
  transition: transform 0.4s var(--ease-smooth), box-shadow 0.4s ease;
}
.next-button:hover { transform: translateY(-3px); box-shadow: 0 8px 20px var(--primary-glow); }


/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 1024px) { 
  .applet-grid { grid-template-columns: 1fr 1fr; } 
}

@media (max-width: 900px) {
  .module-layout { grid-template-columns: 1fr; gap: 2rem; }
  .module-sidebar { position: static; flex-direction: row; flex-wrap: wrap; background: transparent; padding: 0; }
  .module-step { background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); flex: 1 0 auto; min-width: 60px; }
}

@media (max-width: 700px) {
  .card-container { grid-template-columns: 1fr; padding: 0 1.5rem; min-height: auto; }
  .card--home { min-height: auto; padding: 1.5rem; }
  .applet-grid { grid-template-columns: 1fr; }
  
  header h1 { font-size: 2.2rem; }
  .module-content { padding: 2rem 1.5rem; }
  
  .card { flex-direction: row; padding: 1.5rem; } 
  .card-icon { width: 56px; height: 56px; font-size: 1.5rem; }
  .header-back { left: 1rem; top: 1.5rem; padding: 0.6rem 1rem; }
}