:root {
    --bg1: #0e1419;
    --bg2: #14222b;
    --bg3: #0b1116
}

* {
    box-sizing: border-box
}

html, body {
    height: 100%;
    margin: 0;
    overflow-x: hidden;
    scrollbar-width: none
}

html::-webkit-scrollbar, body::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important
}

body {
    background: #0f0f10;
    color: #f5f6f7;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial
}

main, section, header, footer, nav {
    margin: 0;
    padding: 0
}

/* Fond global */
.bg-gradient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(1200px 600px at 22% 0%, color-mix(in oklab, var(--bg2), #000 20%), transparent 65%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 55%, var(--bg3) 100%)
}

/* Page & blur */
.page {
    min-height: 100dvh;
    position: relative;
    z-index: 1
}

.bg-blur {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-size: cover;
    background-position: 50% 35%;
    filter: blur(120px) saturate(120%) brightness(90%);
    transform: scale(1.18);
    opacity: .9
}

/* HERO */
.hero {
    position: relative;
    z-index: 3;
    min-height: 62vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    margin: 0;
    touch-action: pan-y; /* ✅ autorise le scroll vertical tout en gérant le swipe horizontal */
}

.hero-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: 50% 35%;
    transform: scale(1.02);
    opacity: 0;
    transition: opacity .75s ease, transform 10s ease;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, .95) 55%, rgba(0, 0, 0, 0) 100%);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, .95) 55%, rgba(0, 0, 0, 0) 100%)
}

.hero-layer.is-active {
    opacity: 1;
    transform: scale(1.06)
}

.hero-logo {
    position: absolute;
    bottom: 7rem;
    left: 2rem;
    z-index: 4;
    width: min(420px, 42vw);
    height: 120px;
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .55));
    opacity: 0;
    transition: opacity .6s ease .15s
}

.hero-logo.is-in {
    opacity: 1
}

.hero-title-fallback {
    position: absolute;
    bottom: 8rem;
    left: 2rem;
    z-index: 4;
    margin: 0;
    font-weight: 800;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    text-shadow: 0 4px 14px rgba(0, 0, 0, .75)
}

.hero-meta-bar {
    position: relative;
    z-index: 4;
    width: 100%;
    background: rgba(0, 0, 0, .35);
    padding: .75rem 2rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .6)
}

.hero-meta-top {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    font-size: 1.05rem;
    font-weight: 600
}

.hero-meta-bottom {
    display: flex;
    align-items: center;
    gap: .5rem
}

.hero-meta-bottom img {
    height: 26px;
    width: auto;
    display: block
}

.hero-meta-bottom span {
    font-size: 1.05rem;
    font-weight: 700
}

/* Dots intégrés et centrés dans la meta-bar */
.hero-meta-bar .hero-dots {
    position: static;
    margin-top: .35rem;
    display: flex;
    justify-content: center;
    gap: .5rem;
    z-index: 4
}

.hero-meta-bar .hero-dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    padding: 2px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, .25);
    border: 1px solid rgba(255, 255, 255, .25);
    position: relative
}

.hero-meta-bar .hero-dots .dot .dot-inner {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: rgba(255, 255, 255, .35)
}

.hero-meta-bar .hero-dots .dot.is-active {
    border-color: rgba(255, 255, 255, .45);
    background: conic-gradient(#fff var(--dot-progress, 0deg), rgba(255, 255, 255, .25) 0)
}

/* Flèches */
.hero-arrows {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 .75rem;
    z-index: 5;
    pointer-events: none
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
    transition: background .2s, transform .1s
}

.hero-arrows .btn-icon {
    pointer-events: auto;
    background: rgba(0, 0, 0, .2);
    border: 1px solid rgba(255, 255, 255, .12)
}

.btn-icon:hover {
    background: rgba(255, 255, 255, .08)
}

.btn-icon:active {
    transform: translateY(1px)
}

.btn-icon .bi {
    font-size: 18px;
    line-height: 1
}

/* Skeleton de base */
.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .14), rgba(255, 255, 255, .08));
    background-size: 200% 100%;
    animation: sk 1.2s linear infinite
}

