/* ═══════════════════════════════════════════════════════════════════
   TortugaTV — TV Edition (10-foot UI)
   Ottimizzato per schermi TV 32"–65" con telecomando/D-pad
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Outfit:wght@400;500;600;700;800&family=Orbitron:wght@400;500;700;900&display=swap');

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #121226;
    --bg-card: #1a1a2e;
    --bg-card-hover: #23233a;
    --accent: #00f2ff;
    --accent-hover: #00ccff;
    --accent-pink: #ff003c;
    --text-primary: #ffffff;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border: rgba(0, 242, 255, 0.3);
    --radius-sm: 4px;
    --radius-md: 8px;
    --transition: 0.3s ease;
    --focus-ring: 0 0 0 4px rgba(0, 242, 255, 0.7), 0 0 20px rgba(0, 242, 255, 0.3);
    --tv-font-scale: 1.3;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    /* TV: prevent text selection, cursor */
    user-select: none;
    cursor: none;
    font-size: calc(16px * var(--tv-font-scale));
}

/* Show cursor on mouse movement (for mini-PC with mouse) */
body.has-mouse { cursor: default; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #555; border-radius: 5px; }

/* ─── TV Focus System ──────────────────────────────────────────────── */
[data-focusable]:focus,
.poster-card:focus,
.genre-chip:focus,
.ep-card:focus,
.btn:focus,
.top10-card:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    transform: scale(1.06);
    z-index: 100;
    transition: all 0.2s ease;
}

.poster-card:focus .poster-img { filter: brightness(0.7); }
.poster-card:focus .poster-overlay { opacity: 1; }
.poster-card:focus .poster-play { transform: translate(-50%, -50%) scale(1); }

/* ─── Preloader (TV) ───────────────────────────────────────────────── */
.preloader {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease, visibility 1s ease;
}
.preloader.fade-out { opacity: 0; visibility: hidden; }

.preloader-content { text-align: center; color: white; animation: fadeIn 0.8s ease; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.preloader-logo { font-size: 6rem; margin-bottom: 24px; }
.preloader-logo-img { width: 180px; height: auto; max-height: 25vh; object-fit: contain; filter: drop-shadow(0 0 15px rgba(0,242,255,0.4)); margin-bottom: 20px; }
.preloader-title { font-family: 'Outfit', sans-serif; font-size: 3rem; font-weight: 800; color: var(--accent-pink); margin-bottom: 8px; }
.preloader-subtitle { font-size: 1.2rem; color: var(--text-muted); margin-bottom: 40px; letter-spacing: 3px; text-transform: uppercase; }
.preloader-hint { color: var(--text-secondary); margin-bottom: 24px; font-size: 1.1rem; }
.preloader-hint kbd { background: rgba(255,255,255,0.1); padding: 4px 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); font-family: inherit; }
.preloader-status { font-size: 1.2rem; color: var(--text-secondary); }
.preloader-countdown { font-size: 4rem; font-weight: 700; margin-top: 24px; color: var(--accent); }

.btn-tv { padding: 20px 50px; font-size: 1.5rem; border-radius: 12px; }
.btn-tv:focus { box-shadow: var(--focus-ring); transform: scale(1.08); }

/* ─── Navbar (TV) ──────────────────────────────────────────────────── */
.navbar-tv {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    padding: 0 3%;
    height: 80px;
    display: flex;
    align-items: center;
    gap: 40px;
    background: linear-gradient(180deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0) 100%);
    transition: background var(--transition);
}
.navbar-tv.scrolled {
    background: rgba(11,11,15,0.97);
    backdrop-filter: blur(20px);
    box-shadow: 0 1px 0 var(--border);
}

.navbar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; cursor: pointer; flex-shrink: 0; }
.logo-icon { font-size: 32px; }
.logo-text { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 24px; color: var(--accent-pink); letter-spacing: -0.5px; white-space: nowrap; }

.nav-links { display: flex; gap: 6px; flex-shrink: 0; }
.nav-link {
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.nav-link:hover, .nav-link:focus { color: white; background: rgba(255,255,255,0.08); }
.nav-link.active { color: white; font-weight: 600; }

.navbar-search { margin-left: auto; flex-shrink: 0; }
.search-wrapper { position: relative; }
.search-input-tv {
    width: 320px;
    height: 48px;
    padding: 0 44px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    background: rgba(0,0,0,0.5);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    outline: none;
    transition: var(--transition);
}
.search-input-tv:focus { border-color: var(--accent-pink); background: rgba(0,0,0,0.75); width: 400px; box-shadow: 0 0 0 3px rgba(255,51,102,0.3); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 18px; pointer-events: none; }
.search-clear { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: white; cursor: pointer; font-size: 18px; display: none; }
.search-clear.visible { display: block; }

/* ─── Hero Billboard (TV) ──────────────────────────────────────────── */
.hero-billboard { position: relative; width: 100%; height: 85vh; min-height: 600px; background-size: cover; background-position: center 20%; }
.hero-billboard::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg-primary) 0%, transparent 50%), linear-gradient(to right, rgba(11,11,15,0.9) 0%, transparent 60%); }

