/* =================================
   TYPOGRAPHY HELPERS
================================= */

.freight-text {
  font-family: "freight-text-pro", serif;
  font-weight: 400;
  font-style: normal;
}

.freight-text-italic {
  font-family: "freight-text-pro", serif;
  font-weight: 400;
  font-style: italic;
}

.freight-text-light {
  font-family: "freight-text-pro", serif;
  font-weight: 300;
  font-style: normal;
}

.freight-sans-book {
  font-family: "freight-sans-pro", sans-serif;
  font-weight: 400;
  font-style: normal;
}

.freight-sans-medium {
  font-family: "freight-sans-pro", sans-serif;
  font-weight: 500;
  font-style: normal;
}


/* =================================
   ROOT / GLOBAL
================================= */

:root {
  --body-font-size: clamp(15px, 1.6vw, 16px);
  --padY: 12px;
  --padX: 2.5vw;

  --ui-font: "freight-sans-pro", sans-serif;
  --ui-weight: 500;
  --ui-size: clamp(16px, 1.4vw, 18px);
  --ui-line: 1.05;
  --ui-letter: 0;
}

html.is-scroll-locked {
  overflow: hidden;
  height: 100%;
}

body {
  background-color: white;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body.is-scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;

  /* viktigt: klipp inte filter-output */
  overflow: visible;
  height: auto;
}

body.is-project-open {
  overflow: hidden;
}

body.is-siteinfo-open {
  overflow: hidden;
}

a {
  text-decoration: none;
  color: black;
}

a:hover,
button:hover,
#modalDescription:hover {
  color: #00ff00;
}


/* =================================
   SHARED UI TYPOGRAPHY
================================= */

.brand,
.workLink,
.headerProjectTitle,
.infoToggle,
.headerClose,
.modalCaption,
#modalDescription {
  font-family: var(--ui-font);
  font-weight: var(--ui-weight);
  font-size: var(--ui-size);
  line-height: var(--ui-line);
  letter-spacing: var(--ui-letter);
  font-style: normal;

  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.siteModalBody,
.textModalBody {
  font-size: var(--body-font-size);
}


/* =================================
   HEADER
================================= */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;

  padding: var(--padY) var(--padX);

  font-family: var(--ui-font);
  font-weight: var(--ui-weight);
  font-size: var(--ui-size);
  line-height: var(--ui-line);
  letter-spacing: var(--ui-letter);
}

.headerCenter {
  position: relative;
  justify-self: center;
  text-align: center;
  align-self: baseline;
  height: 1em;
  line-height: var(--ui-line);
}

.workLink,
.headerProjectTitle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  line-height: var(--ui-line);
}

.headerProjectTitle {
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
  padding: 0;
  isolation: isolate;
  font-style: italic;
}

.headerProjectTitle::before {
  content: "";
  position: absolute;
  inset: -10px -14px;
  background: rgba(240, 240, 240, 0.9);
  filter: blur(18px);
  z-index: -1;
  pointer-events: none;
}


/* Header states */

body.is-project-open .workLink {
  opacity: 0.18;
  filter: blur(5px);
  pointer-events: none;
}

body.is-project-open .headerProjectTitle {
  opacity: 1;
}

body.is-project-open .header .infoToggle,
body.is-siteinfo-open .header .infoToggle {
  opacity: 0.5;
  filter: blur(5px);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.20);
  pointer-events: none;
}

body.is-project-open .headerClose,
body.is-siteinfo-open .headerClose {
  opacity: 1;
  pointer-events: auto;
}


/* Header links/buttons */

.brand,
.link {
  text-decoration: none;
  color: #000;
}

.brand {
  grid-column: 1;
  justify-self: start;
  pointer-events: auto;
  position: relative;
  z-index: 1003;
}

.brandInner {
  position: relative;
  display: inline-block;
  width: fit-content;
  isolation: isolate;
  z-index: 0;
}

.brandInner::before {
  content: "";
  position: absolute;
  inset: -10px -14px;
  background: rgba(240, 240, 240, 0.9);
  filter: blur(18px);
  z-index: -1;
  pointer-events: none;
  opacity: 0;
}

body.is-project-open .brandInner::before,
body.is-siteinfo-open .brandInner::before {
  opacity: 1;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  line-height: var(--ui-line);
}

.nav {
  grid-column: 3;
  justify-self: end;
  position: relative;
  display: block;
  min-height: 1em;
}

