/* Adaptive Safety Solutions: the partners strip, between "Waarom wij" and "Diensten" (in place of the key figures).
 * Ported from prototypes/partners-franja (repo ASS-Webpage), with the site's own tokens.
 *
 * At rest (no JavaScript, or reduced motion) the logos stand in one centred row, in colour.
 * With franja.js the strip gets .is-moving: the logos run in one line through a viewfinder in the middle. The one in
 * the viewfinder is in focus (franja.js sets --f from 0 to 1 on each item): its own colours, a little larger. The
 * others wait in grey. Visitors can drag the line (.is-dragging while they do) or tap a logo. No buttons: the
 * client chose to leave out the arrows and the pause button.
 * On the left, the label and a large two-tone headline; the second part in olive.
 * Uses the site's tokens: --paper, --line, --ink, --olive, --mist, --ease-out, and its .wrap and .kicker. */

.franja {
  --franja-logo-k: 0.62;   /* logo size: each logo's --w times this, in px */
  --franja-logo-max: 46px; /* tallest a logo may be */
  --franja-gap: 56px;      /* space between two logos */

  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.franja__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "stage";
  gap: 18px;
  align-items: center;
  padding-block: clamp(48px, 6vw, 96px) clamp(56px, 7vw, 112px);
}

.franja__head {
  grid-area: head;
}

.franja__head .kicker {
  margin-bottom: clamp(14px, 1.6vw, 22px);
}

/* "Vertrouwen verdien je" in ink, "elke dienst opnieuw." in olive: one h2, two tones */
.franja__title {
  max-width: 22ch;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.franja__title span {
  color: var(--olive);
}

.franja__stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
}

.franja__row {
  position: relative;
}

.franja__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px var(--franja-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.franja__item {
  flex: none;
}

.franja__item img {
  display: block;
  width: calc(var(--w) * var(--franja-logo-k) * 1px);
  height: auto;
  max-height: var(--franja-logo-max);
  object-fit: contain;
}

/* The viewfinder only exists while the strip moves */
.franja__finder {
  display: none;
}

/* Provisional until the client confirms the names, the sixth logo and each organisation's permission */
.franja__flag {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--quiet);
}

.franja__flag .flag-inline {
  margin: 0 6px 0 0;
}

/* Moving ------------------------------------------------------------------------------------------------------ */

.franja.is-moving .franja__stage {
  overflow: hidden;
  padding-block: 24px;
  cursor: grab;
  touch-action: pan-y; /* a sideways swipe moves the line; up and down still scroll the page */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 86%, transparent 100%);
}

.franja.is-moving .franja__list {
  flex-wrap: nowrap;
  justify-content: flex-start;
  width: max-content;
  -webkit-user-select: none;
  user-select: none;
  will-change: transform;
}

.franja.is-moving .franja__item {
  cursor: pointer;
}

.franja.is-dragging .franja__stage,
.franja.is-dragging .franja__item {
  cursor: grabbing;
}

/* --f: how far in focus (franja.js); --hover: the logo under the pointer */
.franja.is-moving .franja__item:hover {
  --hover: 1;
}

.franja.is-moving .franja__item img {
  --on: max(var(--f, 0), var(--hover, 0));
  filter: grayscale(calc(1 - var(--on)));
  opacity: calc(0.5 + var(--on) * 0.5);
  transform: scale(calc(1 + var(--f, 0) * 0.08));
  -webkit-user-drag: none;
}

/* The viewfinder: four corners around the logo in focus. franja.js sets its size (--fw, --fh) for each logo; the
   corners move there with transform only. While the line moves they open up and fade a little; when a visitor
   brings a logo in they close in a touch too far first (.is-locked), like a camera finding focus. */
.franja.is-moving .franja__finder {
  --fw: 160px;
  --fh: 84px;
  --open-x: 0px;
  --open-y: 0px;

  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.franja__finder i {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border: 0 solid var(--olive);
  transition: transform 0.55s var(--ease-out), opacity 0.3s;
}

.franja__finder i:nth-child(1) {
  border-top-width: 2px;
  border-left-width: 2px;
  transform: translate(calc(var(--fw) / -2 - var(--open-x)), calc(var(--fh) / -2 - var(--open-y)));
}

.franja__finder i:nth-child(2) {
  border-top-width: 2px;
  border-right-width: 2px;
  transform: translate(calc(var(--fw) / 2 - 14px + var(--open-x)), calc(var(--fh) / -2 - var(--open-y)));
}

.franja__finder i:nth-child(3) {
  border-bottom-width: 2px;
  border-left-width: 2px;
  transform: translate(calc(var(--fw) / -2 - var(--open-x)), calc(var(--fh) / 2 - 14px + var(--open-y)));
}

.franja__finder i:nth-child(4) {
  border-right-width: 2px;
  border-bottom-width: 2px;
  transform: translate(calc(var(--fw) / 2 - 14px + var(--open-x)), calc(var(--fh) / 2 - 14px + var(--open-y)));
}

.franja__finder.is-panning {
  --open-x: 12px;
  --open-y: 6px;
}

.franja__finder.is-panning i {
  opacity: 0.45;
}

.franja__finder.is-locked {
  --open-x: -5px;
  --open-y: -3px;
}

/* The way in (franja.js, initGather) ------------------------------------------------------------------------- */

/* Copies of the logos in a fixed layer: behind the text of "Waarom wij" and of this strip, above their backgrounds */
.franja-gather {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.franja-gather[hidden] {
  display: none;
}

.franja-gather__logo {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform, opacity, filter;
}

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

.stance > .wrap,
.franja__inner {
  position: relative;
  z-index: 1;
}

/* While they are on their way the line's own logos and the viewfinder wait */
.franja.is-gathering .franja__item img {
  visibility: hidden;
}

.franja.is-moving .franja__finder {
  transition: opacity 0.5s ease;
}

.franja.is-gathering .franja__finder {
  opacity: 0;
  transition-duration: 0s;
}

/* Computer (the site's own breakpoint) ----------------------------------------------------------------------- */

@media (min-width: 901px) {
  .franja {
    --franja-logo-k: 0.8;
    --franja-logo-max: 60px;
    --franja-gap: 96px;
  }

  /* The label and the headline on the left, the logos on the right. Half and half: at 4vw each line
     of the headline fits its column from 901 px up. */
  .franja__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "kicker ."
      "title stage";
    gap: 0 clamp(40px, 5vw, 80px);
  }

  /* The logos line up with the middle of the headline itself, not of the label and the headline together */
  .franja__head {
    display: contents;
  }

  .franja__head .kicker {
    grid-area: kicker;
  }

  .franja__title {
    grid-area: title;
    align-self: center;
  }

  .franja__stage {
    align-self: center;
  }

  /* "Vertrouwen verdien je" first, "elke dienst opnieuw." on its own line under it */
  .franja__title span {
    display: block;
  }

}

@media (prefers-reduced-motion: reduce) {
  .franja__finder i {
    transition: none;
  }
}
