/* North London Stained Glass: Light on the Wall.
   A plain hallway wall; each of Rachel's windows throws its own light across it. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/BricolageGrotesque-var-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
}

:root {
  --plaster: #e6e5e0;
  --plaster-hi: #f0efeb;
  --ink: #22211f;
  --ink-2: #4a4741;
  --amber: #d9731a;
  --amber-ink: #9a4b0c;
  --face: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --gutter: clamp(1.25rem, 5vw, 5rem);
  /* content edge: the gutter, or wider on big screens so the page holds together at 84rem */
  --edge: max(var(--gutter), calc((100vw - 84rem) / 2));
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  background: var(--plaster);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--face);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  scrollbar-color: #b3afa6 var(--plaster);
}

body { margin: 0; min-height: 100svh; }
img { display: block; max-width: 100%; height: auto; }
::selection { background: var(--amber); color: #fff; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { color: var(--amber-ink); }
:focus-visible { outline: 2px solid var(--amber-ink); outline-offset: 4px; border-radius: 2px; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  padding: .6rem 1rem; background: var(--ink); color: var(--plaster);
  text-decoration: none; border-radius: 2px;
}
.skip:focus { top: 1rem; color: var(--plaster); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- the wall and its light ---------- */

.wall {
  position: relative;
  isolation: isolate;
  background: radial-gradient(130% 60% at 20% 0%, var(--plaster-hi), var(--plaster) 60%) var(--plaster) no-repeat;
}
.wall > *, main > :not(.wall-light) { position: relative; z-index: 2; }
.wall > .top { z-index: 4; }   /* the header sits over the first screen and must stay clickable */

/* the light cast by the piece in view: fixed to the viewport, behind the content */
.wall-light {
  position: fixed; inset: 0; z-index: 1 !important;
  pointer-events: none;
  overflow: hidden;
}
.wall-light span {
  position: absolute;
  left: var(--x, 50vw); top: var(--y, 22svh);
  width: var(--w, 38vw); height: var(--h, 60svh);
  background-position: 50% 45%;
  background-size: cover;
  filter: blur(2.5px) saturate(2.4) brightness(1.08);
  opacity: 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 30%, #000 62%, transparent 96%), linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, #000 30%, #000 62%, transparent 96%), linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
          mask-composite: intersect;
  transition: opacity 1.1s var(--ease-out);
  animation: sun 48s ease-in-out infinite alternate;
}
.wall-light span.on { opacity: .88; }
/* light thrown to the right of a window on the left, and the other way round */
.wall-light span[data-side="left"] { transform-origin: 0 50%; transform: perspective(1100px) rotateY(-48deg) skewY(14deg); }
.wall-light span[data-side="right"] { transform-origin: 100% 50%; transform: perspective(1100px) rotateY(48deg) skewY(-14deg); }

@keyframes sun {
  from { translate: 0 0; }
  to   { translate: 2.5vw 2svh; }
}

/* ---------- header ---------- */

.top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1.5rem;
  padding: 1.5rem var(--edge) 0;
}
.brand { font-weight: 600; letter-spacing: -0.01em; text-decoration: none; }
.home .brand { visibility: hidden; }
.top nav ul { display: flex; flex-wrap: wrap; gap: .4rem 1.75rem; margin: 0; padding: 0; list-style: none; }
.top nav a { font-size: .95rem; font-weight: 500; text-decoration: none; }
.top nav a:hover, .top nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; }
.top nav .short { display: none; }

/* ---------- first screen (home) ---------- */

.first {
  position: relative;
  min-height: 100svh;
  margin-top: -3.6rem;   /* the header sits over the wall */
  overflow: hidden;
}
.first .skirting { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; }

