/* 
 * PhysMath Hub - Modern Aesthetic Stylesheet 
 * Cyber-Academic Glassmorphism & Micro-animations
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600&display=swap');

:root {
  --font-heading: 'Prompt', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Dark Mode Default Palette */
  --bg-main: #090d16;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(6, 182, 212, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --phys-color: #06b6d4;
  --phys-glow: rgba(6, 182, 212, 0.35);
  --math-color: #a855f7;
  --math-glow: rgba(168, 85, 247, 0.35);
  --accent-gold: #f59e0b;
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-active: rgba(14, 165, 233, 0.5);
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --phys-color: #0284c7;
  --phys-glow: rgba(2, 132, 199, 0.2);
  --math-color: #7e22ce;
  --math-glow: rgba(126, 34, 206, 0.2);
  --accent-gold: #d97706;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Atmosphere Grid & Gradient Orbs */
.bg-grid-pattern {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] .bg-grid-pattern {
  background-image: 
    linear-gradient(to right, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
}

.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.25;
}

.orb-phys {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #06b6d4 0%, rgba(6, 182, 212, 0) 70%);
  top: -100px;
  left: -100px;
}

.orb-math {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #a855f7 0%, rgba(168, 85, 247, 0) 70%);
  top: 30%;
  right: -150px;
}

.orb-gold {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #f59e0b 0%, rgba(245, 158, 11, 0) 70%);
  bottom: -100px;
  left: 30%;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
}

.glass-nav {
  background: rgba(9, 13, 22, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

[data-theme="light"] .glass-nav {
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Modern Card Glow & Hover */
.resource-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 1.25rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.resource-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-active);
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.4), 0 0 24px -4px var(--phys-glow);
}

.resource-card.math-card:hover {
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.4), 0 0 24px -4px var(--math-glow);
}

/* Animated Gradient Border for Featured items */
.featured-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
}

/* Filter Buttons */
.filter-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-btn.active {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.35);
}

.filter-btn.math-active.active {
  background: linear-gradient(135deg, #a855f7, #6366f1);
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.35);
}

/* Modal Animations */
.modal-overlay {
  background: rgba(4, 7, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease-out;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  transform: scale(0.94) translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* KaTeX Formatting in Formula Drawer */
.katex-display {
  margin: 0.6em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3em 0;
}

.katex {
  font-size: 1.15em !important;
}

/* Pulse animation for live badge */
@keyframes pulseGlow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

.pulse-dot {
  animation: pulseGlow 2s infinite ease-in-out;
}

/* Drag and drop active border */
.drag-active {
  border-color: #06b6d4 !important;
  background-color: rgba(6, 182, 212, 0.1) !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast-msg {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  padding: 0.9rem 1.4rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInToast {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
