/*
  Lara Sugar Hughes.
  White paper and photographs reproduced flat and square-on: small prints scattered
  over the index, each project a sideways-scrolling strip of pictures in uneven sizes,
  spaced Helvetica capitals, and the photographer's own notes written in the margins.
*/

:root {
  --paper: #ffffff;
  --ink: #1c1c1a;
  --grey: #8f8f8b;
  --pencil: #3a3a37;
  --biro: #34477d;
  --pink: #ff5fa8;
  --mustard: #f7b500; /* a bright, zippy mustard */

  --font-head: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-hand: "Reenie Beanie", "Bradley Hand", cursive;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --gutter: clamp(16px, 4vw, 64px);
  --small: 12px;
  --spaced: 0.3em;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* no rubber-band bounce: pulling past the bottom is handled by main.js */
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-head);
  font-size: var(--small);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* pushed thumbnails may slide past the edge; never scroll the page sideways */
  overflow-x: clip;
}

/* Prints pushed past the sides are cut off at the edge of the screen rather than widening the
   page (which makes phones zoom out and shift it sideways). */
body > main {
  overflow-x: clip;
}


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

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 5px;
}

/* ---------- Type ---------- */

.spaced {
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--spaced);
  /* letter-spacing leaves a gap after the last letter; take it back so centring is true */
  margin-right: calc(var(--spaced) * -1);
}

.grey {
  color: var(--grey);
}

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

/* Stays pinned at the top while the page scrolls, floating over the prints as they pass. */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 28px var(--gutter) 18px;
  pointer-events: none; /* let prints under the bar still be hovered and clicked */
}

.header a,
.header button {
  pointer-events: auto;
}

.about .header {
  background: var(--paper);
}

button.header__link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.name {
  position: relative;
  display: inline-block;
  font-size: clamp(13px, 1.2vw, 16px);
}

.name__text,
.header__link {
  display: block;
  font-size: clamp(13px, 1.2vw, 16px);
  line-height: 1.2;
}

.header__link,
.footer a {
  transition: color 0.2s ease;
}

/*
  Instagram and Email, pinned to the bottom right-hand corner of every page so they're always
  to hand: solid black, pink under the pointer (and, on a touch screen, a pink flash when
  tapped, main.js).
*/
.corner {
  position: fixed;
  right: var(--gutter);
  bottom: 18px;
  z-index: 30; /* above the About page too */
  /* resting on the footer's line at the foot of the index, and lifted with the page (main.js) */
  translate: 0 calc((var(--pull) + var(--dock, 0px)) * -1);
  display: flex;
  gap: 20px;
  font-size: var(--small);
  line-height: 1.55;
}

.corner a {
  color: #000;
  transition: color 0.3s ease;
}

.corner a:hover,
.corner a:focus-visible,
.corner a.is-pressed {
  color: var(--pink);
}

/* Email turns mustard rather than pink. */
.corner a[href^="mailto:"]:hover,
.corner a[href^="mailto:"]:focus-visible,
.corner a[href^="mailto:"].is-pressed {
  color: var(--mustard);
}

.header__link:hover,
.footer a:hover {
  color: var(--grey);
}

/*
  Where a photograph passes under the name, main.js cuts that part out of the typeset name
  and lets this hand-written copy show through, each letter centred on its typeset twin.
*/
.name__hand {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.name__hand--dark {
  color: var(--pencil);
}

.name__hand--light {
  color: #f5f3ed;
}

.name__ink {
  position: absolute;
  inset: 0;
  filter: url(#biro);
}

.name__ink span {
  position: absolute;
  font-family: var(--font-hand);
  font-size: 2em;
  line-height: 1;
  white-space: pre;
  transform: translate(-50%, -54%) translateY(var(--y, 0)) rotate(var(--r, 0deg)) scale(var(--s, 1));
}

/* ---------- Index: scattered prints ---------- */

/* main.js throws each print onto the page at its own size and spot. */
.field {
  position: relative;
  margin: clamp(14px, 3vh, 36px) var(--gutter) 0;
  padding: 0;
  list-style: none;
}

.field__cell {
  position: absolute;
}

/* Prints stay out of sight until it's their turn to appear (main.js). */
.field__cell[data-waiting] .thumb {
  opacity: 0;
  pointer-events: none; /* an unseen print can't be hovered, so nothing gets nudged aside */
}

/* On hover a print grows from its centre and main.js nudges aside only what it covers. */
.thumb {
  position: relative;
  display: block;
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--s, 1));
  transition: transform 0.45s var(--ease);
  will-change: transform;
}

