/*
  Main stylesheet. Tokens live in variables.css (load that first).
  Layout: a 12-column grid. Everything is left-aligned.
*/

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--colour-paper);
  color: var(--colour-ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
}

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

h1,
h2,
h3,
p,
ul,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

/* Hidden until focused with the keyboard: lets people jump past the header */
.skip-link {
  position: absolute;
  left: var(--page-gutter);
  top: -100%;
  padding: var(--space-s);
  background: var(--colour-ink);
  color: var(--colour-paper);
}

.skip-link:focus {
  top: var(--space-s);
}

/* ---------- Layout helpers ---------- */

.wrap {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  column-gap: var(--grid-gap);
}

/* A section that opens with a full-width rule and a small label in the first columns */
.band {
  margin-top: var(--space-xl);
  padding-top: var(--space-s);
  border-top: var(--rule);
  row-gap: var(--space-m); /* related items sit close; bigger breaks are set where needed */
}

.band-label {
  grid-column: 1 / 4;
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
}

.small {
  font-size: var(--text-small);
}

.muted {
  color: var(--colour-ink-muted);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s) var(--space-m);
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
}

/* Empty image space, sized to the intended image ratio */
.placeholder {
  display: flex;
  align-items: flex-end;
  padding: var(--space-s);
  border: var(--rule);
  font-size: var(--text-label);
  color: var(--colour-ink-muted);
}

/* ---------- Header ---------- */

.site-header {
  padding-top: var(--space-m);
  align-items: start;
}

.site-name {
  grid-column: 1 / 7;
  font-size: var(--text-name);
  font-weight: var(--weight-black);
  line-height: 1;
  letter-spacing: var(--tracking-heading);
}

.site-name a {
  text-decoration: none;
}

.site-nav {
  grid-column: 7 / 13;
}

.site-nav ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--grid-gap);
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
}

.site-nav a {
  display: inline-block;
  padding-block: 0.25rem; /* larger tap target */
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  text-decoration: underline;
}

/* ---------- Introduction ---------- */

.intro-portrait {
  grid-column: 7 / 10;
  margin-top: var(--space-xl);
}

/* The portrait sits just above the About rule, so they read as one group */
.intro-band {
  margin-top: var(--space-m);
}

.intro-text {
  grid-column: 7 / 13;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-m) var(--grid-gap);
  font-size: var(--text-small);
}

.intro-text .links {
  grid-column: 1 / -1;
}

/* ---------- Selected work (Together, Apart) ---------- */

/* The green field marks this section, so it has no rule. Equal space above and below. */
.feature {
  margin-top: var(--space-xl);
  padding-bottom: var(--space-l);
  background: var(--colour-eucalypt);
}

.feature .band {
  margin-top: 0;
  padding-top: var(--space-l);
  border-top: 0;
  align-items: start;
}

/* The colour edge already ends the feature, so the next rule needs less space */
.feature + section .band {
  margin-top: var(--space-l);
}

/* Muted grey is too low-contrast on eucalypt, so use full black here */
.feature .placeholder {
  color: var(--colour-ink);
}

.feature-year {
  grid-column: 1 / 7;
  font-size: var(--text-display);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}

.feature-heading {
  grid-column: 7 / 13;
}

.feature-title {
  font-size: var(--text-display);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}

.feature-title span {
  display: block;
}

/* "Apart" steps two grid columns to the right of "Together," */
.feature-title .apart {
  padding-left: calc((100% + var(--grid-gap)) / 6 * 2);
}

.feature-meta {
  margin-top: var(--space-m);
  font-size: var(--text-small);
}

.feature-image {
  grid-column: 1 / 9;
  aspect-ratio: 3 / 2;
  margin-top: var(--space-l); /* separates the title group from the image */
}

.feature-image img,
.photo-a img,
.photo-b img,
.project-row-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feature-text {
  grid-column: 10 / 13;
  align-self: end;
  display: grid;
  gap: var(--space-m);
  font-size: var(--text-small);
}

/* ---------- Photography ---------- */

.photo-a {
  grid-column: 4 / 8;
  aspect-ratio: 4 / 5;
}

.photo-b {
  grid-column: 8 / 13;
  align-self: end;
  aspect-ratio: 3 / 2;
}

.photo-links {
  grid-column: 8 / 13;
}

/* ---------- Inner page heading ---------- */

