/* ==========================================================================
   nyteshift: light to dark — pass 5, the live wire
   Layered after pass4.css. One faint wire runs the length of the page. It
   starts from the streak in the N once the lockup has docked into the nav,
   runs down the margin, stands under "What I do" and branches into a lane
   beside each service, crosses into the night, meets at the Projects sign,
   passes the work, becomes How I work's current, passes Start a project and
   ends in the footer's bar.

   Static by default: with no script nothing here moves or hides; with
   reduced motion main.js draws the wire lit and still. Geometry is measured
   by main.js (never while scrolling) and handed over in px. Everything that
   moves while you scroll is transform or opacity on a layer of its own.
   ========================================================================== */

:root {
  /* the wire: two levels of faint. Unlit it is barely there; lit it is a crisp copper hairline on paper
     and a sodium line with a little glow on carbon */
  --wire-day: #DDD8CC;
  --wire-day-lit: #BF9C78;
  --wire-night: #333533;
  --wire-night-lit: var(--sodium);
  /* the sign, off: an unlit tube of glass */
  --sign-off: #2F312F;
  --sign-red: #B4492A;
  --rail: 40px;          /* the wire's margin, set by main.js */
}

/* Space Grotesk at the three weights the page uses, as static files cut from the supplied variable font
   (media/font, same outlines; OFL). WebKit on Windows draws a variable font only at its default weight
   (300), so without these every heading there came out light. Every engine now draws the same files;
   the variable font stays for any other weight. */
