/* ============================================
   LEARN ENGLISH BY US - DESIGN SYSTEM
   ============================================ */

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

/* ============================================
   VARIABILI TEMA DINAMICO E PALETTE
   ============================================ */

:root {
  /* PALETTE DI BASE */
  --mainColor: #00247D;
  --accentRed: #CF142B;
  --mainColorLight: #1e3a8a;
  
  --bg-light: #f0f4f8;
  --bg-dark: #0f172a;
  --card-bg-light: rgba(255, 255, 255, 0.9);
  --card-bg-dark: rgba(30, 41, 59, 0.9);
  
  --text-light: #1e293b;
  --text-dark: #f1f5f9;
  
  --shadow-light: rgba(0, 36, 125, 0.15);
  --shadow-dark: rgba(0, 0, 0, 0.3);

  /* VARS VOCAB (Ex paste) */
  --vocab-bg-primary: #f8fafc;
  --vocab-bg-secondary: #f1f5f9;
  --vocab-bg-card: #ffffff;
  --vocab-text-primary: #0f172a;
  --vocab-text-secondary: #475569;
  --vocab-accent-pink: #ec4899;
  --vocab-accent-coral: #f43f5e;
  --vocab-accent-blue: #3b82f6;
  --vocab-accent-dark-blue: #1e3a8a;
  --vocab-glass-bg: rgba(255, 255, 255, 0.8);
  --vocab-glass-border: rgba(0, 0, 0, 0.1);
  --vocab-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  --vocab-shadow-sm: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Dark theme overrides for local variables */
html[data-bs-theme="dark"], 
[data-theme="dark"] {
  /* Forzati i colori accesi del tema chiaro per non sbiadire nel dark mode */
  --mainColor: #00247D;
  --accentRed: #CF142B;
  --mainColorLight: #1e3a8a;
  
  --bg-light: #0a0e27;
  --bg-dark: #1a1f3a;
  --card-bg-light: rgba(30, 41, 59, 0.9);
  --card-bg-dark: rgba(255, 255, 255, 0.9);
  --text-light: #f1f5f9;
  --text-dark: #1e293b;
  --shadow-light: rgba(0,0,0,0.3);
  --shadow-dark: rgba(0,36,125,0.15);

  --vocab-bg-primary: #0f172a;
  --vocab-bg-secondary: #1e293b;
  --vocab-bg-card: #1e293b;
  --vocab-text-primary: #f8fafc;
  --vocab-text-secondary: #94a3b8;
  --vocab-glass-bg: rgba(30, 41, 59, 0.7);
  --vocab-glass-border: rgba(255, 255, 255, 0.1);
  --vocab-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  --vocab-shadow-sm: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* ============================================
   BASE STYLES
   ============================================ */

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

html {
  scroll-behavior: smooth;
}

html,
body {
  height: 100% !important;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  min-height: 100vh;
  display: flex !important;
  flex-direction: column !important;
  transition: background-color 0.3s ease, color 0.3s ease;
  padding-top: 80px;
}

.site-main {
  flex: 1 0 auto;
}

/* ============================================
   HERO E SEZIONI GENERICHE (dal tuo main originale)
   ============================================ */

.hero-section {
  position: relative;
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--bg-hero);
  transition: background 0.3s ease;
}

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
}

.shape-1 {
  width: 500px;
  height: 500px;
  background: rgba(0, 36, 125, 0.15);
  top: -200px;
  right: -100px;
}

.shape-2 {
  width: 400px;
  height: 400px;
  background: rgba(207, 20, 43, 0.1);
  bottom: -100px;
  left: -100px;
}

[data-bs-theme="dark"] .shape-1 {
  background: rgba(0, 36, 125, 0.15);
}

