/**
 * Portfolio feed (front page only)
 * Modules: single, flicker, series carousel, pair, contact sheet, full bleed, text container.
 * Sizes follow the reference: images are 100vw - 40px wide on phones and
 * 80vw x 70vh (portraits 75vh) from 760px; carousels grow at 1020px; sheets cap at 1440px.
 *
 * @package Peter_Lipton
 * @since 7.0.0
 */

/* ========================================
   BACKGROUND + SCROLL CONTAINER
   ======================================== */

.portfolio-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--color-bg);
  transition: background-color var(--fade);
}

.portfolio-single-view {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow-y: scroll;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.portfolio-single-view::-webkit-scrollbar {
  display: none;
}

.portfolio-slide {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portfolio-slide__content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ========================================
   SINGLE + CAPTION
   ======================================== */

.portfolio-slide__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity var(--fade);
}

.portfolio-slide.is-active .portfolio-slide__figure {
  opacity: 1;
}

.portfolio-slide__image {
  width: calc(100vw - 40px);
  height: auto;
  max-height: calc(100vh - 90px);
  max-height: calc(100svh - 90px);
  object-fit: contain;
}

.portfolio-slide__caption {
  margin-top: 14px;
  font-size: var(--font-size-small);
  line-height: 1.4;
  text-align: center;
  max-width: calc(100vw - 40px);
}

.portfolio-slide__image-caption,
.portfolio-slide__item-caption {
  display: block;
}

.portfolio-slide__image-caption:empty {
  display: none;
}

/* Caption for carousels, pairs, flickers and sheets sits at the bottom of the slide */
.portfolio-slide__caption--overlay {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  margin: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease 0.2s;
}

.portfolio-slide.is-active .portfolio-slide__caption--overlay {
  opacity: 1;
}

@media (min-width: 760px) {
  .portfolio-slide__image {
    width: 80vw;
    height: 70vh;
    height: 70svh;
    max-height: none;
  }

  .portfolio-slide__image--portrait {
    height: 75vh;
    height: 75svh;
  }

  .portfolio-slide__caption {
    max-width: 80vw;
  }
}

/* ========================================
   FULL BLEED
   ======================================== */

.portfolio-slide--full .portfolio-slide__figure {
  width: 100%;
  height: 100%;
}

.portfolio-slide__image--full {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
}

/* ========================================
   FLICKER (frames cycle in place; a click advances)
   ======================================== */

.flicker {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--fade);
}

.portfolio-slide.is-active .flicker {
  opacity: 1;
}

.flicker__frame {
  display: none;
  width: calc(100vw - 40px);
  height: auto;
  max-height: calc(100vh - 90px);
  max-height: calc(100svh - 90px);
  object-fit: contain;
}

.flicker__frame.is-visible {
  display: block;
}

.flicker .text-container.flicker__frame.is-visible {
  display: flex;
  height: 70vh;
  height: 70svh;
  width: auto;
}

@media (min-width: 760px) {
  .flicker__frame {
    width: 80vw;
    height: 70vh;
    height: 70svh;
    max-height: none;
  }

  .flicker__frame--portrait {
    height: 75vh;
    height: 75svh;
  }
}

/* ========================================
   SERIES CAROUSEL
   Neighbours peek in at the edges (--peek: 20px, 60px from 1020px).
   ======================================== */

.carousel {
  position: relative;
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
}

.carousel-left,
.carousel-right {
  display: none;
}

@media (hover: hover) {
  .carousel-left,
  .carousel-right {
    position: absolute;
    z-index: 4;
    width: 50%;
    height: 100%;
    top: 0;
    cursor: pointer;
    display: block;
  }

  .carousel-left { left: 0; }
  .carousel-right { right: 0; }

  .carousel-left.disable,
  .carousel-right.disable {
    cursor: auto;
  }
}

.carousel .holder {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--fade);
}

.portfolio-slide.is-active .carousel .holder {
  opacity: 1;
}

