/* Global styles and variables */
:root {
    --primary-color: #a87ab6;
    --secondary-color: #54bfc1;
    --background-dark: #1a1a2e;
    --background-medium: #1f2847;
    --text-light: #f0f0f0;
    --text-dark: #aaaaaa;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --glass-background: rgba(255, 255, 255, 0.05);
    --glass-backdrop-filter: blur(10px) saturate(180%);
    --card-hover-scale: 1.03;
    --transition-speed: 0.3s;
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Base font size for rem calculations */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-light);
    line-height: 1.6;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 4%; /* Use percentage for horizontal padding */
}

/* Navbar with logo */
.navbar {
    background-color: var(--glass-background);
    backdrop-filter: var(--glass-backdrop-filter);
    -webkit-backdrop-filter: var(--glass-backdrop-filter);
    border-bottom: 1px solid var(--border-color);
    padding: 0.625rem 0; /* Use rem for padding */
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 30px var(--shadow-light);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar .logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--primary-color);
    font-size: clamp(1rem, 3.5vw, 1.7rem); 
    font-weight: bold;
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}



.logo-img {
    height: 2.5rem; /* Use rem */
    width: auto;
    transition: transform var(--transition-speed) ease;
}

.navbar .logo:hover {
    color: var(--secondary-color);
}

.navbar .logo:hover .logo-img {
    transform: scale(1.1);
}

.navbar .nav-links {
    list-style: none;
    display: flex;
}

.navbar .nav-links li {
    margin-left: 1.875rem; /* Use rem */
}

.navbar .nav-links a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem; /* Use rem */
    padding: 0.3125rem 0; /* Use rem */
    position: relative;
    transition: color var(--transition-speed) ease;
}

.navbar .nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    bottom: -0.3125rem; /* Use rem */
    left: 0;
    transition: width var(--transition-speed) ease;
}

.navbar .nav-links a:hover {
    color: var(--primary-color);
}

.navbar .nav-links a:hover::after {
    width: 100%;
}

/* Hamburger menu for mobile */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    z-index: 1001;
}

