/* ==========================================================================
 * Media queries : tactile, tablette, mobile
 *
 * Partiel de style.css. Charge dans l'ordre numerique par les templates :
 * l'ordre est significatif, ne pas permuter les <link>.
 * ========================================================================== */

/* Touch: titres posters toujours visibles (pas de hover) */
@media (hover: none) {
  .poster-overlay {
    opacity: 1;
  }

  .poster-card:hover,
  .poster-grid-item:hover .poster-grid-img,
  .franchise-studio-card:hover,
  .top10-item:hover .top10-poster,
  .top10-item:hover .top10-rank,
  .episode-btn:hover {
    transform: none;
  }

  .poster-card:hover {
    box-shadow: none;
    outline-color: transparent;
  }

  .poster-grid-item:hover .poster-grid-img {
    box-shadow: none;
    outline-color: transparent;
  }
}

@media (max-width: 1024px) {
  .search-modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablette / mobile large : navbar burger + admin */
@media (max-width: 900px) {
  .ps-nav {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .ps-burger {
    display: flex;
    order: 3;
    margin-left: 0.35rem;
  }

  .nav-search-btn {
    order: 2;
    margin-left: auto;
  }

  .ps-search-wrap {
    order: 3;
    max-width: 100%;
    width: 100%;
  }

  .search-suggest {
    max-height: min(50vh, 320px);
  }

  .ps-nav-links {
    display: none;
    order: 4;
    width: 100%;
    flex-direction: column;
    gap: var(--space-1);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
  }

  .ps-nav-actions {
    display: none;
    order: 5;
  }

  .ps-nav.menu-open .ps-nav-actions {
    display: flex;
  }

  .ps-nav.menu-open .ps-nav-links {
    display: flex;
    animation: fadeUp var(--dur-base) ease;
  }

  .ps-nav.menu-open .ps-nav-links .nav-link {
    padding: 0.85rem 0.9rem;
    font-size: 1rem;
    min-height: 44px;
  }

  .ps-nav.menu-open .ps-nav-links .nav-link.active::after {
    display: none;
  }

  .ps-nav.menu-open .ps-nav-links .nav-link.active {
    background: var(--surface);
    color: var(--accent);
  }

  .ps-nav-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    width: 100%;
    margin-left: 0;
    margin-top: 0.35rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
  }

  .nav-user-label {
    display: block;
    max-width: none;
    padding: 0.35rem 0.9rem 0.15rem;
    font-size: 0.85rem;
  }

  .nav-notifications {
    width: 100%;
    padding: 0.35rem 0.9rem;
  }

  .nav-notif-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 0.55rem;
    height: 2.6rem;
    padding: 0 0.85rem;
  }

  .nav-notif-btn::after {
    content: "Notifications";
    font-size: 0.92rem;
  }

  .nav-notif-panel {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: 0.75rem;
    width: auto;
    max-height: 60vh;
  }

  .btn-nav {
    width: 100%;
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    min-height: 44px;
    justify-content: center;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-header {
    flex-direction: column;
  }

  .admin-user-panel {
    width: 100vw;
  }

  .admin-active-titles {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
  }

  .admin-topbar-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: space-between;
  }

  .admin-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.75rem 0.9rem;
    min-height: 44px;
  }

  .admin-users-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-search-field {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .admin-auto-head {
    flex-direction: column;
  }

  .admin-table {
    font-size: 0.78rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.55rem 0.4rem;
  }

  .admin-table-actions {
    flex-direction: column;
  }

  .search-modal {
    padding: 1.25rem 0.85rem 1rem;
  }

  .search-modal-body {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    overflow-y: auto;
  }

  .search-modal-main,
  .search-modal-aside {
    overflow: visible;
  }

  .search-modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-page {
    display: block;
    padding-top: var(--space-5);
  }

  .catalog-filters-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 2.15rem;
    padding: 0 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border-soft);
    background: var(--glass-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
  }

  .catalog-sidebar {
    position: fixed;
    z-index: 80;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(20rem, 88vw);
    max-height: none;
    padding: 5.5rem 1.1rem 1.5rem;
    background: rgba(18, 17, 24, 0.96);
    border-right: 1px solid var(--glass-border-soft);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  .catalog-page.filters-open .catalog-sidebar {
    transform: none;
  }

  .catalog-page.filters-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 79;
    background: rgba(0, 0, 0, 0.55);
  }

  .catalog-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .ps-content {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    padding-bottom: var(--space-10);
  }

  .search-modal {
    padding: 1rem 0.65rem 0.75rem;
    align-items: stretch;
  }

  .search-modal-content {
    width: 100%;
    max-height: calc(100dvh - 1.5rem);
    padding: 0.95rem 0.9rem 1.1rem;
  }

  .search-modal-body {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    overflow-y: auto;
  }

  .search-modal-main,
  .search-modal-aside {
    overflow: visible;
  }

  .search-modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ps-search,
  .search-modal-input,
  .catalog-facet-search,
  .auth-field input,
  .profile-form input,
  select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"] {
    font-size: 16px;
  }

  .page-wrap {
    padding-top: var(--space-5);
    padding-bottom: var(--space-8);
  }

  .page-head {
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
  }

  .page-title {
    font-size: 1.45rem;
  }

  .section-title {
    font-size: 1.05rem;
  }

  .ps-rail-section {
    margin-bottom: 1.75rem;
  }

  .hero-section {
    height: 56vh;
    height: 56dvh;
    min-height: 280px;
    max-height: 520px;
    margin-bottom: var(--space-5);
  }

  .hero-content {
    padding: 1.25rem 1rem 3.25rem;
    max-width: 100%;
  }

  .hero-badge {
    font-size: 0.72rem;
    margin-bottom: 0.55rem;
  }

  .hero-title {
    font-size: clamp(1.45rem, 7vw, 2.1rem);
    margin-bottom: 0.55rem;
  }

  .hero-synopsis {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    margin-bottom: 0.9rem;
  }

  .btn-hero {
    padding: 0.65rem 1.35rem;
    font-size: 0.9rem;
    min-height: 44px;
  }

  .hero-dots {
    bottom: 0.85rem;
    gap: 0.45rem;
  }

  .hero-dot {
    width: 10px;
    height: 10px;
  }

  .hero-dot.active {
    width: 28px;
  }

  .hero-actions {
    gap: 0.5rem;
  }

  .btn-hero-more,
  .btn-hero-list {
    padding: 0.6rem 1rem;
    min-height: 44px;
  }

  .hero-arrow,
  .rail-btn {
    display: none;
  }

  .rail {
    gap: var(--space-3);
    padding-left: 0;
    padding-right: 0;
    scroll-padding-inline: 0;
    -webkit-overflow-scrolling: touch;
  }

  .poster-card {
    width: clamp(110px, 32vw, 150px);
  }

  #panel-home .poster-card.poster-landscape {
    width: clamp(170px, 62vw, 260px);
  }

  .profile-list .poster-card.poster-landscape {
    width: clamp(230px, 78vw, 310px);
  }

  .profile-list-create {
    flex-direction: column;
  }

  .top10-rank {
    font-size: clamp(2.5rem, 12vw, 4rem);
    min-width: 1.75rem;
    -webkit-text-stroke-width: 1.5px;
  }

  .top10-poster {
    width: clamp(90px, 26vw, 120px);
  }

  .top10-item {
    gap: 0.4rem;
  }

  .franchise-studios-section {
    margin-bottom: 1.75rem;
  }

  .franchise-studios-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .franchise-studio-card {
    min-height: 120px;
    padding: 1.1rem 0.75rem;
    gap: 0.45rem;
  }

  .franchise-studio-card img {
    max-width: 120px;
    max-height: 48px;
  }

  .franchise-studio-fallback {
    font-size: 0.95rem;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .filter-more {
    margin-left: 0;
    width: 100%;
    min-height: 44px;
  }

  .profile-stats {
    grid-template-columns: 1fr;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-select,
  .filter-input {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
    padding: 0.65rem 2.25rem 0.65rem 0.85rem;
  }

  .filter-input {
    width: 100%;
  }

  .poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-3);
  }

  .poster-title {
    font-size: 0.72rem;
  }

  .poster-meta {
    font-size: 0.65rem;
  }

  .poster-overlay {
    padding: var(--space-2);
  }

  .pagination {
    gap: 0.35rem;
    margin-top: var(--space-6);
  }

  .pagination-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 0.45rem 0.7rem;
  }

  .pagination-meta {
    width: 100%;
    text-align: center;
    margin-left: 0;
    margin-top: 0.35rem;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    max-height: 92vh;
    max-height: 92dvh;
  }

  .auth-modal-content {
    max-width: 100%;
    padding: 1.5rem 1.1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .detail-tags {
    justify-content: center;
  }

  .loader {
    left: 1rem;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    justify-content: center;
  }

  .watch-player-modal {
    padding: 0;
    align-items: stretch;
  }

  .watch-player-modal-content {
    width: 100%;
    max-width: none;
    max-height: none;
    min-height: 100dvh;
    border-radius: 0;
    padding: 0;
  }

  .watch-player-modal .watch-player-stage {
    max-height: min(42vh, 360px);
    min-height: 0;
    aspect-ratio: 16 / 9;
    border-radius: 0;
  }

  .watch-player-modal .watch-player-info,
  .watch-player-modal .watch-episodes {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .watch-player-modal .watch-episodes {
    min-height: min(48vh, 460px);
  }

  .watch-player-modal .episode-btn {
    max-width: 100%;
    width: 100%;
  }

  .watch-player-stage {
    max-height: none;
    aspect-ratio: 16 / 9;
  }

  .watch-player-info {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.65rem 1rem;
    gap: 0.35rem;
  }

  .ps-player-right {
    width: 100%;
    justify-content: flex-end;
  }

  .ps-player-volume {
    width: 56px;
  }

  .ps-player-time {
    min-width: auto;
  }

  .watch-now-playing {
    font-size: 0.85rem;
    width: 100%;
  }

  .watch-content {
    padding-top: 3.25rem;
    padding-bottom: var(--space-10);
  }

  .watch-hero {
    min-height: clamp(320px, 58vh, 520px);
    margin-bottom: -1.75rem;
  }

  .watch-hero-bg {
    background-position: center top;
  }

  .watch-hero-shade {
    background:
      linear-gradient(
        180deg,
        rgba(18, 17, 24, 0.16) 0%,
        rgba(18, 17, 24, 0.28) 42%,
        rgba(18, 17, 24, 0.72) 78%,
        var(--bg) 100%
      ),
      linear-gradient(90deg, rgba(18, 17, 24, 0.4), rgba(18, 17, 24, 0.12));
  }

  .watch-hero-inner {
    padding-top: 3.5rem;
    padding-bottom: var(--space-10);
    text-align: center;
  }

  .watch-hero .watch-header-text {
    max-width: none;
  }

  .watch-hero .watch-ratings,
  .watch-hero .detail-tags,
  .watch-hero .watch-actions {
    justify-content: center;
  }

  #watch-play-btn {
    min-width: 12rem;
  }

  .watch-overview {
    text-align: left;
    font-size: 0.9rem;
  }

  .watch-ratings,
  .detail-tags {
    justify-content: center;
  }

  .season-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
    margin-bottom: var(--space-4);
  }

  .season-tabs::-webkit-scrollbar {
    display: none;
  }

  .season-tab {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 0.65rem 1.2rem;
    font-size: 0.95rem;
  }

  .episode-list {
    flex-direction: column;
  }

  .episode-btn {
    max-width: 100%;
    width: 100%;
    min-height: 72px;
    padding: 1rem 1.1rem;
  }

  .watch-player-modal .episode-btn {
    max-width: 100%;
    width: 100%;
  }

  .profile-card {
    padding: 1rem 1.1rem;
  }

  .profile-form {
    max-width: none;
  }

  .profile-guest {
    padding: 1.5rem 1rem;
  }

  .admin-page {
    padding: 1rem 1rem 2.5rem;
  }

  .admin-header h1 {
    font-size: 1.4rem;
  }

  .admin-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .stat-card {
    padding: 0.85rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .admin-card {
    padding: 0.95rem;
  }

  .admin-file-row {
    flex-direction: column;
    gap: var(--space-1);
  }

  .admin-users-pagination {
    flex-wrap: wrap;
    gap: 0.65rem;
  }
}