.carousel .holder img,
.carousel .holder .text-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateZ(0);
  z-index: 1;
  opacity: 1;
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
  will-change: transform, opacity;
}

.carousel .holder img {
  max-height: 50vh;
  max-height: 50svh;
  max-width: calc(100vw - 80px);
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: pointer;
}

.carousel .holder .text-container {
  height: 50vh;
  height: 50svh;
  width: auto;
  max-width: calc(100vw - 80px);
}

.carousel .holder .center {
  z-index: 3;
}

.carousel .holder .left {
  transform: translate(calc(-100% - 50vw + var(--peek)), -50%) translateZ(0);
  z-index: 2;
}

.carousel .holder .right {
  transform: translate(calc(50vw - var(--peek)), -50%) translateZ(0);
  z-index: 2;
}

.carousel .holder .left.out {
  transform: translate(calc(-100% - 50vw), -50%) translateZ(0);
  opacity: 0;
  z-index: 1;
}

.carousel .holder .right.out {
  transform: translate(50vw, -50%) translateZ(0);
  opacity: 0;
  z-index: 1;
}

@media (min-width: 1020px) {
  .carousel .holder img {
    max-height: 70vh;
    max-height: 70svh;
  }

  .carousel .holder .text-container {
    height: 70vh;
    height: 70svh;
  }
}

/* ========================================
   PAIR
   Two columns from 760px, each its own slideshow with a 01/05 counter;
   on phones the halves stack, one screen each.
   ======================================== */

.portfolio-slide--pair {
  height: auto;
}

.portfolio-slide--pair .portfolio-slide__content {
  height: auto;
}

.pair {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  opacity: 0;
  transition: opacity var(--fade);
}

.portfolio-slide.is-active .pair {
  opacity: 1;
}

.pair__half {
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pair__item {
  display: none;
  width: calc(100vw - 40px);
  height: auto;
  max-height: calc(100vh - 90px);
  max-height: calc(100svh - 90px);
  object-fit: contain;
}

.pair__item.is-visible {
  display: block;
}

.pair .text-container.pair__item.is-visible {
  display: flex;
  height: auto;
  max-height: none;
}

.pair__counter {
  position: relative;
  top: 10px;
  font-size: 10px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

@media (min-width: 760px) {
  .portfolio-slide--pair {
    height: 100vh;
    height: 100svh;
  }

  .portfolio-slide--pair .portfolio-slide__content {
    height: 100%;
  }

  .pair {
    height: 100%;
    grid-template-columns: 1fr 1fr;
    column-gap: 8.3333vw;
    padding: 0 8.3333vw;
  }

  .pair--portrait {
    column-gap: 13.3333vw;
    padding: 0 13.3333vw;
  }

  .pair__half {
    height: 100%;
  }

  .pair__item {
    width: 100%;
    max-height: 75vh;
    max-height: 75svh;
  }
}

/* ========================================
   CONTACT SHEET (3 columns; click a frame to view it in the carousel)
   ======================================== */

.portfolio-slide--sheet {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}

.portfolio-slide--sheet .portfolio-slide__content {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}

.sheet {
  position: relative;
  width: 100%;
}

.sheet__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--header-h) + 25px) 25px 25px;
  opacity: 0;
  transition: opacity var(--fade);
}

.portfolio-slide.is-active .sheet__grid {
  opacity: 1;
}

.sheet__item {
  display: block;
  padding: 0;
  transition: opacity 0.2s ease;
}

.sheet__item:hover {
  opacity: 0.8;
}

.sheet__item img {
  width: 100%;
  height: auto;
}

.sheet__viewer {
  display: none;
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
}

.sheet.is-open .sheet__grid {
  display: none;
}

.sheet.is-open .sheet__viewer {
  display: block;
}

