/* The new direction: a forest at night, pale mist for type, and dew for the one bright thing.
   Flat colour throughout. */
:root {
  --night: #0b1510; /* the page */
  --canopy: #112019; /* raised surfaces */
  --forest: #1b3526; /* glows, fields */
  --moss: #2f5a41; /* strong lines, hovers */
  --sage: #a3b8aa; /* secondary text */
  --mist: #e7eee7; /* text */
  --dew: #d4f3de; /* the drop, highlights, focus */
  --line: rgb(231 238 231 / 0.09);
  --display: "Host Grotesk", ui-sans-serif, system-ui, sans-serif; /* the big headings */
  --text: "Host Grotesk", ui-sans-serif, system-ui, sans-serif; /* everything else */
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gutter: clamp(20px, 4vw, 56px);
  color-scheme: dark;
}

/* The two alternatives to compare: an elegant serif for the big headings, or Geist throughout,
   as on the old site. */
html[data-font="serif"] {
  --display: "Instrument Serif", ui-serif, Georgia, serif;
}

html[data-font="serif"] .hero-title,
html[data-font="serif"] .work-head h2,
html[data-font="serif"] .contact h2 {
  font-weight: 400;
  letter-spacing: -0.01em;
}

html[data-font="serif"] .hero-title {
  font-size: clamp(46px, 6vw, 88px);
  line-height: 0.98;
}

html[data-font="geist"] {
  --display: "Geist", ui-sans-serif, system-ui, sans-serif;
  --text: "Geist", ui-sans-serif, system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--night);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--mist);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--night);
}

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

a {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------------------------------
   Nav */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 72px;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  transition: background-color 250ms ease, border-color 250ms ease;
}

/* Once the page has scrolled, the nav gets a backing so words don't run under it. */
.nav.solid {
  background: rgb(11 21 16 / 0.78);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom-color: var(--line);
}

.mark {
  font: 500 14px/1 var(--mono);
  letter-spacing: 0.02em;
  text-decoration: none;
}

.mark-tld {
  color: var(--sage);
}

.links {
  display: flex;
  gap: 4px;
}

.links a {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 180ms ease;
}

.links a:hover {
  background: rgb(231 238 231 / 0.06);
}

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

/* Everything in the middle: the photo, the name under it, and what I do under that. */
.hero {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  padding: 96px var(--gutter) 64px;
  display: grid;
  place-items: center;
  text-align: center;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The hero's background: the rain, which starts falling once the intro is over (or the pools,
   set aside, which fade in). */
.hero-liquid {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
}

.hero-liquid.fades {
  transition: opacity 1600ms ease;
}

html.intro .hero-liquid {
  opacity: 0;
  transition: none;
}

.label {
  margin: 0;
  font: 500 12px/1.4 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
}

.hero-photo {
  width: clamp(112px, 11vw, 168px);
  height: auto;
  aspect-ratio: 1;
  margin-bottom: 28px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 30%;
  box-shadow: 0 0 0 1px rgb(231 238 231 / 0.14);
}

.hero-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(40px, 5.2vw, 76px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.hero-line {
  margin: 16px 0 0;
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.4;
  color: var(--sage);
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 36px;
}

/* In the bottom corner, a nudge to scroll, where a drop keeps running down a short line. */
.hero-scroll {
  position: absolute;
  bottom: 32px;
  right: var(--gutter);
  margin: 0;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sage);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.hero-scroll:hover {
  color: var(--mist);
}

.scroll-drop {
  position: relative;
  width: 1px;
  height: 36px;
  background: rgb(231 238 231 / 0.2);
}

.scroll-drop::after {
  content: "";
  position: absolute;
  left: -2.5px;
  top: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dew);
  animation: run 2.4s cubic-bezier(0.55, 0, 0.45, 1) infinite;
}

@keyframes run {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(30px);
    opacity: 0;
  }
}

.button {
  display: inline-flex;
  align-items: center;
  height: 52px;
  padding: 0 24px;
  border-radius: 12px;
  background: var(--mist);
  color: var(--night);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 180ms ease, transform 180ms ease;
}

.button:hover {
  background: var(--dew);
}

.button:active {
  transform: scale(0.98);
}

.text-link {
  font-size: 16px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgb(231 238 231 / 0.35);
  text-underline-offset: 6px;
  transition: text-decoration-color 180ms ease;
}

.text-link:hover {
  text-decoration-color: var(--dew);
}

