/*------------------------------------
  Mobile & tablet adjustments
  Loaded after theme.css. Desktop (>= 1200px) is left unchanged.
------------------------------------*/

html,
body {
  overflow-x: hidden;
}

/* ---------- Header on phones: logo centred at the top, the 3 menus centred below ---------- */
@media (max-width: 767.98px) {
  #logoAndNav .navbar {
    flex-wrap: wrap;
    justify-content: center !important;
  }

  #logoAndNav #logo {
    flex: 0 0 100%;
    display: flex;
    justify-content: center;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }

  #logoAndNav #logo img {
    display: block;
    height: 80px;
    width: auto;
  }

  #logoAndNav #catalog,
  #logoAndNav #subscription,
  #logoAndNav #aboutus {
    padding: 0.5rem 0.75rem;
  }
}

/* ‹ › arrows of the film rows (all screens): shown only when there are more posters on that side
   (classes can-prev / can-next set by film-rails.js) */
.rail-wrap {
  position: relative;
}

.rail-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  padding: 0;
  border: 0;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.rail-arrow--prev {
  left: calc(-1 * var(--poster-gap, 0px));
  background: linear-gradient(to right, rgba(14, 13, 18, 0.9), rgba(14, 13, 18, 0));
}

.rail-arrow--next {
  right: calc(-1 * var(--poster-gap, 0px));
  background: linear-gradient(to left, rgba(14, 13, 18, 0.9), rgba(14, 13, 18, 0));
}

.rail-arrow i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(14, 13, 18, 0.75);
  border: 1px solid rgba(245, 202, 153, 0.6);
  color: #f5ca99;
  font-size: 0.8rem;
}

.rail-wrap.can-prev .rail-arrow--prev,
.rail-wrap.can-next .rail-arrow--next {
  opacity: 1;
  pointer-events: auto;
}

/* Gentle nudge on the "next" arrow to invite swiping */
.rail-wrap.can-next:not(.can-prev) .rail-arrow--next i {
  animation: rail-nudge 1.6s ease-in-out 3;
}

@keyframes rail-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

/* ---------- Catalog on desktop (mouse, >= 1200px): one row of 6 posters per category ----------
   Same poster size as the original 6-column grid; more than 6 films: the row scrolls 6 by 6 with the ‹ › arrows
   (or the trackpad). Exact complement of the tablet & mobile media query below. */
@media (min-width: 1200px) and (hover: hover), (min-width: 1200px) and (pointer: fine), (min-width: 1400.02px) {
  .film-rail {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    /* room for the hover zoom (scale 1.05), which the scrolling row would otherwise clip */
    padding-top: 12px;
    padding-bottom: 12px;
    margin-top: -12px;
    margin-bottom: -12px;
  }

  .film-rail::-webkit-scrollbar {
    display: none;
  }

  .film-rail > [class*="col-"] {
    scroll-snap-align: start;
  }

  /* Arrows outside the posters, centred in the page margin (48px at 1200-1480px, wider above) */
  .rail-arrow {
    width: 36px;
    background: none;
  }

  .rail-arrow--prev {
    left: -42px;
  }

  .rail-arrow--next {
    right: -42px;
  }

  .rail-arrow i {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, color 0.2s ease;
  }

  .rail-arrow:hover i,
  .rail-arrow:focus-visible i {
    background: #f5ca99;
    color: #121621;
  }
}

/* ---------- Catalog on tablet & mobile: compact hero + swipeable rows (streaming style) ----------
   Applies to phones, tablets (incl. touch tablets in landscape) and narrow windows.
   Desktop with a mouse (>= 1200px) keeps the original hero, with rows of 6 posters (block above).
   Heights derive from the screen height so that the hero and at least 3 rows fit on screen:
   header + hero + 3 x (row title + poster + gap) = screen height. */
