/* Shared responsive safety layer for public Arabic and French templates.
   Loaded after page modules so rules below cannot be lost to older bundles. */
@media (max-width: 1024px) {
  .tm-main, .tm-main > *, .tm-main :where(section,article,figure,form,fieldset) { min-width:0; }
  .tm-main :where(img,video,iframe,embed,object) { max-width:100%; }
  .tm-main :where(.tm-entry-content,.entry-content,.tm-story__content,.tm-single-article__content,.tm-en-copy) { min-width:0; max-width:100%; overflow-wrap:anywhere; }
  .tm-main :where(.tm-entry-content,.entry-content,.tm-story__content,.tm-single-article__content,.tm-en-copy) :where(img,video,iframe,embed) { max-width:100%!important; height:auto; }
  .tm-main :where(.tm-entry-content,.entry-content,.tm-story__content,.tm-single-article__content) figure { box-sizing:border-box; min-width:0; max-width:100%!important; width:auto!important; transform:none!important; margin-inline:0!important; }
  .tm-main :where(.tm-entry-content,.entry-content,.tm-story__content,.tm-single-article__content) :is(.wp-block-table,.wp-block-preformatted,.wp-block-code,pre) { max-width:100%; overflow-x:auto; overscroll-behavior-inline:contain; -webkit-overflow-scrolling:touch; }
  .tm-main :where(.tm-entry-content,.entry-content,.tm-story__content,.tm-single-article__content) table { max-width:100%; }
  .tm-main :where(.tm-page-content,.tm-container,.tm-content-section,.tm-workshops-shell,.tm-magazine-archive__container,.tm-en-page) { min-width:0; }
  .tm-main :where(.tm-contact-form,.tm-accreditation-form,.tm-accreditation-form-shell,.tm-accreditation-fields,.tm-accreditation-field) { min-width:0; max-width:100%; }
  .tm-main :where(.tm-contact-form,.tm-accreditation-form) :where(input,textarea,select) { box-sizing:border-box; min-width:0; max-width:100%; }
  .tm-main :where(.tm-contact-form,.tm-accreditation-form) label { min-width:0; overflow-wrap:break-word; }
  .tm-main .tm-workshop-modal__content, .tm-main .tm-workshop-modal__hero {min-width:0;}
}
@media (max-width: 820px) {
  /* The header remains one compact row; the menu expands beneath it. */
  .tm-header .tm-header__mobile { min-width:0; }
  .tm-header .tm-header__mobile .tm-brand { min-width:0; }
  .tm-header .tm-header__mobile .tm-brand__mobile-title { min-width:0; overflow:hidden; }
  .tm-header .tm-menu-toggle, .tm-header .tm-menu-toggle svg { flex-shrink:0; }
  .tm-header .tm-mobile-panel {max-width:100%;}
  /* Poster rails scroll within their own region, never across the page. */
  .tm-main :where(.tm-jury-deck__track,.tm-films-catalog-section__carousel,.tm-workshops-grid,.tm-reels__track,.tm-home-films__track,.tm-home-juries__track) {
    max-width:100%; scroll-padding-inline:8px; -webkit-overflow-scrolling:touch;
  }
  /* Biography and film/portrait dialogs stay within the screen. */
  :is(.tm-home-jury-modal__panel,.tm-home-film-modal__panel,.tm-home-honor-modal__panel,.tm-home-leadership-modal__panel,.tm-reel-dialog__panel,.tm-workshop-modal__panel,.tm-media-lightbox__dialog) {
    box-sizing:border-box; max-width:calc(100vw - 24px); max-height:calc(100dvh - 24px); overflow-y:auto; overscroll-behavior:contain;
  }
  .tm-workshop-modal__panel { border-radius:14px!important; }
  .tm-workshop-modal__content :where(img,p,figure) {max-width:100%;}
  .tm-workshop-trainers article { min-width:0; }
}
@media (max-width: 600px) {
  .tm-main :where(.tm-contact-row,.tm-accreditation-fields) { grid-template-columns:minmax(0,1fr)!important; }
  .tm-main .tm-contact-row > *, .tm-main .tm-accreditation-fields > * {min-width:0;}
  .tm-main :where(.tm-accreditation-form,.tm-contact-form) :where(input,textarea,select) {width:100%;}
  .tm-program-embedded .filters { display:grid!important; grid-template-columns:minmax(0,1fr) auto!important; align-items:stretch; }
  .tm-program-embedded .filters .type-chips { grid-column:1 / -1; display:flex; flex-wrap:wrap; min-width:0; }
  .tm-program-embedded .filters .ctrl:has(input) { min-width:0; grid-column:1 / -1; }
  .tm-program-embedded .filters .ctrl input {width:100%!important; min-width:0;}
  .tm-program-embedded .filters select.ctrl {min-width:0;max-width:100%;}
  .tm-program-embedded .controls {max-width:100%;}
  .tm-program-embedded .daytabs { overscroll-behavior-inline:contain; -webkit-overflow-scrolling:touch; }
  .tm-mediatheque-tools__head {display:flex;flex-wrap:wrap;gap:15px;}
  .tm-mediatheque-tools__head > div {min-width:0;}
  .tm-mediatheque-tools__actions {max-width:100%;min-width:0;display:flex;flex-wrap:wrap;gap:8px;}
  .tm-filter-row {display:grid;grid-template-columns:minmax(0,1fr)!important;}
  .tm-filter-row .tm-filter-select { min-width:0;max-width:100%;}
  .tm-filter-row select {max-width:100%;min-width:0;}
  .tm-magazine-edition__header, .tm-media-section-title, .tm-diary-section-header {min-width:0;flex-wrap:wrap;}
  .tm-main :where(.tm-news-archive-grid,.tm-diary-news-grid,.tm-media-hub__grid,.tm-media-release-grid) > * {min-width:0;}
  .tm-main :where(.tm-accreditation-form,.tm-contact-form) :where(button[type="submit"],.tm-contact-submit) { min-height:44px; }
}
@media(max-width:380px){
  .tm-header .tm-header__mobile {gap:7px;}
  .tm-header .tm-brand__mobile-title {font-size:10px;line-height:1.3;}
  .tm-main :where(.tm-entry-content,.entry-content,.tm-story__content,.tm-single-article__content) blockquote {padding:16px;}
  .tm-workshop-decks .tm-workshop-card__summary {padding-inline:12px!important;}
}
@media (prefers-reduced-motion:reduce){
  .tm-main :where(.tm-jury-deck__track,.tm-films-catalog-section__carousel,.tm-workshops-grid,.tm-reels__track) {scroll-behavior:auto!important;}
}