.infoToggle,
.headerClose {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  margin: 0;
  line-height: var(--ui-line);
}

.infoToggle {
  z-index: 1001;
  opacity: 1;
  pointer-events: auto;
}

.headerClose {
  z-index: 1002;
  opacity: 0;
  pointer-events: none;
  isolation: isolate;
}

.headerClose::before {
  content: "";
  position: absolute;
  inset: -10px -14px;
  background: rgba(240, 240, 240, 0.9);
  filter: blur(18px);
  z-index: -1;
  pointer-events: none;
}

body.is-project-open .infoToggle,
body.is-siteinfo-open .infoToggle {
  opacity: 0;
  pointer-events: none;
  filter: none;
  text-shadow: none;
}

body.is-project-open .headerClose,
body.is-siteinfo-open .headerClose {
  opacity: 1;
  pointer-events: auto;
}

.link--mobile {
  display: none;
}

.link--desktop {
  display: inline;
}


/* =================================
   MAIN / PAGE LAYOUT
================================= */

.main {
  padding: 16px 2.5vw;
}

#work.main {
  padding-top: 100px;
  padding-bottom: 80px;
}

/* Liquify-freeze på bakgrunden */
body.is-siteinfo-open .main{
  filter: url(#liquifyFreeze);
}

body.is-project-open .workGrid {
  filter: blur(5px);
  opacity: 0.7;
  transition: filter 200ms ease, opacity 200ms ease;
}


/* =================================
   WORK GRID
================================= */

.workGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 60px;
}

.workItem {
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
  will-change: transform;
}

.thumbLink {
  display: block;
  text-decoration: none;
  color: inherit;
}

.thumb {
  background: white;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;

  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Reveal / settle */

.workItem .thumb.is-armed {
  transform: translate3d(0, var(--revealStartY, 34px), 0);
  transition: none;
}

.workItem .thumb.is-settling {
  transform: translate3d(0, 0, 0);
  transition: transform 520ms cubic-bezier(.2, .8, .2, 1);
}

/* Caption */

.caption {
  margin-top: 10px;
  text-align: center;
}

.title {
  font-weight: 500;
  text-align: center;
  display: none;
}


/* =================================
   PROJECT MODAL
================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border: none;
  padding: 0;
  background: transparent;
  overflow: hidden;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 220ms ease, visibility 0s linear 0s;
}

.modalBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);

  opacity: 0;
  transition: opacity 220ms ease;
}

.modal.is-open .modalBackdrop {
  opacity: 1;
}

.modalPanel {
  position: absolute;
  inset: 0;
}


/* =================================
   MODAL FIGURE / LAYOUT
================================= */

.modalFigure {
  position: fixed;
  inset: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;

  background: #fff;

  --ui: #000;
  --halo: #fff;
  --contentLeft: 18vw;
  --topY: calc(env(safe-area-inset-top) + 16px + 2vh);
  --topBarH: 56px;
  --mediaShift: -30px;
  --arrowLift: 50px;

  --edgeL: calc(env(safe-area-inset-left) + 24px);
  --edgeR: calc(env(safe-area-inset-right) + 24px);

  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: calc(env(safe-area-inset-bottom) + 60px);

  display: grid;
  grid-template-rows:
    calc(var(--topY) + var(--topBarH))
    1fr
    auto;
  row-gap: 6px;

  opacity: 0;
 transform: translateY(10px);
 transition: opacity 220ms ease, transform 220ms ease;

}

.modal.is-open .modalFigure {
  opacity: 1;
  transform: translateY(0);
}

body.is-project-open .modalFigure {
  background: transparent;
}

.modalMedia {
  grid-row: 2;
position: relative;

display: flex;
align-items: center;
justify-content: center;

overflow: hidden;

transform: translateY(var(--mediaShift));

}


/* =================================
   CAROUSEL
================================= */

.modalCarousel {
  --gap: 40px;
  --maxH: 80vh;

  height: 100%;
  overflow: hidden;

    touch-action: pan-y;
}

.modalCarousel.is-preparing {
  opacity: 0;
}

.modalCarousel.is-ready {
  opacity: 1;
  transition: opacity 140ms ease;
}

.modalTrack {
  display: flex;
  align-items: center;
  gap: var(--gap);
  will-change: transform;
}

.modalSlide {
  flex: 0 0 auto;
  height: min(var(--maxH), 820px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modalSlideImg {
  height: 100%;
  width: auto;
  max-width: 80vw;
  object-fit: contain;
}


/* User-select / drag */

.modalCarousel,
.modalTrack,
.modalSlide,
.modalSlideImg {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.modalSlideImg {
  -webkit-user-drag: none;
  user-drag: none;
}


/* =================================
   VIDEO SLIDES
================================= */

.modalSlide.is-video {
  background: transparent;
  position: relative;
  display: grid;
  place-items: center;
}

.modalSlide.is-video .modalVideoPoster,
.modalSlide.is-video .modalSlideVideo {
  grid-area: 1 / 1;
  height: 100%;
  width: auto;
  max-width: 73vw;
  object-fit: contain;
  display: block;
}

.modalSlide.is-video .modalVideoPoster {
  opacity: 1;
  transition: opacity 120ms linear;
}

.modalSlide.is-video .modalSlideVideo {
  opacity: 1;
  transition: none;
}

.modalSlide.is-video.is-video-ready .modalVideoPoster {
  opacity: 0;
}


/* =================================
   CLICK ZONES
================================= */

.clickZone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 12;
  cursor: default;
}

.clickZone--prev {
  left: 0;
}

.clickZone--next {
  right: 0;
}

#projectModal.is-multi .clickZone--prev {
  cursor: w-resize;
}

#projectModal.is-multi .clickZone--next {
  cursor: e-resize;
}

#projectModal.is-single .clickZone {
  pointer-events: none;
  cursor: default;
}