[data-bs-theme="dark"] .shape-2 {
  background: rgba(207, 20, 43, 0.1);
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(0, 36, 125, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 36, 125, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
}

[data-bs-theme="dark"] .hero-grid {
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
}

/* Hero Content */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.text-gradient {
  background: linear-gradient(135deg, var(--mainColor), var(--accentRed));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-accent {
  color: var(--accentRed);
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.6;
  transition: color 0.3s ease;
}

/* Buttons */
.btn-primary-custom {
  padding: 0.875rem 2rem;
  background: linear-gradient(135deg, var(--mainColor), var(--mainColorLight));
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

[data-bs-theme="dark"] .btn-primary-custom {
  background: linear-gradient(135deg, var(--mainColor), var(--mainColorLight));
}

.btn-outline-custom {
  padding: 0.875rem 2rem;
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-outline-custom:hover {
  border-color: var(--mainColor);
  color: var(--mainColor);
}

/* Stats */
.stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--mainColor);
  line-height: 1;
  transition: color 0.3s ease;
}

[data-bs-theme="dark"] .stat-num {
  color: var(--mainColor);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  transition: color 0.3s ease;
}


/* ============================================
   HEADER SPETTACOLARE (GRAMMAR)
   ============================================ */

.grammar-header {
    background: linear-gradient(135deg, var(--mainColor) 0%, #001a5c 50%, var(--accentRed) 100%);
    padding: 5rem 0;
    position: relative;
    overflow: hidden;
}

html[data-bs-theme="dark"] .grammar-header {
    background: linear-gradient(135deg, var(--mainColor) 0%, #001a5c 50%, var(--accentRed) 100%);
}

.grammar-bg-pattern {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    animation: patternFloat 20s linear infinite;
}

@keyframes patternFloat {
    0% { transform: translate(0, 0); }
    100% { transform: translate(60px, 60px); }
}

/* Orb sfocati animati */
.grammar-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: orbFloat 10s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: white;
    top: -200px;
    right: -100px;
}

html[data-bs-theme="dark"] .orb-1 {
    background: rgba(255,255,255,0.2);
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.5);
    bottom: -100px;
    left: -50px;
    animation-delay: -5s;
}

html[data-bs-theme="dark"] .orb-2 {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.1); }
}

/* Badge con animazione */
.badge-float {
    display: inline-block;
    animation: badgeFloat 3s ease-in-out infinite;
}