.hero-content { position: absolute; bottom: 15%; left: 3%; max-width: 650px; z-index: 2; }
.hero-badge { display: inline-block; background: var(--accent); color: white; padding: 5px 14px; border-radius: 4px; font-size: 14px; font-weight: 700; text-transform: uppercase; margin-bottom: 16px; letter-spacing: 0.5px; }
.hero-title { font-family: 'Outfit', sans-serif; font-size: clamp(2.5rem, 5vw, 4.5rem); font-weight: 800; line-height: 1.1; margin-bottom: 18px; text-shadow: 0 2px 24px rgba(0,0,0,0.6); }
.hero-plot { font-size: 18px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 28px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-actions { display: flex; gap: 16px; }

.btn { display: inline-flex; align-items: center; gap: 10px; padding: 14px 32px; border-radius: 6px; font-family: 'Inter', sans-serif; font-size: 18px; font-weight: 600; cursor: pointer; border: none; transition: var(--transition); }
.btn-play { background: white; color: black; }
.btn-play:hover, .btn-play:focus { background: rgba(255,255,255,0.85); }
.btn-info { background: rgba(109,109,110,0.7); color: white; }
.btn-info:hover, .btn-info:focus { background: rgba(109,109,110,0.5); }

/* ─── Content Rows (TV) ───────────────────────────────────────────── */
.main-content { position: relative; z-index: 5; padding: 0 3% 100px; margin-top: -80px; }
.row-section { margin-bottom: 50px; }
.row-title { font-family: 'Outfit', sans-serif; font-size: 26px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.row-title .count-badge { font-size: 14px; font-weight: 500; color: var(--accent-pink); background: rgba(255,51,102,0.12); padding: 3px 10px; border-radius: 100px; }

.row-scroll { display: flex; overflow-x: auto; overflow-y: hidden; gap: 16px; padding-bottom: 12px; scroll-behavior: smooth; -ms-overflow-style: none; scrollbar-width: none; }
.row-scroll::-webkit-scrollbar { display: none; }

/* ─── Poster Card (TV - larger) ────────────────────────────────────── */
.poster-card {
    flex: 0 0 auto;
    width: 220px;
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.25,0.8,0.25,1);
    position: relative;
    border-radius: var(--radius-md);
    /* Make focusable for D-pad */
    outline: none;
}
.poster-card:hover, .poster-card:focus { transform: scale(1.1); z-index: 10; }

.poster-img-wrap { position: relative; width: 100%; aspect-ratio: 2/3; border-radius: var(--radius-md); overflow: hidden; background: var(--bg-card); }
.poster-img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition); }
.poster-card:hover .poster-img, .poster-card:focus .poster-img { filter: brightness(0.6); }

.poster-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 12px; opacity: 0; transition: opacity var(--transition); }
.poster-card:hover .poster-overlay, .poster-card:focus .poster-overlay { opacity: 1; }

.poster-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8); width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.9); display: flex; align-items: center; justify-content: center; font-size: 22px; color: black; transition: transform 0.3s ease; }
.poster-card:hover .poster-play, .poster-card:focus .poster-play { transform: translate(-50%, -50%) scale(1); }

