/* ---------- Homepage and Work page (lib/page.php): menu, creed, practice rows, form spacing, the tools at the bottom ---------- */

/* ---------- Menu button: top right, where the clock was ---------- */
.hud-menu {
  position: absolute;
  top: calc(var(--gutter) - 8px);
  right: calc(var(--gutter) - 10px);
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  pointer-events: auto;
  display: grid;
  place-items: center;
}
.hud-menu i {
  grid-area: 1 / 1;
  display: block;
  width: 22px;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.5s var(--ease, ease), width 0.3s var(--ease, ease);
}
.hud-menu i:first-child { transform: translateY(-4px); }
.hud-menu i:last-child { transform: translateY(4px); width: 14px; justify-self: end; margin-right: 11px; }
.hud-menu:hover i:last-child { width: 22px; }
.hud-menu[aria-expanded='true'] i:first-child { transform: rotate(45deg); }
.hud-menu[aria-expanded='true'] i:last-child { transform: rotate(-45deg); width: 22px; }
.hud-menu:focus-visible { outline: 1px solid currentColor; outline-offset: -4px; border-radius: 50%; }

/* ---------- The menu itself: full screen, big serif links ---------- */
.menu {
  position: fixed;
  inset: 0;
  z-index: 45; /* above the page and its edge fades, under the HUD so the button stays on top */
  display: grid;
  grid-template-rows: 1fr auto;
  padding: calc(var(--gutter) + 72px) var(--gutter) calc(var(--gutter) + 64px);
  background: rgba(5, 5, 5, 0.97);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s var(--ease, ease), visibility 0s 0.45s;
}
.menu[hidden] { display: grid; }
.menu { overflow-y: auto; overscroll-behavior: contain; }
.menu.open { opacity: 1; visibility: visible; transition: opacity 0.45s var(--ease, ease); }
.menu-list { list-style: none; align-self: center; display: grid; gap: clamp(2px, 1vh, 10px); }
.menu-list a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
  font-family: var(--serif);
  font-size: clamp(48px, 9vw, 128px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--fg);
  text-decoration: none;
  transform: translateY(24px);
  opacity: 0;
  transition: transform 0.7s var(--ease, ease), opacity 0.7s var(--ease, ease), color 0.3s;
}
.menu-list a .n { font-family: var(--text); font-size: 12.5px; letter-spacing: 0.14em; color: var(--dim); transform: translateY(-1.6em); }
.menu-list a em { color: var(--dim); }
.menu.open .menu-list a { transform: none; opacity: 1; }
.menu.open .menu-list li:nth-child(2) a { transition-delay: 0.05s; }
.menu.open .menu-list li:nth-child(3) a { transition-delay: 0.1s; }
.menu.open .menu-list li:nth-child(4) a { transition-delay: 0.15s; }
@media (hover: hover) {
  .menu-list:hover a { color: var(--faint); }
  .menu-list a:hover { color: var(--fg); font-style: italic; }
}
.menu-list a[aria-current='page'] { font-style: italic; }
.menu-foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--dim); font-size: 12.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.menu-foot a { color: inherit; text-decoration: none; }
.menu-foot a:hover { color: var(--fg); }
/* Short screens (a phone on its side): tighter, and it can scroll rather than spill. */
@media (max-height: 560px) {
  .menu { padding-top: calc(var(--gutter) + 52px); padding-bottom: calc(var(--gutter) + 8px); gap: 12px; }
  .menu .menu-list a { font-size: clamp(30px, min(9vw, 10.5vh), 128px); }
}
html.menu-on { overflow: hidden; }
html.menu-on .hud-br, html.menu-on .rc-launch { opacity: 0; pointer-events: none; }

/* ---------- Creed: one short line now, so less scroll to light it ---------- */
.lab-creed { height: 150vh; }
.lab-creed.done { height: 80svh; }
.lab-creed .creed-stick { height: 100svh; }
.lab-creed.done .creed-stick { height: 80svh; }
.lab-creed .creed-text { max-width: 17ch; text-align: center; font-size: clamp(36px, min(7vw, 9svh), 124px); }