.thumb.is-open {
  z-index: 2;
}

/* Photographs can't be dragged off or long-pressed to save (main.js guardPhotos). */
.thumb,
.shot,
.flight {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.thumb img,
.shot img,
.flight img {
  -webkit-user-drag: none;
}

.thumb img {
  width: 100%;
}

/* ---------- Project: one screen, no vertical scroll ---------- */

body[data-page="project"] {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.project {
  --pad: clamp(56px, 9vh, 90px); /* room above and below the photographs for notes */
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/*
  Photographs run left to right in one strip that fills the space between header and text.
  --track is the tallest a picture can be; each one takes its own share of it (--h),
  sits at its own height (--drop) and keeps its own distance from the last (--gap).
  The padding above and below is room for notes.
*/
.reel {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--pad) var(--gutter);
  container-type: size;
  scrollbar-width: none; /* replaced by the grey dot below */
  overscroll-behavior-x: contain;
}

.reel::-webkit-scrollbar {
  display: none;
}

/* The strip and its scroll dot sit half an inch higher than their space; the words below stay put. */
.reel,
.scrubber {
  translate: 0 -0.5in;
}

.shot {
  --track: 100cqh; /* the reel's height inside its padding */
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--track) * var(--h) * var(--ar));
  margin: calc(var(--track) * (1 - var(--h)) * var(--drop)) var(--after, 0px) 0 var(--gap);
}

.shot img {
  width: 100%;
}

/* The small index print, stretched underneath until the full-size photograph has loaded. */
.shot .plate {
  background-size: 100% 100%;
}

/* A project of one photograph: as large as the page allows, in the middle of it (the strip
   isn't lifted, so the picture sits centred between the name and the words). */
.project--single .reel {
  align-items: center;
}

.project--single .reel,
.project--single .scrubber {
  translate: none;
}

.project--single .shot {
  width: min(calc(var(--track) * var(--h) * var(--ar)), 100cqw);
  margin: 0 auto;
}

.project--single .note {
  font-size: clamp(15px, calc(var(--track) * 0.048), 23px);
}

/* The scroll indicator: a small grey dot that travels along under the photographs. */
.scrubber {
  position: relative;
  height: 16px;
  margin: calc(var(--pad) * -0.5) var(--gutter) 0;
  cursor: pointer;
  touch-action: none;
  transition: opacity 0.7s ease 0.3s;
}

.scrubber__dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: #b4b4af;
}

.arriving .scrubber,
.leaving .scrubber {
  opacity: 0;
}

/* The words, laid out across the foot of the screen rather than down it. */
.info {
  --column-gap: clamp(24px, 3vw, 48px);
  --side: max(120px, (100% - 2 * var(--column-gap)) / 6); /* the title's column and Previous/Next's */
  display: grid;
  /* Previous/Next's column widens for a long title (leftwards, taking room from the words
     beside it), so its titles never wrap and it never moves. */
  grid-template-columns: var(--side) minmax(0, 1fr) minmax(var(--side), max-content);
  gap: 32px var(--column-gap);
  /* Title, words and Next all sit on one bottom line, the same on every project: the band
     is pinned to the foot of the screen, so a longer description grows upwards and the title
     never moves. */
  align-items: end;
  padding: 18px var(--gutter) 56px; /* the bottom line sits clear of Instagram and Email in the corner */
}

.info__title {
  margin: 0;
  font-size: var(--small);
  line-height: 1.55; /* the same as the words beside it, so they share one bottom line exactly */
}

/* The description on the left, the credits on the right, both resting on the bottom line. */
.info__text {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(24px, 3vw, 48px);
  align-items: end;
  font-size: var(--small);
  line-height: 1.55;
}

/* Space only between paragraphs, never after the last: the last line sits on the bottom line. */
.info__text p {
  margin: 0;
  break-inside: avoid;
}

.info__text p + p {
  margin-top: 0.6em;
}

