:root {
  --bg: #060606;
  --fg: #f1ede6;
  --mute: #8f8b84;
  --line: rgba(241, 237, 230, .16);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Atkinson Hyperlegible', Arial, sans-serif;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

#scroll {
  height: 850vh;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* Background video and fallback artwork */
.artwork {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

.artwork img,
.artwork video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.artwork video {
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}

.artwork video.ready {
  opacity: 1;
}

#shade {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .35) 0, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, .5) 100%);
  pointer-events: none;
  z-index: 2;
}

/* Particle assembly canvas for the entrance animation */
#particle-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  opacity: 1;
  transition: opacity .55s cubic-bezier(0.2, 0.8, 0.4, 1);
}

#particle-stage.fading {
  opacity: 0;
}

#particle-stage.done {
  opacity: 0;
  display: none;
}

#bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 28px 0;
  font-size: 13px;
  color: var(--mute);
  z-index: 10;
}

#bar b {
  font-weight: 400;
  color: var(--fg);
}

#dots {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 10;
}

#dots button {
  width: 30px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .3s, transform .3s;
}

#dots button::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--mute);
}

#dots button.on::before {
  background: var(--fg);
  border-color: var(--fg);
  transform: scale(1.3);
}

#dots button:focus-visible,
a:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

/* Centered content layout — balanced spacing between human & robot */
#content {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 5;
}

.panel {
  grid-area: 1/1;
  width: min(580px, 86vw);
  text-align: center;
  will-change: transform, filter;
}

/* Avoid briefly painting sections before the scroll state is initialized. */
.panel:not([aria-label="Introduction"]) { visibility: hidden; }

.panel:first-child,
.panel[aria-label="Introduction"] {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity .6s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel:first-child.assembled,
.panel[aria-label="Introduction"].assembled {
  opacity: 1;
}

.hi {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(20px, 2.6vw, 28px);
  color: var(--mute);
  margin-bottom: 6px;
  text-align: center;
}

.services-link { color: var(--fg); font-family: var(--sans); font-size: 13px; margin-top: 18px; text-underline-offset: 4px; }
.services-link:hover { color: #d4a27c; }

.down {
  display: block;
  margin: 34px auto 0;
  width: 18px;
  height: 28px;
  stroke: var(--mute);
  animation: bob 2.4s ease-in-out infinite;
  cursor: pointer;
}

@keyframes bob {
  50% {
    transform: translateY(7px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .down {
    animation: none;
  }
  .panel:first-child,
  .panel[aria-label="Introduction"] {
    opacity: 1 !important;
  }
  #particle-stage {
    display: none !important;
  }
}

.panel h1 {
  font-family: "Caveat", "Comic Sans MS", cursive;
  font-weight: 700;
  font-size: clamp(38px, 6vw, 76px);
  line-height: 1.05;
  letter-spacing: normal;
}

.panel h2,
.project-heading h2 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(30px, 4.2vw, 50px);
  line-height: 1.05;
  letter-spacing: -.01em;
  margin-bottom: 26px;
  text-align: center;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 10px;
  text-decoration-color: var(--mute);
}

.lede {
  margin: 20px auto 0;
  max-width: 40ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--mute);
  text-align: center;
}

.work {
  display: grid;
  gap: 16px;
}

.work a {
  color: inherit;
  text-decoration: none;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 24px;
  align-items: center;
}

.thumb {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #0d0d0d;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.work h3 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.12;
}

.work small {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--mute);
}

.stack {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stack figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.tile {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(13, 13, 13, .7);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 32px);
}

.tile img {
  width: 55%;
  height: 55%;
  object-fit: contain;
}

.stack figcaption {
  font-size: 13px;
  color: var(--mute);
}

.links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 26px;
  align-items: center;
}

.links a {
  color: var(--fg);
  text-decoration: none;
  font-family: var(--serif);
  font-size: clamp(20px, 2.6vw, 28px);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: border-color .3s;
}

.links a:hover {
  border-color: var(--fg);
}

