/* What We Solve — matches Website Screens/What we solve (Desktop 1–7 at 1440px, Mobile 1–12 at 410px).
   The section is pinned while you scroll through it. js/what-we-solve.js turns the
   scroll position into:
     the intro screen fading away
     --draw on the dashed lines (0 = not drawn, 1 = fully traced)
     each card's position, and where the problem/solution split falls on it
     which background photo is showing */

.wws {
  --wws-gutter: clamp(24px, 4.45vw, 64px);
  /* Card and photo settings (chosen with the tuning sliders) */
  --card-scale: 0.82;
  --card-shape: 0.97;        /* card height relative to the design's proportions */
  --card-title-scale: 1.2;
  --card-text-scale: 1.01;
  --bg-shade: 0.36;          /* black overlay on the photos */
  --head-top: 96px;                         /* sits below the docked nav */
  --title-size: clamp(30px, 3.472vw, 58px); /* 50px at 1440px wide */
  /* the dashed line under the header */
  --across: calc(var(--head-top) + var(--title-size) * 2.5 + 22px);

  position: relative;
  /* 100vh stage + one "beat" of scrolling (75vh) per step; the number of
     beats is set by js/what-we-solve.js from the number of cards */
  height: calc(100vh + var(--beats, 6.6) * var(--beat, 75vh));
  background: var(--black);
  color: var(--white);
}

.wws__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh; /* the full screen with the browser bars hidden, so no gap opens at the
                     bottom when they slide away while you scroll on a phone */
  overflow: hidden;
}

/* ---------- Background photos ---------- */

.wws__bgs,
.wws__bg {
  position: absolute;
  inset: 0;
}

.wws__bg {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

.wws__bgs::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / var(--bg-shade, 0.4)); /* black overlay to darken the photos */
}

/* ---------- Header ---------- */

.wws__head {
  position: absolute;
  top: var(--head-top);
  left: var(--wws-gutter);
  right: var(--wws-gutter);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
}

.wws__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--title-size);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.wws__title em,
.wws__intro-title em {
  font-style: italic;
}

.wws__lede {
  max-width: 36.5vw;
  margin: 0.35em 0 0;
  font-family: var(--font-display);
  font-size: clamp(15px, 1.48vw, 24px);
  line-height: 1.45;
  text-align: right;
}

/* ---------- Dashed lines ---------- */

.wws__line {
  --draw: 0;
  position: absolute;
  pointer-events: none;
}

.wws__line--across {
  top: var(--across);
  top: round(var(--across), 1px); /* whole pixels keep the 1px line crisp */
  left: var(--wws-gutter);
  right: var(--wws-gutter);
  height: 1px;
  background: repeating-linear-gradient(90deg, rgb(255 255 255 / 0.75) 0 12px, transparent 12px 20px);
  clip-path: inset(0 calc((1 - var(--draw)) * 100%) 0 0);
}

.wws__line--down {
  top: calc(var(--across) + 31px);
  bottom: 4.5vh; /* stops short of the bottom edge */
  bottom: calc(4.5vh + 100lvh - 100dvh); /* ...of what's visible, above any browser bar */
  left: 50%;
  left: round(down, 50%, 1px); /* whole pixels keep the 1px line crisp, matching the horizontal one */
  width: 1px;
  background: repeating-linear-gradient(180deg, rgb(255 255 255 / 0.75) 0 12px, transparent 12px 20px);
  clip-path: inset(0 0 calc((1 - var(--draw)) * 100%) 0);
}

/* Phones: the line that sweeps up the screen */
.wws__line--wipe {
  display: none;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgb(255 255 255 / 0.75) 0 10px, transparent 10px 17px);
}

/* ---------- Cards ---------- */

.wws__card {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(min(32.7vw, 56vh, 560px) * var(--card-scale, 1));
  aspect-ratio: calc(471 / 352 / var(--card-shape, 1));
  container-type: inline-size;
  will-change: transform, filter;
}

.wws__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.wws__face--problem {
  justify-content: space-between;
  padding: 7cqw;
  background: var(--beige);
  color: var(--black);
}

.wws__face--solution {
  align-items: center;
  padding: 9.5cqw 7cqw 10cqw;
  background: var(--green);
  color: var(--white);
  text-align: center;
}

.wws__card-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: calc(5.7cqw * var(--card-title-scale, 1));
  line-height: 1.15;
}

.wws__card-text {
  margin: 0;
  font-family: var(--font-mono);
  font-size: calc(3.3cqw * var(--card-text-scale, 1));
  line-height: 1.23;
  text-transform: uppercase;
}

.wws__face--solution .wws__card-text {
  margin-top: 8cqw;
}

.wws__card-logo {
  width: 21.6cqw;
  height: auto;
  margin-top: auto;
}

/* ---------- Intro screen ---------- */

.wws__intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 var(--wws-gutter);
  background: var(--beige);
  color: var(--black);
  text-align: center;
}

.wws__intro-text {
  max-width: 860px;
}

.wws__intro-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 4.1vw, 68px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.wws__intro-lede {
  margin: 0.9em auto 0;
  font-family: var(--font-display);
  font-size: clamp(16px, 1.53vw, 24px);
  line-height: 1.35;
}

/* ---------- Phones and tablets ---------- */

@media (max-width: 959px) {
  .wws {
    /* Phone card size and text, chosen with the sliders */
    --card-scale: 1.08;
    --card-title-scale: 1;
    --card-text-scale: 1;
    --head-top: 80px;
    --title-size: clamp(30px, 8.3vw, 44px);
  }

  .wws__head {
    flex-direction: column;
    gap: 0;
  }

  .wws__lede {
    max-width: 480px;
    margin-top: 16px;
    font-size: 16px;
    line-height: 1.5;
    text-align: left;
  }

  .wws__line--across,
  .wws__line--down {
    display: none;
  }

  .wws__line--wipe {
    display: block;
  }

  .wws__card {
    width: calc(min(69vw, 360px) * var(--card-scale, 1));
    aspect-ratio: calc(282 / 209 / var(--card-shape, 1));
  }

  .wws__face--problem {
    padding: 6cqw;
  }

  .wws__face--solution {
    padding: 6cqw;
  }

  .wws__card-title {
    font-size: calc(7.1cqw * var(--card-title-scale, 1));
  }

  /* "Problem / Heading 01" on two lines, as in the design */
  .wws__face--problem .wws__card-title {
    max-width: 6em;
  }

  .wws__card-text {
    font-size: calc(4.1cqw * var(--card-text-scale, 1));
  }

  .wws__face--solution .wws__card-text {
    margin-top: 5cqw;
  }

  .wws__card-logo {
    width: 24cqw;
  }
}
