:root {
  /* Flip these two to swap the whole page between light and dark. */
  --paper: #111111;
  --ink-rgb: 243 241 238;

  --ink: rgb(var(--ink-rgb));
  --muted: rgb(var(--ink-rgb) / 0.7);
  --line: rgb(var(--ink-rgb) / 0.22);
  --page-gutter: clamp(0.7rem, 1vw, 1.1rem);
  --bio-width: clamp(20rem, 46vw, 48rem);
  --project-indent: clamp(3rem, 6vw, 10rem);
  --content-max: min(100%, clamp(42rem, 72vw, 72rem));
}

* {
  box-sizing: border-box;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.fade-in {
  animation: view-in 0.4s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    animation: none;
  }
}

/* Author display rules otherwise beat the hidden attribute. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  /* Scale the whole page with the viewport, while preserving the browser's
     font preferences rather than locking the layout to a single laptop size. */
  font-size: clamp(12px, 0.68vw + 8.8px, 15.7px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Geist Mono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-weight: 300;
  overflow-x: hidden;
}

.portfolio-shell,
.project-view,
.project-section,
.cv {
  overflow-x: clip;
}

img {
  max-width: 100%;
  display: block;
}

button,
a {
  font: inherit;
}

.portfolio-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  padding: var(--page-gutter) var(--page-gutter) 0.45rem;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem 1.1rem;
  align-items: start;
  min-height: 2.3rem;
}

.info-block {
  max-width: var(--bio-width);
  min-width: 0;
  cursor: pointer;
}

.mini-label {
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.info-block p {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.45;
  color: rgb(var(--ink-rgb) / 0.74);
}

.info-block p + p {
  margin-top: 0.5rem;
}

.meta-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  gap: 0.6rem;
  padding-top: 0.2rem;
}

.meta-links,
.meta-copy {
  display: flex;
  gap: 1.3rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  font-size: 0.59rem;
  color: rgb(var(--ink-rgb) / 0.78);
}

.meta-links a,
.info-block a {
  color: var(--ink);
  text-decoration: none;
}

.meta-links a:hover,
.info-block a:hover,
.meta-links a:focus-visible,
.info-block a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Absorbs the free space between the bio and the work list, so the
   preview centres in the empty band rather than in the whole viewport. */
.preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

/* The preview is a hover interaction, and it needs room for the image
   and its caption side by side — so it stays off touch and narrow screens. */
@media (hover: none), (max-width: 820px) {
  .preview {
    display: none;
  }
}

.preview.is-visible {
  opacity: 1;
}

/* Sized by its content, so the caption's first line starts level with the
   top of the image and the pair centres as one block. */
.preview__frame {
  display: flex;
  align-items: flex-start;
  gap: 1.4rem;
  margin: 0;
  max-width: calc(100vw - (2 * var(--page-gutter)));
}

.preview__media {
  display: grid;
  min-width: 0;
}

.preview__slide {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  max-width: 56vw;
  opacity: 0;
}

.preview__slide.is-active {
  opacity: 1;
}

.preview__img,
.preview__video {
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  max-width: 100%;
  max-height: 46vh;
}

/* Follows the bio directly, with a deliberate gap so the two blocks
   read as separate rather than running together. */
.cv {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 3.4rem;
  padding-bottom: 3rem;
  width: min(100%, var(--content-max));
  max-width: 100%;
}

.cv-group {
  width: 100%;
}

.project-view-back {
  margin-top: 0;
}

