/* Homepage — one scroll: slogan -> the library (one scattered field) -> services -> contact.
   Every section is one screen and the page snaps between them (plain CSS, so
   it holds with JS off; the field's scatter is plain CSS too). Rules under .fx
   are the scroll-linked slogan dissolve and gallery arrival, and the field's
   drift, that assets/js/home.js drives; home-mark.js sets .fx before paint
   and removes it itself if home.js never arrives. */

body.home {
  background: var(--night);
  color: var(--on-night);
  font: 400 16px/1.6 var(--font-body);
  overflow-x: clip;
}
.home .mono {
  font-size: 0.72rem;
}

/* ---------- header ---------- */
.hbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(13, 13, 13, 0.86);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.hbar nav {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2.4vw, 28px);
}
.hbar nav > a:not(.btn) {
  color: var(--on-night);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 12px 2px;
  opacity: 0.86;
  transition: opacity 0.2s;
}
.hbar nav > a:not(.btn):hover {
  opacity: 1;
}

/* ---------- 1. hero ---------- */
.scene-hero .pin {
  min-height: 100svh;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 90px var(--gutter) 60px;
  position: relative;
  overflow: hidden;
}
.slogan {
  font: 400 clamp(2.18rem, 8.84vw, 8.06rem)/0.95 var(--font-display);
  text-transform: uppercase;
  letter-spacing: -0.005em;
  will-change: transform, opacity;
}
.slogan .ln {
  display: block;
  overflow: hidden;
  padding-bottom: 0.04em;
}
.slogan .ln > span {
  display: inline-block;
  animation: lineUp 1.1s var(--ease-out) both;
}
.slogan .ln:nth-child(2) > span {
  animation-delay: 0.14s;
}
.slogan .ln:nth-child(3) > span {
  animation-delay: 0.28s;
}
.slogan .ln-red {
  color: var(--red);
}
@keyframes lineUp {
  from {
    transform: translateY(105%);
  }
  to {
    transform: none;
  }
}
.hero-sub {
  margin-top: 28px;
  color: var(--on-night-2);
  animation: fadeIn 0.9s 0.9s both;
}
.cue {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  color: var(--on-night-2);
  display: grid;
  justify-items: center;
  gap: 10px;
  animation: fadeIn 0.9s 1.3s both;
}
.cue span {
  width: 1px;
  height: 38px;
  background: linear-gradient(var(--on-night-2), transparent);
  animation: cue 1.8s 1.6s ease-in-out infinite;
  transform-origin: top;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes cue {
  0% {
    transform: scaleY(0);
  }
  50% {
    transform: scaleY(1);
  }
  100% {
    transform: scaleY(1);
    opacity: 0;
  }
}

/* ---------- 2. the library ----------
   Every piece at once, scattered small over a white field (the Boss's pin,
   2026-10-22: Simon Wheatley's portfolio). Positions come from
   build-home.mjs as inline custom properties: --x/--y/--w (% of the field)
   for landscape screens, --px/--py/--pw for portrait ones. The layout is
   plain CSS, so it holds with JS off. home.js adds the drift (--dx/--dy on
   the field) and plays a hovered video. White here is the Boss's call, an
   exception to the black/cream brand grounds; Dark mode flips it to black. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.scene-lib { --lib-bg: #fff; --lib-fg: #000; background: var(--lib-bg); color: var(--lib-fg); transition: background-color 0.5s, color 0.5s; }
.scene-lib.dark { --lib-bg: var(--black); --lib-fg: var(--cream); }
.stage { position: relative; height: calc(100svh - var(--hbar-h)); min-height: 520px; overflow: clip; }
.lib { position: absolute; inset: 0; }
/* Depth (Boss, 2026-10-27): a real 3D space. The stage holds the camera
   (--persp, from build-home.mjs); each piece sits on its plane at --z (far
   -720px .. near +160px), already unprojected by the build so it lands where
   the layout put it. */
.stage { perspective: var(--persp, 1200px); perspective-origin: 50% 50%; }
/* The 3D camera makes the stage its own layer, so the difference-blended
   title would blend with nothing (white on white): give it the ground. */
.stage { background: var(--lib-bg); transition: background-color 0.5s; }
.lib { transform-style: preserve-3d; pointer-events: none; } /* the z=0 box would cover the far planes */
.lib .st { pointer-events: auto; }
.st { position: absolute; left: var(--x); top: var(--y); width: var(--w); z-index: 1; display: block; line-height: 0;
  transform-origin: var(--o); transform: translateZ(var(--z, 0px));
  transition: transform 0.55s var(--ease-out), z-index 0s 0.55s; }
.st img, .st video { display: block; width: 100%; height: auto; }
.st video { position: absolute; inset: 0; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s; }
.st video.on { opacity: 1; }
.st:focus-visible { outline: 2px solid var(--lib-fg); outline-offset: 3px; }
/* Hover (home.js): the piece is lifted into .peek, a flat copy above the 3D
   space that grows from where it sits, so no neighbour can paint over it. */
.peek { position: absolute; z-index: 5; line-height: 0; cursor: pointer; transform-origin: 0 0;
  background: var(--lib-bg); transition: transform 0.42s var(--ease-out); will-change: transform; }
.peek[hidden] { display: none; }
.peek img, .peek video { display: block; width: 100%; height: 100%; object-fit: cover; }
.peek video { position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s; }
.peek video.on { opacity: 1; }
.fx .st.lifted { opacity: 0; }

/* Title and corner labels: small caps, and difference-blended so they stay
   legible over any photo they cross (white on black, black on white). */
.lib-title, .lib-c { mix-blend-mode: difference; color: #fff; z-index: 6; }
.lib-title { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(90%, 40rem);
  text-align: center; pointer-events: none; text-transform: uppercase; line-height: 1.15; }
.lib-title p { margin: 0; }
#lib-a { font: 800 clamp(0.95rem, 1.5vw, 1.25rem)/1.15 var(--font-display); letter-spacing: 0.01em; }
#lib-b { font-size: clamp(0.85rem, 1.3vw, 1.1rem); font-weight: 400; }
.lib-c { position: absolute; margin: 0; padding: 14px 18px; font: 700 0.68rem/1 var(--font-body); font-stretch: 125%;
  letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none; background: none; border: 0; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; }
.lib-c[hidden] { display: none; }
p.lib-c { cursor: default; }
.lib-tl { left: 0; top: 0; } .lib-tr { right: 0; top: 0; }
.lib-bl { left: 0; bottom: 0; } .lib-br { right: 0; bottom: 0; }
.lib-bc { left: 50%; bottom: 0; transform: translateX(-50%); white-space: nowrap; pointer-events: none; }
.lib-c:hover { text-decoration: underline; text-underline-offset: 3px; }
.hint-touch { display: none; }
@media not ((hover: hover) and (pointer: fine)) { .hint-fine { display: none; } .hint-touch { display: inline; } }

/* Fine pointer on a wide screen: the field overhangs the stage by 5% on each
   side and drifts against the cursor by at most 4.5% (overscan > drift, so
   the field never shows its edge). */
@media (hover: hover) and (pointer: fine) and (min-aspect-ratio: 1/1) {
  .fx .lib { inset: -5%; }
}

/* Arrival: home.js sets --g on the field from 0 (slogan on screen) to 1
   (gallery at rest) as the page scrolls between them. The pieces start
   bunched small in the middle and spread to their places, scrubbed by the
   scroll. `translate`/`scale` are their own properties, so they stack with
   the hover's `transform` instead of fighting it. */
.fx .lib { container-type: size; will-change: transform;
  /* The camera: the space turns a few degrees with the cursor (home.js sets
     --tx/--ty, -1..1; on touch screens they float on their own), so the near
     plane sweeps past the far one. */
  transform: translate3d(var(--dx, 0px), var(--dy, 0px), 0) rotateY(calc(var(--tx, 0) * 3.5deg)) rotateX(calc(var(--ty, 0) * -2.5deg)); }
.fx .st { translate: calc(var(--fx) * (1 - var(--g, 1)) * 0.92cqw) calc(var(--fy) * (1 - var(--g, 1)) * 0.92cqh);
  scale: calc(0.45 + 0.55 * var(--g, 1)); opacity: calc(0.15 + 0.85 * var(--g, 1)); }
@media (max-aspect-ratio: 1/1) {
  .fx .st { translate: calc(var(--pfx) * (1 - var(--g, 1)) * 0.92cqw) calc(var(--pfy) * (1 - var(--g, 1)) * 0.92cqh); }
}

/* Portrait screens (phones): a tall 3D field you scroll through (build-home
   PHONE_H; Boss, 2026-11-05: packed, no gaps, firmly on the 3D design). The
   stage is sized from the width, so the build's layout is exact on every
   phone. Three packed columns, each on its own depth plane (--pz); --px/--py/
   --pw are already unprojected for it. home.js moves the camera's vertical
   origin (--poy) with the screen, so the columns slide past each other as
   the page scrolls; a column's pieces share one depth, so they never part.
   Without JS the columns lie flat (--qx/--qy/--qw). No hover; taps open the
   viewer. */
@media (max-aspect-ratio: 1/1) {
  .stage { height: calc(100vw * var(--phone-h, 4)); min-height: 0; }
  .fx .stage { perspective-origin: 50% var(--poy, 50%); }
  .st { left: var(--qx); top: var(--qy); width: var(--qw); transform: none; }
  .fx .st { left: var(--px); top: var(--py); width: var(--pw); transform-origin: 50% 50%;
    transform: translateZ(var(--pz, 0px)); backface-visibility: hidden; }
  /* A piece still loading shows a tone, never a hole in the field. */
  .st { background: color-mix(in srgb, var(--lib-fg) 8%, transparent); }
  /* Taps go to the stage (home.js finds the piece), not 3D hit-testing. */
  .fx .lib .st { pointer-events: none; }
  .fx .stage { cursor: pointer; }
  .st.echo { display: none; }
  /* The title sits right under the top labels; the columns start under it. */
  .lib-title { top: 64px; }
  /* The field is taller than the screen: give its bottom a snap point too,
     or the page snaps from the middle of it straight to services. */
  .stage::after { content: ""; position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; scroll-snap-align: end; }
  /* A tall plane tilts too far at its ends: turn it less. */
  .fx .lib { transform: rotateY(calc(var(--tx, 0) * 2.5deg)) rotateX(calc(var(--ty, 0) * -0.6deg)); }
}
/* Narrow phones: "Light mode" and the centre hint would touch. */
@media (max-width: 359px) { .lib-bc { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .st, .st:hover, .scene-lib { transition: none; }
}

/* ---------- 3. services ---------- */
.scene-services {
  background: var(--paper);
  color: var(--ink);
  min-height: calc(100svh - var(--hbar-h, 77px));
  display: grid;
  align-content: center;
  padding: clamp(28px, 6svh, 72px) var(--gutter);
}
.svc-head {
  max-width: var(--max);
  margin: 0 auto clamp(20px, 3.5svh, 44px);
  width: 100%;
}
.svc-head .mono {
  color: var(--red-ink);
}
.svc-head h2 {
  font: 400 clamp(1.77rem, 5.2vw, 4.16rem)/0.95 var(--font-display);
  text-transform: uppercase;
  margin-top: 8px;
}
.svc {
  list-style: none;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
}
.svc-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 12px clamp(20px, 4vw, 56px);
  padding: clamp(14px, 2.6svh, 32px) 0;
  border-top: 1px solid var(--ink);
  align-items: start;
}
.svc-n {
  font: 400 clamp(1.14rem, 2.08vw, 1.77rem)/1 var(--font-display);
  color: var(--red);
}
.svc-row h3 {
  font: 400 clamp(1.04rem, 2.08vw, 1.66rem)/0.95 var(--font-display);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.svc-row p {
  color: var(--ink-2);
  max-width: 46ch;
}
.svc-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}
.svc-tags li {
  font: 400 0.74rem/1 var(--font-mono);
  padding: 8px 10px;
  background: var(--paper-2);
}

/* ---------- 4. contact ---------- */
.scene-contact {
  background: var(--night);
  color: var(--on-night);
  /* contact + footer = one screen; home.js measures --foot-h */
  min-height: calc(100svh - var(--hbar-h, 77px) - var(--foot-h, 107px));
  display: grid;
  align-content: center;
  padding: clamp(28px, 6svh, 80px) var(--gutter);
}
.contact-in {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}
.contact-copy .mono {
  color: #ff5a62;
}
.contact-copy h2 {
  font: 400 clamp(1.77rem, 4.16vw, 3.43rem)/0.95 var(--font-display);
  text-transform: uppercase;
  margin: 10px 0 18px;
}
.contact-copy p:last-child {
  color: var(--on-night-2);
  max-width: 36ch;
}
.cform {
  display: grid;
  gap: 14px;
}
.f2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.fld {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--on-night-2);
}
.fld em {
  font-style: normal;
  opacity: 0.7;
}
.fld input,
.fld select,
.fld textarea {
  width: 100%;
  font: 400 1rem/1.4 var(--font-body);
  color: #fff;
  background: var(--night-2);
  border: 1.5px solid #2c2c2c;
  border-radius: 0;
  padding: 13px 14px;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.fld select {
  background-image:
    linear-gradient(45deg, transparent 50%, #aaa 50%),
    linear-gradient(-45deg, transparent 50%, #aaa 50%);
  background-position:
    calc(100% - 20px) 21px,
    calc(100% - 14px) 21px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.fld textarea {
  resize: vertical;
  min-height: 120px;
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  outline: none;
  border-color: var(--red);
  background: #222;
}
.fld [aria-invalid="true"] {
  border-color: #ff5a62;
}
.cform .btn {
  justify-self: start;
  min-width: 180px;
}
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.form-status {
  min-height: 1.4em;
  font-size: 0.92rem;
}
.form-status.ok {
  color: #6be38d;
}
.form-status.err {
  color: #ff8a90;
}

.hfoot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  align-items: center;
  justify-content: space-between;
  padding: 28px var(--gutter) max(32px, env(safe-area-inset-bottom));
  border-top: 1px solid #222;
  color: var(--on-night-2);
}
.hfoot a {
  color: var(--on-night);
  padding: 12px 0;
  display: inline-block;
  font-size: 0.9rem;
}

/* ---------- pinned, scroll-linked version ---------- */
/* ---------- one screen per section ----------
   The page snaps section to section: slogan, gallery, services, contact (+
   footer). Each fills the screen under the fixed header, so the page never
   rests on half of one and half of the next. A section taller than the
   screen (services and contact on a phone) snaps to its top and scrolls
   inside normally. */
html:has(body.home) { scroll-snap-type: y mandatory; scroll-padding-top: var(--hbar-h, 77px); }
.scene-hero, .scene-lib, .scene-services, .scene-contact { scroll-snap-align: start; }
.hfoot { scroll-snap-align: end; }
.scene-hero .pin { height: 100svh; min-height: 0; }
@media (max-width: 760px) {
  .svc-row {
    grid-template-columns: 1fr;
  }
  .svc-n {
    font-size: 2rem;
  }
  .contact-in {
    grid-template-columns: 1fr;
  }
  .f2 {
    grid-template-columns: 1fr;
  }
  .cform .btn {
    justify-self: stretch;
  }
  .hbar nav > a[href="#work"] {
    display: none;
  }
}
@media (max-width: 380px) {
  .hbar nav > a[href="#services"] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slogan .ln > span,
  .hero-sub,
  .cue,
  .cue span {
    animation: none;
  }
}

/* ==========================================================================
   Brand 2026 overrides. Section grounds alternate: hero black, the sets on
   cream (the media reads better on a light ground), services charcoal,
   contact black, footer charcoal.
   ========================================================================== */
body.home {
  --hbar-h: 77px; /* logo 44px + 16px clear space above and below + rule */
  background: var(--black);
  color: var(--cream);
}
.hbar {
  /* 16px clear space around the logo */
  padding: 16px var(--gutter);
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--black);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--graphite);
}
.hbar nav > a:not(.btn) {
  color: var(--cream);
  opacity: 1;
  font-weight: 700;
  font-stretch: 125%;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}
.hbar nav > a:not(.btn):hover {
  color: var(--white);
}
.slogan .ln-red {
  color: var(--warm-grey);
}
.cue span {
  background: var(--warm-grey);
}

/* services: charcoal */
.scene-services {
  background: var(--charcoal);
  color: var(--cream);
}
.svc-head .mono,
.svc-n {
  color: var(--cream);
}
.svc-row {
  border-top-color: var(--graphite);
}
.svc-row p {
  color: var(--warm-grey);
}
.svc-tags li {
  background: var(--graphite);
  color: var(--cream);
  border-radius: 4px;
}

/* contact: black */
.scene-contact {
  background: var(--black);
}
.contact-copy .mono {
  color: var(--cream);
}
.fld {
  color: var(--warm-grey);
}
.fld input,
.fld select,
.fld textarea {
  color: var(--cream);
  background-color: var(--charcoal);
  border: 2px solid var(--graphite);
  border-radius: 4px;
}
.fld select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--warm-grey) 50%),
    linear-gradient(-45deg, transparent 50%, var(--warm-grey) 50%);
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  border-color: var(--cream);
  background-color: var(--charcoal);
}
.fld [aria-invalid="true"] {
  border-color: var(--cream);
  border-style: dashed;
}
.form-status.ok,
.form-status.err {
  color: var(--cream);
}

.hfoot {
  background: var(--charcoal);
  border-top: 0;
  color: var(--warm-grey);
}
.hfoot a {
  color: var(--cream);
}
.hbar .btn-sm {
  white-space: nowrap;
}
@media (max-width: 760px) {
  .hbar .btn-sm {
    font-size: 0.72rem;
    padding: 10px 12px;
  }
  .hbar nav > a:not(.btn) {
    font-size: 0.72rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
/* Re-assert the narrow-screen hides over the inline-flex above. */
@media (max-width: 760px) {
  .hbar nav > a:not(.btn)[href="#work"] {
    display: none;
  }
}
@media (max-width: 380px) {
  .hbar nav > a:not(.btn)[href="#services"] {
    display: none;
  }
}

/* ---------- service area + service links (2026-11-09) ---------- */
.svc-lede {
  color: var(--ink-2);
  max-width: 60ch;
  margin-top: 12px;
}
.svc-tags a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.svc-tags a:hover {
  color: var(--ink);
}