.hamburger span {
    height: 5px;
    width: 30px;
    padding: 0.2%;
    background-color: var(--text-light);
    margin-bottom: 5px;
    border-radius: 2px;
    transition: all var(--transition-speed) ease;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Main content layout */
.main-content {
    flex: 1;
    padding: 2.5rem 4%; /* Use rem and percentage */
    animation: fadeIn 1s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-title, .anime-title {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 2.5rem; /* Use rem */
    font-size: clamp(1.8rem, 5vw, 2.4rem); /* Responsive font size */
    font-weight: 700;
    text-shadow: 0 0 10px rgba(168, 122, 182, 0.4);
}

/* Hero Section (Homepage) */
.hero-section {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 1.875rem; /* Use rem */
    margin-bottom: 3.125rem; /* Use rem */
    align-items: flex-start;
}

/* Enhanced video player */
.video-container {
    flex: 2;
    background-color: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 10px 30px var(--shadow-medium);
    position: relative;
    width: 100%; /* Ensure it's responsive */
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

.video-container .main-video-player {
    position: absolute; /* Position absolutely to respect padding-top */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
    object-fit: contain;
    background-color: #000000;
}

.anime-description-sidebar {
    flex: 1;
    min-width: 300px; /* Prevent it from getting too small */
    background-color: var(--background-medium);
    padding: 1.875rem; /* Use rem */
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px var(--shadow-medium);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.anime-description-sidebar h2 {
    color: var(--primary-color);
    margin-bottom: 0.9375rem; /* Use rem */
    font-size: 1.8rem; /* Use rem */
}

.anime-description-sidebar p {
    color: var(--text-dark);
    line-height: 1.8;
    margin-bottom: 1.5625rem; /* Use rem */
    font-size: 1.05rem; /* Use rem */
}

/* General cards */
.card {
    background-color: var(--background-medium);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 20px var(--shadow-medium);
    padding: 0.9375rem; /* Use rem */
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    border: 1px solid var(--border-color);
    will-change: transform, box-shadow;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px var(--shadow-medium);
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5625rem; /* Use rem */
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem; /* Use rem */
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border: none;
    will-change: transform, box-shadow;
}

.button.primary-button {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 5px 15px rgba(168, 122, 182, 0.4);
}

.button.primary-button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(84, 191, 193, 0.5);
}

.button.primary-button svg {
    margin-right: 0.5rem; /* Use rem */
    fill: #fff;
}

/* Pulse effect */
.pulse-effect, .episode-card:hover {
    animation: pulse 3.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(185, 77, 218, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(168, 122, 182, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(168, 122, 182, 0); }
}

/* Episode previews */
.episodes-preview h2 {
    color: var(--primary-color);
    font-size: clamp(2rem, 6vw, 2.8rem); /* Responsive font size */
    text-align: center;
    margin-bottom: 1.875rem; /* Use rem */
}

.episode-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.875rem; /* Use rem */
    justify-content: center;
}

.episode-card {
    overflow: hidden;
    cursor: pointer;
    text-align: center;
    padding: 0;
}

.episode-card img {
    width: 100%;
    height: 11.25rem; /* Use rem */
    object-fit: cover;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    transition: transform var(--transition-speed) ease;
}

.episode-card:hover img {
    transform: scale(1.05);
}

.episode-card h3 {
    color: var(--text-light);
    font-size: 1.4rem; /* Use rem */
    margin: 0.9375rem 0 0.625rem; /* Use rem */
    padding: 0 0.9375rem; /* Use rem */
}

.cuore-effect, .episode-card-full:hover {
    animation: onda 3.5s infinite;
}

@keyframes onda {
    0% { box-shadow: 0 0 0 0 rgba(185, 77, 218, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(168, 122, 182, 0); }
    100% { box-shadow: 0 0 0 0 rgba(168, 122, 182, 0); }
}

/* Episodes page */
.video-player-section {
    margin-bottom: 2.5rem; /* Use rem */
}

.current-episode-title {
    color: var(--secondary-color);
    font-size: clamp(1.6rem, 4vw, 2rem); /* Responsive font size */
    text-align: center;
    margin-top: 0.5rem;
    margin-bottom: 0.9375rem; /* Use rem */
}

      @media (max-width: 600px) {
    .current-episode-title {
        font-size: 1.50rem;
    font-weight: bold;
    }
}
.episode-list.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.875rem; /* Use rem */
}

.episode-card-full {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    border: 1px solid transparent;
    transition: all var(--transition-speed) ease;
}

.episode-card-full.active {
    border-color: var(--primary-color);
    animation: onda 7.0s infinite;
    background-color: rgba(168, 122, 182, 0.1);
}

.episode-card-full img {
    width: 100%;
    height: 12.5rem; /* Use rem */
    object-fit: cover;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    transition: transform var(--transition-speed) ease;
}

.episode-card-full:hover img {
    transform: scale(1.03);
}

.episode-card-full .episode-details {
    padding: 0.9375rem; /* Use rem */
    flex-grow: 1;
}

.episode-card-full h3 {
    color: var(--primary-color);
    font-size: 1.6rem; /* Use rem */
    margin-bottom: 0.5625rem; /* Use rem */
}

.episode-card-full p {
    color: var(--text-dark);
    font-size: 1rem; /* Use rem */
    line-height: 1.7;
}

/* Footer */
footer {
    background-color: var(--background-medium);
    padding: 1.25rem 0; /* Use rem */
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    box-shadow: 0 -4px 30px var(--shadow-light);
}

footer p {
    color: var(--text-dark);
    font-size: 0.62rem; /* Use rem */
}

footer a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Accessibility */
a:focus, button:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile-First Media Queries */

@media (max-width: 992px) {
    .hero-section {
        flex-direction: column;
        align-items: center;
    }

    .video-container, .anime-description-sidebar {
        width: 100%;
        max-width: 100%; /* No max-width restriction for full responsiveness */
    }
}

@media (max-width: 768px) {
    .navbar .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        background-color: var(--background-medium);
        position: absolute;
        top: 4.125rem; /* Use rem for top position */
        left: 0;
        padding: 1.25rem 0; /* Use rem */
        border-top: 1px solid var(--border-color);
        box-shadow: 0 4px 15px var(--shadow-medium);
    }

    .navbar .nav-links.active {
        display: flex;
    }

    .navbar .nav-links li {
        margin: 0.625rem 0; /* Use rem */
        text-align: center;
    }

    .navbar .hamburger {
        display: flex;
    }
}

.navbar .logo {
    font-size: clamp(1rem, 4vw, 1.7rem);
}

/* Error Report Button & Modal */
.error-report-btn {
  position: fixed;
  bottom: 1.875rem;
  right: 1.875rem;
  z-index: 1000;
  padding: 0.75rem 1.25rem;
  background-color: #8c00ff;
  color: white;
  border: none;
  border-radius: 1.875rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.error-report-btn:hover {
  background-color: #e63939;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 68, 68, 0.4);
}

.error-report-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Modal style */
.error-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.7);
  z-index: 2000;
  backdrop-filter: blur(3px);
}

.modal-content {
  background: #1a1a2e;
  width: 90%;
  max-width: 31.25rem;
  margin: 5rem auto;
  padding: 1.875rem;
  border-radius: 0.75rem;
  position: relative;
  border: 1px solid #2d2d4d;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-title {
  color: #fff;
  margin-bottom: 1.5625rem;
  font-size: 1.5rem;
  text-align: center;
}

.close-modal {
  position: absolute;
  top: 0.9375rem;
  right: 1.25rem;
  font-size: 1.75rem;
  color: #aaa;
  cursor: pointer;
  transition: color 0.2s;
}

.close-modal:hover {
  color: #fff;
}

/* Form style */
.error-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  margin-bottom: 0.9375rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: #e6e6e6;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.9375rem;
  background: #16213e;
  border: 1px solid #2d2d4d;
  border-radius: 0.375rem;
  color: #fff;
  font-size: 0.95rem;
  transition: border-color 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: #4CAF50;
}