/* the base of the wall: a painted skirting board at a real board's height */
.skirting {
  height: clamp(4.5rem, 8svh, 6.5rem);
  background:
    linear-gradient(#fbfaf7, #fbfaf7) 0 0 / 100% 3px no-repeat,
    linear-gradient(rgba(0,0,0,.06), rgba(0,0,0,0)) 0 3px / 100% 7px no-repeat,
    linear-gradient(#f2f1ec, #e7e5df);
  box-shadow: 0 -8px 14px -10px rgba(40,30,20,.35);
  border-bottom: 4px solid #6e6254;
}
.first .window {
  position: absolute; z-index: 3;
  left: var(--edge); top: 9svh;
  height: 70svh; aspect-ratio: 3 / 4.4;
  margin: 0;
}
/* the hero reveal keeps its place on the wall */
.first .window img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; }
.cast {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  /* fade on the untilted layer, so the light is gone before the skirting board */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 18svh), transparent calc(100% - 10svh));
          mask-image: linear-gradient(to bottom, #000 calc(100% - 18svh), transparent calc(100% - 10svh));
}
.cast span {
  position: absolute;
  background: url("/img/light/hero.webp") 50% 45% / cover no-repeat;
  animation: sun 46s ease-in-out infinite alternate;
}
.cast .on-wall {
  left: calc(var(--edge) + 38svh); top: 44svh; width: min(30vw, 34rem); height: 50svh;   /* falls below and short of the text column */
  transform-origin: 0 50%;
  transform: perspective(1400px) rotateY(-48deg) skewY(14deg);
  filter: blur(2px) saturate(2) brightness(1.05);
  opacity: .78;
  /* fades out above the skirting, so the light never butts into the board */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent), linear-gradient(to bottom, transparent, #000 15%, #000 58%, transparent 88%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent), linear-gradient(to bottom, transparent, #000 15%, #000 58%, transparent 88%);
          mask-composite: intersect;
}
.first .words {
  position: absolute; z-index: 3;
  right: var(--edge); top: 18svh;
  width: min(38rem, 44vw);
}
.first h1 {
  margin: 0;
  font-size: clamp(3rem, 5.6vw, 5.6rem);
  font-weight: 600; line-height: .92; letter-spacing: -0.035em;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}
.maker { margin: 1.2rem 0 0; font-size: 1.3rem; font-weight: 500; letter-spacing: -0.01em; }
.first .does { margin: 2.4rem 0 0; max-width: 30rem; font-size: 1.12rem; color: var(--ink-2); text-wrap: pretty; }
.first .where { margin: 2.2rem 0 0; font-size: .98rem; color: var(--ink-2); max-width: 32rem; }

/* the one action */
.email {
  display: inline-block;
  font-weight: 500; letter-spacing: -0.02em;
  text-decoration: underline;
  text-decoration-color: var(--amber);
  text-decoration-thickness: 3px;
  text-underline-offset: .18em;
  overflow-wrap: anywhere;
  transition: color .25s var(--ease-out);
}
.email:hover { color: var(--amber-ink); }
.first .email { margin-top: 2rem; font-size: clamp(1.6rem, 2.4vw, 2.2rem); }

/* ---------- page intro (inner pages) ---------- */

.intro {
  padding: clamp(4rem, 12svh, 8rem) var(--edge) clamp(2rem, 6svh, 4rem);
}
.intro h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
  font-weight: 600; line-height: .95; letter-spacing: -0.035em;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
  max-width: 14ch;
}
.intro .lede { margin: 2rem 0 0; max-width: 36rem; font-size: 1.2rem; line-height: 1.5; text-wrap: pretty; }
.intro .lede + .lede { margin-top: 1rem; }

/* ---------- the run of windows ---------- */

/* windows zig-zag down the wall, each leaving bare wall beside it for its light */
.run {
  list-style: none; margin: 0; padding: 6rem var(--edge) 8rem;
  display: flow-root;
}
.run > li { width: 44%; }
.run > li + li { margin-top: -18svh; }
.run > li:nth-child(even) { margin-left: auto; }
.run > li:nth-child(4n + 3) { margin-left: 6%; width: 40%; }
.run > li:nth-child(4n) { margin-right: 4%; width: 40%; }
.run > li:last-child { margin-bottom: 0; }

.piece { margin: 0; }
.piece a {
  display: block;
  text-decoration: none;
  color: inherit;
}
/* each photo sits in a reveal cut into the wall: shadowed on the top and the
   side the light comes from, with a painted sill along the bottom */