.page-head {
  margin-top: var(--space-xl);
}

.page-title {
  grid-column: 1 / -1;
  font-size: var(--text-title);
  font-weight: var(--weight-black);
  line-height: 1;
  letter-spacing: var(--tracking-heading);
}

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

.about-intro {
  margin-top: var(--space-xl);
  align-items: end;
}

.about-portrait {
  grid-column: 1 / 5;
}

/* Opening statement, bottom-aligned with the portrait */
.about-lead {
  grid-column: 7 / 13;
  max-width: 28ch;
  font-size: var(--text-lead);
  font-weight: var(--weight-medium);
  line-height: 1.35;
}

/* About sections are short and closely related, so they sit closer than homepage sections */
.about-intro ~ .band {
  margin-top: var(--space-l);
}

/* Text column used by About sections; matches the homepage intro column */
.band-content {
  grid-column: 7 / 13;
  display: grid;
  gap: var(--space-m);
  max-width: 60ch;
  font-size: var(--text-small);
}

/* Work and study: name and details on the left, years on the right */
.entries {
  grid-column: 7 / 13;
  display: grid;
  gap: var(--space-m);
  font-size: var(--text-small);
}

.entries li {
  display: grid;
  grid-template-columns: 2fr 1fr;
  column-gap: var(--grid-gap);
}

/* Three levels: place (medium), role (regular), note such as awards (smaller, grey, set apart) */
.entry-title {
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
}

.entry-note {
  max-width: 44ch;
  margin-top: var(--space-s);
  font-size: var(--text-label);
  line-height: 1.5;
  color: var(--colour-ink-muted);
}

/* Skills: groups of square icon tiles, each with its name beside it */
.skills {
  grid-column: 7 / 13;
  display: grid;
  gap: var(--space-m);
  font-size: var(--text-small);
}

/* As many columns as fit; drops to one on narrow screens without a media query */
.skill-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr));
  gap: var(--space-s) var(--grid-gap);
  margin-top: var(--space-s);
}

/* Longer names need wider columns */
.skill-list-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.skill-list li {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  line-height: 1.35;
}

.skill-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 3rem;
  aspect-ratio: 1;
  border: var(--rule);
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
}

.skill-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.interests {
  grid-column: 7 / 13;
  columns: 2;
  column-gap: var(--grid-gap);
  font-size: var(--text-small);
}

.project-text {
  grid-column: 4 / 11;
  display: grid;
  gap: var(--space-m);
  max-width: 40rem;
}

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

/* Listing: one band per project, newest first */
.project-row {
  align-items: start;
}

.project-row-image {
  grid-column: 4 / 10;
  aspect-ratio: 3 / 2;
}

.project-row-text {
  grid-column: 10 / 13;
  align-self: end;
  display: grid;
  gap: var(--space-s);
  font-size: var(--text-small);
}

.project-row-title {
  font-size: var(--text-title);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}

.project-row-title a {
  text-decoration: none;
}

.project-row-title a:hover {
  text-decoration: underline;
}

/* Single project page */
.project-meta {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-s) var(--grid-gap);
  margin-top: var(--space-m);
  font-size: var(--text-small);
}

.project-meta dt {
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  color: var(--colour-ink-muted);
}

.project-meta dd {
  margin: 0;
}

.project-hero {
  grid-column: 1 / 10;
  margin-top: var(--space-l);
}

/* Placeholders hold a 3:2 space; real images keep their own proportions */
.project-hero.placeholder {
  aspect-ratio: 3 / 2;
}

.figure-grid {
  grid-column: 4 / 13;
  align-items: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-l) var(--grid-gap);
}

/* A drawing that needs the full width, such as a long section */
.figure-grid .figure-wide {
  grid-column: 1 / -1;
}

.figure-stack {
  display: grid;
  gap: var(--space-l);
  align-content: start;
  min-width: 0;
}

/* Images open full size in the browser's own viewer, which gives zoom for free */
.figure-grid a,
.project-hero a {
  display: block;
  cursor: zoom-in;
}

.figure-grid .placeholder {
  aspect-ratio: 3 / 2;
}

.figure-grid figcaption {
  margin-top: var(--space-s);
  font-size: var(--text-small);
}

.project-nav {
  justify-content: space-between;
  grid-column: 4 / 13;
}

/* ---------- Scrolling image and About reveal (homepage) ---------- */

