/* Atelier Maisons — charger APRÈS fusion.css et terrae-video.css.
 * Activation : body.mc-maison + cinema.mjs, sur les 18 intérieurs seulement.
 * Référence consultée : https://www.masseto.com/en/ (place donnée au film).
 * Noir / ivoire / orange : jetons existants, aucune police ajoutée.
 * Audit : fusion.css fixe déjà le 16:9 / cover ; terrae-video.css le
 * 9:16 / contain et les états de lecture. Aucun sélecteur de média ici.
 * Les wrappers sont les figure.tf-film et .trv-frame DÉJÀ présents.
 */

body.mc-maison .tf-film[data-mc-cinema="landscape"] {
  --mc-cinema-pad: clamp(10px, 1.1vw, 18px);
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  width: calc(100% - 2 * clamp(14px, 3vw, 48px));
  max-width: 1440px;
  margin: clamp(56px, 7vw, 112px) auto clamp(72px, 9vw, 144px);
  padding: var(--mc-cinema-pad);
  background: #000;
  color: var(--tf-ivory, var(--tc-paper, #f4f0e8));
  color-scheme: dark;
}

body.mc-maison .tf-film[data-mc-cinema="landscape"] > figcaption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .42fr);
  align-items: start;
  gap: 24px clamp(24px, 4vw, 64px);
  margin: 0;
  padding: clamp(24px, 3vw, 44px) clamp(8px, 2vw, 30px);
  border: 0;
  border-top: 1px solid var(--tf-orange, #f37021);
  color: inherit;
}

body.mc-maison .tf-film[data-mc-cinema="landscape"] > figcaption > p {
  min-width: 0;
  margin: 0;
}

body.mc-maison .tf-film[data-mc-cinema="landscape"] .tf-film-kicker {
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.7;
}

body.mc-maison .tf-film[data-mc-cinema="landscape"] > figcaption strong {
  max-width: 28ch;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

body.mc-maison .tf-film[data-mc-cinema="landscape"] > figcaption > small {
  align-self: end;
  max-width: 42ch;
  font-size: 14px;
  line-height: 1.7;
  color: inherit;
  overflow-wrap: anywhere;
}

/* Seules les figures contenant un vrai lecteur reçoivent cet attribut.
 * La figure .trv-still voisine, la grille et les textes métier sont intacts.
 * Les placements 12 colonnes existants restent la source de vérité.
 */
body.mc-maison .trv figure[data-mc-cinema="portrait"] {
  box-sizing: border-box;
  min-width: 0;
  padding: clamp(8px, 1vw, 14px);
  background: #000;
  color: var(--tc-paper, #f4f0e8);
  color-scheme: dark;
}

body.mc-maison .trv figure[data-mc-cinema="portrait"] > figcaption {
  max-width: none;
  margin: 0;
  padding: 18px 4px 8px;
  border-top: 1px solid var(--tf-orange, #f37021);
  font-size: 14px;
  line-height: 1.7;
  color: inherit;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

body.mc-maison .trv figure[data-mc-cinema="portrait"] > .trv-frame {
  isolation: isolate;
}

/* Aucun display sur les commandes : le contrat [hidden] reste prioritaire. */
body.mc-maison .trv figure[data-mc-cinema="portrait"] .trv-control {
  min-width: 44px;
  min-height: 44px;
  max-width: calc(100% - 24px);
  white-space: normal;
  background: var(--tc-ink, #06100c);
  color: var(--tc-paper, #f4f0e8);
  border-color: currentColor;
}

body.mc-maison .trv figure[data-mc-cinema="portrait"] .trv-control:focus-visible {
  outline: 2px solid var(--tc-paper, #f4f0e8);
  outline-offset: 3px;
}

/* Décor ajouté uniquement au déclenchement IO. Il n'intercepte aucun geste.
 * Les 72 px inférieurs restent découverts, y compris les commandes natives.
 * Un focus ou pointeur dans le lecteur supprime immédiatement le décor.
 */
body.mc-maison :is(.tf-film, .trv-frame) > .mc-cinema-matte {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

body.mc-maison .tf-film[data-mc-cinema="landscape"] > .mc-cinema-matte {
  inset: var(--mc-cinema-pad) var(--mc-cinema-pad) auto;
  aspect-ratio: 16 / 9;
}

body.mc-maison :is(.tf-film, .trv-frame)[data-mc-cinema-entering] > .mc-cinema-matte {
  opacity: 1;
}

body.mc-maison :is(.tf-film, .trv-frame) > .mc-cinema-matte::before,
body.mc-maison :is(.tf-film, .trv-frame) > .mc-cinema-matte::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 72px;
  width: 50%;
  background: #000;
  opacity: .84;
}

body.mc-maison :is(.tf-film, .trv-frame) > .mc-cinema-matte::before { left: 0; }
body.mc-maison :is(.tf-film, .trv-frame) > .mc-cinema-matte::after { right: 0; }

@media (prefers-reduced-motion: no-preference) and (forced-colors: none) and (prefers-contrast: no-preference) {
  body.mc-maison :is(.tf-film, .trv-frame)[data-mc-cinema-entering] {
    animation: mc-cinema-settle 1000ms cubic-bezier(.2, .7, .2, 1) both;
  }
  body.mc-maison :is(.tf-film, .trv-frame)[data-mc-cinema-entering] > .mc-cinema-matte::before {
    animation: mc-cinema-left 900ms cubic-bezier(.2, .7, .2, 1) both;
  }
  body.mc-maison :is(.tf-film, .trv-frame)[data-mc-cinema-entering] > .mc-cinema-matte::after {
    animation: mc-cinema-right 900ms cubic-bezier(.2, .7, .2, 1) both;
  }
}

/* Scale sur le wrapper existant : 0,8 %, sans overflow/crop ajouté.
 * Pas de transform, object-fit, filtre ou opacité appliqué au video.
 */
@keyframes mc-cinema-settle { from { scale: 1.008; } to { scale: 1; } }
@keyframes mc-cinema-left { to { transform: translateX(-101%); opacity: 0; } }
@keyframes mc-cinema-right { to { transform: translateX(101%); opacity: 0; } }

@media (min-width: 1101px) {
  body.mc-maison .trv .trv-major[data-mc-cinema="portrait"] { max-width: 520px; }
}

/* 390 px : cadre paysage 362 px, image 342 px ; légende sur une colonne.
 * 1440 px : cadre paysage 1353,6 px, image ~1322 px ; légende à deux colonnes.
 * Dimensions théoriques si le parent occupe le viewport, sans rendu effectué.
 */
@media (max-width: 767px) {
  body.mc-maison .tf-film[data-mc-cinema="landscape"] > figcaption {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 24px 8px 20px;
  }
  body.mc-maison .tf-film[data-mc-cinema="landscape"] > figcaption > small {
    align-self: start;
  }
  body.mc-maison .trv .trv-minor[data-mc-cinema="portrait"] {
    width: 76%;
    max-width: 280px;
  }
}

body.mc-maison[data-tc-cine-paused="true"] :is(.tf-film, .trv-frame)[data-mc-cinema-entering],
body.mc-maison :is(.tf-film, .trv-frame)[data-mc-cinema-entering]:focus-within {
  animation: none;
}

body.mc-maison[data-tc-cine-paused="true"] :is(.tf-film, .trv-frame) > .mc-cinema-matte,
body.mc-maison :is(.tf-film, .trv-frame):focus-within > .mc-cinema-matte {
  display: none;
}

@media (prefers-reduced-motion: reduce), (forced-colors: active), (prefers-contrast: more), print {
  body.mc-maison :is(.tf-film, .trv-frame)[data-mc-cinema-entering] { animation: none; }
  body.mc-maison :is(.tf-film, .trv-frame) > .mc-cinema-matte { display: none; }
}

@media (forced-colors: active) {
  body.mc-maison .trv figure[data-mc-cinema="portrait"] .trv-control {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonText;
  }
  body.mc-maison .trv figure[data-mc-cinema="portrait"] .trv-control:focus-visible {
    outline-color: Highlight;
  }
}
