/* ─── Fonts ─────────────────────────────────────────────── */

@font-face {
  font-family: "ISCitadel";
  src: url("../fonts/ISCitadel-Regular.otf");
  font-weight: 400;
}

@font-face {
  font-family: "ISCitadel";
  src: url("../fonts/ISCitadel-Italic.otf");
  font-weight: 400;
  font-style: italic;
}

@font-face {
  font-family: "ISPlasma";
  src: url("../fonts/ISPlasmaVF.ttf");
}

@font-face {
  font-family: "Modulat";
  src: url("../fonts/ModulatVF.ttf");
}

/* ─── Reset ─────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #888;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #fff;
  color: #000;
  font-family: "ISCitadel", helvetica, sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "onum", "dlig";
}

@media (min-width: 769px) {
  body {
    font-size: 0.9rem;
  }
}

/* ─── Intro video ────────────────────────────────────────── */

.intro-video-wrap {
  position: fixed;
  inset: 0;
  z-index: 200;
  opacity: 1;
  transition: opacity 1s ease;
  pointer-events: none;
}

.intro-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body:not(.intro) .intro-video-wrap {
  opacity: 0;
}

/* ─── Header ─────────────────────────────────────────────── */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 250;
  padding: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  mix-blend-mode: difference;
  color: #fff;
  transition:
    opacity 0.4s ease,
    transform 1s cubic-bezier(0.65, 0, 0.35, 1);
}

body.intro .header {
  transform: translateY(calc(50vh - 2rem));
}

body.intro .grid-view,
body.intro .project-list {
  opacity: 0;
}

.header-name {
  pointer-events: all;
  cursor: default;
}

.header-tagline {
  position: relative;
  display: inline-block;
  pointer-events: all;
  cursor: pointer;
  transition: color 0.2s ease;
}

.header-tagline:hover {
  color: #888;
}

.tagline-default,
.tagline-about,
.tagline-close {
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

.tagline-about,
.tagline-close {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  opacity: 0;
}

.header-project-name {
  pointer-events: all;
  cursor: pointer;
  transition: color 0.2s ease;
}

.header-project-name:hover {
  color: #888;
}

.header-project-about {
  display: inline-block;
  white-space: nowrap;
  vertical-align: bottom;
  font-style: italic;
  padding-right: 0.35em;
}

body.ready .tagline-default {
  opacity: 0;
}

body.ready .tagline-about {
  opacity: 1;
}

.header-tagline.open .tagline-about {
  opacity: 0;
}

.header-tagline.open .tagline-close {
  opacity: 1;
}

/* ─── Grid ───────────────────────────────────────────────── */

.grid-view {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36vw;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  background: transparent;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-top: max(0px, calc((100vh - 36vw) / 16));
  padding-bottom: max(0px, calc((100vh - 36vw) / 16));
  transition:
    opacity 0.4s ease,
    width 0.6s cubic-bezier(0.76, 0, 0.24, 1),
    gap 0.6s cubic-bezier(0.76, 0, 0.24, 1),
    padding-top 0.6s cubic-bezier(0.76, 0, 0.24, 1),
    padding-bottom 0.6s cubic-bezier(0.76, 0, 0.24, 1);
}

.grid-view::-webkit-scrollbar {
  display: none;
}

body.about-open .grid-view {
  opacity: 0.05;
}

.grid-cell {
  position: relative;
  cursor: pointer;
  opacity: 0.1;
  transition: opacity 0.5s linear;
}

.grid-cell.is-focused {
  opacity: 1;
}

/* Plain block wrapper (not a grid item, unlike .grid-cell) that clips
   the oversized, scrolled cover — see the comment on .cell-cover. */
.cell-frame {
  display: block;
  overflow: hidden;
}

/* Rendered larger than its frame (see PARALLAX_SCALE in script.js) so
   the frame's overflow:hidden can clip it while JS nudges it up/down
   on scroll — the image drifts inside its frame instead of the whole
   cell moving. */
.cell-cover {
  display: block;
  width: 100%;
  height: auto;
  will-change: transform;
}

/* ─── Project list ───────────────────────────────────────── */

.project-list {
  position: fixed;
  bottom: 2rem;
  left: 0;
  right: 0;
  z-index: 50;
  text-align: center;
  mix-blend-mode: difference;
  color: #fff;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.project-list-item {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateX(100vw);
  transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
  pointer-events: none;
  white-space: nowrap;
}

.project-list-item.no-transition {
  transition: none;
}

.project-list-item.active {
  transform: translateX(0);
}

.project-list-item.off-left {
  transform: translateX(-100vw);
}

body.about-open .project-list {
  opacity: 0.05;
}

/* ─── About panel ────────────────────────────────────────── */

.about-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 900;
  width: min(85vw, 58rem);
  padding: 0 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: center;
  mix-blend-mode: difference;
  color: #fff;
}

