/* Header: title and line on the left, link on the right */
.head {
  margin-top: clamp(56px, 13vh, 150px);
  padding-bottom: clamp(72px, 12vh, 140px);
}
.title-row {
  --t: clamp(46px, 8vw, 128px);
  grid-column: 1 / 13;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px calc(var(--t) * .27);
}
.lede {
  margin-top: clamp(14px, 2.4vh, 26px);
  font-size: 16px;
  line-height: 1.5;
  color: var(--mut);
  max-width: 60ch;
}
.action {
  position: relative;
  flex: none;
  margin: 9px clamp(20px, 4.6vw, 76px) 0 auto;
  padding-bottom: 9px;
  font-size: calc(clamp(16px, calc(var(--t) * .17), 22px) * 1.15);
  line-height: 1;
}
.action::before,
.action::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
}
.action::before { background: #3a3b3f; }
.action::after {
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .6s var(--ease);
}
.action:is(:hover, :focus-visible)::after { transform: scaleX(1); transform-origin: left; }

/* Header visual: phones (nightmare) or one wide screen (melantha) */
.visual { padding-bottom: clamp(72px, 12vh, 140px); }
.head:has(+ .visual) { padding-bottom: clamp(72px, 12vh, 130px); }

.phones {
  --pw: min(clamp(345px, 21vw, 420px), calc((100vw - 2 * var(--m) - 48px) / 3));
  grid-column: 1 / 13;
  justify-self: center;
  width: 100%;
  max-width: calc(3 * var(--pw) + 2 * clamp(170px, 12vw, 260px));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

/* A phone: the screenshot sits behind Apple's iPhone 16 bezel (1359 x 2736, transparent screen at 90, 90) */
.phone {
  --sx: 6.62%;
  --sy: 3.29%;
  --sw: 86.75%;
  --sh: 93.42%;
  position: relative;
  flex: none;
  width: var(--pw, 150px);
  aspect-ratio: 1359 / 2736;
}
.phone img {
  position: absolute;
  left: var(--sx);
  top: var(--sy);
  width: var(--sw);
  height: var(--sh);
  object-fit: cover;
  border-radius: calc(var(--pw, 150px) * .125);
}
.phone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/iphone-16-black.png") center / 100% 100% no-repeat;
  pointer-events: none;
}

/* A website screenshot */
.shot {
  margin: 0 0 24px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #000;
}
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; }

.visual.wide .shot { grid-column: 1 / 13; justify-self: center; width: 90%; margin: 0; border-radius: 12px; }

/* Sections: label on the left, text on the axis of the home page description */
.sec { border-top: 1px solid var(--line); padding-block: clamp(36px, 6vh, 64px); }
.sec h2 {
  grid-column: 1 / 6;
  font-weight: 300;
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.1;
  letter-spacing: -.035em;
}
.sec .body {
  grid-column: 7 / 12;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 17px;
  line-height: 1.55;
  color: #bdbcb8;
  max-width: 52ch;
}
.sec .body p { text-wrap: pretty; }

.dec { display: flex; flex-direction: column; gap: 6px; }
.dec h3 { font-weight: 400; font-size: 17px; color: var(--fg); }
.dec p { color: var(--mut); }

/* Three columns (nightmare decisions, test steps) or two (melantha flow) */
:is(.decisions, .steps, .flow) .body {
  grid-column: 1 / 13;
  max-width: none;
  display: grid;
  margin-top: clamp(28px, 4vh, 48px);
}
:is(.decisions, .steps) .body { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px clamp(24px, 3vw, 48px); }
.flow .body { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 56px clamp(24px, 3vw, 48px); }

/* Before and after, above each decision */
.pair {
  --pw: min(170px, calc((100vw - 2 * var(--m) - 48px) / 6 - 28px));
  order: -1;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  color: var(--mut);
}
.pair .arr { flex: none; }

/* Results */
.stats { display: flex; flex-wrap: wrap; gap: 20px 56px; }
.stat b {
  display: block;
  font-weight: 300;
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1;
  letter-spacing: -.04em;
  color: var(--fg);
}
.stat span { display: block; margin-top: 10px; font-size: 15px; color: var(--mut); }
/* Optical alignment: the digits 1 and 3 have empty space on their left. */
.stat .optical-1 { margin-left: -.09em; }
.stat .optical-3 { margin-left: -.02em; }

/* Next project */
.next { display: block; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 34px var(--m); }
.next small { display: block; margin-bottom: 10px; font-size: 14px; color: var(--mut); transition: color .4s; }
.next b {
  display: block;
  font-weight: 300;
  font-size: clamp(32px, 4.4vw, 64px);
  line-height: 1.05;
  letter-spacing: -.035em;
}
.next:is(:hover, :focus-visible) small { color: var(--fg); }

/* While Next project is hovered, the rest of the page dims and blurs */
header, main > section, footer { transition: opacity .5s var(--ease), filter .5s var(--ease); }
body:has(.next:is(:hover, :focus-visible)) :is(header, main > section, footer) {
  opacity: .3;
  filter: blur(3px);
}

/* Enlarged screens (js/zoom.js) */
:is(.visual, .steps, .flow) .shot,
.pair .phone { cursor: zoom-in; }
.shot:focus-visible,
.pair .phone:focus-visible { outline: 1px solid var(--fg); outline-offset: 6px; }

#zoom {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 10, .92);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity .35s var(--ease);
}
#zoom.on { opacity: 1; }
#zoom .zs,
#zoom .zp { transform: scale(.96); transition: transform .5s var(--ease); }
#zoom.on .zs,
#zoom.on .zp { transform: none; }
#zoom .zs { width: min(1600px, 92vw, calc(86vh * 1.6)); margin: 0; }
#zoom .zp { --pw: min(640px, 92vw, calc(86vh * .4967)); }
#zoom .x {
  position: absolute;
  top: clamp(14px, 3vh, 28px);
  right: clamp(14px, 3vw, 36px);
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #3a3b3f;
  border-radius: 50%;
  background: rgba(16, 17, 19, .8);
  color: var(--fg);
  cursor: pointer;
  transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}
#zoom .x:is(:hover, :focus-visible) { background: var(--fg); color: var(--bg); border-color: var(--fg); outline: none; }

@media (prefers-reduced-motion: reduce) {
  #zoom, #zoom .zs, #zoom .zp { transition: none; }
}

@media (max-width: 820px) {
  .title-row { flex-direction: column; align-items: flex-start; }
  .action { margin: 4px 0 0; }
  .phones {
    --pw: min(250px, 62vw);
    justify-self: stretch;
    width: auto;
    max-width: none;
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    margin-inline: calc(var(--m) * -1);
    padding-inline: var(--m);
    scroll-padding-inline: var(--m);
  }
  .phones::-webkit-scrollbar { display: none; }
  .phones .phone { scroll-snap-align: start; }
  .sec h2, .sec .body { grid-column: 1 / 13; }
  .sec h2 { margin-bottom: 20px; }
  :is(.decisions, .steps, .flow) .body { grid-template-columns: 1fr; gap: 48px; }
  .pair { --pw: min(140px, 32vw); }
}
