@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;600;700;800&display=swap');

/* Register CSS custom properties for transition interpolations */
@property --glow-x {
  syntax: "<length-percentage>";
  inherits: true;
  initial-value: 50%;
}
@property --glow-y {
  syntax: "<length-percentage>";
  inherits: true;
  initial-value: 50%;
}
@property --glow-opacity {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

:root {
  /* Colors */
  --bg-dark: #0a0712;
  --bg-card: rgba(22, 17, 39, 0.6);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-glass-hover: rgba(255, 255, 255, 0.15);
  
  --text-main: #f5f3fa;
  --text-muted: #9f9ab7;
  
  /* Glowing gradients/neon accents */
  --color-cyan: #00f2fe;
  --color-purple: #9d4edd;
  --color-magenta: #ff007f;
  --color-blue: #3a86ff;
  
  --font-family-title: 'Outfit', sans-serif;
  --font-family-body: 'Inter', sans-serif;
}

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

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

/* Background Galaxy Image and Particle Overlay */
.bg-galaxy {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background-image: url('assets/hero_bg.png');
  background-size: cover;
  background-position: center;
  opacity: 0.7;
  filter: saturate(1.2) contrast(1.1);
}

.bg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: radial-gradient(circle at 50% 50%, rgba(10, 7, 18, 0.4) 0%, rgba(10, 7, 18, 0.95) 100%);
  pointer-events: none;
}

/* Canvas background for animated particles */
#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Header & Nav */
header {
  width: 100%;
  padding: 1.5rem 2rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2.2rem;
  height: 2.2rem;
  background: linear-gradient(135deg, var(--color-cyan), var(--color-purple));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--bg-dark);
  font-family: var(--font-family-title);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.logo-text {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 1.25rem;
  background: linear-gradient(to right, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.nav-link {
  font-family: var(--font-family-title);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  border: 1px solid transparent;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
}

.nav-link:hover {
  color: var(--text-main);
  border-color: var(--border-glass-hover);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
}

/* Main Container */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

/* Hero Section */
.hero {
  text-align: center;
  margin-bottom: 4.5rem;
  position: relative;
}

.hero-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 100px;
  background: rgba(157, 78, 221, 0.15);
  border: 1px solid rgba(157, 78, 221, 0.3);
  color: #c8b6ff;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: var(--font-family-title);
  box-shadow: 0 0 10px rgba(157, 78, 221, 0.1);
}

.hero h1 {
  font-family: var(--font-family-title);
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #ffffff 30%, #e0aaff 60%, var(--color-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 650px;
  margin: 0 auto 2.5rem auto;
  line-height: 1.6;
}

/* Filter Controls */
.filter-container {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 3.5rem;
}

.filter-btn {
  background: rgba(22, 17, 39, 0.7);
  border: 1px solid var(--border-glass);
  padding: 0.6rem 1.4rem;
  color: var(--text-muted);
  border-radius: 50px;
  font-family: var(--font-family-title);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

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

.filter-btn.active {
  background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
  border-color: transparent;
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(157, 78, 221, 0.4);
}

/* App Grid */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2.5rem;
  margin-top: 1.5rem;
}

/* Interactive Glowing Card */
.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;

  /* Custom variables for card local mouse coordinates */
  --glow-x: 50%;
  --glow-y: 50%;
  --glow-opacity: 0;
  --glow-color: rgba(0, 242, 254, 0.15);
}

/* Card hover and glow effects */
.app-card:hover {
  transform: translateY(-8px);
  border-color: var(--border-glass-hover);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  --glow-opacity: 1;
}

/* Background spotlight mask on the card container */
.app-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    circle 220px at var(--glow-x) var(--glow-y),
    var(--glow-color) 0%,
    transparent 100%
  );
  opacity: var(--glow-opacity);
  transition: --glow-opacity 0.4s ease;
}

/* Card Image Section */
.card-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  overflow: hidden;
  background: #110e20;
}

.card-image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-card:hover .card-image-wrapper img {
  transform: scale(1.08);
}

.card-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.35rem 0.8rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-family-title);
  text-transform: uppercase;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.badge-scienze {
  background: rgba(0, 242, 254, 0.2);
  border: 1px solid var(--color-cyan);
  color: #a5f8fc;
}

.badge-umanistiche {
  background: rgba(255, 0, 127, 0.2);
  border: 1px solid var(--color-magenta);
  color: #ffb3d9;
}

.badge-astronomia {
  background: rgba(157, 78, 221, 0.2);
  border: 1px solid var(--color-purple);
  color: #e5ccff;
}

/* Card Body */
.card-body {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  position: relative;
  z-index: 2;
}

.card-body h3 {
  font-family: var(--font-family-title);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  transition: color 0.3s ease;
}

.app-card:hover .card-body h3 {
  color: var(--color-cyan);
}

.card-body p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.author-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.author-avatar {
  width: 1.5rem;
  height: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--color-cyan);
  font-weight: bold;
}

.author-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.action-link {
  font-family: var(--font-family-title);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-cyan);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: transform 0.3s ease;
}

.app-card:hover .action-link {
  transform: translateX(4px);
}

/* Footer Section */
footer {
  margin-top: 6rem;
  padding: 3rem 2rem;
  border-top: 1px solid var(--border-glass);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer p {
  margin-bottom: 0.75rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--color-cyan);
}

/* Responsive Grid and styles */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.5rem;
  }
  
  main {
    padding: 2.5rem 1.25rem;
  }
  
  .filter-container {
    flex-wrap: wrap;
  }
  
  .app-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

/* Motion Accessibility override */
@media (prefers-reduced-motion: reduce) {
  .app-card {
    transition: none !important;
  }
  .app-card:hover {
    transform: none !important;
  }
  .app-card::before {
    display: none !important;
  }
  .card-image-wrapper img {
    transition: none !important;
  }
  .app-card:hover .card-image-wrapper img {
    transform: none !important;
  }
}