textarea.form-input {
  min-height: 7.5rem;
  resize: vertical;
}

/* Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(1.25rem); }
  to { opacity: 1.5; transform: translateY(0); }
}

.modal-content {
  animation: fadeIn 0.5s ease-out;
}

.anime-details-text {
    background-color: transparent;
    }

        /* Player button styles */
        .plyr__control-group {
            display: flex;
            gap: 0.3125rem;
        }
        
        .plyr__control[title="Cambia Player"] svg {
            width: 1.125rem;
            height: 1.125rem;
        }

    .plyr--full-frame,
    .plyr__video-wrapper {
        background: #000000 !important;
    }
@media (max-width: 992px) {
    .telegram-alert {
    font-size: 0.85rem;

    }
}
     /* Telegram popup styles */
        .telegram-alert {
            background: linear-gradient(135deg, #0088cc, #00aced);
            color: white;
            padding: 0.9375rem;
            border-radius: 0.5rem;
            margin: 1.25rem 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }
        
        .telegram-alert a {
            color: white;
            text-decoration: none;
            font-weight: bold;
            flex-grow: 1;
            text-align: center;
        }
        
        .telegram-alert a i {
            margin-right: 0.5rem;
            font-size: 1.8em;
        }
        
        .close-alert {
            cursor: pointer;
            margin-left: 0.9375rem;
            font-size: 1.2em;
        }




.cookie-banner-new {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 40.625rem;
    background-color: #1a202c;
    color: #e2e8f0;
    padding: 1.25rem 1.875rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border: 1px solid #2d3748;
    z-index: 9999;
    display: none;
    text-align: center;
    transition: opacity 0.5s ease-in-out;
}

.cookie-content-new h2 {
    color: #54bfc1;
    margin-bottom: 0.625rem;
    font-size: 1.8rem;
}

.cookie-content-new p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    color: #a0aec0;
}

.cookie-buttons-new button {
    font-family: inherit;
    padding: 0.75rem 1.5625rem;
    margin: 0.3125rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#accept-cookies {
    background-color: #54bfc1;
    color: #1a202c;
}

#accept-cookies:hover {
    background-color: #81e6d9;
    box-shadow: 0 4px 15px rgba(0, 150, 136, 0.3);
}

#reject-cookies {
    background-color: #2d3748;
    color: #e2e8f0;
}

#reject-cookies:hover {
    background-color: #4a5568;
}

/* Slower and gradual animations */
@keyframes expandText {
    0% { max-height: calc(1.6rem * var(--lines, 2)); opacity: 0.95; }
    100% { max-height: 62.5rem; opacity: 1; }
}

@keyframes fadeGradient {
    0% { opacity: 1; }
    50% { opacity: 0.50;}
    100% { opacity: 0; }
}

/* Episode card */
.episode-card-full .episode-details p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--lines, 2);
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    max-height: calc(1.6rem * var(--lines, 1));
    opacity: 0.95;
    cursor: pointer;
}

/* Fade-out effect for truncated text */
.episode-card-full .episode-details p::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1.6rem;
    pointer-events: none;
    opacity: 1;
}

/* Hover: fluid expansion + gradient removal */
.episode-card-full:hover .episode-details p {
    display: block;
    -webkit-line-clamp: unset;
    animation: expandText 1.2s forwards ease;
}

.episode-card-full:hover .episode-details p::after {
    animation: fadeGradient 0.8s forwards ease;
}






/*======================================================*/
/* EFFETTO MACCHINA DA SCRIVERE (Typing Effect) */
/*======================================================*/

/* Stile del cursore e della digitazione */
#typewriter-text {
    /* Il testo inizia nascosto, viene rivelato gradualmente da JS */
    overflow: hidden; 
    color: var(--text-light); 
    
    /* Applica lo stile dei titoli */
    font-size: clamp(1.8rem, 5vw, 2.4rem); 
    font-weight: 700;
    margin: 1.5rem auto 2.5rem; /* Margini consistenti con i titoli di pagina */
    text-align: center;
    
    /* Bordo destro che funge da cursore */
    border-right: 0.15em solid var(--primary-color); 
    
    /* Limita l'elemento su una sola linea e impedisce il wrapping */
    white-space: nowrap; 
}

/* Animazione del cursore (lampeggiamento) */
@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: var(--primary-color); }
}

/* Applica l'animazione di lampeggiamento al cursore alla fine della digitazione */
.typing-finished {
    /* La classe viene aggiunta da JavaScript al termine della digitazione */
    border-right: 0.15em solid var(--primary-color) !important;
    animation: blink-caret 0.75s step-end infinite;
}