@media (max-width: 560px) {
  #dots {
    right: 12px;
  }
  .work a {
    grid-template-columns: 100px 1fr;
    gap: 16px;
  }
  .stack {
    gap: 10px;
  }
}

/* One stationary heading anchors the three project cards. */
.project-heading { grid-area: 1/1; width: min(580px, 86vw); text-align: center; pointer-events: none; opacity: 0; }
.project-heading-spacer { height: 150px; }
.panel:has(.work) > h2 { visibility: hidden; }
@media (max-width: 560px) { .project-heading-spacer { height: 100px; } }

#intro-exit-particles { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #intro-exit-particles { display: none; } }

/* Project layout: image and story sit together between the two figures. */
.panel:has(.work), .project-heading { width: min(840px, 62vw); text-align: left; }
.panel:has(.work) > h2, .project-heading h2 {
  text-align: left;
  font-size: clamp(22px, 2vw, 30px);
  letter-spacing: .08em;
  text-decoration: none;
  margin-bottom: 32px;
}
.project-heading h2::after { content: ''; display: block; width: 42px; height: 1px; background: var(--mute); margin-top: 16px; }
.panel:has(.work) > h2::after { content: ''; display: block; height: 1px; margin-top: 16px; }
.work a { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(24px, 3vw, 48px); text-align: left; }
.thumb { aspect-ratio: 16 / 10; border-radius: 12px; }
.work h3 { font-size: clamp(25px, 3vw, 42px); }
.work small { max-width: 34ch; font-size: clamp(13px, 1.15vw, 16px); }
.project-heading-spacer { height: auto; aspect-ratio: 16 / 10; width: calc((100% - clamp(24px, 3vw, 48px)) * 1.15 / 2.15); }
@media (max-width: 700px) {
  .panel:has(.work), .project-heading { width: min(86vw, 500px); }
  .work a { grid-template-columns: 1fr; gap: 18px; }
  .thumb { width: min(100%, 310px); }
  .work h3 { font-size: 27px; }
  .project-heading-spacer { width: min(100%, 310px); aspect-ratio: 16 / 10; height: auto; margin-bottom: 18px; }
  .project-heading-spacer::after { content: ''; display: block; height: 110px; }
}

