/* ===========================================================================
   Homepage — hero, the two statements, the collage, the two frames,
   and the land plate. The deck itself lives in projects.css, which is the
   only page that shows it.
   =========================================================================== */

/* --- The hero ------------------------------------------------------------
   One photograph, mounted. The frame around it is the page's ground showing
   through on three sides, with the header band closing the fourth — which
   is what stops the picture reading as wallpaper and starts it reading as
   a plate the company has put on the wall.                                */

.hero {
  padding: 0 var(--frame) var(--frame);
}

.hero__frame {
  position: relative;
  /* The header has already taken its strip, so the frame takes the rest. */
  height: calc(100svh - var(--hdr));
  min-height: 460px;
  overflow: hidden;
}

/* --- The deck ------------------------------------------------------------
   Five buildings in one frame, stacked and cross-faded. Every frame is
   `position: absolute` in the same box, so the stack has no height of its
   own and the frame keeps the height it was given. Only the frame carrying
   `is-on` is opaque; the rest wait at zero. The fade is long — 1.1s — on
   purpose: a photograph changing quickly is a carousel, and a photograph
   changing slowly is a building being looked at.                          */

.hero__deck {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--ink);
}

.hero__media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  opacity: 0;
  transition: opacity 1100ms var(--ease);
}

.hero__media.is-on { opacity: 1; }

/* Script un-hides the others once it takes over; with scripting off the
   first frame is simply the hero it always was. */
.hero__media[hidden] { display: none; }

/* --- Which building, and the means to change it --------------------------
   A name and a row of hairlines. The bar that marks the current frame is
   the same 2px rule the whole site uses for "you are here".              */

.hero__now {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75em;
}

.hero__now-name {
  margin: 0;
  font-family: 'Lahzeh', sans-serif;
  font-weight: 500;
  font-size: var(--fs-key);
  color: var(--paper);
  word-spacing: 0.16em;
  transition: opacity 320ms var(--ease);
}

.hero__now-name.is-swapping { opacity: 0; }

.hero__pips {
  display: flex;
  gap: 0.5rem;
}

.hero__pip {
  width: clamp(26px, 3.4vw, 44px);
  height: 2px;
  padding: 0;
  border: 0;
  /* A shade stronger than `--hair`: this one lies over photography, not
     over the ground. */
  background: rgba(251, 251, 251, 0.4);
  cursor: pointer;
  transition: background-color var(--t) var(--ease);
}

.hero__pip:hover { background: var(--muted); }
.hero__pip[aria-selected='true'] { background: var(--paper); }

/* The pip is 2px tall, which is far too small to hit. The hit area is a
   transparent band around it, so the target is a comfortable 22px while
   the mark stays a hairline. */
.hero__pip::before {
  content: '';
  position: absolute;
  inset-block: -10px;
  inset-inline: 0;
}

.hero__pip { position: relative; }

/* --- The tally -----------------------------------------------------------
   A figure that counts up to itself when it is first scrolled to. The final
   value is in the markup, so with scripting off — or with motion reduced —
   it is simply the number. `tabular-nums` keeps the line from reflowing
   while the digits change width. */

.tally {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.hero__wash {
  position: absolute;
  inset: 0;
  z-index: 10;
  padding: clamp(2rem, 5vh, 4.5rem) clamp(1.5rem, 4vw, 4rem) clamp(3rem, 8vh, 6rem);
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 10, 0.62) 0%,
    rgba(10, 10, 10, 0.28) 34%,
    rgba(10, 10, 10, 0.42) 68%,
    rgba(10, 10, 10, 0.88) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero__line {
  font-family: 'Lahzeh', sans-serif;
  font-weight: 600;
  font-size: clamp(1.75rem, 3.6vw, 3rem);
  line-height: 1.4;
  margin: 0;
  max-width: 20ch;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}

/* --- The headline reveal -------------------------------------------------
   A wipe, not a keystroke simulation.

   Persian is a joined script: a letter's shape depends on its neighbours.
   Revealing a line character by character — or wrapping each character in
   its own element so it can be animated — makes the glyphs re-shape and
   jump as each one lands. So the line is laid out complete and correctly
   shaped, and a clip travels across it. The typing is in the timing, not in
   the text.

   `clip-path` has no logical form, so this is written physically and is
   RTL-specific: the visible region starts empty on the right and grows
   leftwards, which is the reading direction. Each line carries its own
   `--dur` and `--delay`, written by site.js from the line's length so a
   long line takes longer to type than a short one.                        */

.reveal { display: block; }

.reveal__line {
  display: block;
  position: relative;
  width: fit-content;
}

/* `is-armed` is written by script and only by script. With JavaScript off,
   or with motion reduced, the headline is simply a headline. */
.reveal.is-armed .reveal__line { clip-path: inset(0 0 0 100%); }

.reveal.is-armed .reveal__line::after {
  content: '';
  position: absolute;
  inset-block: 0.16em 0.2em;
  inset-inline-start: 0;
  width: 2px;
  background: var(--brand);
  opacity: 0;
}

.reveal.is-revealed .reveal__line {
  animation: wipe var(--dur, 900ms) linear var(--delay, 0ms) both;
}

.reveal.is-revealed .reveal__line::after {
  animation: caret var(--dur, 900ms) linear var(--delay, 0ms) both;
}

/* The resting state does not depend on an animation having run. Script sets
   `is-done` once the wipe is over — or on a timer, if it never started — and
   from then on the headline is simply a headline. An animation that fails to
   fire must never be able to leave the page's first line invisible. */
.reveal.is-done .reveal__line {
  clip-path: none;
  animation: none;
}

.reveal.is-done .reveal__line::after { content: none; }

@keyframes wipe {
  from { clip-path: inset(0 0 0 100%); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes caret {
  from  { inset-inline-start: 0;    opacity: 1; }
  99%   { inset-inline-start: 100%; opacity: 1; }
  to    { inset-inline-start: 100%; opacity: 0; }
}

.hero__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-band);
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.75rem, 4vw, 4.5rem);
}