/* =================================
   MODAL TEXT / CAPTION
================================= */

#modalDescription {
  position: relative;
  z-index: 40;
  margin: 0;
  padding: 0;
  cursor: pointer;
  color: var(--ui);
  pointer-events: auto;
}

#modalDescription.is-hidden {
  display: none;
}

.modalCaption {
  opacity: 0.85;
  margin: 2px 0;
  text-align: center;
}

.modalCaption:empty {
  display: none;
}

.iconShape {
  fill: var(--ui);
  stroke: var(--halo);
  stroke-width: 0.8;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}


/* =================================
   TEXT MODAL (READ MORE)
================================= */

.textModal {
  position: fixed;
    inset: 0;
    z-index: 30;

    display: flex;
    justify-content: center;
    align-items: center;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 0s linear 180ms;
}

.textModal.is-open {
  opacity: 1;
 visibility: visible;
 pointer-events: none;
 transition: opacity 180ms ease, visibility 0s linear 0s;
}

.textModalInner {
  position: relative;
  box-sizing: border-box;
  width: min(60ch, calc(100vw - 48px));
  max-height: min(70vh, 640px);
  overflow: auto;

  padding: 24px 24px 28px;
  background: var(--descBg, #fff);
  color: var(--ui);

  pointer-events: auto;
 transform: translateY(-30px);

 opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.textModal.is-open .textModalInner {
  opacity: 1;
  transform: translateY(-30px);
}

.textModalBody {
  font-family: "freight-sans-pro", sans-serif;
  font-size: var(--body-font-size);
  line-height: 1.4;
}

.textModalBody p {
  margin: 0 0 0.9em 0;
}

.textModalBody p:last-child {
  margin-bottom: 0;
}


/* =================================
   SITE MODAL (INFO)
================================= */

.siteModal {
  position: fixed;
  inset: 0;
  z-index: 50;

  display: none;
  justify-content: center;
  align-items: center;

  pointer-events: none;
}

.siteModal.is-open {
  display: flex;
  pointer-events: auto;
}

.siteModalInner {
  box-sizing: border-box;
  width: min(60ch, calc(100vw - 48px));
  max-height: min(70vh, 640px);
  overflow: auto;

  padding: 22px 22px 24px;
  background: white;
  color: #000;
}

.siteModalBody {
  font-family: "freight-sans-pro", sans-serif;
  font-size: var(--body-font-size);
  line-height: 1.4;
}

.siteModalBody p,
.textModalBody p {
  margin: 0 0 0.8em 0;
}


/* =================================
   MODAL FOOTER
================================= */

.modalFooter {
  position: fixed;
  left: var(--padX);
  right: var(--padX);
  bottom: calc(env(safe-area-inset-bottom) + var(--padY) + 18px);
  z-index: 20;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.modal.is-open .modalFooter {
  opacity: 1;
  transform: translateY(0);
}

.modalFooterInner {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: calc(100vw - (2 * var(--padX)));
  pointer-events: none;
}

.modalFooterInner::before {
  content: "";
  position: absolute;
  inset: -10px -14px;
  background: rgba(240, 240, 240, 0.9);
  filter: blur(18px);
  z-index: -1;
  pointer-events: none;
}


/* =================================
   RESPONSIVE — GRID
================================= */

@media (max-width: 1200px) {
  .workGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .workGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .main {
    padding: 16px 16px;
  }

  .workGrid {
    grid-template-columns: 1fr;
  }
}


/* =================================
   Liten desktop
================================= */

@media (min-width: 1025px) and (max-width: 1280px) {
  .modalCarousel {
    --gap: 28px;
    --maxH: 76vh;
  }

  .modalSlide {
    height: min(var(--maxH), 820px);
  }

  .modalSlideImg {
    height: 100%;
    width: auto;
    max-width: none;
    object-fit: contain;
  }

  .modalSlide.is-video .modalVideoPoster,
  .modalSlide.is-video .modalSlideVideo {
    height: 100%;
    width: auto;
    max-width: 92vw;
    object-fit: contain;
  }
}

/* =================================
   RESPONSIVE — TABLET
================================= */

@media (min-width: 701px) and (max-width: 1024px) {
  :root {
    --ui-size: 18px;
    --body-font-size: 19px;
  }

  .textModalBody,
  .siteModalBody {
    font-size: 18px;
    line-height: 1.45;
  }

  .modalCarousel {
    --gap: 24px;
    --maxH: 72vh;
  }

  .clickZone {
   display: none;
   pointer-events: none;
 }

  .modalFigure {
    --mediaShift: -20px;
    display: block;
  }

  .modalMedia {
      position: fixed;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      transform: translateY(var(--mediaShift));
    }

  .modalSlide {
    height: min(var(--maxH), 820px);
  }

  .modalSlideImg {
    height: 100%;
    width: auto;
    max-width: none;
    object-fit: contain;
  }

  .modalSlide.is-video .modalVideoPoster,
  .modalSlide.is-video .modalSlideVideo {
    display: block;
   width: auto;
   height: auto;
   max-width: 92vw;
   max-height: var(--maxH);
   object-fit: contain;
  }

  .modalTrack {
  height: 100%;
}
}


/* =================================
   RESPONSIVE — MOBILE
================================= */

@media (max-width: 700px) {
  :root {
    --padX: 16px;
    --padY: 12px;
    --ui-size: 16px;
    --body-font-size: 16px;
  }

  .header {
    align-items: center;
    --padX: 16px;
    --padY: 12px;
  }

  .link--desktop {
    display: none;
  }

  .link--mobile {
    display: inline;
  }

  .clickZone {
  display: none;
  pointer-events: none;
}

  .modalFigure {
    --mediaShift: -6px;
    --arrowLift: 45px;
    display: block;
  }

  .modalMedia {
   position: fixed;
   inset: 0;
   display: flex;
   align-items: center;
   justify-content: center;
   transform: translateY(var(--mediaShift));
 }

  #modalDescription {
    margin-left: 0;
    padding-left: var(--edgeL);
    padding-right: var(--edgeR);
    max-width: calc(100vw - var(--edgeL) - var(--edgeR));
  }


  .modalCarousel {
    --gap: 14px;
    --maxH: 68vh;
  }

  .modalSlide {
    height: auto;
    max-height: var(--maxH);
  }

  .modalSlideImg {
    display: block;
    width: auto;
    height: auto;
    max-width: 92vw;
    max-height: var(--maxH);
    object-fit: contain;
  }

  .modalSlide.is-video .modalVideoPoster,
  .modalSlide.is-video .modalSlideVideo {
    display: block;
    width: auto;
    height: auto;
    max-width: 92vw;
    max-height: var(--maxH);
    object-fit: contain;
  }

  .textModal{
  align-items: center;
}

.textModalInner{
  transform: translateY(-6px);
}

.textModal.is-open .textModalInner {
    transform: translateY(-6px);
  }

.modalTrack {
  height: 100%;
}
}


/* =================================
   RESPONSIVE — SMALL MOBILE
================================= */

@media (max-width: 640px) {
  #vw .brandInner {
    display: none;
  }

  #vw::after {
    content: attr(data-short);
    color: inherit;
    font: inherit;
    font-size: 0.9em;
    letter-spacing: 0.06em;
  }
}
