/* ==========================================================================
   The front page: one house in Cairo, over one day.

   Two parts. THE FILM: a full-height opening in which the day passes — the
   hours' photographs cross-fade and the ground takes the colour of each hour —
   with the wordmark and the whole navigation set over it, centred. THE DAY:
   the same hours as chapters underneath, each centred on its own axis: the
   hour, a line, a photograph, the pieces.

   One rule governs the layout: everything is symmetrical about the centre
   line. Where a block is not — two columns of reading text, say — it is
   because reading text is left-aligned, and for no other reason.

   The colours: every chapter re-declares the design system's inks for its
   hour, so cards, links and eyebrows recolour themselves without knowing the
   time. The change between two hours is a gradient across the top of each
   chapter, where nothing but the hour numeral sits.
   ========================================================================== */

/* ---- The film. ---------------------------------------------------------- */
.day-film {
  position: relative; min-height: 100svh;
  background: #0E0D0B; color: #F3F1ED;
  overflow: hidden; isolation: isolate;
}
.day-film__scenes { position: absolute; inset: 0; }
.day-film__scene {
  position: absolute; inset: 0; margin: 0;
  opacity: 0; transition: opacity 1.8s var(--ease-ui);
}
.day-film__scene.is-on { opacity: 1; }
.day-film__scene img {
  width: 100%; height: 100%; object-fit: cover; object-position: center; display: block;
  transform: scale(1.06);
}
/* The picture settles while it is on screen — a slow pull back, nothing more. */
.day-film__scene.is-on img { animation: day-settle 9s var(--ease-ui) forwards; }
@keyframes day-settle { from { transform: scale(1.06); } to { transform: scale(1); } }
/* Dark at the top for the header, dark at the foot for the caption; the middle
   of the picture is left alone. */
.day-film__scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 9, 7, .62) 0, rgba(10, 9, 7, 0) 34%),
    linear-gradient(to top,    rgba(10, 9, 7, .70) 0, rgba(10, 9, 7, 0) 40%);
}