.hero__stat dt {
  font-weight: 400;
  font-size: var(--fs-key);
  color: var(--muted);
  margin-block-end: 0.2em;
}

.hero__stat dd {
  margin: 0;
  font-weight: 400;
  font-size: clamp(1.25rem, 2.2vw, 1.875rem);
  line-height: 1.1;
}

/* --- The collage ---------------------------------------------------------
   Eight photographs held in one grid, drained of colour until touched.
   It is the only place on the site where an image is small.               */

.collage {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: var(--frame);
  height: min(78svh, 760px);
  padding-inline: var(--frame);
}

.collage__cell {
  position: relative;
  overflow: hidden;
  transition: transform 520ms var(--ease), z-index 0ms;
}

.collage__cell:hover { transform: scale(1.11); z-index: 10; }

.collage__cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0);
  transition: filter 520ms var(--ease);
}

.collage__cell:hover img { filter: saturate(1); }

.collage__cell:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
.collage__cell:nth-child(2) { grid-column: 3;     grid-row: 1 / 3; }
.collage__cell:nth-child(3) { grid-column: 4;     grid-row: 1 / 3; }
.collage__cell:nth-child(4) { grid-column: 1;     grid-row: 2; }
.collage__cell:nth-child(5) { grid-column: 2;     grid-row: 2; }
.collage__cell:nth-child(6) { grid-column: 1;     grid-row: 3; }
.collage__cell:nth-child(7) { grid-column: 2;     grid-row: 3; }
.collage__cell:nth-child(8) { grid-column: 3 / 5; grid-row: 3; }

/* --- The two ways in -----------------------------------------------------
   Two tiles, wider than they are tall, at the same inset and the same gap
   as everything else on the page.                                        */

.ways {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--frame);
  padding-inline: var(--frame);
}

.ways > .tile {
  grid-column: span 12;
  --tile-ratio: 16 / 10;
}

@media (min-width: 720px) {
  .ways > .tile { grid-column: span 6; --tile-ratio: 3 / 2; }
}

/* --- The land plate ------------------------------------------------------
   The one drawing on the homepage: an empty plot assembling into a building
   as the section is scrolled through.                                     */

.land {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--sp-band) clamp(1rem, 2vw, 2rem);
  align-content: center;
  width: 100%;
}

.land__head { grid-column: 1 / 7; display: flex; flex-direction: column; gap: var(--sp-step); align-items: flex-start; }
.land__plate { grid-column: 7 / 13; align-self: center; }
.land__legend { grid-column: 1 / 13; }

.land__plate svg { width: 100%; height: auto; display: block; }

.land__stage {
  opacity: 0.09;
  transition: opacity 640ms var(--ease);
}

.land__stage.is-built { opacity: 1; }

.land__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-step) clamp(1.5rem, 4vw, 4rem);
  margin: 0;
  padding: var(--sp-step) 0 0;
  border-block-start: 1px solid var(--hair-soft);
  list-style: none;
  color: var(--muted);
}

.land__legend li {
  font-weight: 400;
  font-size: var(--fs-key);
  word-spacing: 0.16em;
  transition: color 420ms var(--ease), font-weight 420ms var(--ease);
}

.land__legend li.is-built { color: var(--paper); font-weight: 400; }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1023px) {
  .land__head, .land__plate, .land__legend { grid-column: 1 / 13; }
  .land__plate { overflow-x: auto; }
  .land__plate svg { min-width: 680px; }
}

@media (max-width: 859px) {
  .collage {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    height: min(64svh, 560px);
  }
  .collage__cell:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .collage__cell:nth-child(2) { grid-column: 1;     grid-row: 2; }
  .collage__cell:nth-child(3) { grid-column: 2;     grid-row: 2; }
  .collage__cell:nth-child(4) { grid-column: 1;     grid-row: 3; }
  .collage__cell:nth-child(5) { grid-column: 2;     grid-row: 3; }
  .collage__cell:nth-child(6) { grid-column: 1;     grid-row: 4; }
  .collage__cell:nth-child(7) { grid-column: 2;     grid-row: 4; }
  .collage__cell:nth-child(8) { display: none; }

  .hero__line { max-width: none; }
}