.sk-line {
    display: inline-block;
    min-width: 120px;
    height: 16px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .12)
}

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

/* HERO skeleton spécifique (même volume que le Hero final) */
.hero--skeleton .hero-layer {
    opacity: 1;
    background: rgba(255, 255, 255, .04)
}

.hero--skeleton .hero-logo.skeleton {
    width: min(420px, 42vw);
    height: 120px;
    left: 2rem;
    bottom: 7rem;
    position: absolute;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08)
}

.hero--skeleton .hero-meta-bar {
    padding: .75rem 2rem
}

.hero--skeleton .hero-meta-top .sk-line {
    height: 16px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .12)
}

.hero--skeleton .sk-chip {
    display: inline-block;
    height: 22px;
    width: 64px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12)
}

.hero--skeleton .sk-logo {
    display: inline-block;
    width: 30px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .12)
}

.hero--skeleton .sk-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    display: inline-block
}

.hero--skeleton .hero-meta-bottom {
    gap: .5rem
}

.hero--skeleton .hero-dots {
    margin-top: .35rem;
    display: flex;
    justify-content: center;
    gap: .5rem
}

/* TopNav */
.topnav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 .75rem;
    background: transparent;
    transition: background .25s ease, box-shadow .25s ease, backdrop-filter .25s ease
}

.topnav.is-scrolled {
    background: rgba(0, 0, 0, .28);
    backdrop-filter: blur(6px) saturate(130%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .25)
}

.topnav .left {
    flex: 1
}

.topnav .left, .topnav .right {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-width: 0
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 800;
    letter-spacing: .3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .5)
}

.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: #00d1ff;
    box-shadow: 0 0 18px rgba(0, 209, 255, .6)
}

/* Recherche (TopNav) */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 32px;
    height: 32px;
    transition: width .28s cubic-bezier(.2, .8, .2, 1);
    flex: 0 1 auto
}

.search-field {
    position: absolute;
    inset: 0 auto 0 0;
    height: 32px;
    width: 0;
    opacity: 0;
    pointer-events: none;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .18);
    color: #fff;
    border-radius: 10px;
    padding: 0 40px 0 12px;
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(255, 255, 255, .06);
    transition: width .28s cubic-bezier(.2, .8, .2, 1), opacity .2s ease
}

.search-field::placeholder {
    color: rgba(255, 255, 255, .65)
}

.search-trigger {
    position: absolute;
    right: 0;
    top: 0;
    width: 32px;
    height: 32px;
    z-index: 2
}

.search-icon-in {
    position: absolute;
    right: 0;
    top: 0;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: #fff;
    opacity: .9;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5))
}

.topnav.is-search-open .search-wrap {
    width: min(520px, 70vw)
}

.topnav.is-search-open .search-field {
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .24);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .08)
}

/* Contenu principal */
#content {
    padding: 0
}

.content {
    --page-x: clamp(12px, 4vw, 24px);
    --content-w: 100vw;
    --content-left: calc((100vw - var(--content-w)) / 2);
    position: relative;
    z-index: 4;
    width: 100%;
    max-width: none;
    margin: 1.5rem 0 5rem;
    padding: 2rem var(--page-x)
}

.section-title {
    font-weight: 800;
    font-size: 1.3rem;
    margin: 0 0 .75rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .6)
}

.after-topnav {
    padding-top: 56px
}

/* Cartes média */
.media-card {
    position: relative;
    z-index: 0;
    flex: 0 0 auto;
    width: var(--card-w, 160px);
    perspective: 900px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .28s ease, transform .28s cubic-bezier(.2, .8, .2, 1)
}

.media-card.is-in {
    opacity: 1;
    transform: none
}

.media-card:hover, .media-card:focus-within {
    z-index: 5
}