/* ------------------------------------------------------------------------------------------
   About: the label on the left; on the right, a big line whose words light up as it scrolls
   through, then the details. */

.about {
  border-top: 1px solid var(--line);
}

.about-wrap {
  max-width: 1248px;
  margin: 0 auto;
  padding: 144px 24px 152px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(0, 3fr);
  gap: 32px 48px;
}

.about .label {
  margin: 12px 0 0;
}

.about-lead {
  max-width: 24ch;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(30px, 3.8vw, 54px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--mist);
}

/* Words start dim (still readable, over 3:1 at this size) and light up as the line scrolls by. */
.about-lead .word {
  color: #5c6d63;
  transition: color 300ms ease;
}

.about-lead .word.lit {
  color: var(--mist);
}

.about-more {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 32px 64px;
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.about-more p {
  max-width: 52ch;
  margin: 0;
  font-size: 18px;
  line-height: 1.65;
  color: var(--sage);
}

.facts {
  display: grid;
  gap: 20px;
  margin: 0;
}

.facts div {
  display: grid;
  gap: 6px;
}

.facts dt {
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage);
}

.facts dd {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  color: var(--mist);
}

/* ------------------------------------------------------------------------------------------
   Work: the projects scroll past on the left while the laptop and phone stay pinned on the
   right, their screens swapping to the project in view. */

.work {
  /* The stage reaches the window's edge, and on phones hangs below its column; neither may spill
     out of the section (a sideways scroll, or its glow over the contact section). Clip keeps the
     stage sticky, where hidden would not. */
  overflow: clip;
  border-top: 1px solid var(--line);
}

.stage-wrap {
  /* How far the stage runs past the column into the empty margin on the right, up to a limit. */
  --bleed: clamp(24px, calc((100vw - 1248px) / 2 + 24px), 264px);
  position: relative;
  max-width: 1248px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(300px, 5fr) 7fr;
  grid-template-rows: auto 1fr;
  column-gap: 24px;
}

.work-head {
  grid-column: 1;
  grid-row: 1;
  padding-top: 128px;
}

.work-head h2,
.contact h2 {
  margin: 16px 0 0;
  font-family: var(--display);
  font-size: clamp(36px, 4.4vw, 60px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

/* The stage runs from the heading down, so the devices sit beside it from the start, and out to
   the right into the margin, so they can be big. */
.stage {
  --glow: #2f7a52; /* the script changes it to the colour of the project on screen */
  grid-column: 2;
  grid-row: 1 / 3;
  margin-right: calc(-1 * var(--bleed));
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  align-self: start;
  overflow: hidden;
}

.stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: pointer;
  opacity: 0;
  transition: opacity 700ms ease;
}

.stage.ready canvas {
  opacity: 1;
}

/* A soft glow behind the devices in the colour of the project on screen. */
.glow {
  position: absolute;
  inset: 12% 6% 8%;
  background-color: var(--glow);
  opacity: 0.22;
  -webkit-mask-image: radial-gradient(closest-side, #000 15%, transparent);
  mask-image: radial-gradient(closest-side, #000 15%, transparent);
  transition: background-color 900ms ease;
}

.projects {
  grid-column: 1;
  grid-row: 2;
  list-style: none;
  margin: 0;
  padding: 0;
}

.project {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
}

.project-card {
  max-width: 420px;
  padding: 32px 0;
}

/* The first project follows straight on from the heading. Under it goes about half the usual
   gap between cards; the next card's block holds the other half, so the gaps stay even. */
@media (min-width: 900px) {
  .project:first-child {
    min-height: 0;
    align-items: flex-start;
    padding: 24px 0 33svh;
  }
}

.tag {
  margin: 0 0 20px;
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sage);
}

.project h3 {
  margin: 0 0 20px;
  font-family: var(--display);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
}

.blurb {
  margin: 0 0 24px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--sage);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 32px;
  padding: 0;
  list-style: none;
}

.badges li {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--canopy);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 500;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  background: var(--mist);
  color: var(--night);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 180ms ease;
}

.project-link:hover {
  background: var(--dew);
}

.project-link svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 20;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------------------------------
   Contact: in the middle, like the hero, with the email as the big thing. */

.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 144px var(--gutter) 136px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.contact h2 {
  max-width: 14ch;
  font-size: clamp(40px, 6vw, 84px);
  text-wrap: balance;
}