.sheet__close {
  position: absolute;
  top: var(--header-top);
  left: var(--gutter);
  z-index: 6;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sheet__close svg {
  width: 15px;
  height: 15px;
}

@media (min-width: 760px) {
  .sheet__grid {
    gap: 105px;
    padding: 105px;
  }
}

@media (min-width: 1440px) {
  .sheet__grid {
    max-width: 1230px;
  }
}

/* ========================================
   TEXT CONTAINER (takes an image slot; plain text on the ground)
   ======================================== */

/*
 * Text, padding and spacing scale with the card's width, like an image would:
 * the pixel values (per card or from the Customizer) are the sizes at a card
 * about 500px wide (0.2cqw = 1px there). On top of that, portfolio.js measures
 * each card and sets --tc-fit (0.3 to 2) so the text fills the card without
 * overflowing. Older browsers keep the fixed sizes.
 */
.text-container {
  display: flex;
  justify-content: center;
  aspect-ratio: var(--tc-ratio, 1 / 1);
  overflow: hidden;
  container-type: inline-size;
  background-color: var(--tc-bg, transparent);
  color: var(--tc-color, inherit);
  font-family: var(--tc-font, inherit);
}

/* The text area, aligned per card */
.text-container__inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: var(--tc-align-items, center);
  justify-content: center;
  text-align: var(--tc-align, center);
  font-size: var(--tc-size, var(--font-size));
  font-size: clamp(12px, calc(var(--tc-size-num, 17) * 0.2cqw * var(--tc-fit, 1)), calc(var(--tc-size-num, 17) * 3.2px));
  padding: var(--tc-padding, 40px);
  padding: clamp(12px, calc(var(--tc-padding-num, 40) * 0.2cqw), calc(var(--tc-padding-num, 40) * 1.6px));
  gap: var(--tc-spacing, 20px);
  gap: clamp(6px, calc(var(--tc-spacing-num, 20) * 0.2cqw * var(--tc-fit, 1)), calc(var(--tc-spacing-num, 20) * 3.2px));
}

.text-container__title {
  font-size: calc(1em * var(--tc-title-scale, 1.2));
  font-weight: var(--tc-title-weight, 500);
  line-height: var(--line-height);
}

.text-container__body {
  line-height: var(--line-height);
  margin: 0;
  max-width: 100%;
}

.text-container__link {
  border-bottom: 1px solid currentColor;
}

.portfolio-slide__text {
  height: 70vh;
  height: 70svh;
  width: auto;
  max-width: calc(100vw - 40px);
  opacity: 0;
  transition: opacity var(--fade);
}

.portfolio-slide.is-active .portfolio-slide__text {
  opacity: 1;
}

/* ========================================
   INDEX OVERLAY
   Phones: two columns of 135x90. From 760px: centred rows of 240x200.
   ======================================== */

.portfolio-grid-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--grid-background, var(--color-bg));
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}

.portfolio-grid-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.portfolio-grid-overlay__close {
  position: fixed;
  top: calc(var(--header-top) - 2px);
  left: var(--gutter);
  z-index: 2001;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.2s ease;
}

.portfolio-grid-overlay__close:hover {
  opacity: 0.6;
}

.portfolio-grid-overlay__close svg {
  width: 15px;
  height: 15px;
}

.portfolio-grid-overlay__scroll {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 70px 35px;
}

.portfolio-grid-overlay__container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 35px;
}

.portfolio-grid-item {
  position: relative;
  height: 90px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.portfolio-grid-overlay.is-active .portfolio-grid-item {
  opacity: 1;
}

.portfolio-grid-item__wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portfolio-grid-item__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* A text card in the index fills its cell and keeps its text readable (12px minimum) */
.portfolio-grid-item__text {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  pointer-events: none;
}

@media (min-width: 760px) {
  .portfolio-grid-overlay__scroll {
    padding: calc(var(--header-h) - 37px) 0 40px;
    text-align: center;
    font-size: 0;
  }

  .portfolio-grid-overlay__container {
    display: block;
  }

  .portfolio-grid-item {
    display: inline-block;
    vertical-align: middle;
    width: 240px;
    height: 200px;
    margin: 37px 30px;
  }
}

/* ========================================
   NO CONTENT
   ======================================== */

.portfolio-single-view .no-content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100svh;
  text-align: center;
  padding: 45px;
}