@media (max-width: 1199.98px), (hover: none) and (pointer: coarse) and (max-width: 1400px) {
  :root {
    --screen-h: 100vh;
    --header-h: 96px;
    --hero-h: clamp(150px, calc(var(--screen-h) * 0.28), 340px);
    --rail-title-h: 1.9rem;
    --rail-gap: 0.5rem;
    --rail-gutter: 2.5rem;
    --poster-gap: 0.35rem;
    --poster-h: clamp(90px, calc((var(--screen-h) - var(--header-h) - var(--hero-h)) / 3 - var(--rail-title-h) - var(--rail-gap)), 300px);
  }

  /* Landscape tablets: little height available, so a flatter hero */
  @media (orientation: landscape) {
    :root {
      --hero-h: clamp(150px, calc(var(--screen-h) * 0.22), 340px);
    }
  }

  /* Screen height without the browser's address bar */
  @supports (height: 100svh) {
    :root {
      --screen-h: 100svh;
    }
  }

  /* Hero */
  /* min-height: the carousel script forces "height: auto" on the slides */
  .home-slider .min-h-676rem {
    min-height: var(--hero-h);
  }

  .home-slider .nav-meta {
    font-size: 0.8rem;
  }

  .home-slider .mb-3.pb-1 {
    margin-bottom: 0.4rem !important;
    padding-bottom: 0 !important;
  }

  .home-slider h1.display-12 {
    font-size: clamp(1.4rem, 4vw, 2.5rem);
    margin-bottom: 0.75rem !important;
  }

  .home-slider .btn {
    align-self: flex-start;
    padding: 0.45rem 1.5rem !important;
  }

  .home-slider .slick-pagination {
    margin-bottom: 0.4rem !important;
  }

  /* Rows */
  .catalog-section .container {
    max-width: none;
    padding: 0 var(--rail-gutter) var(--rail-gap) !important;
  }

  .catalog-section .home-section header {
    display: flex !important;
    align-items: center;
    height: var(--rail-title-h);
    margin: 0 !important;
  }

  .catalog-section .home-section header .font-size-24 {
    font-size: 1.15rem;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* No separator line next to the row titles (kept on desktop); Bootstrap's d-lg-block is !important */
  .catalog-section .home-section header > .border-top {
    display: none !important;
  }

  /* The row stays within the page margins: it is clipped exactly at the edge of the last whole poster */
  .film-rail {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    margin-left: calc(-1 * var(--poster-gap)) !important;
    margin-right: calc(-1 * var(--poster-gap)) !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .film-rail::-webkit-scrollbar {
    display: none;
  }

  /* Poster size follows the available height (550x814 format); film-rails.js then sets --poster-slot
     so that a whole number of posters fills the screen width */
  .film-rail > [class*="col-"] {
    flex: 0 0 auto;
    width: var(--poster-slot, calc(var(--poster-h) * 550 / 814 + 2 * var(--poster-gap)));
    max-width: none;
    padding-left: var(--poster-gap) !important;
    padding-right: var(--poster-gap) !important;
    scroll-snap-align: start;
  }

  .film-rail .mb-4 {
    margin-bottom: 0 !important;
  }

  /* No zoom on tap: it would be clipped by the scrolling row */
  .film-rail .image-link:hover .gradient-x-overlay-1 {
    transform: none;
  }

  .film-rail .position-absolute.pl-3 {
    padding: 0 0.5rem 0.4rem !important;
  }

  .film-rail .product-title,
  .film-rail .image-link:hover .product-title {
    font-size: 0.7rem;
    line-height: 1.2;
  }

}


/* Phones */
@media (max-width: 767.98px) {
  :root {
    --header-h: 136px;
    --hero-h: clamp(150px, calc(var(--screen-h) * 0.24), 260px);
    --rail-gutter: 16px;
  }

}

/* Narrow desktop windows (mouse): keep a thin scrollbar so the row can be scrolled */
@media (max-width: 1199.98px) and (hover: hover) and (pointer: fine) {
  .film-rail {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    padding-bottom: 6px;
  }

  .film-rail::-webkit-scrollbar {
    display: block;
    height: 6px;
  }

  .film-rail::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
  }
}

/* ---------- Footer ---------- */
@media (max-width: 767.98px) {
  /* Facebook / Twitter / Vimeo centred: no empty logo link pushing them, no Bootstrap negative margins (mx-n3) */
  footer .border-bottom > a:empty {
    display: none;
  }

  footer .border-bottom > ul {
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    justify-content: center;
  }

  footer .border-bottom > ul > li {
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
  }
}

/* ---------- Intro video: show the whole frame on portrait screens ---------- */
@media (orientation: portrait) {
  #background-video {
    object-fit: contain;
    background: #000;
  }
}

/* Carousel dots always in a row below 1200 px (where d-xl-none shows them): slick calls jQuery .show() on them,
   which writes an inline "display: block" when they are seen as hidden at that moment (dots then stacked on the left) */
@media (max-width: 1199.98px) {
  .home-slider .slick-pagination {
    display: flex !important;
  }
}

/* Very small phones (iPhone SE 1st gen, ...) */
@media (max-width: 374.98px) {
  #logoAndNav #catalog,
  #logoAndNav #subscription,
  #logoAndNav #aboutus {
    font-size: 0.85rem;
    padding: 0.5rem 0.5rem;
  }
}