.contact-lede {
  max-width: 44ch;
  margin: 24px 0 40px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--sage);
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.contact-actions .button {
  gap: 10px;
}

.contact-actions svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--canopy);
  color: var(--mist);
  font: 600 16px/1 var(--text);
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease;
}

.copy:hover,
.icon-button:hover {
  border-color: rgb(231 238 231 / 0.28);
}

.icon-button {
  width: 52px;
  padding: 0;
  color: var(--sage);
}

.icon-button:hover {
  color: var(--mist);
}

.contact-actions .icon-brand {
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: none;
}

.copy .icon-done,
.copy.done .icon-copy {
  display: none;
}

.copy.done .icon-done {
  display: block;
  color: var(--dew);
}

/* The note under the buttons: empty until something's copied. */
.copied {
  min-height: 20px;
  margin: 20px 0 0;
  font: 500 13px/1.5 var(--mono);
  color: var(--sage);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding: 28px var(--gutter);
  border-top: 1px solid var(--line);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sage);
}

.footer p {
  margin: 0 auto 0 0;
}

.footer a {
  color: var(--sage);
  text-decoration: none;
  transition: color 180ms ease;
}

.footer a:hover {
  color: var(--mist);
}

/* ------------------------------------------------------------------------------------------
   The intro: a drop falls to the middle of the window and spreads into a line, which pulls
   apart, up and down; each part of the page fades in as a line passes it. The script draws the
   liquid on a canvas in the curtain. */

.curtain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

html:not(.intro) .curtain {
  display: none;
}

.curtain canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

html.intro .rise {
  opacity: 0;
}

/* If the script never runs, the page fades in on its own. */
html.intro:not(.dropping) .rise {
  animation: appear 500ms ease 1.5s forwards;
}

@keyframes appear {
  to {
    opacity: 1;
  }
}

/* Prototype controls: replay the intro and switch the background. They sit in the gap between
   the words and the buttons. */
.controls {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
}

.controls[hidden] {
  display: none;
}

.replay,
.switch a {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(11 21 16 / 0.7);
  color: var(--sage);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease;
}

.replay:hover,
.switch a:hover {
  color: var(--mist);
  border-color: rgb(231 238 231 / 0.25);
}

.replay[hidden] {
  display: none;
}

.switch {
  display: flex;
}

.switch a:first-child {
  border-radius: 10px 0 0 10px;
}

.switch a:last-child {
  margin-left: -1px;
  border-radius: 0 10px 10px 0;
}

.switch a[aria-current] {
  color: var(--night);
  background: var(--mist);
  border-color: var(--mist);
}

/* Phones: the phone model fills the pinned stage and the project cards scroll over it; About
   stacks. */
@media (max-width: 899px) {
  .about-wrap {
    grid-template-columns: 1fr;
    padding: 112px 16px 120px;
  }
  .about-more {
    grid-template-columns: 1fr;
    margin-top: 48px;
  }
  .stage-wrap {
    display: block;
    padding: 0;
  }
  .work-head {
    padding: 104px 16px 24px;
  }
  .stage {
    height: 100svh;
    margin-right: 0;
    margin-bottom: -100svh;
  }
  .glow {
    inset: 4% 0 40%;
  }
  .projects {
    position: relative;
    padding: 0 16px;
  }
  .project {
    min-height: 115svh;
    align-items: flex-end;
    padding-bottom: 6svh;
  }
  .project-card {
    width: 100%;
    max-width: none;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgb(11 21 16 / 0.86);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .project h3 {
    margin-bottom: 12px;
    font-size: 32px;
  }
  .tag {
    margin-bottom: 12px;
  }
  .blurb {
    margin-bottom: 16px;
    font-size: 15px;
  }
  .badges {
    margin-bottom: 20px;
  }
  .project-link {
    width: 100%;
    justify-content: center;
  }
  /* Email me and Copy email share the row; GitHub keeps its square. */
  .contact-actions .button,
  .copy {
    flex: 1 1 0;
    padding: 0 12px;
    white-space: nowrap;
  }
}

@media (max-width: 720px) {
  .links a {
    padding: 10px 10px;
    font-size: 14px;
  }
  .hero-actions {
    width: 100%;
    margin-top: 28px;
  }
  .hero-scroll {
    display: none; /* the thumb already knows to scroll */
  }
  .button {
    flex: 1;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .scroll-drop::after {
    animation: none;
  }
  .glow,
  .stage canvas,
  .about-lead .word {
    transition: none;
  }
}