/* Credits under the description: one line each, quieter than the words above them. */
.info__credits {
  color: var(--grey);
}

.info__credits a:hover {
  color: var(--ink);
}

/* "Previous" just above "Next", with the next project's title under Next. Every line stays
   on one line, so they sit in exactly the same place on every project: right on the edge,
   with Next's title on the bottom line. */
.info__nav {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.9em;
  font-size: var(--small);
  line-height: 1.55;
  text-align: right;
  white-space: nowrap;
}

.info__step {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.info__step:hover .step__title {
  color: var(--grey);
}

#prev-link:hover .grey {
  color: var(--ink);
}

.info__step .grey {
  transition: color 0.2s ease;
}

/* Just clicked: that one link goes grey while the page turns (main.js). */
.info__step.is-pressed .step__title,
#prev-link.is-pressed .grey {
  color: var(--grey);
}

/* ---------- Arriving from the index ---------- */

/* Floating copies of the prints while they fall away or fly into the strip (main.js). */
.flight {
  position: fixed;
  inset: 0;
  z-index: 9; /* under the header, so the name can write itself over them */
  pointer-events: none;
}

.flight img {
  position: absolute;
  transform-origin: 0 0;
  will-change: transform;
}

/* Until the photographs land, the strip's own pictures and the words stay out of sight. */
.arriving .shot img,
.arriving .note {
  opacity: 0;
}

/* The photographer's own handwriting, set into the strip: it arrives and leaves with the notes. */
.leaving .shot--writing img {
  opacity: 0;
  transition-duration: 0.25s;
  transition-delay: 0s;
}

.shot--writing img {
  transition: opacity 0.7s ease 0.35s;
}

.arriving .info {
  transform: translateY(110%);
  opacity: 0;
}

/* Heading back to the index: the words drop away and the notes fade before the photographs fly home. */
.leaving .info {
  transform: translateY(110%);
  opacity: 0;
  transition-duration: 0.35s;
  transition-delay: 0s;
}

.leaving .note {
  opacity: 0;
  transition-duration: 0.25s;
  transition-delay: 0s;
}

.info {
  transition: transform 0.9s var(--ease) 0.1s, opacity 0.6s ease 0.1s;
}

.note {
  transition: opacity 0.7s ease 0.35s;
}

/* ---------- Margin notes ---------- */

/*
  The photographer's handwriting around a picture, in pen.
  main.js picks the place, angle and wobble of every line and letter.
*/
.note {
  position: absolute;
  z-index: 1;
  margin: 0;
  width: max-content;
  max-width: 14em;
  font-family: var(--font-hand);
  /* in proportion to the photograph it's written beside (--track and --h come from the .shot) */
  font-size: clamp(15px, calc(var(--track) * var(--h) * 0.075), 30px);
  line-height: 1.05;
  color: var(--pencil);
  filter: url(#biro);
  transform: rotate(var(--tilt, 0deg));
  will-change: transform; /* keep the inked note on its own layer so scrolling never redraws it */
  transform-origin: left top;
  pointer-events: none;
}

.note--biro {
  color: var(--biro);
}

.note__line {
  display: block;
  white-space: nowrap;
  transform: translateX(var(--indent, 0)) rotate(var(--lean, 0deg));
}

.note__line span {
  display: inline-block;
  white-space: pre;
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg)) scale(var(--s, 1));
}

.note__mark {
  display: inline-block;
  width: 1.7em;
  height: 0.7em;
  margin: 0 0.3em;
  vertical-align: middle;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: round;
}

.note--left {
  right: calc(100% + 14px);
  top: var(--at);
  text-align: right;
  transform-origin: right top;
}

.note--right {
  left: calc(100% + 14px);
  top: var(--at);
}

.note--above {
  bottom: calc(100% + 6px);
  left: var(--at);
  transform-origin: left bottom;
}

.note--below {
  top: calc(100% + 8px);
  left: var(--at);
}

/* Written sideways up the edge of the print, reading top to bottom. */
.note--side {
  left: calc(100% + 10px);
  top: var(--at);
  transform: rotate(calc(90deg + var(--tilt, 0deg))) translateY(-100%);
}

/* ---------- Details lists ---------- */

