/* Site header, shared by every page: name, nav pill and sound toggle.
   main.js (desk) and header.js (everywhere) drive it. */

/* The header carries its own palette and type, so it looks the same on
   every page whatever that page calls its tokens (the work page's --paper
   is its backdrop, the desk's is the light card colour). */
.site-head {
  --ink: #1d1c1a;
  --paper: #f7f5f0;
  --muted: #6f6a61;
  --line: #ddd8ce;
  --pixel: 'Geist Pixel', ui-monospace, monospace;
  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --pixel-s: 13.16px;
  --pixel-l: 26.32px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

/* Fixed on every section. Over the desk it's just type and two glass pills;
   once the page scrolls (.stuck) a frosted band fades in behind it, the
   role line folds away and the whole thing tightens to --head-h. The band
   is a pseudo-element so the header itself never becomes a containing
   block (the phone nav inside it is fixed to the bottom of the screen). */
.site-head {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: var(--head-h);
  padding: calc(var(--top) - 8px) var(--edge) 8px;
  pointer-events: none;
  transition: padding 420ms var(--ease-out);
}

.site-head::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-bottom: 1px solid rgb(29 28 26 / 0.08);
  background: rgb(232 229 222 / 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  opacity: 0;
  transition: opacity 300ms ease-out, background-color 800ms ease-out, border-color 800ms ease-out;
}

.site-head > * {
  pointer-events: auto;
}

.site-head.stuck {
  padding-block: 0;
}

.site-head.stuck::before {
  opacity: 1;
}

/* Glass shared by the nav and the sound toggle: a translucent pill with a
   lit top edge and a soft, low shadow, so both read as one set. */
.actions-bar,
.sound {
  border: 1px solid rgb(29 28 26 / 0.08);
  background: rgb(247 245 240 / 0.62);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.75), 0 1px 2px rgb(29 28 26 / 0.05);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
}

.intro {
  justify-self: start;
  display: grid;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
}

.intro:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.intro span {
  transition: color 800ms ease-out;
}

/* The role tucks under the name, and folds away once the bar is stuck. */
.intro .role {
  display: grid;
  max-height: 1.6em;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  transition: max-height 420ms var(--ease-out), opacity 240ms ease-out, margin 420ms var(--ease-out), color 800ms ease-out;
}

.stuck .intro .role {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

/* Pixel type for the name, nav and sound label. The font has no bold,
   so never fake one. */
.intro .name,
.actions-bar :is(a, button),
.sound .label {
  font-family: var(--pixel);
  font-variation-settings: 'ELSH' 1;
  font-weight: 400;
  font-synthesis: none;
}

.intro .name {
  font-size: var(--pixel-l);
  line-height: 1.2;
}

/* Sound: four pixel bars that dance while sound is on and lie flat when off. */
.sound {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 18px 0 16px;
  border-radius: 999px;
  color: var(--ink);
  cursor: var(--hand);
  transition: opacity 500ms var(--ease-out), translate 500ms var(--ease-out), background-color 800ms ease-out, border-color 800ms ease-out, color 800ms ease-out, scale 160ms ease-out;
}

.sound .label {
  font-size: 15px;
  line-height: 1;
}

.eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.eq i {
  width: 3px;
  height: 100%;
  background: currentColor;
  transform-origin: bottom;
  scale: 1 0.22;
  opacity: 0.45;
  transition: scale 300ms var(--ease-out), opacity 300ms ease-out;
}

.sound[aria-pressed='true'] .eq i {
  opacity: 1;
  animation: eq 900ms ease-in-out infinite alternate;
}

.sound[aria-pressed='true'] .eq i:nth-child(2) {
  animation-duration: 700ms;
  animation-delay: -300ms;
}

.sound[aria-pressed='true'] .eq i:nth-child(3) {
  animation-duration: 1100ms;
  animation-delay: -500ms;
}

.sound[aria-pressed='true'] .eq i:nth-child(4) {
  animation-duration: 800ms;
  animation-delay: -150ms;
}

@keyframes eq {
  0% {
    scale: 1 0.3;
  }
  50% {
    scale: 1 1;
  }
  100% {
    scale: 1 0.55;
  }
}

.sound:active {
  scale: 0.96;
}

.sound:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .sound:hover {
    background: var(--paper);
  }

  .night .sound:hover {
    background: rgb(255 255 255 / 0.14);
  }
}


/* Header nav: keyboard- and touch-friendly versions of every scene
   interaction, centred between the name and the sound toggle. */
.actions {
  max-width: calc(100vw - 2 * var(--gutter));
}

/* Phones and narrow tablets: the nav would collide with the name up top, so
   it's fixed to the bottom where thumbs reach. */
@media (max-width: 800px) {
  .site-head {
    grid-template-columns: 1fr auto;
  }

  .actions {
    position: fixed;
    left: 50%;
    bottom: var(--top);
    transform: translateX(-50%);
  }
}

/* The nav pill, with a dark thumb that slides to whichever section you're
   pointing at, or rests on the one you're reading. */
.actions-bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: 3px;
  border-radius: 999px;
  transition: background-color 800ms ease-out, border-color 800ms ease-out;
}

.bar-thumb {
  position: absolute;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--ink);
  opacity: 0;
  transition: translate 300ms var(--ease-out), width 300ms var(--ease-out), opacity 150ms ease-out, background-color 800ms ease-out;
}

.bar-thumb.show {
  opacity: 1;
}

.actions-bar :is(a, button) {
  position: relative;
  display: block;
  text-decoration: none;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  cursor: var(--hand);
  transition: color 200ms ease-out, scale 160ms ease-out;
}

.actions-bar :is(a, button).lit {
  color: var(--paper);
}

.actions-bar :is(a, button):active {
  scale: 0.96;
}

.actions-bar :is(a, button):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .sound {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  /* Bars only on phones; the label stays for screen readers. */
  .sound .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .actions-bar {
    flex-wrap: nowrap;
  }

  .actions-bar :is(a, button) {
    padding: 8px 10px;
  }
}


/* Case studies: a Contact button where the home page has its sound toggle.
   Hover: a circle of colour grows from where the pointer came in and fills the
   pill, while the arrow in its round badge turns up 45deg (src/header.js sets
   --bx/--by to the entry point). */
.head-cta {
  --ease-cta: cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 5px 0 20px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: var(--hand);
  transition: color 0.5s var(--ease-cta);
}

.head-cta::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: var(--bx, 50%);
  top: var(--by, 50%);
  width: 240%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #c0392b;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.7s var(--ease-cta);
  pointer-events: none;
}

.head-cta-arrow {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
}

.head-cta-arrow svg {
  width: 16px;
  height: 16px;
  transition: transform 0.6s var(--ease-cta);
}

@media (hover: hover) {
  .head-cta:hover::before { transform: translate(-50%, -50%) scale(1); }
}

.head-cta:focus-visible::before {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
}

.head-cta:is(:hover, :focus-visible) .head-cta-arrow svg { transform: rotate(-45deg); }

.head-cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

@media (hover: none) {
  .head-cta { transition: color 0.5s var(--ease-cta), scale 0.3s var(--ease-cta); }
  .head-cta:active { scale: 0.96; transition-duration: 0.5s, 0.08s; }
}

@media (prefers-reduced-motion: reduce) {
  .head-cta::before, .head-cta-arrow svg { transition: none; }
}
