/* ==========================================================================
   tombruzda.com — v2 — case study components

   Loaded on case study pages only, next to site.css. Everything here is a
   component the three case studies share, taken from the Figma components of
   the same name:

     .project          the page itself   (Frame 1 — 12px margin, 12px stack)
     .project-header   Project/Header    (5198:10673)
     .project-text     Project/Text      (5193:10448)
     .frame / .pair    the media boxes   (ratios 1.6 and 0.8)

   A new case study is those four classes and nothing else; only the copy and
   the media change. Numbers are the design's own at 1440.
   ========================================================================== */

:root {

  /* Cap trim for the project title.
     The design trims that one line to the cap height, so "Trees" sits on the
     48px padding rather than on the invisible slack above its ascenders.
     General Sans: ascender 1.010em, descender .240em, cap height .718em. With
     line-height 1.09375 (64 -> 70) the half-leading is (1.09375 - 1.25)/2 =
     -.078125em, which puts the cap top .2139em below the line box and leaves
     .1619em under the baseline. Pulling exactly that much off each end leaves
     a box .718em tall — the cap height, at any size. */
  --cap-top: -.2139em;
  --cap-bottom: -.1619em;
}

/* ---------------------------------------------------------------- page --
   The design is drawn 1440 wide, but nothing below is a fixed size: the page
   fills the viewport and the media boxes are ratios, so they simply get
   bigger. Only the copy is capped — a 2000px line of 14px text is unreadable
   however much room there is.                                              */

.project {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gutter);
}

/* -------------------------------------------------------------- header --
   Project/Header: the title, then two equal columns 80 apart — the summary
   on the left, the facts on the right.                                     */

.project-header {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: var(--project-pad) 0;
}

.project-title {                 /* Title Large — 64/70, 0 */
  margin: var(--cap-top) 0 var(--cap-bottom);
  font-weight: 400;
  font-size: clamp(40px, 4.445vw, 64px);   /* reaches the 64px ceiling at 1440 */
  line-height: 1.09375;                     /* 64 x 1.09375 = 70 */
  text-transform: capitalize;
}

.project-head-row {
  display: flex;
  align-items: flex-start;
  gap: 80px;
}
.project-head-row > * { flex: 1 1 0; min-width: 0; }

.project-summary {               /* Title 2XSmall — 20/26, +1.5% */
  margin: 0;
  font-size: clamp(17px, 1.389vw, 20px);    /* 1.389vw = 20px at 1440 */
  line-height: 1.3;                          /* 20 x 1.3 = 26 */
  letter-spacing: .015em;                    /* retracked -1% -> +1.5% */
}

.project-info { margin: 0; }