@keyframes badgeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.badge-grammar {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    color: white;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.text-3d {
    text-shadow: 
        0 1px 0 rgba(255,255,255,0.1),
        0 2px 0 rgba(255,255,255,0.1),
        0 3px 0 rgba(255,255,255,0.1),
        0 4px 10px rgba(0,0,0,0.3);
    animation: title3D 2s ease-out;
}

@keyframes title3D {
    from {
        opacity: 0;
        transform: translateY(30px) rotateX(-20deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.header-subtitle {
    animation: fadeInUp 1s ease-out 0.3s backwards;
}

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

/* ============================================
   ILLUSTRAZIONE 3D ORBITANTE
   ============================================ */

.grammar-illustration {
    position: relative;
    width: 350px;
    height: 350px;
    margin: 0 auto;
    perspective: 1000px;
    transform-style: preserve-3d;
}

.grammar-icon-main {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(50px);
    font-size: 5rem;
    z-index: 3;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
    animation: iconPulse 3s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { 
        transform: translate(-50%, -50%) translateZ(50px) scale(1);
        filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
    }
    50% { 
        transform: translate(-50%, -50%) translateZ(70px) scale(1.1);
        filter: drop-shadow(0 30px 60px rgba(0, 0, 0, 0.4));
    }
}

/* Anelli orbitanti */
.orbit-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: ringRotate 20s linear infinite;
}

.ring-1 {
    width: 250px;
    height: 250px;
}

.ring-2 {
    width: 300px;
    height: 300px;
    border-style: dashed;
    animation-duration: 30s;
    animation-direction: reverse;
}

@keyframes ringRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Icone in orbita 3D */
.grammar-orbit {
    position: absolute;
    font-size: 2.5rem;
    top: 50%;
    left: 50%;
    transform-style: preserve-3d;
    animation: orbit3D 8s linear infinite;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

.orbit-1 { animation-delay: 0s; }
.orbit-2 { animation-delay: -2.66s; font-size: 2rem; }
.orbit-3 { animation-delay: -5.33s; font-size: 2.2rem; }

@keyframes orbit3D {
    0% { transform: translate(-50%, -50%) rotate(0deg) translateX(120px) rotate(0deg) translateZ(20px); }
    25% { transform: translate(-50%, -50%) rotate(90deg) translateX(120px) rotate(-90deg) translateZ(50px); }
    50% { transform: translate(-50%, -50%) rotate(180deg) translateX(120px) rotate(-180deg) translateZ(20px); }
    75% { transform: translate(-50%, -50%) rotate(270deg) translateX(120px) rotate(-270deg) translateZ(-10px); }
    100% { transform: translate(-50%, -50%) rotate(360deg) translateX(120px) rotate(-360deg) translateZ(20px); }
}

/* ============================================
   CONTROLS CON TEMA DINAMICO - APPLE LIQUID GLASS
   ============================================ */

.grammar-controls {
    background: transparent; /* Lasciamo che lo sfondo della pagina si veda sotto */
    position: relative;
    z-index: 10;
}

/* Liquid Glass Card (Stile Apple) */
.controls-card {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 8px 32px rgba(0, 36, 125, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: slideUp 0.6s ease-out;
}

html[data-bs-theme="dark"] .controls-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}

.controls-card:hover {
    box-shadow: 
        0 15px 45px rgba(0, 36, 125, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

html[data-bs-theme="dark"] .controls-card:hover {
    box-shadow: 
        0 15px 45px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Bottoni difficoltà Liquid Glass */
.difficulty-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.difficulty-btn {
    position: relative;
    padding: 0.5rem 1.25rem;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

html[data-bs-theme="dark"] .difficulty-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Effetto Active & Hover (Colori vibranti sopra il vetro) */
.difficulty-btn:hover,
.difficulty-btn.active {
    background: linear-gradient(135deg, var(--mainColor) 0%, var(--accentRed) 100%);
    color: white !important;
    border-color: transparent;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 10px 25px rgba(207, 20, 43, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

html[data-bs-theme="dark"] .difficulty-btn:hover,
html[data-bs-theme="dark"] .difficulty-btn.active {
    background: linear-gradient(135deg, var(--mainColor) 0%, var(--accentRed) 100%);
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Rimuoviamo il vecchio glow finto e usiamo l'effetto glass diretto */
.difficulty-btn .btn-glow {
    display: none;
}

.difficulty-btn .btn-text {
    position: relative;
    z-index: 1;
}

/* Search con animazione Liquid Glass */
.search-grammar {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 50px;
    padding: 0.5rem;
    transition: all 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

html[data-bs-theme="dark"] .search-grammar {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.search-grammar:focus-within {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--mainColor);
    box-shadow: 
        0 0 0 4px rgba(0, 36, 125, 0.15), 
        0 10px 30px rgba(0, 36, 125, 0.1);
    transform: translateY(-2px);
}

html[data-bs-theme="dark"] .search-grammar:focus-within {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 0 0 4px rgba(255, 255, 255, 0.1), 
        0 10px 30px rgba(0, 0, 0, 0.4);
}

.search-icon-animated {
    padding: 0 1rem;
    color: var(--text-muted);
    animation: searchPulse 2s ease-in-out infinite;
}

@keyframes searchPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.search-grammar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem;
    font-size: 0.95rem;
    outline: none;
    color: inherit;
}

html[data-bs-theme="dark"] .search-grammar input {
    color: white;
}

.search-grammar input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.search-clear {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
}

.search-grammar:focus-within .search-clear {
    opacity: 1;
}

/* ============================================
   GRAMMAR ITEMS ULTRA 3D
   ============================================ */

.grammar-content {
    background: var(--bg-light);
    transition: background 0.3s ease;
}

[data-theme="dark"], html[data-bs-theme="dark"] .grammar-content {
    background: var(--bg-dark);
}

.grammar-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.grammar-item-3d {
    position: relative;
    background: var(--card-bg-light);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 6px var(--shadow-light);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    transform-style: preserve-3d;
    animation: itemEntrance 0.6s ease-out backwards;
}

[data-theme="dark"], html[data-bs-theme="dark"] .grammar-item-3d {
    background: var(--card-bg-dark);
    box-shadow: 0 4px 6px var(--shadow-dark);
}

/* Staggered entrance */
.grammar-item-3d:nth-child(1) { animation-delay: 0.1s; }
.grammar-item-3d:nth-child(2) { animation-delay: 0.2s; }
.grammar-item-3d:nth-child(3) { animation-delay: 0.3s; }
.grammar-item-3d:nth-child(4) { animation-delay: 0.4s; }
.grammar-item-3d:nth-child(5) { animation-delay: 0.5s; }
.grammar-item-3d:nth-child(6) { animation-delay: 0.6s; }

@keyframes itemEntrance {
    from { opacity: 0; transform: translateX(-50px) rotateY(-15deg); }
    to { opacity: 1; transform: translateX(0) rotateY(0); }
}

.grammar-item-3d:hover {
    transform: translateX(15px) translateZ(30px) scale(1.02);
    box-shadow: 0 25px 50px var(--shadow-light);
}

[data-theme="dark"], html[data-bs-theme="dark"] .grammar-item-3d:hover {
    box-shadow: 0 25px 50px var(--shadow-dark);
}

/* Glow bar laterale */
.item-glow {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: linear-gradient(180deg, var(--mainColor), var(--accentRed));
    opacity: 0;
    transition: all 0.3s ease;
}

.grammar-item-3d:hover .item-glow {
    opacity: 1;
    width: 8px;
    box-shadow: 0 0 20px var(--mainColor);
}

.item-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    position: relative;
    transform-style: preserve-3d;
}

/* Icona 3D animata */
.item-icon {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(0, 36, 125, 0.1), rgba(207, 20, 43, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
    transform: translateZ(20px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.grammar-item-3d:hover .item-icon {
    transform: translateZ(40px) scale(1.1) rotateY(10deg);
    background: linear-gradient(135deg, var(--mainColor), var(--accentRed));
    box-shadow: 0 15px 30px rgba(0, 36, 125, 0.3);
    color: white;
}

/* Shine effect sull'icona */
.item-icon::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 40%, rgba(255, 255, 255, 0.3) 50%, transparent 60%);
    transform: rotate(45deg) translateX(-100%);
    transition: transform 0.6s;
}

.grammar-item-3d:hover .item-icon::after {
    transform: rotate(45deg) translateX(100%);
}

.item-info {
    flex: 1;
    transform: translateZ(10px);
}

.item-info h4 {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}

html[data-bs-theme="dark"] .item-info h4 {
    color: var(--text-dark);
}

.grammar-item-3d:hover .item-info h4 {
    color: var(--mainColor);
}

html[data-bs-theme="dark"] .grammar-item-3d:hover .item-info h4 {
    color: var(--mainColorLight);
}

.item-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

html[data-bs-theme="dark"] .item-info p {
    color: rgba(var(--bs-body-color-rgb), 0.6);
}

.item-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.level-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.level-badge.A1 { background: #dcfce7; color: #166534; }
.level-badge.A2 { background: #dbeafe; color: #1e40af; }
.level-badge.B1 { background: #fef3c7; color: #92400e; }
.level-badge.B2 { background: #fee2e2; color: #991b1b; }

.grammar-item-3d:hover .level-badge {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.duration {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.item-action {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transform: translateZ(20px);
}

/* Progress ring 3D */
.progress-ring {
    position: relative;
    width: 55px;
    height: 55px;
    transform-style: preserve-3d;
}

.progress-ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.ring-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 4;
}

[data-theme="dark"], html[data-bs-theme="dark"] .ring-bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.ring-progress {
    fill: none;
    stroke: url(#gradient);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
    filter: drop-shadow(0 0 5px var(--mainColor));
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--mainColor);
}

html[data-bs-theme="dark"] .progress-text {
    color: var(--mainColorLight);
}

/* Arrow icon animato */
.arrow-icon {
    width: 45px;
    height: 45px;
    border-radius: 14px;
    background: rgba(0, 36, 125, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mainColor);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"], html[data-bs-theme="dark"] .arrow-icon {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.grammar-item-3d:hover .arrow-icon {
    background: var(--mainColor);
    color: white;
    transform: translateX(10px) translateZ(30px) rotate(360deg);
    box-shadow: 0 10px 25px rgba(0, 36, 125, 0.4);
}

/* Shine sull'arrow */
.arrow-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.grammar-item-3d:hover .arrow-icon::before {
    transform: translateX(100%);
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, rgba(0,36,125,0.05) 25%, rgba(0,36,125,0.1) 50%, rgba(0,36,125,0.05) 75%);
    background-size: 200% 100%;
    animation: skeletonWave 1.5s ease-in-out infinite;
    border-radius: 12px;
}

@keyframes skeletonWave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ============================================
   CARD 3D CON ROTAZIONE (VOCAB)
   ============================================ */

.vocab-card-wrapper {
    perspective: 1500px;
    height: 320px;
    cursor: pointer;
    width: 100%;
}

.vocab-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.vocab-card-wrapper.flipped .vocab-card-inner {
    transform: rotateY(180deg);
}

.vocab-card-wrapper.is-rotating .vocab-card-inner {
    animation: rotate3D 0.8s ease-in-out;
}

@keyframes rotate3D {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(90deg) scale(0.95); }
    100% { transform: rotateY(180deg) scale(1); }
}

.vocab-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 24px;
    overflow: hidden;
}

/* FRONT */
.vocab-card-front {
    background: linear-gradient(135deg, var(--mainColor) 0%, #0f172a 50%, var(--accentRed) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    box-shadow: var(--vocab-shadow-sm), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 2;
}

[data-bs-theme="dark"] .vocab-card-front {
    background: linear-gradient(135deg, var(--mainColor) 0%, #0f172a 50%, var(--accentRed) 100%);
}


/* BACK */
.vocab-card-back {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--vocab-shadow);
    border: 2px solid rgba(236, 72, 153, 0.2);
    z-index: 1;
}

.card-bg-pattern {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(207, 20, 43, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 36, 125, 0.1) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    animation: patternMove 20s linear infinite;
}

.card-bg-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
            rgba(207, 20, 43, 0.3) 0%,
            transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.vocab-card-wrapper:hover:not(.flipped) .card-bg-glow {
    opacity: 1;
}

.card-bg-glow-back {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
            rgba(207, 20, 43, 0.2) 0%,
            transparent 70%);
    opacity: 0;
    pointer-events: none;
}

.vocab-card-wrapper.flipped:hover .card-bg-glow-back {
    opacity: 0.6;
}

@keyframes patternMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(60px, 60px); }
}

.vocab-icon-wrap {
    position: relative;
    margin-bottom: 1.5rem;
    z-index: 1;
}

.vocab-icon {
    font-size: 4rem;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
    animation: icon3D 3s ease-in-out infinite;
    display: inline-block;
}

@keyframes icon3D {
    0%, 100% { transform: translateY(0) rotateY(0deg) scale(1); }
    25% { transform: translateY(-5px) rotateY(5deg) scale(1.1); }
    50% { transform: translateY(0) rotateY(0deg) scale(1); }
    75% { transform: translateY(-5px) rotateY(-5deg) scale(1.1); }
}

.icon-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border: 2px solid rgba(207, 20, 43, 0.3);
    border-radius: 50%;
    animation: ringExpand 2s ease-out infinite;
}

.icon-ring:nth-child(2) {
    animation-delay: 0.5s;
    width: 120px;
    height: 120px;
    border-color: rgba(0, 36, 125, 0.3);
}

@keyframes ringExpand {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

.vocab-title {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
}

.vocab-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
    z-index: 1;
    text-transform: uppercase;
}

.shine-effect {
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    background: linear-gradient(45deg,
            transparent 45%,
            rgba(255, 255, 255, 0.15) 50%,
            transparent 55%);
    transform: rotate(45deg) translateX(-100%);
    pointer-events: none;
    z-index: 0.5;
}

.vocab-card-wrapper:hover .shine-effect {
    animation: shineSwipe 0.8s ease-in-out forwards;
}

@keyframes shineSwipe {
    0% { transform: rotate(45deg) translateX(-100%); }
    100% { transform: rotate(45deg) translateX(100%); }
}

.vocab-level-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(207, 20, 43, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(207, 20, 43, 0.3);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 1;
}

.flip-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.vocab-card-wrapper.flipped .flip-hint {
    opacity: 0;
    pointer-events: none;
}

.hint-icon {
    animation: spin 3s linear infinite;
    display: inline-block;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.back-header {
    background: linear-gradient(135deg, var(--mainColor) 0%, var(--accentRed) 100%);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.word-count {
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    font-size: 0.8rem;
    color: white;
    font-weight: 600;
}

.back-content {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--vocab-text-secondary);
}

.vocab-preview {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.preview-dot {
    width: 8px;
    height: 8px;
    background: var(--accentRed);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite both;
}

.preview-dot:nth-child(1) { animation-delay: -0.32s; }
.preview-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.btn-enter-vocab {
    margin: 1.25rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--mainColor) 0%, var(--accentRed) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-enter-vocab:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(207, 20, 43, 0.4);
    color: white;
}

.btn-arrow {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.btn-enter-vocab:hover .btn-arrow {
    transform: translateX(4px);
}

.flip-hint-back {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--vocab-text-secondary);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.vocab-card-wrapper.flipped .flip-hint-back {
    opacity: 1;
}

.spinner-3d {
    width: 70px;
    height: 70px;
    border: 4px solid rgba(207, 20, 43, 0.1);
    border-top-color: var(--accentRed);
    border-right-color: var(--mainColor);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
    position: relative;
}

.spinner-3d::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 3px solid transparent;
    border-top-color: var(--mainColor);
    border-left-color: var(--accentRed);
    border-radius: 50%;
    animation: spin 0.8s linear infinite reverse;
}

/* Responsive generale */
@media (max-width: 768px) {
    .grammar-illustration {
        width: 250px;
        height: 250px;
    }
    
    .orbit-ring.ring-1 {
        width: 180px;
        height: 180px;
    }
    
    .orbit-ring.ring-2 {
        width: 220px;
        height: 220px;
    }
    
    .grammar-orbit {
        font-size: 1.8rem;
    }
    
    @keyframes orbit3D {
        0% { transform: translate(-50%, -50%) rotate(0deg) translateX(90px) rotate(0deg) translateZ(20px); }
        50% { transform: translate(-50%, -50%) rotate(180deg) translateX(90px) rotate(-180deg) translateZ(50px); }
        100% { transform: translate(-50%, -50%) rotate(360deg) translateX(90px) rotate(-360deg) translateZ(20px); }
    }
}

/* ============================================
   VOCABULARY LIST — TOPIC CARDS
   ============================================ */
.topic-card {
    position: relative;
    border-radius: 28px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
    text-decoration: none;
    display: block;
    height: 230px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03);
}

[data-bs-theme="dark"] .topic-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.topic-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03);
    text-decoration: none;
}

[data-bs-theme="dark"] .topic-card:hover {
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

/* Gradient border top */
.topic-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--mainColor) 30%,
        var(--accentRed) 70%,
        transparent 100%);
    z-index: 3;
    opacity: 0.9;
}

/* Shine sweep on hover */
.topic-card::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%; height: 100%;
    background: linear-gradient(
        120deg,
        transparent 0%,
        rgba(255, 255, 255, 0.07) 40%,
        rgba(255, 255, 255, 0.13) 50%,
        rgba(255, 255, 255, 0.07) 60%,
        transparent 100%
    );
    transform: skewX(-15deg);
    transition: left 0.7s ease;
    pointer-events: none;
    z-index: 2;
}

.topic-card:hover::after { left: 160%; }

/* Inner ambient glow */
.topic-card-glow {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(0, 36, 125, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(207, 20, 43, 0.1) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 0;
}

.topic-card:hover .topic-card-glow { opacity: 1; }

/* Body */
.topic-card-body {
    position: relative;
    z-index: 1;
    height: 100%;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Icon */
.topic-card-icon {
    width: 52px; height: 52px;
    background: rgba(0, 36, 125, 0.08);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--mainColor);
    transition: transform 0.35s ease, background 0.35s ease;
    border: 1px solid rgba(0, 36, 125, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] .topic-card-icon {
    background: rgba(255, 255, 255, 0.08);
    color: #93c5fd;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.topic-card:hover .topic-card-icon {
    transform: scale(1.15) rotate(-6deg);
    background: linear-gradient(135deg, var(--mainColor) 0%, var(--accentRed) 100%);
    border-color: transparent;
    color: white;
    box-shadow: 0 8px 20px rgba(0, 36, 125, 0.35);
}

/* Cert badge */
.topic-cert-badge {
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--accentRed) 0%, #ec4899 100%);
    color: white;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 12px rgba(207, 20, 43, 0.3);
}

/* Title */
.topic-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.3;
    transition: color 0.4s ease;
}

[data-bs-theme="dark"] .topic-card-title {
    color: #f8fafc;
}

/* Content */
.topic-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.topic-card-desc {
    font-size: 0.83rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.4s ease;
}

[data-bs-theme="dark"] .topic-card-desc {
    color: #94a3b8;
}

/* Footer */
.topic-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stars */
.topic-stars { display: flex; gap: 3px; }

.topic-stars i {
    font-size: 0.78rem;
    color: rgba(0, 0, 0, 0.15);
    transition: color 0.3s ease;
}

[data-bs-theme="dark"] .topic-stars i {
    color: rgba(255, 255, 255, 0.15);
}

.topic-stars i.filled {
    color: #f59e0b;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.6));
}

/* Arrow */
.topic-card-arrow {
    width: 34px; height: 34px;
    background: rgba(0, 36, 125, 0.07);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mainColor);
    font-size: 0.85rem;
    transition: all 0.35s ease;
    border: 1px solid rgba(0, 36, 125, 0.12);
}

[data-bs-theme="dark"] .topic-card-arrow {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.topic-card:hover .topic-card-arrow {
    background: linear-gradient(135deg, var(--mainColor) 0%, var(--accentRed) 100%);
    border-color: transparent;
    color: white;
    transform: translateX(4px);
    box-shadow: 0 6px 16px rgba(0, 36, 125, 0.35);
}

/* Entrance animation */
.topic-card.animate-in {
    animation: topicCardEntrance 0.5s ease-out backwards;
}

@keyframes topicCardEntrance {
    from { opacity: 0; transform: translateY(28px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Empty state ── */
.vocab-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    transition: background 0.4s ease, border-color 0.4s ease;
}

[data-bs-theme="dark"] .vocab-empty-state {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.vocab-empty-state i {
    font-size: 3rem;
    color: #94a3b8;
    margin-bottom: 1rem;
    display: block;
}

.vocab-empty-state p {
    color: #64748b;
    font-size: 1.05rem;
    margin: 0;
    transition: color 0.4s ease;
}

[data-bs-theme="dark"] .vocab-empty-state p {
    color: #94a3b8;
}