/* ---------- Practice: titles only; each row's picture fades in behind it on hover ---------- */
.lab-practice .row { grid-template-columns: 1fr; padding-top: clamp(26px, 3.6vw, 44px); padding-bottom: clamp(26px, 3.6vw, 44px); overflow: hidden; isolation: isolate; }
/* The title stays unpositioned so its link can stretch over the whole row; the picture sits behind
   it at -1 (the row's isolation keeps that inside the row). */
.lab-practice .row-t { position: static; }
.row-bg {
  position: absolute;
  inset: 1px 0 0;
  z-index: -1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.8s var(--ease, ease);
  pointer-events: none;
}
/* Dark on the left where the title sits, so it always reads. */
.row-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #050505 0%, rgba(5, 5, 5, 0.82) 30%, rgba(5, 5, 5, 0.35) 70%, rgba(5, 5, 5, 0.6) 100%),
    linear-gradient(180deg, rgba(5, 5, 5, 0.5), transparent 30%, transparent 70%, rgba(5, 5, 5, 0.5));
}
.row.lit .row-bg { opacity: 1; }
@media (hover: hover) {
  .lab-practice .rows .row:hover .row-bg { opacity: 1; }
  .lab-practice .rows:hover .row-t { color: var(--faint); }
  .lab-practice .rows .row:hover .row-t { color: var(--fg); }
}
/* Screens drifting sideways (web: sites; applications: phone screens). */
/* The tilt is on a frame the size of the row, not on the long strip itself: tilting the strip would
   swing its far end (the part on screen) well below the row. */