@media(max-width:820px){
  .tm-jury-deck__navigation button,
  .tm-films-catalog-section__arrow,
  .tm-workshop-deck__nav button,
  .tm-reels__arrow {min-width:44px!important; min-height:44px!important;}
}


/* Home film rail: constrain the grid item to the phone viewport, so posters
   scroll inside the carousel instead of stretching its parent. */
@media (max-width: 820px) {
  .tm-home-blocks > .tm-home-films .tm-home-films__inner {
    min-width: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__carousel-wrap {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 12px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__carousel,
  .tm-home-blocks > .tm-home-films .tm-home-films__carousel.tm-mobile-carousel {
    display: flex !important;
    flex-flow: row nowrap !important;
    grid-column: 1 / -1;
    grid-row: 1;
    justify-content: flex-start !important;
    align-items: stretch;
    box-sizing: border-box !important;
    gap: 14px !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 4px 10px 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    scroll-padding-inline: 10px !important;
    overscroll-behavior-x: contain !important;
    touch-action: pan-x pan-y !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__carousel::-webkit-scrollbar {
    display: none;
  }
  .tm-home-blocks > .tm-home-films .tm-home-film-card {
    flex: 0 0 min(70vw, 250px) !important;
    width: min(70vw, 250px) !important;
    min-width: 0 !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: normal;
  }
  .tm-home-blocks > .tm-home-films .tm-home-film-card[hidden] {
    display: none !important;
  }
  /* Visible accessible navigation complements finger swipes on phones. */
  .tm-home-blocks > .tm-home-films .tm-home-films__arrow {
    position: static !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    grid-row: 2;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    background: #fff !important;
    color: #111318 !important;
    border: 1px solid #bbb6b1 !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    opacity: 1;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__prev {
    grid-column: 1;
    justify-self: end;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__next {
    grid-column: 2;
    justify-self: start;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__arrow[disabled] {
    opacity: .32 !important;
    pointer-events: none;
  }
  .tm-home-blocks > .tm-home-films .tm-home-films__arrow:focus-visible {
    outline: 3px solid #6d91aa;
    outline-offset: 3px;
  }
}