.frame, .first .window {
  position: relative;
  display: block;
  padding: .8rem;
  background: #d9d7d0;
  box-shadow:
    inset 0 14px 18px -12px rgba(40,30,20,.42),
    inset 12px 0 16px -12px rgba(40,30,20,.28),
    inset -1px 0 0 rgba(255,255,255,.55);
  transition: box-shadow .4s var(--ease-out);
}
.frame::after, .first .window::after {
  content: "";
  position: absolute; left: -.5rem; right: -.5rem; bottom: -.55rem; height: .55rem;
  background: linear-gradient(#fbfaf7, #ebe9e3);
  box-shadow: 0 4px 6px -2px rgba(40,30,20,.22);
}
.first .window { position: absolute; }
.frame img {
  width: 100%;
  max-height: 78svh;
  object-fit: cover;
}
.piece a:hover .frame {
  box-shadow:
    inset 0 18px 24px -12px rgba(40,30,20,.55),
    inset 16px 0 20px -12px rgba(40,30,20,.38),
    inset -1px 0 0 rgba(255,255,255,.55);
}
.count {
  display: inline-block;
  margin-top: 1rem;
  font-size: .92rem; font-weight: 500; color: var(--ink-2);
  text-decoration: underline; text-decoration-color: transparent;
  text-underline-offset: .22em;
  transition: text-decoration-color .25s var(--ease-out);
}
.piece a:hover .count { text-decoration-color: var(--amber); color: var(--ink); }

/* ---------- two doorways (home) ---------- */

.doorways {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem);
  padding: 4rem var(--edge) 2rem;
}
.doorways h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 600; line-height: 1; letter-spacing: -0.03em;
}
.doorways h2 a { text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: .16em; }
.doorways p { margin: 1.2rem 0 0; max-width: 32rem; color: var(--ink-2); text-wrap: pretty; }

/* ---------- about ---------- */

.story {
  display: grid; grid-template-columns: minmax(0, 36rem) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 6rem);
  padding: 0 var(--edge) 4rem;
  align-items: start;
}
.story .text p { margin: 0 0 1.2rem; font-size: 1.12rem; text-wrap: pretty; }
.story .text p:first-child { font-size: 1.35rem; line-height: 1.45; letter-spacing: -0.01em; }
.story .run { padding: 0; }
.story .run > li:nth-child(n) { width: 100%; margin: 0 0 4rem; }

/* ---------- close: the email, again ---------- */

.close {
  padding: clamp(5rem, 16svh, 10rem) var(--edge) 3rem;
  border-top: 1px solid rgba(34,33,31,.12);
  background: linear-gradient(rgba(240,239,235,.55), rgba(240,239,235,.85));
}
.close .email { margin-top: 0; font-size: clamp(2rem, 5vw, 4.4rem); letter-spacing: -0.035em; line-height: 1.05; }
.close dl {
  display: grid; grid-template-columns: repeat(3, minmax(0, auto)); justify-content: start;
  gap: 1rem clamp(2rem, 6vw, 5rem);
  margin: 3.5rem 0 0;
}
.close dt { font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.close dd { margin: .25rem 0 0; font-variant-numeric: tabular-nums; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  margin-top: 5rem; padding-top: 1.5rem;
  border-top: 1px solid rgba(34,33,31,.1);
  font-size: .9rem; color: var(--ink-2);
}
.foot nav ul { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: 0; padding: 0; list-style: none; }

/* mobile email bar */
.bar { display: none; }

/* ---------- viewer ---------- */

.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #1b1a18; color: #efeee9;
}
.viewer::backdrop { background: rgba(20,19,17,.9); }
.viewer[open] { display: grid; grid-template-rows: auto 1fr auto; animation: fade .35s var(--ease-out); }
@keyframes fade { from { opacity: 0; } }
.viewer .bar-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem clamp(1rem, 3vw, 2rem);
}
.viewer .n { font-variant-numeric: tabular-nums; color: #b9b6ae; font-size: .95rem; }
.viewer button {
  font: inherit; color: inherit; background: none; border: 1px solid rgba(239,238,233,.28);
  border-radius: 999px; padding: .55rem 1.1rem; cursor: pointer;
  transition: background .2s var(--ease-out), border-color .2s var(--ease-out);
}
.viewer button:hover { background: rgba(239,238,233,.1); border-color: rgba(239,238,233,.6); }
.viewer button:disabled { opacity: .35; cursor: default; background: none; }
.viewer :focus-visible { outline-color: #f0a25e; }
.track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.track::-webkit-scrollbar { display: none; }
.track figure {
  flex: 0 0 100%; margin: 0; scroll-snap-align: center;
  display: grid; place-items: center; padding: 0 clamp(.75rem, 4vw, 4rem);
  min-height: 0;
}
.track img { max-height: calc(100dvh - 11rem); width: auto; max-width: 100%; object-fit: contain; }
.viewer .bar-bottom {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem) calc(1rem + env(safe-area-inset-bottom));
}
.viewer .said { margin: 0; text-align: center; font-size: 1.05rem; line-height: 1.45; max-width: 46rem; justify-self: center; text-wrap: pretty; }
.viewer .said:empty { visibility: hidden; }

/* ---------- 404 ---------- */
.lost { min-height: 70svh; }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .wall-light span, .cast span { animation: none; }
  .wall-light span { transition-duration: .01s; }
  .frame, .viewer[open] { transition: none; animation: none; }
}

