/* (CMS 4.5) Canvas pages (grid-loose.php / ajax/canvas.php, ported from
   Crazy Legs). Items sit where the canvas editor placed them: left and width
   as percentages of the canvas, top in cqw (also a percentage of the canvas
   WIDTH, as in the editor; the ul is an inline-size container). js/site.js
   (sizeCanvases) sets the canvas height to its lowest item and --text-scale
   (canvas width / the editor's 1920px) so text keeps its size relative to the
   canvas. Both views are in the page: the desktop one above 768px, the phone
   one at 768px and under. Text items' typography comes from css/textEntry.css. */

.canvaspage .grid_loose {
  position: relative;
  width: 100%;
}

.canvaspage ul.canvas {
  position: relative;
  width: 100%;
  min-height: 40vh;
  margin: 0;
  padding: 0;
  list-style-type: none;
  container-type: inline-size;
}

.canvaspage ul.canvas-mobile {
  display: none;
}

@media all and (max-width: 768px) {
  .canvaspage ul.canvas-desktop {
    display: none;
  }

  .canvaspage ul.canvas-mobile {
    display: block;
  }
}

.canvaspage ul.canvas > li.item {
  position: absolute;
  margin: 0;
  padding: 0;
  height: auto;
}

.canvaspage ul.canvas .canvasItem {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

/* text items' typography is all css/textEntry.css, shared with the canvas
   editor, so the two can't differ */

/* the item's aspect-ratio (on the li) is the frame: the media fills it */
.canvaspage ul.canvas .mediawrap {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.canvaspage ul.canvas .mediawrap img,
.canvaspage ul.canvas .mediawrap video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.canvaspage ul.canvas .mediawrap video {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.canvaspage ul.canvas .textEntry .textEntry_inner {
  width: 100%;
  zoom: calc(var(--text-scale, 1) * var(--item-text-scale, 1));
}

/* Loops: muted, filling the frame over the still (js/site.js plays them in
   view, or on hover) */
.canvaspage ul.canvas .mediawrap video.canvasLoop {
  opacity: 0;
  transition: opacity 0.3s;
}

.canvaspage ul.canvas .mediawrap video.canvasLoop.playing {
  opacity: 1;
}

/* Full videos, as on a director's page (.vertscroll figure.cell in
   css/styles.css): the play button (.cell .playButton, css/styles.css) swaps
   the player into .videowrap, over the still */
.canvaspage ul.canvas figure.cell {
  margin: 0;
}

.canvaspage ul.canvas figure.cell .videowrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvaspage ul.canvas figure.cell .videowrap video {
  position: absolute;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  object-fit: contain;
}

.canvaspage ul.canvas figure.cell .videowrap .video-js {
  width: 100%;
  height: 100%;
  padding-top: 0;
}

.canvaspage ul.canvas figure.cell .videowrap .video-js.vjs-fullscreen video {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.canvaspage ul.canvas figure.cell.playing .videowrap {
  opacity: 1;
  pointer-events: auto;
}

.canvaspage ul.canvas figure.cell.playing .mediawrap {
  opacity: 0;
}

/* a video's title and caption at its bottom left, as on a director's page
   (.vertscroll figure.cell figcaption, css/styles.css), hidden while it
   plays. Sized to its own cell with container queries, since editors make
   cells any size: on a director's page the title is about 4.4% of its tile's
   width (3.5vw on a tile 80% of the window), 2.2% from the bottom and 3%
   from the left, so these keep those proportions at every cell size. */
.canvaspage ul.canvas figure.cell {
  container-type: inline-size;
}

.canvaspage ul.canvas figure.cell figcaption {
  position: absolute;
  bottom: 2.2cqw;
  left: 3cqw;
  right: 3cqw;
  z-index: 1;
  color: #fff;
  text-align: left;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.3s;
}

.canvaspage ul.canvas figure.cell figcaption h3 {
  font-size: 4.4cqw;
  line-height: 1;
  letter-spacing: -0.03em;
}

.canvaspage ul.canvas figure.cell.playing figcaption {
  opacity: 0;
}
