/* Phone-only appearance overrides.
   This file is loaded after the shared styles, only at 560px and below.
   Keep changes inside this media query so laptop styling stays independent. */
@media (max-width: 560px) {
  :root {
    --mobile-card-columns: 2;
    --mobile-platform-columns: 6;
    --mobile-card-gap: 8px;
  }

  /* Platforms stay on one line; arrows reveal the rest. */
  .phone-carousel,
  .popular-carousel {
    position: relative;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 24px;
    gap: 6px;
    align-items: center;
    padding-bottom: 0;
  }
  .phone-carousel > button,
  .popular-carousel > .popular-arrow {
    position: static;
    display: grid;
    place-items: center;
    width: 24px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid rgb(var(--primary-rgb) / .35);
    border-radius: 999px;
    background: var(--surface-800);
    color: var(--text);
    font-size: 10px;
    cursor: pointer;
  }
  .phone-carousel > button:disabled { opacity: .25; cursor: default; }
  .phone-carousel > button:hover:not(:disabled) { background: var(--accent-dim); border-color: var(--accent); }
  .phone-platform-carousel > .platform-grid {
    grid-template-columns: none;
    grid-template-rows: 1fr;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - (var(--mobile-platform-columns) - 1) * 6px) / var(--mobile-platform-columns));
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .phone-platform-carousel .platform-grid::-webkit-scrollbar { display: none; }
  .phone-platform-carousel .platform-card { gap: 7px; padding: 4px 0 8px; scroll-snap-align: start; }
  .platform-logo { width: min(44px, 100%); height: auto; aspect-ratio: 1; border-radius: 10px; }
  .platform-name { font-size: 8px; }

  /* Catalog, search results, saved titles, and collection filters. */
  .film-grid {
    grid-template-columns: repeat(var(--mobile-card-columns), minmax(0, 1fr));
    gap: 18px var(--mobile-card-gap);
  }
  #catalog-pagination { gap: 10px; }

  /* Movie rows use a left arrow, a scrolling viewport, and a right arrow. */
  .popular-carousel .popular-grid {
    grid-template-columns: none;
    grid-auto-columns: calc((100% - (var(--mobile-card-columns) - 1) * var(--mobile-card-gap)) / var(--mobile-card-columns));
    column-gap: var(--mobile-card-gap);
    row-gap: 0;
  }

  /* Platform movies/series, recommendations, and chronological title rows. */
  .platform-title-row,
  .detail-poster-row {
    grid-auto-columns: calc((100% - (var(--mobile-card-columns) - 1) * var(--mobile-card-gap)) / var(--mobile-card-columns));
    gap: var(--mobile-card-gap);
  }

  .film-grid .card-info,
  .platform-title-row .film-card .card-info,
  .detail-poster-row .film-card .card-info { padding: 8px 0 0; }
  .film-grid .card-title,
  .platform-title-row .film-card .card-title,
  .detail-poster-row .film-card .card-title { margin-top: 3px; font-size: 11px; }
  .film-grid .card-year,
  .platform-title-row .card-year,
  .detail-poster-row .card-year { font-size: 10px; }
  .film-grid .card-meta,
  .platform-title-row .card-meta,
  .detail-poster-row .card-meta { gap: 3px; margin-top: 5px; font-size: 9px; }
  .film-grid .card-meta > span:first-child,
  .platform-title-row .card-meta > span:first-child,
  .detail-poster-row .card-meta > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .film-grid .card-meta .rating,
  .platform-title-row .card-meta .rating,
  .detail-poster-row .card-meta .rating { flex-shrink: 0; white-space: nowrap; }

  /* Two movie/TV cards per mobile row across every browsing section. */
  body .film-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  body .cinema-rail,
  body .cinema-hero-trending .cinema-rail,
  body .popular-carousel .popular-grid,
  body .platform-title-row,
  body .detail-poster-row {
    grid-template-columns: none !important;
    grid-auto-columns: calc((100% - var(--mobile-card-gap)) / 2) !important;
    column-gap: var(--mobile-card-gap) !important;
  }

  /* Keep the large ranking numbers proportional to the smaller artwork. */
  body .cinema-ranked-rail .cinema-card,
  body .cinema-hero-trending .cinema-card {
    padding-left: clamp(20px, 5vw, 28px);
  }
  body .cinema-ranked-rail .cinema-rank,
  body .cinema-hero-trending .cinema-rank {
    top: 32%;
    left: 0;
    font-size: clamp(46px, 14vw, 68px);
    -webkit-text-stroke-width: 1px;
  }
  body .cinema-hero-trending .cinema-rail { padding-block: 12px 16px; }
  body .cinema-hero-trending .cinema-card-title-in { margin-top: 8px; font-size: 12px; }
  body .cinema-card-info { min-width: 0; gap: 5px; flex-wrap: wrap; font-size: 9px; }
  body .cinema-card-rating { white-space: nowrap; }
  body .cinema-card-media { padding: 3px 5px; font-size: 7px; }
  body .film-grid .card-title { font-size: 12px; }

  /* Movie / TV / All filters match the rounded glass reference on phones. */
  body .cinema-mixed-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  body .cinema-mixed-heading > .cinema-section-tools { display: none; }
  body .cinema-mobile-media-tools {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    max-width: 340px;
  }
  body .cinema-mobile-media-toggle {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 3px;
    padding: 3px;
    border: 1px solid rgb(255 255 255 / .23);
    border-radius: 999px;
    background: rgb(255 255 255 / .07);
    backdrop-filter: blur(16px);
  }
  body .cinema-mobile-media-tools :is(button, a) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 9px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgb(255 255 255 / .7);
    font: 600 clamp(11px, 2.8vw, 12px)/1 "Space Grotesk", sans-serif;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
    text-decoration: none;
    transition: background .2s ease, color .2s ease, box-shadow .2s ease;
  }
  body .cinema-mobile-media-toggle button { flex: 1 1 0; }
  body .cinema-mobile-media-tools .cinema-control-icon { width:14px; height:14px; flex-basis:14px; }
  body .cinema-mobile-media-tools :is(button, a)[aria-pressed="true"] {
    background: #fff;
    color: #111;
    box-shadow: 0 2px 8px rgb(0 0 0 / .12);
  }
  body .cinema-mobile-media-tools .cinema-mobile-media-all {
    flex: 0 0 auto;
    min-width: 70px;
    min-height: 38px;
    padding-inline: 10px;
    border: 1px solid rgb(255 255 255 / .23);
    background: rgb(255 255 255 / .07);
    backdrop-filter: blur(16px);
  }
  body .cinema-mobile-media-all .cinema-control-icon { width:13px; height:13px; flex-basis:13px; }
  @media (max-width:360px) {
    body .cinema-mobile-media-tools { gap:7px; }
    body .cinema-mobile-media-tools :is(button,a) { gap:6px; padding-inline:8px; }
    body .cinema-mobile-media-tools .cinema-mobile-media-all { padding-inline:10px; }
    body .cinema-mobile-media-tools .cinema-control-icon { width:14px; height:14px; flex-basis:14px; }
  }
  body .cinema-mobile-media-tools :is(button, a):focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
  }
  body .cinema-mixed-heading > #my-list-count { order: 3; align-self: flex-start; font-size: 9px; }

  /* Keep two illustrated category cards visible on phones. */
  body #browse-genre .cinema-genre-grid { gap: 7px; }
  body #browse-genre .cinema-genre-chip { min-height: 35px; padding-inline: 12px; font-size: 11px; }
  body .cinema-genre-gallery { margin-top: 0; }
  body .cinema-category-rail {
    grid-auto-columns: calc((100% - var(--mobile-card-gap)) / 2);
    gap: var(--mobile-card-gap);
    padding-block: 8px 18px;
  }
  body .cinema-category-card { padding: 13px 11px; border-radius: 15px; }
  body .cinema-category-name { font-size: clamp(13px, 3.8vw, 18px); }
  body .cinema-category-badge { top: 8px; right: 8px; padding: 4px 7px; font-size: 7px; }
  body .cinema-category-arrow { width: 31px; height: 31px; font-size: 12px; }
  body .cinema-category-arrow.is-previous { left: -12px; }
  body .cinema-category-arrow.is-next { right: -12px; }
}