@keyframes project-page-switch {
  from {
    opacity: 0.15;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.project-view.is-project-switching {
  animation: project-page-switch 1.05s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.project-view-controls {
  position: relative;
  display: flex;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 1.4rem;
}

.project-view-controls .cv-back {
  margin-bottom: 0;
}

.project-view-next {
  position: absolute;
  top: 0;
  right: 0;
}

.cv-back {
  display: block;
  align-self: flex-start;
  margin-bottom: 1.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
}

.cv-back:hover,
.cv-back:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.cv-group + .cv-group {
  margin-top: 2rem;
}

/* Same column logic as a work row: label left, detail right. */
.cv-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  gap: 0.7rem 1.05rem;
  padding: 0.5rem 0 0.55rem;
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
  line-height: 1.45;
  letter-spacing: -0.02em;
}

.cv-role {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.cv-meta {
  color: rgb(var(--ink-rgb) / 0.68);
}

.cv-desc {
  margin: 0;
  color: rgb(var(--ink-rgb) / 0.74);
}

.cv-toggle.is-active {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.project-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.6rem;
  padding-top: 3.4rem;
  padding-bottom: 3rem;
  width: 100%;
  max-width: 100%;
}

/* One group of images at a time; the track slides sideways between them.
   Named apart from .project-view-media, which is the images themselves. */
.project-view-slider {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  animation: hero-slide 0.5s ease both;
}

.project-view-track {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  transition: transform 0.55s ease;
}

/* Each slide fills the viewport width; its images share that width by
   aspect ratio rather than wrapping. */
.project-view-media-row {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  gap: 1.4rem;
}

.project-view-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-left: auto;
  /* Pulled in from the very edge so the arrows are easier to hit. */
  margin-right: 1.6rem;
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  color: rgb(var(--ink-rgb) / 0.68);
}

.project-view-count {
  font-variant-numeric: tabular-nums;
}

.project-view-arrow {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
}

.project-view-arrow[disabled] {
  color: rgb(var(--ink-rgb) / 0.3);
  cursor: default;
}

/* Images keep their own dimensions -- they only ever shrink to fit,
   never stretch to fill a column. */
/* The view is a flex column inside a full-height shell; without this its
   children shrink to fit the viewport and squash the images. */
.project-view > * {
  flex: none;
}

/* Each image grows in proportion to its aspect ratio, so the row fills the
   full width edge to edge and every image lands the same height. */
/* One height for every image in a project, computed from the first slide
   so that slide spans the full width exactly. Later slides inherit it. */
.project-view-media {
  display: block;
  flex: 0 0 auto;
  width: auto;
  height: var(--media-height, 26rem);
  /* A panorama would otherwise run past the slide and be clipped. */
  max-width: 100%;
  object-fit: contain;
}

/* Indented from the image row above, so the caption sits inside it. */
.project-view-head,
.project-view-text {
  margin-left: var(--project-indent);
  max-width: calc(100% - var(--project-indent));
}

/* When the images stop short of the full width, the title and text move
   into the space beside them, aligned to the top of the images. */
.project-view.is-side-text {
  display: grid;
  grid-template-columns: minmax(0, var(--media-width, auto)) minmax(0, 17rem);
  /* Title row hugs its content; the last row takes the slack, so the
     title stays level with the top of the images. */
  grid-template-rows: auto auto 1fr;
  column-gap: 3.4rem;
  row-gap: 1.2rem;
  align-items: start;
}

.is-side-text .project-view-back {
  grid-column: 1 / -1;
  grid-row: 1;
  justify-self: start;
}

.is-side-text .project-view-controls {
  grid-column: 1 / -1;
  grid-row: 1;
}

.is-side-text .project-view-slider {
  grid-column: 1;
  grid-row: 2 / span 2;
}

.is-side-text .project-view-head {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  margin-left: 0;
}

.is-side-text .project-view-text {
  grid-column: 2;
  grid-row: 3;
  align-self: start;
  margin-top: -1rem;
  margin-left: 0;
  max-width: none;
}

.project-view.is-large-indent .project-view-head,
.project-view.is-large-indent .project-view-text {
  margin-left: calc(var(--project-indent) + 4rem);
  max-width: calc(100% - var(--project-indent) - 4rem);
}

.project-view.is-side-text.is-large-indent .project-view-head,
.project-view.is-side-text.is-large-indent .project-view-text {
  --side-project-indent: clamp(1.5rem, 3vw, 3rem);
  margin-left: var(--side-project-indent);
  width: calc(100% - var(--side-project-indent));
  max-width: calc(100% - var(--side-project-indent));
}

.project-view[data-project-layout="below"] {
  display: flex;
}

.project-view[data-project-layout="below"] .project-view-slider,
.project-view[data-project-layout="below"] .project-view-head,
.project-view[data-project-layout="below"] .project-view-text {
  grid-column: auto;
  grid-row: auto;
}

.project-view:not(.is-side-text) .project-view-slider,
.project-view:not(.is-side-text) .project-view-head,
.project-view:not(.is-side-text) .project-view-text {
  grid-column: auto;
  grid-row: auto;
}

.project-view-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-self: stretch;
  gap: 0.3rem 1.3rem;
  font-size: 0.62rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink);
  animation: view-in 0.5s ease 0.1s both;
}

