:root {
  --font-display: sregs, Simonetta, Georgia, serif;
  --font-accent: Neuton, Georgia, serif;
  --font-body: Simonetta, "Iowan Old Style", Palatino, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* the sky's own page colour at 19:22, matching the hero's canvas fade */
  --bg: #050303;
  --bg-rgb: 5, 3, 3;
  --fg: #e6e6e6;
  --fg-dim: rgba(244, 236, 233, 0.7);
  --fg-faint: rgba(244, 236, 233, 0.42);
  --accent: #e8a463;
  /* the accent, unpacked, so rules and glows can take it at any strength */
  --accent-rgb: 232, 164, 99;
  --line: rgba(244, 236, 233, 0.12);

  /* One rail for the whole page. The hero title, the scan, the project list
     and the footer all hang off the same left edge — before this, each block
     had a width of its own and nothing below the fold lined up. */
  --rail: 68rem;
  --gutter: clamp(1.5rem, 6vw, 2.5rem);
  --section-pad: clamp(4rem, 10vh, 7rem);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

@font-face {
  font-family: sregs;
  src: url(../assets/sregs.otf) format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}


* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

::selection {
  background: rgba(var(--accent-rgb), 0.28);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  font-family: var(--font-accent);
  transform: translateY(-120%);
}
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ---------- Shared page furniture ---------- */

.rail {
  width: 100%;
  max-width: var(--rail);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: var(--section-pad);
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.section-head {
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

/* ---------- Hero ---------- */

#hero {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 640px;
  overflow: hidden;
  background: var(--bg);
  /* Scopes the children's z-index to inside this box. Without it, #hero never
     forms a stacking context of its own, so those z-indexes compete globally
     with every other one on the page. */
  isolation: isolate;
}

#webgl {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.2s ease;

  /* The last sliver of the canvas dissolves into the page.
     
     By the time the frame gets here it is already the page's colour: the near
     ground and blades are crushed to ENV.page in the shader (see the note in
     src/grass.js), so this ramp is closing a gap of about five levels out of
     255, across a tenth of the hero's height. It cannot band — the change is
     far below one level per pixel — and it cannot eat any picture, because
     there is no picture left down here to eat.
     
     What it buys is exactness. Crushing to the page's colour gets the render
     *near* --bg, but the value that comes out the far end of tone mapping and
     the sRGB encode is a couple of levels off, and it is off by a different
     amount on a different pipeline. At alpha zero there is nothing to match:
     the bottom row of the canvas is the page, not a colour resembling it. */
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 90%,
    rgba(0, 0, 0, 0.72) 93.5%,
    rgba(0, 0, 0, 0.38) 96.5%,
    rgba(0, 0, 0, 0.12) 98.5%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 90%,
    rgba(0, 0, 0, 0.72) 93.5%,
    rgba(0, 0, 0, 0.38) 96.5%,
    rgba(0, 0, 0, 0.12) 98.5%,
    transparent 100%
  );
}
#hero.model-loaded #webgl {
  opacity: 1;
}

/* no WebGL: the hero keeps its height and its title, there is just no picture */
#hero[data-scene="off"] #webgl {
  display: none;
}

/* On the rail like everything else, rather than a fixed 10rem inset — at
   phone widths that inset left the title two words wide and pushed the
   subtitle off the right edge. */
#hero-content {
  position: absolute;
  top: clamp(4.5rem, 15vh, 9rem);
  left: 0;
  right: 0;
  z-index: 1;
  text-align: left;
  pointer-events: none;
}
#hero-content > * {
  max-width: var(--rail);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

#hi {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.05;
}

#hero-sub {
  margin: 1rem 0 0;
  font-family: var(--font-accent);
  font-size: clamp(1.2rem, 2.6vw, 1.75rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--fg-dim);
}

/* ---- diagonal swipe reveal (title & subtitle, together) ---- */

@property --hero-reveal {
  syntax: "<percentage>";
  inherits: false;
  initial-value: -25%;
}

