/* ============================================
   Lucky Lot. — Portfolio transition
   The maroon box grows to the size of a portfolio
   slide, the first slide comes down inside it like
   a shutter, then the filmstrip fades in around it.
   Loads after portfolio.css and overrides it.
   Driven by portfolio-transition.js.
   ============================================ */

:root {
  --pt-grow: 2500ms;    /* set at runtime from portfolio-transition.js */
  --pt-shutter: 900ms;
  --pt-fade: 600ms;
}

/* ---------- Panel 3: the final frame ---------- */

/* "Email Henry" leaves the text flow and sits on the arrow's line: its baseline
   meets the bottom of the arrow's lowest dot. The offsets are measured, one per
   type size, because the arrow is dots and has no baseline of its own. */
.center-box a.panel3-email {
  position: absolute;
  left: 39%;
  bottom: 40px;
  margin: 0;
  white-space: nowrap;
}

@media (min-width: 400px) and (max-width: 1200px) {
  .center-box a.panel3-email { bottom: 41px; }
}

@media (max-width: 767px) {
  .center-box a.panel3-email { left: 30%; bottom: 35px; }
}

/* ---------- The slide the box grows into ---------- */

/* Every slide is 16:9. Its size is fixed here, not left to the image, so the box
   has a shape to grow into before any image has loaded, and the first slide sits
   dead centre. It also now fits the width of a narrow screen. */
.portfolio-overlay {
  --pt-gutter: 40px;
  --pt-slide-h: min(80vh, calc((100vw - 2 * var(--pt-gutter)) * 0.5625), calc(100vh - 176px));
  --pt-slide-w: calc(var(--pt-slide-h) * 16 / 9);
}

/* The portfolio lives inside the window the box grew into. The filmstrip is that
   window: exactly one slide in size, so a slide on its way out leaves by the window's
   edge, not the screen's. It sits where slide 1 sat: centred under the header, clear
   of the bottom by the old gallery padding. */
.portfolio-overlay { padding-bottom: 40px; }

.portfolio-gallery {
  flex: none;
  width: var(--pt-slide-w);
  height: var(--pt-slide-h);
  margin: auto;
  padding: 0;
  gap: 0;
  border-radius: 4px;
  scrollbar-width: none;
}

.portfolio-gallery::-webkit-scrollbar { display: none; }

.portfolio-slide {
  height: 100%;
  width: 100%;
  border-radius: 0;
}

.portfolio-slide img {
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) {
  .portfolio-overlay { --pt-gutter: 16px; padding-bottom: 24px; }
}

/* ---------- The overlay fades in; it no longer drops ---------- */

/* The drop from the top now belongs to the first slide alone, inside the box. */
.portfolio-overlay {
  transform: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--pt-fade) ease, visibility 0s linear var(--pt-fade);
}

.portfolio-overlay.active {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition: opacity var(--pt-fade) ease;
}

/* ---------- The growing box ---------- */

/* A full-screen sheet of the box's maroon, seen only through an opening that starts
   on the box and widens to the slide. It sits above the smoke and below the copy. */
.pt-grower {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(173, 134, 134, 0.4);
  /* No transition here: the script steps the clip-path frame by frame. */
}

/* The real box hands its colour to the sheet for the length of the transition. */
.center-box.pt-bare {
  background: transparent;
  pointer-events: none;
}

.pt-shutter {
  position: absolute;
  display: block;
  object-fit: contain;
  transform: translateY(-101%);
  transition: transform var(--pt-shutter) cubic-bezier(0.76, 0, 0.24, 1);
  will-change: transform;
}

.pt-shutter.is-down { transform: translateY(0); }