/* Leave the center of the closing shot open for the handshake. */
.contact-panel { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0 clamp(28px, 5vw, 80px); text-align: left; }
.contact-info { width: min(23vw, 240px); }
.contact-qr { width: min(23vw, 240px); }
.contact-kicker { color: var(--mute); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 14px; }
.contact-info h2 { text-align: left; text-decoration: none; margin: 0 0 18px; }
.contact-info p:not(.contact-kicker) { color: var(--mute); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }
.contact-info a { display: block; color: var(--fg); text-decoration: none; font-size: 13px; line-height: 1.7; margin-top: 17px; }
.contact-info a strong { font-weight: 400; color: var(--mute); }
.contact-info a:hover { text-decoration: underline; }
.contact-qr { text-align: center; }
.contact-qr img { display: block; width: min(100%, 220px); height: auto; margin: 0 auto; border-radius: 4px; }
.contact-qr p { font-size: 13px; margin-top: 12px; line-height: 1.5; }
.contact-qr p span { color: var(--mute); }
@media (max-width: 700px) {
  .contact-panel { align-self: end; padding: 20px 28px calc(24px + env(safe-area-inset-bottom, 0px)); align-items: end; background: linear-gradient(transparent, #060606e8 35%); }
  .contact-info { width: 51%; }
  .contact-qr { width: 39%; }
  .contact-info h2 { font-size: 27px; margin-bottom: 8px; }
  .contact-kicker { font-size: 9px; margin-bottom: 6px; }
  .contact-info p:not(.contact-kicker) { font-size: 12px; margin-bottom: 8px; }
  .contact-info a { font-size: 12px; margin-top: 8px; }
  .contact-qr img { width: min(100%, 150px); }
  .contact-qr p { font-size: 11px; margin-top: 5px; }
}

/* A single tool forms from particles in the center of the scene. */
#scroll { height: 1350vh; }
.stack { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 260px; gap: 0; }
#stack-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stack-logo { width: 128px; height: 128px; object-fit: contain; }
.stack-logo.mono { filter: brightness(0) invert(1); }
#stack-name { margin: 18px 0 0; font-size: 14px; color: var(--fg); letter-spacing: .05em; }
@media (max-width: 560px) { .stack { height: 220px; } .stack-logo { width: 105px; height: 105px; } }
@media (prefers-reduced-motion: reduce) { #stack-particles { display: none; } }

/* Four compact marks share the center, each with room to move. */
.stack-row { display: flex; justify-content: center; gap: clamp(12px, 2vw, 28px); align-items: start; width: min(100%, 500px); }
.stack-item { flex: 0 1 105px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.stack-item .stack-logo { width: clamp(54px, 6vw, 86px); height: clamp(54px, 6vw, 86px); }
.stack-item figcaption { color: var(--fg); font-size: 12px; line-height: 1.3; text-align: center; }
@media (max-width: 560px) { .stack-row { gap: 9px; } .stack-item { gap: 10px; } .stack-item .stack-logo { width: 52px; height: 52px; } .stack-item figcaption { font-size: 10px; } }

/* The row is a window onto a continuous scroll-driven track. */
.stack { overflow: hidden; }
.stack-row { position: relative; display: block; width: min(100%, 500px); height: 150px; }
.stack-item { position: absolute; left: 50%; top: 12px; width: 105px; }
@media (max-width: 560px) { .stack-row { height: 120px; } .stack-item { width: 72px; top: 9px; } }

/* Give the stack and its particles room to breathe across the scene. */
.panel[aria-label="Tools I Use"] { width: min(960px, 92vw); }
.stack-row { width: 100%; }
@media (max-width: 560px) { .panel[aria-label="Tools I Use"] { width: 94vw; } }

/* Typography: a personal signature, readable editorial headings, and clear labels. */
body { font-weight: 400; }
.panel h2, .project-heading h2, .work h3 { font-weight: 400; }
.stack-item figcaption { font-size: 12px; }
.contact-kicker { font-size: 12px; }
@media (max-width: 560px) { .stack-item figcaption { font-size: 12px; } .contact-kicker { font-size: 11px; } }

/* A consistent site-wide type system: expressive headings and readable detail. */
.hi { font-weight: 400; }
.panel h2, .project-heading h2, .work h3 { font-weight: 500; }
#bar, .lede, .work small, .stack-item figcaption, .contact-panel { font-family: var(--sans); }
#bar, .work small, .contact-info p:not(.contact-kicker) { line-height: 1.55; }
.stack-item figcaption, .contact-info a, .contact-qr p { font-weight: 400; }

/* Project screenshots can be opened at full size for the fine details. */
.report-thumb { display: grid; place-items: center; background: #fff; }
.report-thumb img { width: 100%; height: auto; object-fit: contain; }
.project-action { display: inline-block; margin-top: 15px; font-family: var(--sans); font-size: 12px; color: var(--fg); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.work a:hover .project-action, .work a:focus-visible .project-action { border-color: var(--fg); }

/* Keep decorative media out of text selections and match selection to the site. */
.artwork, .artwork img, .artwork video, #shade, #scroll, canvas, .down {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.artwork { pointer-events: none; }
::selection { background: #c9a989; color: #17120f; }

/* Native proximity snap keeps scrolling interruptible and touch-friendly. */
#scroll { position: relative; }
.scroll-snap-marker { position: absolute; left: 0; width: 1px; height: 1px; scroll-snap-align: start; pointer-events: none; }
html.has-scroll-snap { scroll-snap-type: y proximity; }
@media (prefers-reduced-motion: reduce) { html.has-scroll-snap { scroll-snap-type: none; scroll-behavior: auto; } }

/* Mobile: keep content clear of the header, navigation, and screen edges. */
@media (max-width: 700px) {
  #bar { padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 0; font-size: 12px; gap: 12px; }
  #bar span { text-align: right; }
  #content { inset: calc(58px + env(safe-area-inset-top, 0px)) 48px calc(16px + env(safe-area-inset-bottom, 0px)) 16px; }
  #dots { right: 0; gap: 0; }
  #dots button { width: 44px; height: 38px; border: 0; border-radius: 0; background: none; display: grid; place-items: center; padding: 0; }
  #dots button::before { content: ''; width: 7px; height: 7px; border: 1px solid var(--mute); border-radius: 50%; }
  #dots button.on { background: none; border: 0; transform: none; }
  #dots button.on::before { background: var(--fg); border-color: var(--fg); transform: scale(1.3); }
  .panel, .panel:has(.work), .panel[aria-label="Tools I Use"] { width: 100%; max-width: 440px; }
  .panel[aria-label="Introduction"] h1 { font-size: clamp(32px, 10vw, 48px); overflow-wrap: anywhere; }
  .hi { font-size: clamp(18px, 5vw, 24px); }
  .lede { font-size: 14px; line-height: 1.5; margin-top: 14px; }
  .down { margin-top: 22px; }
  /* Real headings follow each card's height; the desktop shared heading needs a spacer. */
  .project-heading { display: none; }
  .panel:has(.work) > h2 { visibility: visible; font-size: 22px; margin-bottom: 18px; letter-spacing: .04em; }
  .panel:has(.work) > h2::after { margin-top: 10px; }
  .work a { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .thumb { width: min(100%, 300px); }
  .work h3 { font-size: clamp(22px, 6vw, 27px); line-height: 1.12; }
  .work small { font-size: 13px; line-height: 1.45; margin-top: 7px; }
  .project-action { margin-top: 10px; font-size: 13px; }
  .panel[aria-label="Tools I Use"] h2 { font-size: 30px; margin-bottom: 15px; }
  .stack { height: 190px; }
  .stack-row { height: 115px; }
  .stack-item { width: 62px; }
  .stack-item .stack-logo { width: 48px; height: 48px; }
  .stack-item figcaption { font-size: 11px; line-height: 1.25; overflow-wrap: anywhere; }
  .contact-panel { padding: 18px 0 0; gap: 16px; background: none; }
  .contact-info { width: auto; flex: 1 1 0; min-width: 0; }
  .contact-qr { width: min(37%, 145px); flex: 0 0 auto; }
  .contact-info h2 { margin-bottom: 8px; }
  .contact-info a { overflow-wrap: anywhere; }
  .contact-qr img { width: min(100%, 145px); }
  #shade { background: radial-gradient(ellipse at center, rgba(0,0,0,.55), rgba(0,0,0,.18) 65%, rgba(0,0,0,.45)); }
}
@media (max-width: 700px) and (max-height: 650px) {
  .thumb { width: min(100%, 235px); }
  .panel:has(.work) > h2 { margin-bottom: 10px; }
  .work a { gap: 10px; }
  .work h3 { font-size: 22px; }
  .work small { font-size: 12px; margin-top: 5px; }
  .project-action { margin-top: 6px; }
  .stack { height: 155px; }
}
/* A short landscape screen gets a compact side-by-side project and contact layout. */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  #bar { padding: 12px 18px 0; font-size: 11px; }
  #content { inset: 46px 48px 10px 18px; }
  .panel:has(.work), .panel[aria-label="Tools I Use"] { width: min(100%, 620px); }
  .project-heading { display: none; }
  .panel:has(.work) > h2 { visibility: visible; font-size: 20px; margin-bottom: 10px; }
  .work a { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
  .thumb { width: 100%; max-width: 240px; }
  .work h3 { font-size: 20px; }
  .work small { font-size: 12px; line-height: 1.35; }
  .project-action { margin-top: 6px; }
  .stack { height: 135px; }
  .contact-panel { align-self: center; padding: 0; background: none; }
  .contact-qr img { width: min(100%, 100px); }
  .contact-info p:not(.contact-kicker) { margin-bottom: 6px; }
  .contact-info a { margin-top: 5px; }
}