.poster-type { position: absolute; top: 10px; left: 10px; font-size: 12px; font-weight: 700; color: white; background: rgba(0,0,0,0.75); padding: 3px 9px; border-radius: 4px; text-transform: uppercase; }
.poster-score { position: absolute; top: 10px; right: 10px; font-size: 13px; font-weight: 700; color: #46d369; background: rgba(0,0,0,0.75); padding: 3px 8px; border-radius: 4px; }
.poster-title { font-size: 16px; font-weight: 600; margin-top: 10px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ─── Top 10 ───────────────────────────────────────────────────────── */
.top10-card { flex: 0 0 auto; width: 280px; display: flex; align-items: flex-end; gap: 0; cursor: pointer; transition: transform 0.35s ease; outline: none; }
.top10-card:hover, .top10-card:focus { transform: scale(1.05); z-index: 10; }
.top10-number { font-family: 'Outfit', sans-serif; font-size: 140px; font-weight: 900; line-height: 0.8; color: transparent; -webkit-text-stroke: 3px #444; margin-right: -24px; flex-shrink: 0; position: relative; z-index: 1; }
.top10-poster { width: 160px; aspect-ratio: 2/3; border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; position: relative; z-index: 2; box-shadow: -4px 0 18px rgba(0,0,0,0.5); }
.top10-poster img { width: 100%; height: 100%; object-fit: cover; }

/* ─── Genre Chips (TV) ─────────────────────────────────────────────── */
.genre-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 36px; }
.genre-chip { padding: 10px 24px; border-radius: 24px; background: var(--bg-card); border: 2px solid var(--border); color: var(--text-secondary); font-size: 16px; font-weight: 500; cursor: pointer; transition: var(--transition); outline: none; }
.genre-chip:hover, .genre-chip:focus { background: var(--bg-card-hover); color: white; border-color: rgba(255,255,255,0.3); box-shadow: var(--focus-ring); }
.genre-chip.active { background: var(--accent-pink); color: white; border-color: var(--accent-pink); }

/* ─── Detail View (TV) ─────────────────────────────────────────────── */
.detail-view { padding-top: 80px; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.detail-banner { position: relative; width: 100%; height: 60vh; min-height: 450px; background-size: cover; background-position: center 20%; }
.detail-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg-primary) 0%, transparent 60%), linear-gradient(to right, rgba(11,11,15,0.85) 0%, transparent 55%); }
.detail-info { position: absolute; bottom: 40px; left: 3%; right: 3%; z-index: 2; max-width: 800px; }
.detail-title { font-family: 'Outfit', sans-serif; font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 800; line-height: 1.1; margin-bottom: 14px; }
.detail-meta { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; font-size: 16px; color: var(--text-secondary); flex-wrap: wrap; }
.detail-meta .score { color: #46d369; font-weight: 600; }
.detail-meta .maturity { border: 1px solid var(--text-muted); padding: 0 6px; border-radius: 3px; font-size: 14px; }
.detail-plot { font-size: 17px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 28px; max-width: 700px; }
.detail-actions { display: flex; gap: 14px; flex-wrap: wrap; }

/* ─── Episodes (TV) ────────────────────────────────────────────────── */
.episodes-section { padding: 44px 3%; }
.episodes-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.episodes-title { font-family: 'Outfit', sans-serif; font-size: 26px; font-weight: 700; }
.episodes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; }

.ep-card { display: flex; gap: 16px; padding: 16px; border-radius: var(--radius-md); background: var(--bg-card); border: 2px solid var(--border); cursor: pointer; transition: var(--transition); outline: none; }
.ep-card:hover, .ep-card:focus { background: var(--bg-card-hover); border-color: var(--accent-pink); box-shadow: var(--focus-ring); }
.ep-card.active { border-color: white; }
.ep-num { font-size: 28px; font-weight: 700; color: var(--text-muted); min-width: 36px; display: flex; align-items: center; justify-content: center; }
.ep-info { flex: 1; }
.ep-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.ep-sub { font-size: 14px; color: var(--text-muted); }
.ep-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn { background: none; border: none; color: var(--text-secondary); font-size: 18px; cursor: pointer; padding: 8px; border-radius: 50%; transition: var(--transition); }
.icon-btn:hover, .icon-btn:focus { color: white; background: rgba(255,255,255,0.1); }

/* ─── Player (TV) ──────────────────────────────────────────────────── */
#player-section { background: black; }
.hidden { display: none !important; }
#player-container { position: relative; width: 100%; max-height: 85vh; aspect-ratio: 16/9; background: black; }
#player-container video { width: 100%; height: 100%; outline: none; }
.player-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.big-play { width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,0.15); border: 2px solid white; display: flex; align-items: center; justify-content: center; font-size: 36px; color: white; transition: var(--transition); }
.player-overlay:hover .big-play { transform: scale(1.1); background: rgba(255,255,255,0.25); }
.player-nav { padding: 14px 3%; display: flex; gap: 12px; background: #111; }

/* ─── Search (TV) ──────────────────────────────────────────────────── */
.search-view { padding: 100px 3% 60px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }

/* ─── Loading & Toast (TV) ─────────────────────────────────────────── */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 120px 0; gap: 20px; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,0.1); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner-lg { width: 60px; height: 60px; border-width: 5px; margin: 0 auto 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; }
.toast { background: #333; color: white; padding: 16px 28px; border-radius: 6px; font-size: 18px; box-shadow: 0 4px 16px rgba(0,0,0,0.5); border-left: 5px solid #46d369; }
.toast.error { border-color: var(--accent); }

.download-progress { position: fixed; bottom: -120px; left: 50%; transform: translateX(-50%); background: var(--bg-secondary); padding: 20px 28px; border-radius: var(--radius-md); box-shadow: 0 10px 30px rgba(0,0,0,0.8); border: 1px solid var(--border); transition: bottom 0.3s ease; z-index: 10000; width: 90%; max-width: 500px; }
.download-progress.active { bottom: 30px; }
.progress-title { display: flex; gap: 12px; font-weight: 600; margin-bottom: 12px; font-size: 18px; }
.progress-bar { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--accent-pink); width: 0%; transition: width 0.3s; }
.progress-text { font-size: 14px; color: var(--text-muted); }