/* Poster + glossy */
.poster {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 12px;
    overflow: hidden;
    background: #222;
    transition: transform .28s cubic-bezier(.2, .8, .2, .1);
    transform-origin: center 60%;
    will-change: transform, filter;
    z-index: 0
}

.poster::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08)
}

.poster::after {
    content: "";
    position: absolute;
    top: -20%;
    left: -60%;
    width: 60%;
    height: 140%;
    background: linear-gradient(75deg, rgba(255, 255, 255, .25) 0%, rgba(255, 255, 255, .12) 35%, rgba(255, 255, 255, 0) 60%);
    transform: rotate(12deg) translateX(0);
    filter: blur(2px);
    opacity: .0;
    transition: transform .6s ease, opacity .4s ease;
    pointer-events: none;
    z-index: 3
}

/* Fallback skeleton si image échoue */
.poster.skeleton .info {
    opacity: 1;
    background: linear-gradient(to top, rgba(0, 0, 0, .75) 32%, rgba(0, 0, 0, 0) 100%)
}

.poster.skeleton img {
    display: none !important
}

@media (prefers-reduced-motion: no-preference) {
    .media-card:hover .poster::after, .media-card:focus-within .poster::after {
        transform: rotate(12deg) translateX(220%);
        opacity: .75
    }
}

.media-card:hover .poster, .media-card:focus-within .poster {
    transform: translateY(-10px) scale(1.06) rotateX(2deg) rotateY(-2deg)
}

.poster img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1
}

.poster .info {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(to top, rgba(0, 0, 0, .75) 32%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
    opacity: 0;
    transition: opacity .24s ease;
    padding: .6rem;
    text-align: left;
    z-index: 2
}

.media-card:hover .poster .info, .media-card:focus-within .poster .info {
    opacity: 1
}

/* ===== Tap-to-hover (mobile : 1er tap = hover, 2e = nav) ===== */
@media (hover: none) {
    .poster.is-hover {
        transform: translateY(-10px) scale(1.06) rotateX(2deg) rotateY(-2deg);
    }

    .poster.is-hover::after {
        transform: rotate(12deg) translateX(220%);
        opacity: .75;
    }

    .poster.is-hover .info {
        opacity: 1;
    }
}

.poster .title {
    font-weight: 800;
    font-size: 1rem
}

.poster .meta {
    font-size: .82rem;
    color: #ddd
}

.poster:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px
}

/* Badges */
.media-card .badge {
    z-index: 5
}

.bg-purple {
    background-color: #6f42c1 !important
}

/* Rails horizontaux */
.rail {
    position: relative;
    isolation: isolate
}

.rail-scroll {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    padding: 18px 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    --rail-end-pad: 20px
}

.rail-scroll::-webkit-scrollbar {
    display: none
}

.media-rail {
    display: flex;
    gap: 1rem;
    padding: 0;
    overflow: visible
}

.media-rail::after {
    content: "";
    flex: 0 0 var(--rail-end-pad)
}

/* Full-bleed */
.full-bleed {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    max-width: 100vw
}

.full-bleed .rail-scroll {
    padding-left: calc(var(--content-left) + var(--page-x));
    padding-right: calc(var(--content-left) + var(--page-x));
    --rail-end-pad: calc(var(--content-left) + var(--page-x))
}

/* Scrollbars discrètes (hors root) */
@supports selector(::-webkit-scrollbar) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px
    }

    ::-webkit-scrollbar-track {
        background-color: #0f141a
    }
    ::-webkit-scrollbar-thumb {
        background-color: #33404a;
        border-radius: 4px;
        box-shadow: inset 0 0 0 1px #1a232a
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: #3f4f5c
    }
}

/* Ajustements hauteur écran */
@media (max-height: 900px) {
    .bg-blur, .hero-layer {
        background-position: 50% 30%
    }
}

@media (max-height: 750px) {
    .bg-blur, .hero-layer {
        background-position: 50% 28%
    }
}