@font-face { font-family: "Space Grotesk"; src: url("media/font/SpaceGrotesk-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("media/font/SpaceGrotesk-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("media/font/SpaceGrotesk-640.woff2") format("woff2"); font-weight: 640; font-style: normal; font-display: swap; }

/* (pass 1–4's copper line across the opening is retired: the wire is the page's one light) */
#horizon { display: none; }

/* ==========================================================================
   THE OPENING: the lockup docks into the nav
   ========================================================================== */
.hero { display: block; align-content: normal; min-height: 0; padding: 0; }
.hero__stage {
  position: relative; min-height: 100svh;
  display: grid; align-content: center;
  padding-block: calc(var(--nav-h) + 12vh) 14vh;
}
.hero__stage > .shell { position: relative; z-index: 1; }
.hero--pin { height: calc(100svh + var(--hero-run, 65svh)); }
.hero--pin .hero__stage { position: sticky; top: 0; height: 100svh; min-height: 0; }

/* the headline arrives as the lockup leaves: each word rises, a copper copy of it lighting first */
.hero__line .w { position: relative; display: inline-block; }
.hero__line .w__lit { position: absolute; left: 0; top: 0; color: var(--copper); opacity: 0; pointer-events: none; }
/* (the copies made for the light are not text anyone selects or copies: only the real words are) */
.w__lit, .sign__layer, .cut__half { -webkit-user-select: none; user-select: none; }
.hero__line .w { will-change: auto; }
.nav.is-stuck { -webkit-backdrop-filter: blur(14px) saturate(1.1); }

/* ==========================================================================
   WHAT I DO: large, on the left, standing on the wire
   ========================================================================== */
.svc__shell { position: relative; z-index: 1; }
.svc__block { max-width: none; margin: 0; text-align: left; }
.svc__head {
  font-size: clamp(3.4rem, 15.5vw, 7.25rem); line-height: .9; letter-spacing: -.052em;
  margin-left: -.045em;   /* the W's own side bearing, so it lines up with the text below */
}
.svc__item { justify-items: start; }
.svc__desc { text-wrap: pretty; }
.svc__list { margin-top: clamp(2.25rem, 7vh, 4rem); }

@media (min-width: 1000px) {
  .svc__head { font-size: clamp(4.25rem, min(12.6vw, 20.5vh), 12.5rem); }
  .svc__list {
    grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start;
    column-gap: var(--svc-gap); row-gap: 0;
    margin-top: clamp(2.6rem, 7.5vh, 4.75rem);
  }
  .svc { --svc-gap: clamp(2.75rem, 4.6vw, 5rem); }
  .svc__item h3 { font-size: clamp(1.6rem, min(2.7vw, 4.6vh), 2.9rem); line-height: 1.04; }
  .svc__desc { max-width: 34ch; margin-top: clamp(.7rem, 1.6vh, 1.05rem); }
  .svc__talk { margin-top: clamp(.35rem, 1vh, .7rem); }
}
@media (max-width: 999px) {
  .svc__list { gap: clamp(2.2rem, 6vh, 3.2rem); }
  .svc__item h3 { font-size: clamp(1.75rem, 6.6vw, 2.6rem); }
  .svc__desc { max-width: 40ch; }
}

/* ==========================================================================
   THE WIRE
   One host per section (or per held stage), under the section's content.
   .wire__base is the whole route, unlit. Each .wp is a window onto one piece
   of the lit route: it is moved by transform and its content the other way,
   so the light spreads without anything being repainted.
   ========================================================================== */
.wire { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; overflow: hidden; overflow: clip; }
.wire svg { position: absolute; left: 0; top: 0; overflow: visible; }
.wire path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wire__base path { stroke: var(--wire-day); stroke-width: 1; }
.wire--night .wire__base path { stroke: var(--wire-night); }
.wp { position: absolute; overflow: hidden; }
/* the wire below the sign: lit all at once as it strikes, out again if you go back above it */
.wp--strike { opacity: 0; transition: opacity .9s var(--e-io) .2s; }
.wp--strike.is-on { opacity: 1; }
html.reduce .wp--strike { transition: none; }
/* a host far from the screen is not drawn: no layers, nothing to composite */
.wire.is-off { display: none; }
/* and a section far from the screen gives up the layers its own motion keeps ready */
.is-far, .is-far * { will-change: auto !important; }
/* only a piece the light is moving along is a layer; whole or dark it is just drawn */
.wp.is-live, .wp.is-live > .wp__in { will-change: transform; }
.wp.is-dark { visibility: hidden; }
.wp__in { position: absolute; left: 0; top: 0; }
.wp .core { stroke: var(--wire-day-lit); stroke-width: 1.15; }
.wp .glow { display: none; }
.wire--night .wp .glow { display: inline; stroke: rgba(var(--glow), .12); stroke-width: 5; }
.wire--night .wp .core { stroke: var(--wire-night-lit); stroke-width: 1.25; }

/* the front of the light: a bright point with a short horizon through it, the streak in the mark.
   On paper it is crisp pigment, on carbon it glows */
/* (the lights are only drawn while they show: put away, they are not drawn at all) */
.wh, .wq { display: none; }
.wh.is-on, .wq.is-on { display: block; }
.wh {
  position: absolute; left: -3.5px; top: -3.5px; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, #FFF1DC 0 22%, var(--sodium) 46%, #B07A43 64%, rgba(151, 98, 49, 0) 72%);
  opacity: 0; will-change: transform, opacity;
}
.wh::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 1px; margin: -.5px 0 0 -15px;
  background: linear-gradient(90deg, rgba(151, 98, 49, 0), rgba(176, 122, 67, .9), rgba(151, 98, 49, 0));
}
.wire--night .wh {
  left: -7px; top: -7px; width: 15px; height: 15px;
  background: radial-gradient(circle, #FFFCF6 0 16%, #FFDDB0 30%, rgba(var(--glow), .45) 50%, rgba(var(--glow), 0) 71%);
  box-shadow: 0 0 24px 6px rgba(var(--glow), .26);
}
.wire--night .wh::after {
  width: 64px; margin-left: -32px;
  background: linear-gradient(90deg, rgba(var(--glow), 0), rgba(255, 231, 200, .85), rgba(var(--glow), 0));
}
/* small lights carried along the lit wire by the scroll */
.wq {
  position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle, #FFE9CC 0 30%, var(--sodium) 55%, rgba(255, 179, 92, 0) 75%);
  opacity: 0; will-change: transform, opacity;
}
.wire--night .wq {
  left: -3.5px; top: -3.5px; width: 7px; height: 7px;
  background: radial-gradient(circle, #FFF3E1 0 26%, rgba(var(--glow), .6) 48%, rgba(var(--glow), 0) 74%);
  box-shadow: 0 0 9px 2px rgba(var(--glow), .28);
}
/* where the wire meets the footer's bar */
.wj {
  position: absolute; left: -9px; top: -9px; width: 19px; height: 19px; border-radius: 50%;
  background: radial-gradient(circle, #FFFCF6 0 14%, #FFD9A8 30%, rgba(var(--glow), .4) 48%, rgba(var(--glow), 0) 70%);
  opacity: 0;
}

/* the sections the wire runs under keep their content above it */
.hero__stage, .svc__stage, .how__stage, .start, .foot, .work { position: relative; }
.how__shell, .start__shell, .foot > .shell, .work__shell { position: relative; z-index: 1; }

/* ==========================================================================
   THE NIGHT: Projects
   ========================================================================== */
/* the horizon: the night's top edge, crisp and sodium, with the light it leaves under it */
.work::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; margin-top: -1px; z-index: 3; pointer-events: none;
  background: var(--hz-hot);
  box-shadow: 0 0 3px rgba(var(--glow), .95), 0 3px 12px rgba(var(--glow), .45);
}
.work__dark {
  position: relative; height: var(--lead-h, 86svh); pointer-events: none;
}
/* (pre-rendered and dithered, media/night-edge-haze.webp: the same falloff pass 4 drew with grain and two
   masks, which Firefox and WebKit re-composited at a cost on every frame of the crossing) */
.work__dark::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: min(46vh, 30rem);
  background: url("media/night-edge-haze.webp") 0 0 / 100% 100% no-repeat;
}
/* with no script the night simply starts: no empty lead-in */
html:not(.js) .work__dark { height: clamp(4rem, 12vh, 7rem); }

/* the work's margin keeps clear of the wire */
.work__shell { padding-inline: var(--work-pad, var(--gut)); }

/* the sign: Projects, struck like a sodium lamp */
.sign {
  position: relative; display: block;
  font-size: clamp(4.1rem, 17.4vw, 19rem); font-weight: 640; line-height: .8; letter-spacing: -.056em;
  color: var(--sodium); margin: 0 0 clamp(1.75rem, 5vh, 3rem) -.06em;
  text-wrap: nowrap; white-space: nowrap;
}
.sign__word { position: relative; display: inline-block; }
.sign__layer { position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap; opacity: 0; }
.sign__red { color: var(--sign-red); text-shadow: 0 0 .05em rgba(180, 73, 42, .55); }
.sign__amber { color: var(--sodium); }
.sign__glow { color: transparent; text-shadow: 0 0 .07em rgba(var(--glow), .5), 0 0 .26em rgba(255, 150, 70, .2); }
.sign--live .sign__word { color: var(--sign-off); }
.sign--live.is-lit .sign__amber { opacity: 1; }
.sign--live.is-lit .sign__glow { opacity: .85; }

/* the categories stay under the nav while you browse the projects, and let go after the last one */
.work__browse { position: relative; padding-bottom: 1px; }
.work__bar {
  position: sticky; top: var(--nav-h); z-index: 6;
  background: var(--carbon); box-shadow: inset 0 -1px 0 var(--c-rule-2);
  margin-bottom: clamp(2rem, 5.5vh, 3.5rem);
}
.work__filters::after { display: none; }
.work__bar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 1.75rem; pointer-events: none;
  background: linear-gradient(var(--carbon), rgba(23, 25, 24, 0));
  opacity: 0; transition: opacity .3s var(--e-io);
}
.work__bar.is-stuck::after { opacity: 1; }
.work__bar::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--nav-h); pointer-events: none;
  background: var(--carbon); opacity: 0;
}
.work__bar.is-stuck::before { opacity: 1; }
/* a project reached by keyboard or by link lands clear of the nav and the categories */
.case, .work--cards .case__open { scroll-margin-top: calc(var(--nav-h) + var(--bar-h, 3.5rem) + 1.5rem); }
/* (and focus moving through the page keeps clear of the nav; exactly its height, so the stuck categories,
   which sit right under it, are never nudged into view when one is chosen) */