/* The caption at the foot of the film: the hour, one line, the way in. */
.day-film__caption {
  position: absolute; left: 0; right: 0; bottom: 64px; z-index: 2;
  text-align: center; padding: 0 var(--gap-side);
}
.day-film__title {
  font-family: var(--body); font-size: 11px; font-weight: 700; letter-spacing: .2em;
  text-transform: uppercase; margin: 0; color: rgba(243, 241, 237, .78);
  transition: opacity .6s var(--ease-ui);
}
.day-film__line {
  font-family: var(--display); font-size: clamp(26px, 3.2vw, 46px); line-height: 1.1;
  letter-spacing: -.01em; margin: 14px auto 0; max-width: 26ch; text-wrap: balance;
  transition: opacity .6s var(--ease-ui);
}
.day-film__caption.is-changing .day-film__title,
.day-film__caption.is-changing .day-film__line { opacity: 0; }
.day-film__go {
  display: inline-block; margin-top: 22px;
  font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: #F3F1ED; border-bottom: 1px solid rgba(243, 241, 237, .35); padding-bottom: 4px;
  transition: border-color .3s var(--ease-ui);
}
.day-film__go:hover { border-color: #F3F1ED; }

/* The hours, as a row of marks under the caption. */
.day-film__dots {
  position: absolute; left: 0; right: 0; bottom: 26px; z-index: 2;
  display: flex; justify-content: center; gap: 10px; margin: 0; padding: 0; list-style: none;
}
.day-film__dot {
  all: unset; cursor: pointer; width: 28px; height: 14px; position: relative;
}
.day-film__dot::after {
  content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 1px;
  background: rgba(243, 241, 237, .35); transition: background-color .3s var(--ease-ui);
}
.day-film__dot[aria-current="true"]::after, .day-film__dot:hover::after { background: #F3F1ED; }
.day-film__dot:focus-visible::after { outline: 1px solid #F3F1ED; outline-offset: 3px; }

/* ---- The three houses. -------------------------------------------------- */
.houses { padding: clamp(56px, 8vh, 96px) var(--gap-side); background: var(--paper); border: 0; }
.houses__row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap-tile);
  width: 100%;
}
.houses__door { display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--ink); }
.houses__frame { display: block; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; background: var(--wash); }
.houses__frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .6s var(--ease);
}
.houses__door:hover .houses__frame img { transform: scale(1.03); }
.houses__name { display: block; margin: 18px 0 0; transition: opacity .3s var(--ease-ui); }
.houses__door:hover .houses__name { opacity: .55; }
.houses__line { display: block; margin-top: 6px; color: var(--stone); max-width: 30ch; }
@media (max-width: 809.98px) {
  .houses__row { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .houses__frame { aspect-ratio: 4 / 3; }
}
@media (prefers-reduced-motion: reduce) {
  .houses__frame img, .houses__door:hover .houses__frame img { transition: none; transform: none; }
}

/* ---- The invitation down. One line and one arrow between the houses and
   the first hour, so the reader knows the day is read downward. ---------- */
.day-invite { text-align: center; padding-bottom: clamp(36px, 5vh, 56px); }
.day-invite__title { margin: 10px 0 0; }
.day-invite__line { margin: 10px 0 0; }
.day-invite__arrow {
  display: inline-block; margin-top: 16px;
  font-size: 20px; line-height: 1; color: var(--stone);
  animation: day-drift 2.8s var(--ease) infinite;
}
@keyframes day-drift {
  0%, 100% { transform: translateY(0); opacity: .5; }
  50%      { transform: translateY(7px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .day-invite__arrow { animation: none; } }

/* ---- The day. ----------------------------------------------------------- */
.day { --dawn: 16vh; }

.day-ch {
  --tone: var(--paper);
  --from: var(--tone);
  position: relative; text-align: center;
  /* The top padding is the dawn plus a breath: the hour numeral never stands
     in the change of light, only after it. The dawn was 30vh and the numeral
     176px tall — monumental once, a trek by the fourth hour. Compact now:
     the light still turns, the page just does not stop walking while it does. */
  padding: calc(var(--dawn) + 40px) var(--gap-side) clamp(44px, 6vh, 72px);
  background-color: var(--tone);
  background-image: linear-gradient(to bottom, var(--from) 0, var(--tone) var(--dawn));
  color: var(--ink);
  border: 0;
}
.day-ch.is-night {
  --ink:   #F3F1ED;
  --stone: rgba(243, 241, 237, .58);
  --hair:  rgba(243, 241, 237, .16);
  --wash:  rgba(243, 241, 237, .06);
  --paper: var(--tone);
}
/* Dawn proper: black to paper in one move, by way of the colour the sky
   actually turns first, rather than the grey a straight line gives. */
.day-ch--dawn {
  background-image: linear-gradient(to bottom,
    var(--from) 0,
    #3B2E25 calc(var(--dawn) * .30),
    #9C8A78 calc(var(--dawn) * .55),
    #D9CFC3 calc(var(--dawn) * .80),
    var(--tone) var(--dawn));
}

/* Everything in a chapter stands on the axis. */
.day-ch .wrap { display: flex; flex-direction: column; align-items: center; }
/* The hour, said quietly. It was 176px of numeral — a monument at every
   station; at this size it reads as a margin note: the time, the word, then
   the sentence that matters. */
.day-ch__hour {
  font-family: var(--display); font-weight: 300;
  font-size: clamp(34px, 4.6vw, 64px); line-height: .92; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums; color: var(--ink); margin: 0;
}
.day-ch__hour small {
  display: block; font-family: var(--body); font-size: 10px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase; color: var(--stone);
  margin-top: 8px; line-height: 1.4;
}
.day-ch__head { display: flex; flex-direction: column; align-items: center; }
.day-ch__head .display-l {
  max-width: 26ch; margin: 14px 0 0; text-wrap: balance;
  /* The chapter heading steps down from the page-title size: eight of these
     in a row at display-l is eight shouts. */
  font-size: clamp(24px, 3vw, 38px); line-height: 1.14;
}
.day-ch__text { max-width: 58ch; margin: 12px 0 0; text-wrap: pretty; }
.day-ch__more { margin-top: 16px; }
.day-ch__eyebrow { margin: 0 0 4px; }

/* The photograph: one wide band, edge to edge, the same proportion in every
   chapter so the page keeps a rhythm. */
.day-ch__band {
  width: 100vw; margin: clamp(22px, 3.5vh, 36px) 0 0;
  /* Shallower than 2:1 — a lower horizon lets the page keep walking. */
  aspect-ratio: 21 / 9; overflow: hidden; background: var(--wash);
}
.day-ch__band img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 809.98px) { .day-ch__band { aspect-ratio: 4 / 3; } }

/* The pieces: a row of --n, centred, never wider than the row needs. */
.day-row {
  --n: 4;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: var(--gap-tile);
  width: min(100%, calc(var(--n) * 340px + (var(--n) - 1) * var(--gap-tile)));
  margin: clamp(20px, 3.5vh, 32px) auto 0;
  text-align: left;
}
.day-row[data-count="3"] { --n: 3; }
.day-row[data-count="2"] { --n: 2; }
.day-row[data-count="1"] { --n: 1; }
.is-night .day-row { gap: 10px; }
@media (max-width: 809.98px) {
  .day-row, .day-row[data-count="3"] { --n: 2; width: 100%; }
}

.is-night .cf__nav { color: var(--stone); }
.is-night .cf__nav:hover { color: var(--ink); }

/* ---- The day comes round: the index. ----------------------------------- */
.day-columns {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px 64px;
  width: 100%; margin-top: clamp(40px, 6vh, 64px); text-align: left;
}
.day-columns .eyebrow { margin: 0 0 12px; }
.day-practice__row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--hair);
}
.day-practice__row .display-s { margin: 0; }
.day-contact { margin-top: clamp(40px, 6vh, 64px); }