.rb-tilt { position: absolute; inset: -40% -4%; transform: rotate(-4deg); }
.rb-strip {
  position: absolute;
  top: 50%;
  left: 0;
  display: flex;
  gap: 18px;
  width: max-content;
  transform: translateY(-50%);
  animation: rbDrift 70s linear infinite;
  animation-play-state: paused;
}
.row:hover .rb-strip, .row.lit .rb-strip { animation-play-state: running; }
@keyframes rbDrift { from { translate: 0 0; } to { translate: -50% 0; } }
.rb-strip img { display: block; border-radius: 8px; filter: saturate(0.75) brightness(0.85); }
.rb-web img { width: clamp(190px, 19vw, 300px); aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
/* Phones: the rows are short, so smaller screens, and a lighter shade so they actually show. */
@media (max-width: 700px) {
  .rb-web img { width: 150px; border-radius: 6px; }
  .rb-strip { gap: 10px; }
  .row-bg::after {
    background:
      linear-gradient(90deg, rgba(5, 5, 5, 0.85) 0%, rgba(5, 5, 5, 0.55) 45%, rgba(5, 5, 5, 0.3) 100%),
      linear-gradient(180deg, rgba(5, 5, 5, 0.45), transparent 35%, transparent 65%, rgba(5, 5, 5, 0.45));
  }
}
/* Hosting: a rack of servers, drawn in CSS, with status lights that blink out of step. */
.rb-rack {
  position: absolute;
  inset: -20% -10%;
  transform: perspective(900px) rotateY(-18deg) rotateX(6deg);
  transform-origin: 80% 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 59, 31, 0.95) 0 1.6px, transparent 2.6px) 0 0 / 58px 22px,
    radial-gradient(circle at 50% 50%, rgba(237, 237, 234, 0.55) 0 1.2px, transparent 2.2px) 12px 0 / 58px 22px,
    linear-gradient(rgba(237, 237, 234, 0.1) 1px, transparent 1px) 0 0 / 100% 22px,
    linear-gradient(90deg, rgba(237, 237, 234, 0.07) 1px, transparent 1px) 0 0 / 232px 100%,
    linear-gradient(180deg, #121211, #0b0b0a);
  -webkit-mask-image: linear-gradient(90deg, transparent 18%, #000 60%);
          mask-image: linear-gradient(90deg, transparent 18%, #000 60%);
}
.rb-rack::before, .rb-rack::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(237, 237, 234, 0.9) 0 1.2px, transparent 2.2px) 29px 11px / 116px 44px;
  animation: rbBlink 1.7s steps(2) infinite;
}
.rb-rack::after { background: radial-gradient(circle at 50% 50%, rgba(255, 59, 31, 1) 0 1.4px, transparent 2.4px) 70px 0 / 174px 66px; animation-duration: 2.3s; }
@keyframes rbBlink { 50% { opacity: 0.1; } }
/* A slow light sweeping the rack. */
.pr-host .row-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, transparent 40%, rgba(237, 237, 234, 0.08) 50%, transparent 60%) 0 0 / 300% 100%;
  animation: rbSweep 5s linear infinite;
}
@keyframes rbSweep { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* Applications: a home screen of app icons in the same tilted, fading-in style as the rack.
   A light runs across them corner to corner; a few wear a red notification dot. */
.rb-apps {
  --s: clamp(34px, 3.4vw, 54px);
  position: absolute;
  inset: -30% -10%;
  display: grid;
  grid-template-columns: repeat(40, var(--s));
  grid-auto-rows: var(--s);
  gap: calc(var(--s) * 0.3);
  align-content: center;
  justify-content: end; /* the right is the visible side (the left fades out under the title) */
  transform: perspective(900px) rotateY(-18deg) rotateX(6deg);
  transform-origin: 80% 50%;
  -webkit-mask-image: linear-gradient(90deg, transparent 18%, #000 60%);
          mask-image: linear-gradient(90deg, transparent 18%, #000 60%);
}
.rb-apps i {
  position: relative;
  border-radius: 24%;
  border: 1px solid rgba(237, 237, 234, 0.13);
  background: linear-gradient(160deg, #161615, #0c0c0b);
}
.rb-apps i.f { background: linear-gradient(160deg, #222220, #121211); border-color: rgba(237, 237, 234, 0.2); }
/* The light: each tile brightens briefly as it passes. */
.rb-apps i::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: rgba(237, 237, 234, 0.16);
  box-shadow: 0 0 0 1px rgba(237, 237, 234, 0.35);
  opacity: 0;
  animation: rbTile 6s var(--d, 0s) linear infinite;
  animation-play-state: paused;
}
@keyframes rbTile { 0%, 100% { opacity: 0; } 5% { opacity: 1; } 18% { opacity: 0; } }
.rb-apps i.b::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff3b1f;
  animation: rbBlink 2.1s var(--d, 0s) steps(2) infinite;
  animation-play-state: paused;
}
.row:hover .rb-apps i::before, .row.lit .rb-apps i::before,
.row:hover .rb-apps i::after, .row.lit .rb-apps i::after { animation-play-state: running; }
@media (max-width: 700px) {
  .rb-apps { --s: 26px; }
  .rb-apps i.b::after { width: 5px; height: 5px; top: -2px; right: -2px; }
}

/* Each row is a way in: the whole row is the link (the title's link stretched over it), with an arrow. */
.row-a { color: inherit; text-decoration: none; }
.row-a::after { content: ''; position: absolute; inset: 0; z-index: 2; }
.row-a:focus-visible { outline: none; }
.row:has(.row-a:focus-visible) { outline: 1px solid var(--fg); outline-offset: -1px; }
.row-go {
  position: absolute;
  right: var(--gutter);
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(44px, 4.4vw, 64px);
  height: clamp(44px, 4.4vw, 64px);
  border: 1px solid var(--line, rgba(237, 237, 234, 0.14));
  border-radius: 50%;
  color: var(--fg);
  opacity: 0.4;
  transform: translate(-8px, -50%);
  transition: opacity 0.4s var(--ease, ease), transform 0.4s var(--ease, ease), border-color 0.4s, background 0.4s;
}
.row-go svg { width: 40%; height: 40%; fill: none; stroke: currentColor; stroke-width: 1.3; }
.row.lit .row-go { opacity: 1; transform: translate(0, -50%); border-color: rgba(237, 237, 234, 0.4); background: rgba(5, 5, 5, 0.6); }
@media (hover: hover) {
  .lab-practice .rows:hover .row-go { opacity: 0.15; }
  .lab-practice .rows .row:hover .row-go { opacity: 1; transform: translate(0, -50%); border-color: rgba(237, 237, 234, 0.4); background: rgba(5, 5, 5, 0.6); }
}

.lab-more {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: clamp(36px, 6vw, 64px) var(--gutter) 0;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--dim);
  padding-bottom: 6px;
  transition: gap 0.3s var(--ease, ease), border-color 0.3s;
}
.lab-more svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.lab-more:hover { gap: 16px; border-color: var(--fg); }

/* ---------- The tools, now the last thing before the footer: quiet, and very slow ---------- */
.stack {
  position: relative;
  padding: clamp(72px, 12vh, 140px) 0 clamp(64px, 10vh, 120px);
  overflow: hidden;
}
.stack-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 var(--gutter);
  margin: 0 0 clamp(40px, 7vh, 72px);
}
.stack-k { font-size: 12.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim); }
.stack .bands {
  position: relative;
  inset: auto;
  --br: clamp(180px, 22vmax, 360px);
  /* Dim everywhere, lit where the pointer is; fades out at both edges. */
  -webkit-mask-image:
    radial-gradient(circle var(--br) at var(--hx, 50%) var(--hy, 50%), #000 0%, rgba(0, 0, 0, 0.4) 45%, transparent 75%),
    linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.14) 12%, rgba(0, 0, 0, 0.14) 88%, transparent);
          mask-image:
    radial-gradient(circle var(--br) at var(--hx, 50%) var(--hy, 50%), #000 0%, rgba(0, 0, 0, 0.4) 45%, transparent 75%),
    linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.14) 12%, rgba(0, 0, 0, 0.14) 88%, transparent);
}
.stack .bands-rot { position: relative; left: 0; right: 0; top: auto; transform: none; display: grid; gap: clamp(24px, 4.4vh, 48px); }
.stack .logo { width: clamp(28px, 2.8vw, 46px); height: clamp(28px, 2.8vw, 46px); }
.stack .band-set { gap: clamp(36px, 4.4vw, 76px); padding-right: clamp(36px, 4.4vw, 76px); }
/* Much slower than before; alternate rows drift the other way. */
.stack .band { animation-duration: 240s; animation-direction: normal; }
.stack .band:nth-child(2) { animation-duration: 300s; animation-direction: reverse; }
.stack .band:nth-child(3) { animation-duration: 270s; }
.stack .band:nth-child(4) { animation-duration: 330s; animation-direction: reverse; }
.stack .band:nth-child(5) { animation-duration: 285s; }
@media (hover: none) {
  .stack .bands {
    -webkit-mask-image: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.4) 16%, rgba(0, 0, 0, 0.4) 84%, transparent);
            mask-image: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.4) 16%, rgba(0, 0, 0, 0.4) 84%, transparent);
  }
}
/* The tools sit right after the contact section now; no extra full screen of space around it. */
.found { min-height: auto; padding-bottom: clamp(48px, 8vh, 96px); }

/* The form: each question is a <legend>, which sits outside the step's grid gap, so it was only 4px
   above the first field. Real room under it; the helper line, where there is one, stays close to it. */
.sf-step .sf-q { margin-bottom: clamp(22px, 3.2vw, 32px); }
.sf-step .sf-help { margin-top: -10px; margin-bottom: 6px; }
.sf-body { padding-top: clamp(30px, 4vw, 40px); }
@media (min-width: 641px) { .sf-body { padding-bottom: 22px; } }

/* Phones: the footer stacks, and its first lines sat under the chat button (fixed 64px up, 48px tall).
   Room underneath lets the whole footer scroll clear of it. */
@media (max-width: 640px) {
  .foot { padding-bottom: calc(64px + 48px + 24px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .rb-strip, .rb-rack::before, .rb-rack::after, .pr-host .row-bg::before, .rb-apps i::before, .rb-apps i::after { animation: none; }
  .row-go { transition: none; }
  .menu, .menu-list a { transition: none; }
}