#hi,
#hero-sub {
  --hero-reveal: -25%;
  -webkit-mask-image: linear-gradient(
    to top right,
    #000 calc(var(--hero-reveal) - 25%),
    transparent var(--hero-reveal)
  );
  mask-image: linear-gradient(
    to top right,
    #000 calc(var(--hero-reveal) - 25%),
    transparent var(--hero-reveal)
  );
  animation: hero-reveal-sweep 2.0s ease-out forwards;
  animation-delay: 0.5s;
}

#hero-sub {
  animation-delay: 0.65s;
}

@keyframes hero-reveal-sweep {
  to {
    --hero-reveal: 125%;
  }
}

/* ---------- About ---------- */

/* A scan of me beside the copy, side by side. [data-reveal].in-view (set by
   src/reveal.js when the section first scrolls into view) fades it in once. */

#about .about-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: clamp(2.5rem, 7vw, 5rem);
}

/* ---- the portrait ---- */

/* No plate, no frame: he stands on the page itself, lit by src/portrait.js.
   The box is only there to hold the shot's aspect — the framing inside it is
   fixed, so it never recomposes as the page resizes. */
.portrait {
  position: relative;
  flex: 0 0 clamp(13rem, 26vw, 19rem);
  margin: 0;
  aspect-ratio: 4 / 5;
}

.portrait-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.2s ease;
  /* The scan stops at the waist, where the capture did — off the bottom edge
     of the frame, not partway up it: the crossed arms and hands are real,
     good detail and stay visible. Only the literal bottom edge of the canvas
     box (a hard rectangular crop, not a scan defect) needs dissolving, so
     the fade holds through most of the frame and eases out — like a
     smoothstep, not a straight ramp — across a wide final stretch. */
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0%,
    #000 65%,
    rgba(0, 0, 0, 0.9) 72%,
    rgba(0, 0, 0, 0.65) 79%,
    rgba(0, 0, 0, 0.35) 86%,
    rgba(0, 0, 0, 0.1) 93%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 0%,
    #000 65%,
    rgba(0, 0, 0, 0.9) 72%,
    rgba(0, 0, 0, 0.65) 79%,
    rgba(0, 0, 0, 0.35) 86%,
    rgba(0, 0, 0, 0.1) 93%,
    transparent 100%
  );
}

/* he's actually standing there */
.portrait[data-portrait="ready"] .portrait-canvas {
  opacity: 1;
}

/* no WebGL, or the scan didn't load: the composition holds and the monogram
   stands in for him — see src/portrait.js */
.portrait[data-portrait="missing"] .portrait-canvas {
  display: none;
}
.portrait[data-portrait="missing"]::after {
  content: "R";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 7rem;
  color: rgba(244, 236, 233, 0.12);
}

/* ---- the copy ---- */

.about-copy {
  min-width: 0;
}

.about-copy .section-title {
  margin-bottom: 1.4rem;
}

.about-body {
  margin: 0 0 1.15rem;
  max-width: 34rem;
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--fg-dim);
}
.about-body:last-child {
  margin-bottom: 0;
}

/* the opening paragraph carries a little more weight, so the block has a
   top to it rather than reading as two equal slabs */
.about-lead {
  font-size: 1.15rem;
  line-height: 1.7;
  color: rgba(244, 236, 233, 0.86);
}

/* ---------- Projects ---------- */

#content {
  position: relative;
  background: var(--bg);
}

.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* An index row rather than a sentence with a link in it: number, name,
   what it is, what it's built with, and the arrow that moves on hover. */
.project {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "index body tag arrow";
  align-items: center;
  gap: clamp(1rem, 3vw, 2.25rem);
  padding: 1.6rem clamp(0.75rem, 2vw, 1.25rem);
  margin-inline: clamp(-1.25rem, -2vw, -0.75rem);
  border-radius: 0.6rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.45s ease;
}
.project::before {
  /* the hairline between rows, fading out to the right */
  content: "";
  position: absolute;
  left: clamp(0.75rem, 2vw, 1.25rem);
  right: clamp(0.75rem, 2vw, 1.25rem);
  top: 0;
  height: 1px;
  background: linear-gradient(to right, var(--line), rgba(244, 236, 233, 0.03) 70%, transparent);
}
.project:hover,
.project:focus-visible {
  background-color: rgba(var(--accent-rgb), 0.05);
  text-decoration: none;
}