@media (max-width: 480px) {
  .ps-logo {
    font-size: 1.15rem;
  }

  .ps-nav {
    gap: var(--space-2);
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .search-modal-grid {
    grid-template-columns: 1fr;
  }

  .search-modal-chips {
    grid-template-columns: 1fr;
  }

  .ps-content {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .hero-section {
    height: 52vh;
    height: 52dvh;
    min-height: 240px;
  }

  .hero-content {
    padding: 1rem 0.75rem 2.75rem;
  }

  .hero-synopsis {
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .poster-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
  }

  .poster-card {
    width: clamp(100px, 38vw, 130px);
  }

  .franchise-studios-grid {
    grid-template-columns: 1fr;
  }

  .franchise-studio-card {
    min-height: 100px;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.85rem 1rem;
    gap: 0.85rem;
  }

  .franchise-studio-card img {
    max-width: 90px;
    max-height: 40px;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .watch-title {
    font-size: 1.35rem;
  }
}

/* Landscape téléphone : player plus haut */
@media (max-width: 900px) and (orientation: landscape) {
  .hero-section {
    height: 85vh;
    height: 85dvh;
    min-height: 220px;
    max-height: none;
  }

  .watch-player-stage {
    max-height: 100dvh;
    aspect-ratio: auto;
    height: min(100dvh, calc(100vw * 9 / 16 + 80px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Le raccourcissement generique ci-dessus ferait boucler le balayage des
     squelettes toutes les 0.01ms, soit un scintillement. On le coupe net. */
  .skeleton::after {
    animation: none !important;
    opacity: 0;
  }

  .search-modal-field.is-searching .search-modal-icon svg,
  body:has(.search-modal.is-searching) .nav-search-btn svg {
    animation: none !important;
    transform: none;
  }

  .ps-nav,
  .filter-bar,
  .modal-content,
  .search-modal-content,
  .franchise-studio-card,
  .nav-notif-panel,
  .search-suggest,
  .rail-btn,
  .nav-search-btn,
  .ps-search {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