.details {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  gap: 4px 16px;
  margin: 32px 0 0;
  font-size: var(--small);
}

.details dt {
  color: var(--grey);
}

.details dd {
  margin: 0;
}

.details a {
  border-bottom: 1px solid #d6d6d3;
}

.step__title {
  transition: color 0.2s ease;
}

.defs {
  position: absolute;
}

/* ---------- About: slides in from the right ---------- */

/* The page and the About page move together, like turning to the next sheet. */
:root {
  --slide: 0.75s cubic-bezier(0.65, 0, 0.35, 1);
}

body > .header,
body > main,
body > .footer {
  transition: transform var(--slide);
}

/* The name also fades in with the opening dots. */
body > .header {
  transition: transform var(--slide), opacity 1.4s ease;
}

.about-open {
  overflow: hidden;
}

.about-open body > .header,
.about-open body > main,
.about-open body > .footer {
  transform: translateX(-100vw);
}

.about {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  background: var(--paper);
  transform: translateX(100vw);
  visibility: hidden;
  transition: transform var(--slide), visibility 0s var(--slide);
}

.about-open .about {
  transform: none;
  visibility: visible;
  transition: transform var(--slide), visibility 0s;
}

.no-slide *,
.no-slide .about {
  transition: none !important;
}

.about__body {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr)); /* about | publications | the rest */
  gap: 56px clamp(24px, 3.5vw, 64px);
  align-items: start;
  padding: clamp(64px, 14vh, 160px) var(--gutter) 64px;
}

.about h2 {
  margin: 0 0 22px;
  font-size: var(--small);
}

.about__intro p {
  max-width: 34em;
  margin: 0 0 1em;
  font-size: 14px;
  line-height: 1.65;
}

.about__intro .details {
  margin-top: 28px;
}

.cv {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv li {
  display: grid;
  grid-template-columns: 4.2em 1fr;
  gap: 12px;
}

/* Sections stacked in one column: About with Selected clients under it; Exhibitions with Press. */
.about__stack {
  display: grid;
  gap: 56px;
}

.about__clients p {
  margin: 0;
  max-width: 34em;
  line-height: 1.55;
}

.cv__year {
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1000px) {
  .about__body {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .about__body {
    grid-template-columns: 1fr;
    gap: 44px;
  }
}

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

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 32px;
  margin-top: clamp(120px, 14vw, 200px);
  padding: 22px var(--gutter) 30px;
  color: var(--grey);
}

.footer nav {
  display: flex;
  gap: 24px;
}

/* ---------- Underneath the page ---------- */

/* Scrolling on past the bottom of the index lifts the page off a plain white track, where a
   little pencil man walks to a cord and pulls it (main.js). --pull is how far it's lifted. */
@property --pull {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

:root {
  --pull: 0px;
  transition: --pull 0.9s var(--ease);
}

:root.pulling {
  transition: none;
}

/* He's pulled the cord: the page falls shut. */
:root.dropping {
  transition: --pull 0.45s cubic-bezier(0.55, 0, 0.9, 0.4);
}

body > main,
body > .footer {
  translate: 0 calc(var(--pull) * -1);
}

.under {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  height: 75px;
  overflow: hidden;
  background: var(--paper);
  /* only the strip the page has been lifted off */
  clip-path: inset(calc(100% - var(--pull)) 0 0 0);
  pointer-events: none;
}

.under svg {
  position: absolute;
  left: 0;
  overflow: visible;
  fill: none;
  stroke: var(--pencil);
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#biro);
}

.under path {
  vector-effect: non-scaling-stroke;
  stroke-width: 1.25px;
}

/* Hangs from the underside of the page, so it rides up and down with it. */
.under__cord {
  top: calc(100% - var(--pull));
  width: 100%;
}

.under__cord path {
  stroke-width: 1px;
}

.under__man {
  bottom: 0;
}

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

@media (max-width: 760px) {
  /* On a phone the words scroll sideways too, one block at a time. */
  .info {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: min(78vw, 300px);
    overflow-x: auto;
    scrollbar-width: none;
    max-height: 34svh;
  }

  .info__text {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.6em;
  }

  .info__nav {
    justify-self: start;
    white-space: normal;
  }

  .info__nav,
  .info__step {
    align-items: flex-start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}