/* Shell global */
.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1
}

#content {
    flex: 1 0 auto
}

.app-shell > footer {
    margin-top: auto;
    opacity: .7;
    padding: 2rem 1.5rem;
    text-align: center;
    position: relative;
    z-index: 4
}

/* HERO compact mobile */
@media (max-width: 576px) {
    .hero {
        min-height: 56vh
    }

    .hero-meta-bar {
        padding: .5rem 1rem;
        gap: .25rem
    }

    .hero-meta-top {
        gap: .6rem;
        font-size: .92rem;
        font-weight: 600
    }
    .hero-meta-top span:nth-child(3) {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 70vw;
        opacity: .95
    }

    .hero-meta-bottom img {
        height: 20px
    }

    .hero-meta-bottom span {
        font-size: .95rem
    }
    .hero-logo {
        bottom: 5.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: min(280px, 70vw);
        height: 80px;
        text-align: center
    }
    .hero-title-fallback {
        bottom: 6rem;
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
        width: 90%;
        font-size: clamp(1.3rem, 5.5vw, 2rem)
    }
}

/* RAIL ERROR */
.rail-error {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin: .5rem 0 1.5rem;
    color: #f5f6f7;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .95rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .35)
}

.rail-error strong {
    color: #ff6b6b;
    font-weight: 700
}

.rail-error button {
    margin-left: auto;
    border-radius: 8px;
    padding: .25rem .6rem;
    font-size: .85rem;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .16);
    color: #fff;
    transition: background .2s ease
}

.rail-error button:hover {
    background: rgba(255, 255, 255, .14)
}

/* HTMX page loader (plein écran) */
#page-loader {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center
}

#page-loader.htmx-request {
    display: flex
}

#page-loader .pl-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .25);
    backdrop-filter: blur(4px) saturate(120%);
    transition: opacity .2s ease
}

#page-loader .pl-spinner {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35)
}

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

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    justify-items: start; /* alignement gauche */
    align-items: start;
    margin-top: 1rem
}

.search-card {
    display: flex;
    justify-content: center;
    align-items: stretch
}

/* ===== Episodes (TV) ===== */
.episode-row {
    transition: background-color .18s ease;
    padding: 1rem;
}

.episode-row.with-divider {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

/* Vignettes */
.episode-still {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #222;
}

/* Mobile : plein largeur, ratio 16/9 via padding-top */
.ratio-16x9 {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
}

.cover-abs {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Desktop : largeur fixe + ratio 16/9 via aspect-ratio */
.episode-still--fixed {
    width: 220px;
    aspect-ratio: 16/9;
}

/* Badge numéro d’épisode (en haut à droite) */
.badge-episode {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: .3rem .55rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
    backdrop-filter: saturate(120%) blur(2px);
}

/* Titre + note */
.episode-title {
    margin: 0;
    font-weight: 700;
}

.episode-note.badge {
    background: rgba(0, 209, 255, .15);
    border: 1px solid rgba(0, 209, 255, .35);
    color: #00d1ff;
    font-weight: 700;
}

/* Métadonnées (même couleur que le texte normal) */
.episode-meta {
    margin-top: .25rem;
}

/* Résumé */
.episode-overview {
    margin-top: .5rem;
    margin-bottom: 0;
}

/* ===== Provider Cards (logos en 16/9) ===== */
.provider-card {
    --card-w: 160px; /* même largeur qu'une MediaCard */
}

/* Poster spécifique pour les providers */
.poster--logo {
    aspect-ratio: 16/9; /* ✅ plus “wide”, moins haut */
    background: rgba(255, 255, 255, .05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Logo contenu, pas rogné, bien centré */
.poster--logo img {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    max-width: 70%;
    max-height: 70%;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .45));
    transition: transform .25s ease;
}

/* Léger effet au survol */
.provider-card:hover .poster--logo img,
.provider-card:focus-within .poster--logo img {
    transform: scale(1.06);
}