/* ---- The clock, on the axis at the foot of the screen. ----------------- */
.day-clock {
  /* Off the axis, into the corner: on the centre line it stood directly in
     front of each chapter's own numeral and read as the page printing the
     hour twice. A clock belongs at the edge of a room, not in the doorway. */
  position: fixed; right: 20px; bottom: 16px; z-index: 9;
  pointer-events: none; opacity: 0; transition: opacity .6s var(--ease);
  mix-blend-mode: difference; color: #fff;
  display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
}
.day-clock.is-on { opacity: 1; }
.day-clock__t {
  font-family: var(--display); font-size: 18px; line-height: 1; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.day-clock__w { font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; opacity: .8; }

/* ---- The nav over a dark hour. ----------------------------------------- */
.nav.is-night { background: rgba(14, 13, 11, .66); }
.nav.is-night .nav__link { color: #F3F1ED; }
.nav.is-night .nav__link[aria-current="page"] { color: rgba(243, 241, 237, .55); }
.nav.is-night .nav__wordmark, .nav.is-night .nav__seal { filter: invert(1) brightness(1.08); }
.nav.is-night::after { background: linear-gradient(to bottom, rgba(0, 0, 0, .28), rgba(0, 0, 0, 0)); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav.is-night { background: #0E0D0B; }
}

/* ---- Small screens. ---------------------------------------------------- */
@media (max-width: 1023.98px) {
  .day-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 809.98px) {
  .day { --dawn: 22vh; }
  .day-film__caption { bottom: 56px; }
  /* No clock on a phone: it sat over the pieces. */
  .day-clock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .day-film__scene { transition: none; }
  .day-film__scene.is-on img { animation: none; transform: none; }
}