/* ---------- narrower screens ---------- */
@media (max-width: 64rem) {
  .run > li, .run > li:nth-child(n) { width: 78%; margin-left: 0; margin-right: 0; }
  .run > li:nth-child(even) { margin-left: auto; }
  .run > li + li { margin-top: 5rem; }
  .doorways { grid-template-columns: 1fr; }
  .story { grid-template-columns: 1fr; }
}

@media (max-width: 47.5rem) {
  html { font-size: 100%; }
  .top { padding-top: 1rem; flex-direction: column; align-items: flex-start; gap: .35rem; }
  .home .brand { display: none; }
  .top nav ul { gap: .3rem 1.25rem; }
  .top nav .long { display: none; }
  .top nav .short { display: inline; }
  .top nav .mail { display: none; }

  .first { min-height: auto; margin-top: 0; overflow: visible; }
  .first::after { display: none; }
  .first .window { position: relative; left: auto; top: auto; margin: 1rem var(--gutter) 0; height: 44svh; }
  .first .skirting { display: none; }
  .cast .on-wall { left: 30vw; top: 4svh; width: 80vw; height: 50svh; transform: perspective(900px) rotateY(-34deg) skewY(10deg); opacity: .35; }
  .first .words { position: relative; right: auto; top: auto; width: auto; padding: 2rem var(--gutter) 0; }
  .first h1 { font-size: clamp(2.6rem, 12vw, 3.4rem); }
  .first .does, .first .where { color: #3f3c37; }
  .first .does { margin-top: 1.6rem; }

  .run > li:nth-child(n) { width: 100%; margin-left: 0; margin-right: 0; }
  .run > li + li { margin-top: 5.5rem; }
  .run { padding-top: 3rem; }
  .wall-light { display: none; }

  .close dl { grid-template-columns: 1fr; }
  .bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    padding: .9rem var(--gutter) calc(.9rem + env(safe-area-inset-bottom));
    background: var(--plaster-hi);
    border-top: 1px solid rgba(0,0,0,.1);
    box-shadow: 0 -10px 30px -16px rgba(40,30,20,.35);
    transition: translate .35s var(--ease-out);
  }
  .bar.away { translate: 0 calc(100% + 3rem); box-shadow: none; }
  .bar span { font-size: .9rem; color: var(--ink-2); }
  .bar .email { font-size: 1.15rem; text-decoration-thickness: 2px; }
  .viewer .bar-bottom { grid-template-columns: auto auto; justify-content: space-between; }
  .viewer .said { grid-column: 1 / -1; grid-row: 1; }
}