/* ─── Row Arrows (TV) ──────────────────────────────────────────────── */
.row-scroll-container { position: relative; display: flex; align-items: center; }
.row-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 50px; height: 100%; background: rgba(0,0,0,0.6); color: white; font-size: 36px; border: none; cursor: pointer; z-index: 20; opacity: 0; transition: opacity 0.3s, background 0.3s; display: flex; align-items: center; justify-content: center; }
.row-scroll-container:hover .row-arrow { opacity: 1; }
.row-arrow:hover, .row-arrow:focus { background: rgba(0,0,0,0.85); color: var(--accent-pink); }
.row-arrow-left { left: 0; border-radius: 0 8px 8px 0; }
.row-arrow-right { right: 0; border-radius: 8px 0 0 8px; }

/* ─── TV-Specific Responsive ───────────────────────────────────────── */
/* Small TV (32") */
@media (max-width: 1400px) {
    :root { --tv-font-scale: 1.1; }
    .poster-card { width: 180px; }
    .top10-card { width: 240px; }
    .top10-number { font-size: 110px; }
}

/* Medium TV (42"-55") */
@media (min-width: 1401px) and (max-width: 2000px) {
    :root { --tv-font-scale: 1.3; }
    .poster-card { width: 220px; }
}

/* Large TV (60"-65"+) */
@media (min-width: 2001px) {
    :root { --tv-font-scale: 1.5; }
    .poster-card { width: 260px; }
    .top10-card { width: 320px; }
    .top10-number { font-size: 160px; }
    .navbar-tv { height: 90px; }
    .logo-text { font-size: 28px; }
    .nav-link { font-size: 20px; padding: 12px 24px; }
}

/* 4K TV */
@media (min-width: 3000px) {
    :root { --tv-font-scale: 2; }
    .poster-card { width: 340px; }
    .navbar-tv { height: 100px; }
}

/* Mobile Landscape (Phones) */
@media (max-width: 950px) {
    :root { --tv-font-scale: 0.8; }
    .navbar-tv { height: 60px; padding: 0 15px; gap: 15px; }
    .logo-text { font-size: 16px; }
    .logo-icon { font-size: 20px; }
    .nav-link { font-size: 14px; padding: 8px 12px; }
    .search-input-tv { width: 200px; height: 36px; font-size: 14px; padding: 0 34px; }
    .search-icon { left: 10px; font-size: 14px; }
    .search-input-tv:focus { width: 250px; }
    .hero-title { font-size: 2rem; margin-bottom: 10px; }
    .hero-plot { font-size: 14px; margin-bottom: 15px; -webkit-line-clamp: 2; }
    .btn { padding: 8px 16px; font-size: 14px; }
    .poster-card { width: 140px; }
    .top10-card { width: 180px; }
    .top10-number { font-size: 80px; margin-right: -15px; }
    .top10-poster { width: 120px; }
    .detail-view { padding-top: 60px; }
    .detail-title { font-size: 1.8rem; }
    .detail-info { bottom: 20px; }
    .episodes-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .detail-info { bottom: 20px; }
    .episodes-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .preloader-title { font-size: 2rem; margin-bottom: 5px; }
    .preloader-subtitle { margin-bottom: 15px; font-size: 1rem; }
    .preloader-hint { margin-bottom: 15px; font-size: 0.9rem; }
    .preloader-logo { font-size: 4rem; margin-bottom: 15px; }
    .preloader-logo-img { width: 120px; max-height: 20vh; }
    .preloader-countdown { font-size: 3rem; margin-top: 15px; }
    .btn-tv { padding: 12px 30px; font-size: 1.1rem; }
}

/* Mobile Landscape explicitly (Height < 500px) */
@media (max-height: 500px) {
    .preloader-logo-img { max-height: 12vh; margin-bottom: 10px; }
    .preloader-title { font-size: 1.5rem; margin-bottom: 8px; }
    .preloader-subtitle { margin-bottom: 10px; font-size: 0.8rem; }
    .preloader-hint { margin-bottom: 10px; font-size: 0.8rem; }
    .preloader-countdown { font-size: 2rem; margin-top: 10px; }
    .btn-tv { padding: 8px 20px; font-size: 1rem; }
}