.project-view-type,
.project-view-year {
  color: rgb(var(--ink-rgb) / 0.68);
}

.project-view-year {
  font-variant-numeric: tabular-nums;
}

.project-view-text:empty {
  display: none;
}

.project-view-text {
  /* The negative margin trims the column gap so the rule sits an equal
     distance from the title above and the paragraph below. */
  margin-top: -0.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  width: min(100%, 34rem);
  max-width: calc(100% - var(--project-indent));
  animation: view-in 0.5s ease 0.15s both;
  /* Same size as the title line above it. */
  font-size: 0.62rem;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: rgb(var(--ink-rgb) / 0.74);
}

.project-view-text p {
  margin: 0;
}

.project-view-text p + p {
  margin-top: 0.6rem;
}



/* The hero arrives from where the hover preview sat -- centred and right
   of its final spot -- so it reads as sliding aside. */
@keyframes hero-slide {
  from {
    opacity: 0;
    transform: translateX(90px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes list-slide-out {
  to {
    opacity: 0;
    transform: translateY(48px);
  }
}

.project-section.is-leaving {
  animation: list-slide-out 0.45s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  .project-view-track {
    transition: none;
  }

  .project-view-slider,
  .project-view-head,
  .project-view-text,
  .project-section.is-leaving,
  .project-view.is-project-switching {
    animation: none;
  }
}

@media (max-width: 820px) {
  .cv {
    width: 100%;
  }

  .project-view.is-side-text {
    display: flex;
  }

  .project-view-media-row {
    flex-wrap: wrap;
  }

  .project-view-media {
    width: 100%;
    height: auto;
  }
}

@media (min-width: 821px) {
  .project-view.is-side-text .project-view-controls {
    width: calc(100vw - (2 * var(--page-gutter)));
  }
}

.project-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: 0.8rem;
  min-height: 58vh;
  border-bottom: 1px solid var(--line);
}

.section-title {
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.project-row {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1.6fr) minmax(0, 1.15fr) 9rem;
  align-items: baseline;
  gap: 0.7rem 1.05rem;
  min-height: 1.7rem;
  padding: 0.32rem 0 0.28rem;
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink);
  transition: opacity 0.18s ease;
}

.project-row[data-images] {
  cursor: pointer;
}

.project-row:hover {
  opacity: 0.45;
}

.project-no,
.project-year {
  color: rgb(var(--ink-rgb) / 0.68);
  font-variant-numeric: tabular-nums;
}

.project-name {
  font-weight: 400;
}

.project-type {
  color: rgb(var(--ink-rgb) / 0.74);
}

.project-year {
  justify-self: end;
  text-align: right;
}

@media (min-width: 1200px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) minmax(14rem, auto);
  }

  .project-row {
    grid-template-columns: clamp(2.3rem, 2vw, 2.6rem) minmax(0, 1.6fr) minmax(0, 1.15fr) clamp(4rem, 6vw, 9rem);
  }
}

@media (max-width: 820px) {
  .portfolio-shell {
    padding: 0.85rem 0.8rem 0.5rem;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .meta-block {
    align-items: flex-start;
  }

  .meta-links,
  .meta-copy {
    justify-content: flex-start;
  }

  .cv-entry {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .project-row {
    grid-template-columns: 40px minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 0.6rem 0.8rem;
  }

  .project-year {
    grid-column: 2 / -1;
    justify-self: start;
    text-align: left;
  }
}