html { scroll-padding-top: var(--nav-h); }

/* the room comes up once the sign has struck (and stays up) */
.work--room .work__bar, .work--room .case {
  transition: opacity .75s var(--e-io) var(--in, 0s), transform .95s var(--e-out) var(--in, 0s);
}
.work--room:not(.is-open) .work__bar, .work--room:not(.is-open) .case {
  opacity: 0; transform: translateY(14px); transition-duration: .22s, .22s; transition-delay: 0s, 0s;
}
.work--now .work__bar, .work--now .case { transition: none !important; }

@media (max-width: 780px) {
  /* the bar runs edge to edge and its categories scroll sideways inside it */
  .work__bar { margin-inline: calc(var(--work-pad, var(--gut)) * -1); padding-inline: 0; }
  .work__filters { margin: 0; max-width: none; padding-inline: var(--work-pad, var(--gut)); background: none; }
  .sign { margin-bottom: clamp(1.4rem, 4vh, 2rem); }
}

/* ==========================================================================
   HOW I WORK: its current is a stretch of the wire
   ========================================================================== */
.how__spine { background: var(--wire-night); }

/* ==========================================================================
   REDUCED MOTION: the wire lit and still, the sign lit, nothing held
   ========================================================================== */
html.reduce .wh, html.reduce .wq { display: none; }
html.reduce .wp.is-live, html.reduce .wp.is-live > .wp__in { will-change: auto; }
html.reduce .work__bar::after { transition: none; }