.project-info > div {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.project-info dt,
.project-info dd {               /* Medium — 16/22, no tracking */
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  letter-spacing: 0;
}

.project-info a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------------------------------------------------------------- note --
   Project/Text: a headline and its paragraphs, 16 apart, measure capped at
   the same 668 as one header column. Two paragraphs sit 16 apart as well —
   one flat column does both, exactly as the component does.                */

/* Project/Text as the component stands now: headline Title Large 52/58, body
   Large 18/24 at +1.5%, 24 between them. All three case studies share it. */
.project-text {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 668px;
  padding: var(--project-pad) 0;
}

/* Cap-trimmed like .project-title, same derivation at this line-height:
   content area 1.35em (typo metrics 1010/-240/100), half-leading =
   (58/52 - 1.35)/2, top-to-cap = half-leading + 1.06 - .718. */
.project-text h2 {
  margin: -.2247em 0 -.1727em;
  font-weight: 400;
  font-size: clamp(32px, calc(100vw * 52 / 1440), 52px);   /* 3.611vw = 52px at 1440 */
  line-height: 1.11538;                     /* 58 / 52 */
  letter-spacing: 0;
  max-width: none;
}

.project-text p {               /* Large — 18/24, +1.5% */
  margin: 0;
  font-size: clamp(16px, 1.25vw, 18px);    /* 1.25vw = 18px at 1440 */
  line-height: 1.33333;                     /* 24 / 18 */
  letter-spacing: .015em;
}

/* The component puts 16 between paragraphs and 24 under the headline; the
   flat column gives 24 to both, which only differs if a block ever has two. */
.project-text p + p { margin-top: -8px; }

/* --------------------------------------------------------------- media --
   One box, one ratio, clipped. The image or video is taken out of flow so a
   stacked frame cannot collapse to nothing, and min-width:0 is the same
   insurance the home page needed — Safari counts a loaded file towards a
   grid or flex item's automatic minimum where Chrome resolves it to 0.     */

.frame {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: var(--ar, 1.6);
  background: var(--panel) var(--lqip, none) center / cover no-repeat;
  overflow: hidden;
}

.frame img,
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* These are pictures that happen to move, not players. Some browsers lay
   their own buttons over any video the pointer is on — Opera a pop-out and a
   play control, Edge a picture-in-picture one. With the video out of the
   pointer's way there is nothing for them to attach to; the markup says the
   same thing with disablepictureinpicture and disableremoteplayback. Nothing
   on the page needs the pointer here: the films start by scroll position.
   Videos only — a still keeps its own menu. */
.frame video { pointer-events: none; }

.frame--4-5 { --ar: .8; }

/* Nominally 6:5. The number is the clips' own 1914x1600, which is what the
   design measured too — a flat 1.2 would leave the frame 1.8px short at 1440. */
.frame--6-5 { --ar: 1.19625; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  min-width: 0;
}

/* ------------------------------------------------------- 1199 and below --
   Same two columns, less air between them.                                 */

@media (max-width: 1199px) {
  .project-head-row { gap: 48px; }
}

/* -------------------------------------------------------- 699 and below --
   The header's two columns stack and the pairs go one up, on the same
   breakpoints the home page uses.                                          */

@media (max-width: 699px) {
  .project-header { gap: 24px; }
  .project-head-row { flex-direction: column; gap: 32px; }

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


/* ---------------------------------------------------- next project ------
   The curtain: the case study itself is opaque and sits one layer up, and the
   next project's card is fixed to the bottom of the viewport behind it. The
   margin below .project is the only thing the card can show through, so the
   two must be the same height — hence the shared --next-card-h.

   The background moves to <html> because a z-index:0 fixed element would
   otherwise be painted over by body's own background.                      */

:root {
  /* The design's 1.6 card, but never taller than the space under the sticky
     nav: --nav-h for the bar, then the 12 gutter top and bottom. Without a cap a
     short window would scroll a screenful of nothing to reveal a card whose
     top is off screen anyway. */
  --next-card-h: min(calc((100vw - var(--gutter) * 2) / var(--ar-card)),
                     calc(100svh - var(--nav-h) - var(--gutter) * 2));
}

html { background: var(--ground); }
body { background: none; }

.project {
  position: relative;
  z-index: 1;
  background: var(--ground);
  margin-bottom: calc(var(--next-card-h) + var(--gutter));
}

.next-project {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  display: block;
  padding: 0 var(--gutter) var(--gutter);
}

.next-card {
  position: relative;
  height: var(--next-card-h);
  background: var(--panel) var(--lqip, none) center / cover no-repeat;
  overflow: hidden;
}
.next-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The veil is the component's progressive blur: zero at the top edge, full
   strength at the bottom, with a tint that only ever reaches 24% black. CSS
   has no progressive blur, so it is built from 8 stacked backdrop layers,
   each masked to fade in one band lower than the last.

   The radii are not a linear ramp. Gaussian blurs compose as the square root
   of the sum of squares, so for the STACK to ramp linearly each layer takes
   sqrt(2k-1)/8 of the maximum. Measured against the Figma render row by row,
   this tracks it to within 0.012 of retained detail.

   Figma reports the blur as 100; its radius is twice the CSS one. The maximum
   scales with the card's width so the softness stays proportional on a phone
   instead of washing the whole bottom flat. */
.next-veil {
  position: absolute;
  inset: 50% 0 0;
  pointer-events: none;
  --veil-max: calc((100vw - var(--gutter) * 2) * 50 / 1416);
}
.next-veil span {
  position: absolute;
  inset: 0;
  display: block;
}
.next-veil span:nth-child(1) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.125));
          backdrop-filter: blur(calc(var(--veil-max) * 0.125));
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 12.5%);
          mask-image: linear-gradient(to bottom, transparent 0%, #000 12.5%);
}
.next-veil span:nth-child(2) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.21651));
          backdrop-filter: blur(calc(var(--veil-max) * 0.21651));
  -webkit-mask-image: linear-gradient(to bottom, transparent 12.5%, #000 25%);
          mask-image: linear-gradient(to bottom, transparent 12.5%, #000 25%);
}
.next-veil span:nth-child(3) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.27951));
          backdrop-filter: blur(calc(var(--veil-max) * 0.27951));
  -webkit-mask-image: linear-gradient(to bottom, transparent 25%, #000 37.5%);
          mask-image: linear-gradient(to bottom, transparent 25%, #000 37.5%);
}
.next-veil span:nth-child(4) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.33072));
          backdrop-filter: blur(calc(var(--veil-max) * 0.33072));
  -webkit-mask-image: linear-gradient(to bottom, transparent 37.5%, #000 50%);
          mask-image: linear-gradient(to bottom, transparent 37.5%, #000 50%);
}
.next-veil span:nth-child(5) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.375));
          backdrop-filter: blur(calc(var(--veil-max) * 0.375));
  -webkit-mask-image: linear-gradient(to bottom, transparent 50%, #000 62.5%);
          mask-image: linear-gradient(to bottom, transparent 50%, #000 62.5%);
}
.next-veil span:nth-child(6) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.41458));
          backdrop-filter: blur(calc(var(--veil-max) * 0.41458));
  -webkit-mask-image: linear-gradient(to bottom, transparent 62.5%, #000 75%);
          mask-image: linear-gradient(to bottom, transparent 62.5%, #000 75%);
}
.next-veil span:nth-child(7) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.45069));
          backdrop-filter: blur(calc(var(--veil-max) * 0.45069));
  -webkit-mask-image: linear-gradient(to bottom, transparent 75%, #000 87.5%);
          mask-image: linear-gradient(to bottom, transparent 75%, #000 87.5%);
}
.next-veil span:nth-child(8) {
  -webkit-backdrop-filter: blur(calc(var(--veil-max) * 0.48412));
          backdrop-filter: blur(calc(var(--veil-max) * 0.48412));
  -webkit-mask-image: linear-gradient(to bottom, transparent 87.5%, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 87.5%, #000 100%);
}

/* The tint rides on top of the blur, as the component's own fill does. */
.next-card::after {
  content: "";
  position: absolute;
  inset: 50% 0 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .24));
}

/* The same zoom the home-page cards get: 1.08 over 500ms on Tom's mirrored
   curve. It sits behind the veil, so the progressive blur re-samples the
   growing image and the blurred half grows with it for free.

   The transition has to repeat the opacity leg from site.css — one element
   cannot hold two `transition` declarations, and this file is loaded second,
   so naming only `transform` here would drop the fade. */
@media (hover: hover) {
  .next-card img {
    transform: scale(1);
    transition: transform 500ms cubic-bezier(0, .8, .8, 1), var(--fade-in);
  }
  .next-project:hover .next-card img { transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .next-card img,
  .next-project:hover .next-card img { transform: none; transition: none; }
}

/* z-index because ::after is the element's LAST child in paint order, so the
   scrim would otherwise be drawn over this text, not under it. */
.next-text {
  position: absolute;
  z-index: 1;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Title XLarge, cap-trimmed with the same numbers as .project-title */
.next-name {
  margin: var(--cap-top) 0 var(--cap-bottom);
  font-weight: 400;
  font-size: clamp(40px, 4.445vw, 64px);
  line-height: 1.09375;
}
