/* ==========================================================
   CANTICA EMBED NATURAL FLOW V1

   Objectif :
   - aucun scroll vertical interne hors plein écran ;
   - l'iframe prend la hauteur réelle de la présentation ;
   - le scroll vertical appartient à la page Cantica ;
   - le plein écran natif SolfaSync reste inchangé.
   ========================================================== */

html.cantica-embed-presentation,
html.cantica-embed-presentation body {
  min-height: 0 !important;
  height: auto !important;
}

html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode) {
  min-height: 0 !important;
  height: auto !important;
  block-size: auto !important;
  overflow: visible !important;
  padding: 0 !important;
}

/*
 * Dans l'embed, la toolbar ne doit jamais recouvrir
 * la première ligne SATB pendant le scroll de Cantica.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-toolbar {
  position: static !important;
  top: auto !important;
}

/*
 * Le layout participe à la hauteur naturelle du document.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-layout {
  height: auto !important;
  block-size: auto !important;
  min-height: 0 !important;
  align-items: start !important;
}

/*
 * Le panneau Configuration n'a plus son propre scroll vertical.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-settings {
  position: static !important;
  top: auto !important;
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

/*
 * Point essentiel :
 * suppression du viewport interne de presentationStage.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-stage {
  height: auto !important;
  block-size: auto !important;
  min-height: 0 !important;
  min-block-size: 0 !important;

  overflow: visible !important;

  scroll-snap-type: none !important;
  scroll-padding-block: 0 !important;
  scroll-behavior: auto !important;
}

/*
 * Chaque écran devient un bloc naturel du document Cantica.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-screen {
  min-height: 0 !important;
  min-block-size: 0 !important;
  height: auto !important;
  block-size: auto !important;

  scroll-snap-align: none !important;
}

/*
 * Le corps musical conserve uniquement son éventuelle
 * gestion horizontale lorsqu'une mesure est trop large.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-score-body {
  overflow-y: visible !important;
}

/*
 * Filet de sécurité pour les règles mobiles SolfaSync
 * qui utilisent normalement un viewport de lecture propre.
 */
html.cantica-embed-presentation
body.presentation-mobile-reading {
  height: auto !important;
  min-height: 0 !important;
  overflow-y: visible !important;
}


/* ==========================================================
   CANTICA EMBED VERTICAL FINISH V1

   Cantica utilise la présentation comme document vertical :
   toutes les mesures restent dans le flux et la dernière
   mesure bénéficie d'un espace respiratoire contrôlé.
   Ne s'applique jamais au fullscreen natif SolfaSync.
   ========================================================== */

html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-stage {
  /*
   * Espace de respiration après la dernière mesure.
   * Il fait partie de la surface sombre elle-même.
   */
  padding-bottom:
    clamp(34px, 4vw, 58px) !important;

  border-radius:
    16px !important;
}

/*
 * Le mode Focus de SolfaSync reste utile dans SolfaSync,
 * mais dans l'embed Cantica il ne doit jamais retirer
 * les mesures déjà parcourues du document.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-screen.presentation-past-line {
  display:
    grid !important;
}

/*
 * Dans Cantica, current / next / past ne modifient
 * plus la géométrie verticale de la partition.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-screen.presentation-current-line,

html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-screen.presentation-next-line,

html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-screen.presentation-past-line {
  min-height:
    0 !important;

  min-block-size:
    0 !important;

  opacity:
    1 !important;

  filter:
    none !important;

  transform:
    none !important;
}

/*
 * Neutralise aussi les dimensions spéciales du
 * "reading window" mobile.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-stage.presentation-reading-window
.presentation-screen.presentation-current-line,

html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-stage.presentation-reading-window
.presentation-screen.presentation-next-line {
  min-height:
    0 !important;

  min-block-size:
    0 !important;

  scroll-snap-align:
    none !important;
}

/*
 * Une fin nette : pas de marge parasite après
 * la dernière carte de mesures.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-screen:last-child {
  margin-bottom:
    0 !important;
}

/*
 * Petit espace sombre entre le contenu final et
 * la limite inférieure de l'iframe.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode) {
  padding-bottom:
    clamp(14px, 2vw, 24px) !important;

  background:
    #081322 !important;
}

/* CANTICA MOBILE STAGE NATURAL HEIGHT V1 */

/*
 * Diagnostic runtime :
 *
 * presentationStage :
 *   height      ≈ 422 px
 *   scrollHeight = 570 px
 *   max-height  ≈ 422 px
 *
 * La mesure 2 déborde donc hors du fond sombre.
 *
 * Dans l'embed Cantica mobile, le stage doit suivre
 * naturellement la hauteur de son contenu.
 */
html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
#presentationStage,

html.cantica-embed-presentation
.presentation-page:not(:fullscreen):not(.theater-mode)
.presentation-stage {
  max-height:
    none !important;

  height:
    auto !important;

  block-size:
    auto !important;

  overflow-y:
    visible !important;
}

/* END CANTICA MOBILE STAGE NATURAL HEIGHT V1 */


/* CANTICA MOBILE THEATER ISOLATION V1
   ============================================================
   Le mode embed naturel appartient uniquement à la consultation
   dans Cantica.

   Lorsque SolfaSync passe en theater-mode, les règles natives
   de présentation plein écran reprennent entièrement la main.
   ============================================================ */

/* END CANTICA MOBILE THEATER ISOLATION V1 */