.project-index {
  grid-area: index;
  font-family: var(--font-accent);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: var(--fg-faint);
  transition: color 0.35s ease;
}

.project-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.project-name {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  line-height: 1.2;
  color: var(--fg);
  transition: color 0.35s ease;
}

.project-desc {
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--fg-dim);
}

.project-tag {
  grid-area: tag;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-accent);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  white-space: nowrap;
  transition: border-color 0.35s ease, color 0.35s ease;
}

.project-arrow {
  grid-area: arrow;
  display: flex;
  color: var(--fg-faint);
  transition: transform 0.45s var(--ease-out), color 0.35s ease;
}

.project:hover .project-name,
.project:focus-visible .project-name,
.project:hover .project-index,
.project:focus-visible .project-index,
.project:hover .project-arrow,
.project:focus-visible .project-arrow {
  color: var(--accent);
}
.project:hover .project-tag,
.project:focus-visible .project-tag {
  border-color: rgba(var(--accent-rgb), 0.4);
  color: rgba(var(--accent-rgb), 0.85);
}
.project:hover .project-arrow,
.project:focus-visible .project-arrow {
  transform: translateX(0.35rem);
}

/* ---------- Footer ---------- */

#site-footer {
  position: relative;
  padding-bottom: clamp(2.5rem, 6vh, 4rem);
}
#site-footer::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  top: 0;
  z-index: 0;
  pointer-events: none;
  /* the page settles a shade darker at the bottom, and takes back a little
     of the sunset at the very end */
  background:
    radial-gradient(80% 60% at 50% 100%, rgba(var(--accent-rgb), 0.05), transparent 70%),
    linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.35));
}
#site-footer > .rail {
  position: relative;
  z-index: 1;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(2rem, 6vw, 4rem);
  padding-bottom: clamp(2.5rem, 6vw, 4rem);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 3rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--fg-faint);
  font-family: var(--font-accent);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: none;
}

.footer-link-value {
  position: relative;
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: 1.05rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
  transition: color 0.35s ease;
}
/* the underline draws itself in rather than blinking on */
.footer-link-value::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.15em;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease-out);
}
.footer-links a:hover .footer-link-value,
.footer-links a:focus-visible .footer-link-value {
  color: var(--accent);
}
.footer-links a:hover .footer-link-value::after,
.footer-links a:focus-visible .footer-link-value::after {
  transform: scaleX(1);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-accent);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
}

/* ---------- Scroll reveal ---------- */

/* Everything below the hero arrives the same way: a short lift and fade the
   first time it comes into view. src/reveal.js only sets .in-view. */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 1rem, 0);
  transition: opacity 1.1s ease, transform 1.1s var(--ease-out);
}
[data-reveal].in-view {
  opacity: 1;
  transform: none;
}

/* ---------- Narrow ---------- */

@media (max-width: 720px) {
  #about .about-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 2.25rem;
  }
  .portrait {
    flex-basis: auto;
    width: clamp(11rem, 52vw, 15rem);
    align-self: center;
  }

  .project {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "index body  arrow"
      "index tag   arrow";
    align-items: start;
    row-gap: 0.9rem;
  }
  /* the number and the arrow ride the title's line, not the row's middle */
  .project-index,
  .project-arrow {
    padding-top: 0.32rem;
  }
  .project-tag {
    justify-self: start;
  }

  .footer-top {
    align-items: flex-start;
  }
  .footer-links {
    gap: 1.5rem 2.5rem;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html,
  body {
    scroll-behavior: auto;
  }
  #hi,
  #hero-sub {
    animation: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  [data-reveal],
  .portrait-canvas,
  .project,
  .project-arrow {
    transition-duration: 0.01ms;
  }
}