@media (min-width: 769px) {
  #aboutPanel {
    width: min(70vw, 34rem);
  }
}

.about-panel.open {
  opacity: 1;
  pointer-events: all;
}

.about-panel.closing {
  opacity: 1;
  pointer-events: none;
}

.about-row {
  display: block;
}

.about-label {
  display: block;
  text-align: center;
  font-family: "ISCitadel", helvetica, sans-serif;
  font-style: italic;
}

.about-value {
  text-align: center;
}

.project-desc-title {
  font-style: italic;
}

.about-word {
  display: inline-block;
  transform: translateX(-100vw);
  transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.about-word.no-transition {
  transition: none;
}

.about-panel.open .about-word {
  transform: translateX(0);
}

.about-panel.closing .about-word {
  transform: translateX(100vw);
}

.about-contact {
  text-align: center;
}

.about-credits {
  position: fixed;
  bottom: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 900;
  mix-blend-mode: difference;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  color: #fff;
}

body.about-open .about-credits {
  opacity: 1;
  pointer-events: all;
}

/* ─── Page transition ────────────────────────────────────── */

.page-transition {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #fff;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* ─── Project page ───────────────────────────────────────── */

.project-scroll {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: opacity 0.9s ease;
}

body.about-open .project-scroll {
  opacity: 0.05;
}

.project-scroll::-webkit-scrollbar {
  display: none;
}

.project-slide {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  z-index: 1;
}

/* Cover stays put while the rest of the gallery scrolls over it.
   pointer-events: none keeps it out of hit-testing entirely — in Chrome,
   wheel/scroll input over a position: fixed element chains to the
   viewport instead of the DOM ancestor's overflow:auto container, which
   left the page stuck as long as the cover (the very first thing a
   visitor sees) was under the cursor. Removing it from hit-testing lets
   the event fall straight through to #projectScroll. */
.project-cover {
  position: fixed;
  inset: 0;
  min-height: 0;
  z-index: 0;
  pointer-events: none;
  background: #000;
}

.project-cover-spacer {
  width: 100%;
  height: 100vh;
}

.project-cover-whiteout {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.project-slide img,
.project-slide video {
  display: block;
  width: 100%;
  max-height: 100vh;
  object-fit: contain;
}

/* Ponctuel : TB4 a été importée à l'horizontale, on la pivote de 90°
   vers la gauche (sens anti-horaire) pour la remettre à l'endroit.
   Les max-width/max-height sont inversées par rapport à l'usage normal
   car elles s'appliquent AVANT la rotation : une fois tournée de 90°,
   la largeur de la boîte devient sa hauteur visuelle et vice-versa —
   sans cette inversion, l'image déborde de l'écran. */
img[src*="TB4.png"] {
  transform: rotate(-90deg);
  width: auto !important;
  height: auto !important;
  max-width: calc(110vh - 6px) !important;
  max-height: calc(110vw - 3rem) !important;
  object-fit: contain;
}

/* Every image after the cover: same margin on every side (matching
   between images what the sides already give horizontally), aligned
   with the header's own 1.5rem inset, no forced full-viewport slide
   height, and a transparent slide background so the fixed cover shows
   through the gaps as it fades to white beneath. */
.project-slide--fade {
  min-height: 0;
  background: transparent;
}

/* Portrait (default, before the format-detection JS tags the slide
   .is-landscape): width flush between the two 1.5rem side margins
   (matching the header's inset), a 6px vertical gap between stacked
   images (3px top + 3px bottom, since flex-item margins don't
   collapse), and height capped so a tall portrait image approaches
   the screen height instead of overflowing it — the replaced-element
   sizing algorithm then shrinks width below the flush edges to keep
   that height, which is the point for this orientation. */
.project-slide--fade img,
.project-slide--fade video {
  margin: 3px 1.5rem;
  width: calc(100% - 3rem);
  height: auto;
  max-height: calc(100vh - 6px);
}

@media (min-width: 769px) {

  .project-slide.is-landscape img,
  .project-slide.is-landscape video {
    width: 100%;
    height: 100vh;
    max-height: none;
    object-fit: cover;
  }

  /* Landscape images after the cover: no height cap, so width stays
     flush edge to edge — a landscape image is already shorter than
     the screen, so it never needs the portrait's height cap. */
  .project-slide--fade.is-landscape img,
  .project-slide--fade.is-landscape video {
    width: calc(100% - 3rem);
    height: auto;
    max-height: none;
    object-fit: unset;
  }
}

.project-slide--fade {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.project-slide--fade.is-visible {
  opacity: 1;
}

/* Bottom padding matches .project-list's bottom offset on the index
   (2rem / 1rem on mobile) so the copyright — the last flow child —
   sits the same distance from the page's bottom edge as the index
   titles sit from the viewport's. */
.project-footer-slide {
  position: relative;
  width: 100%;
  padding: 6rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4rem;
  background: #fff;
  z-index: 1;
}

.project-description {
  width: 100%;
  max-width: 60rem;
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
}

.project-desc-credits {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: #000;
  text-align: center;
}

.credit-row {
  display: flex;
  gap: 0.4rem;
}

.info-label {
  font-style: italic;
}

.project-copyright {
  text-align: center;
  color: #000;
}

.project-back {
  position: fixed;
  left: 1.5rem;
  bottom: 1.5rem;
  z-index: 300;
}

.project-back-btn {
  width: 2rem;
  height: 2rem;
  border: none;
  background: #000;
  color: #fff;
  font-family: "ISCitadel", helvetica, sans-serif;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 0.2rem;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.project-back-btn:hover {
  background: #fff;
  color: #000;
}

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
  .header {
    padding: 1rem;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 0.1rem;
  }

  .header-tagline {
    display: block;
    width: 100%;
  }

  /* Cover on mobile: shown at its own proportions (max width, height
     following the aspect ratio) instead of being cropped to fill the
     screen. */
  .project-cover img,
  .project-cover video {
    width: 100%;
    height: auto;
    max-height: 100vh;
    object-fit: contain;
  }

  /* Intro video on mobile: shown at its own proportions (max width,
     height following the aspect ratio) instead of being cropped to
     fill the screen — wrap centers it vertically since its rendered
     height will usually be less than 100vh. */
  .intro-video-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
  }

  .intro-video {
    width: 100%;
    height: auto;
    max-height: 100vh;
    object-fit: contain;
  }

  .grid-view {
    width: 66vw;
    gap: 6px;
    padding-top: max(0px, calc((100vh - 66vw) / 16));
    padding-bottom: max(0px, calc((100vh - 66vw) / 16));
  }

  .project-slide {
    min-height: 0;
  }

  .project-slide--fade img,
  .project-slide--fade video {
    margin: 3px 1rem;
    width: calc(100% - 2rem);
  }

  .about-panel {
    width: 96vw;
    padding: 0 0.75rem;
  }

  .project-footer-slide {
    padding: 4rem 1rem 1rem;
    gap: 2.5rem;
  }

  .project-back {
    left: 1rem;
    bottom: 1rem;
  }

  .project-description {
    gap: 2rem;
  }

  .project-list {
    bottom: 1rem;
  }

  .about-credits {
    bottom: 1rem;
  }

  .credit-row {
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
  }
}