/**
 * Moncine — mise en page responsive (mobile, tablette, bureau).
 * Complète style.css ; chargé après.
 */

/* —— Jetons & base mobile —— */

:root {
    --radius: 10px;
    --card: #1a1a22;
    --space-xs: 0.35rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --container-narrow: 40rem;
    --container-wide: 72rem;
    --header-h: 3.75rem;
    --touch-min: 2.75rem;
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

body.is-nav-open {
    overflow: hidden;
}

@media (min-width: 900px) {
    body.is-nav-open {
        overflow: visible;
    }
}

img,
video {
    max-width: 100%;
    height: auto;
}

/* —— Conteneurs —— */

.container {
    width: 100%;
    max-width: var(--container-narrow);
    margin-left: auto;
    margin-right: auto;
    padding-left: max(1rem, var(--safe-left));
    padding-right: max(1rem, var(--safe-right));
    padding-top: var(--space-md);
    padding-bottom: calc(var(--space-md) + var(--safe-bottom));
}

.page-wide .container--wide {
    max-width: min(var(--container-wide), 100%);
}

.site-footer.container {
    padding-top: var(--space-md);
    padding-bottom: calc(var(--space-lg) + var(--safe-bottom));
}

/* —— En-tête & navigation —— */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.site-header .container,
.site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.site-header .container {
    max-width: 100%;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.logo__img {
    width: 2.75rem;
    height: 2.75rem;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: var(--touch-min);
    height: var(--touch-min);
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle__bar {
    display: block;
    width: 1.15rem;
    height: 2px;
    margin: 0 auto;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-header.is-nav-open .nav-toggle__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.site-header.is-nav-open .nav-toggle__bar:nth-child(2) {
    opacity: 0;
}

.site-header.is-nav-open .nav-toggle__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.site-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    order: 3;
    margin: 0;
    padding: 0.35rem 0 0.5rem;
    border-top: 1px solid var(--border);
}

.site-header.is-nav-open .site-nav {
    display: flex;
}

.site-nav__menu {
    width: 100%;
}

.site-nav a {
    display: block;
    margin: 0;
    padding: 0.65rem 0.5rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 1rem;
    border-radius: 6px;
    min-height: var(--touch-min);
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.site-nav a:hover,
.site-nav a:focus-visible {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.site-header nav a {
    margin-left: 0;
}

@media (min-width: 900px) {
    .nav-toggle {
        display: none;
    }

    .site-header .container,
    .site-header__inner {
        flex-wrap: nowrap;
    }

    .site-nav {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        width: auto;
        order: 0;
        gap: 0.15rem 0.35rem;
        padding: 0;
        border-top: none;
    }

    .site-nav a {
        padding: 0.4rem 0.65rem;
        font-size: 0.9rem;
        min-height: auto;
        white-space: nowrap;
    }

    .site-nav__menu {
        width: auto;
    }
}

/* —— Boutons & formulaires tactiles —— */

.btn {
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
}

.btn-sm {
    min-height: 2.25rem;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="date"],
input[type="file"],
select,
textarea {
    font-size: 1rem;
    min-height: var(--touch-min);
}

textarea {
    min-height: 6rem;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="url"],
    input[type="number"],
    input[type="search"],
    input[type="email"],
    input[type="date"],
    select,
    textarea {
        font-size: inherit;
        min-height: auto;
    }

    textarea {
        min-height: 6rem;
    }

    .btn {
        min-height: auto;
    }
}

/* —— Tableaux : défilement horizontal —— */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 0 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.table-scroll .films-table {
    margin: 0;
    min-width: 44rem;
}

.table-scroll .films-table--wide {
    min-width: 52rem;
}

.table-scroll-hint {
    display: block;
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}

@media (min-width: 1100px) {
    .table-scroll {
        overflow-x: visible;
        border: none;
        background: transparent;
    }

    .table-scroll .films-table,
    .table-scroll .films-table--wide {
        min-width: 0;
    }

    .table-scroll-hint {
        display: none;
    }
}

/* —— Page collection —— */

.collection-page__head {
    flex-direction: column;
    align-items: stretch;
}

.collection-page__head .btn,
.film-detail-page__toolbar .btn {
    width: 100%;
}

.collection-search__row {
    flex-direction: column;
    align-items: stretch;
}

.collection-search__row input[type="search"] {
    width: 100%;
    flex: 1 1 auto;
}

.collection-search__row .btn {
    width: 100%;
}

.collection-search__add .btn {
    width: 100%;
}

.form-actions--split .btn {
    width: 100%;
}

.ui-pill-nav,
.ui-pill-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: 100%;
    padding-bottom: 0.15rem;
}

.ui-pill,
.ui-pill-bar__item {
    flex-shrink: 0;
}

.collection-toolbar__tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.collection-toolbar__tab {
    flex-shrink: 0;
}

.collection-toolbar__fields,
.collection-toolbar__fields--inline {
    grid-template-columns: 1fr;
    max-width: none;
}

.collection-toolbar__fields--inline label,
.collection-toolbar__fields--inline select,
.collection-toolbar__fields--inline input,
.collection-toolbar__fields--inline .btn {
    width: 100%;
}

.collection-toolbar__field-narrow {
    max-width: none;
}

@media (min-width: 640px) {
    .collection-toolbar__fields {
        grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
        max-width: 42rem;
    }

    .collection-toolbar__fields--inline label,
    .collection-toolbar__fields--inline select,
    .collection-toolbar__fields--inline input,
    .collection-toolbar__fields--inline .btn {
        width: auto;
    }

    .collection-toolbar__field-narrow {
        max-width: 7rem;
    }
}

.collection-grid-bar {
    flex-direction: column;
    align-items: stretch;
}

.collection-grid-sort {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 0.2rem;
}

.collection-grid-sort__link {
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .collection-page__head {
        flex-direction: row;
        align-items: center;
    }

    .collection-page__head .btn,
    .film-detail-page__toolbar .btn {
        width: auto;
    }

    .collection-search__row {
        flex-direction: row;
        align-items: center;
    }

    .collection-search__row .btn {
        width: auto;
    }

    .collection-search__add .btn {
        width: auto;
    }

    .form-actions--split .btn {
        width: auto;
    }

    .ui-pill-nav,
    .ui-pill-bar {
        flex-wrap: wrap;
        overflow: visible;
    }

    .collection-grid-bar {
        flex-direction: row;
        align-items: center;
    }

    .collection-grid-sort {
        flex-wrap: wrap;
        overflow: visible;
    }
}

/* —— Fiche film —— */

.film-detail {
    grid-template-columns: 1fr;
}

.film-poster--large {
    max-width: 11rem;
    margin: 0 auto 0.5rem;
}

.film-facts {
    font-size: 0.9rem;
}

.film-facts dt {
    padding-top: 0.35rem;
}

@media (min-width: 640px) {
    .film-detail--with-poster {
        grid-template-columns: minmax(140px, 200px) 1fr;
        gap: 1.25rem 1.5rem;
    }

    .film-detail--with-poster .film-poster--large {
        margin: 0;
        max-width: 200px;
    }
}

/* —— Cartes & résultats —— */

.film-card--with-poster {
    grid-template-columns: 1fr;
}

.film-card--with-poster .film-poster {
    max-width: 10rem;
    margin: 0 auto 0.75rem;
}

@media (min-width: 520px) {
    .film-card--with-poster {
        grid-template-columns: 120px 1fr;
    }

    .film-card--with-poster .film-poster {
        max-width: none;
        margin: 0;
    }
}

.result-actions {
    flex-direction: column;
    align-items: stretch;
}

.result-actions .btn,
.result-actions .inline-form {
    width: 100%;
}

.result-actions .inline-form .btn {
    width: 100%;
}

@media (min-width: 520px) {
    .result-actions {
        flex-direction: row;
        align-items: center;
    }

    .result-actions .btn,
    .result-actions .inline-form,
    .result-actions .inline-form .btn {
        width: auto;
    }
}

/* —— Quiz & formulaires —— */

.checkbox-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 400px) {
    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 640px) {
    .checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

.hero h1 {
    font-size: clamp(1.35rem, 4vw, 1.75rem);
}

.hero-actions {
    flex-direction: column;
    align-items: stretch;
}

.hero-actions .btn {
    flex: 1 1 auto;
    min-width: min(100%, 12rem);
    width: 100%;
}

@media (min-width: 520px) {
    .hero-actions {
        flex-direction: row;
        align-items: center;
    }

    .hero-actions .btn {
        width: auto;
    }
}

/* —— Marquer vu & historique —— */

.marquer-vu-form__row {
    flex-direction: column;
    align-items: stretch;
}

.marquer-vu-form__date,
.marquer-vu-form__note {
    width: 100%;
    max-width: none;
}

@media (min-width: 520px) {
    .marquer-vu-form__row {
        flex-direction: row;
        align-items: center;
    }

    .marquer-vu-form__date {
        width: auto;
        flex: 1 1 10rem;
    }

    .marquer-vu-form__note {
        width: auto;
        max-width: 10rem;
    }
}

.viewings-list__item {
    flex-direction: column;
    align-items: flex-start;
}

@media (min-width: 480px) {
    .viewings-list__item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.sagas-page__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 480px) {
    .sagas-page__actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

/* —— Wishlist actions inline —— */

.wishlist-actions .wishlist-promote-form {
    flex-direction: column;
    align-items: stretch;
}

.wishlist-actions select {
    max-width: none;
    width: 100%;
}

@media (min-width: 640px) {
    .wishlist-actions .wishlist-promote-form {
        flex-direction: row;
        align-items: center;
    }

    .wishlist-actions select {
        max-width: 9rem;
        width: auto;
    }
}

/* —— Statistiques —— */

.stats-grid {
    grid-template-columns: repeat(2, 1fr);
}

.note-chart__row {
    grid-template-columns: 1.25rem 1fr 2rem;
    font-size: 0.85rem;
}

.support-chart__row {
    grid-template-columns: 4.5rem 1fr 3.5rem;
}

@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    }

    .note-chart__row {
        grid-template-columns: 1.5rem 1fr 2.5rem;
    }

    .support-chart__row {
        grid-template-columns: 6.5rem 1fr 4.5rem;
    }
}

/* —— Détails ouverts (accordéon) —— */

.film-edit-panel__summary {
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
}

/* —— Utilitaires —— */

@media (max-width: 639px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 640px) {
    .show-mobile-only {
        display: none !important;
    }
}