/* Tall section: the image stays pinned while the reader scrolls through it */
/* Base layout: image, then About. Stacks in any browser. Scroll effect is added below where supported */
.scroll-stage {
  position: relative;
}

.stage-sticky {
  position: relative;
}

.stage-image {
  margin: 0;
  padding-inline: var(--page-gutter);
}

.stage-image img {
  width: 100%;
  height: 78vh;
  object-fit: cover;
}

/* About sits below the image. It rises in as the image leaves, in browsers that support scroll-linked animation */
.about-reveal {
  padding-block: var(--space-xl) var(--space-l);
}

.intro-name {
  grid-column: 1 / -1;
  font-size: var(--text-display);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}

.intro-meta {
  grid-column: 1 / 7;
  margin-top: var(--space-m);
  font-size: var(--text-small);
  color: var(--colour-ink-muted);
}

.about-reveal .intro-text {
  margin-top: var(--space-m);
}

/* Scroll effect. A small script adds .has-stage only when motion is allowed. Without it, the base layout stays.
   The image pins, shrinks into the top-right corner and reveals the About text behind it. */
.has-stage .scroll-stage {
  height: 240vh;
}

.has-stage .stage-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

/* About text sits in the lower part of the screen, behind the image */
.has-stage .stage-behind {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
}

.has-stage .stage-behind .about-reveal {
  width: 100%;
}

.has-stage .stage-image {
  position: absolute;
  top: var(--space-m);
  bottom: var(--space-m);
  left: 0;
  right: 0;
  z-index: 2;
  transform-origin: top right;
}

.has-stage .stage-image img {
  height: 100%;
}

/* ---------- Elsewhere band: eucalypt field with black text (black passes contrast on eucalypt; white does not) ---------- */

.accent-band {
  background: var(--colour-eucalypt);
  color: var(--colour-ink);
  padding-block: var(--space-l);
}

.accent-band .band-label {
  grid-column: 1 / 4;
}

.accent-band .links {
  grid-column: 4 / -1;
  font-size: var(--text-body);
}

.accent-band a:hover {
  background: var(--colour-paper);
  color: var(--colour-ink);
  text-decoration-thickness: 2px;
}

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

.site-footer {
  padding-bottom: var(--space-m);
  row-gap: var(--space-m);
}

.site-footer .links {
  grid-column: 1 / 8;
}

.site-footer small {
  grid-column: 10 / 13;
  font-size: var(--text-label);
}

/* ---------- Small screens ---------- */

@media (max-width: 48rem) {
  .site-name,
  .site-nav,
  .feature-year,
  .feature-heading,
  .feature-image,
  .feature-text,
  .photo-links,
  .site-footer .links,
  .site-footer small {
    grid-column: 1 / -1;
  }

  .site-nav {
    margin-top: var(--space-m);
  }

  /* Wider label column so labels like "Selected work" stay on one line */
  .band-label {
    grid-column: 1 / 5;
  }

  /* Left edge lines up with the About text below */
  .intro-portrait {
    grid-column: 5 / 13;
  }

  .intro-text {
    grid-column: 5 / 13;
    grid-template-columns: 1fr;
  }

  /* About page: portrait then statement; section content beside the labels */
  .about-portrait {
    grid-column: 1 / 9;
  }

  .about-lead {
    grid-column: 1 / -1;
    margin-top: var(--space-m);
  }

  .band-content,
  .entries,
  .skills,
  .interests {
    grid-column: 5 / 13;
  }

  .interests {
    columns: 1;
  }

  /* Year and title read as one unit */
  .feature-heading {
    margin-top: calc(var(--space-s) - var(--space-m));
  }

  .feature-title .apart {
    padding-left: 1.2em;
  }

  .photo-a {
    grid-column: 1 / 9;
  }

  .photo-b {
    grid-column: 4 / 13;
  }
}

@media (max-width: 48rem) {
  .project-text {
    grid-column: 1 / -1;
  }
}

@media (max-width: 48rem) {
  .project-row-image,
  .project-row-text,
  .project-hero,
  .figure-grid,
  .project-nav {
    grid-column: 1 / -1;
  }

  .project-meta,
  .figure-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 48rem) {
  .intro-meta,
  .accent-band .band-label,
  .accent-band .links {
    grid-column: 1 / -1;
  }

  .accent-band .links {
    margin-top: var(--space-s);
  }
}
