/* About: the intro beside the portrait, the lists and the notes below. Then
   the portrait, the sheet of photos it opens, and a picked photo.
   Paper: "Planning · About · photo fan & scatter". */

/* About's <main> is slightly tighter than the other pages. */
main.about {
  gap: 22px;
  padding-bottom: 48px;
}
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  grid-template-areas: "heading portrait" "biography portrait" "peers portrait";
  column-gap: 44px;
  row-gap: 20px;
}
.heading {
  grid-area: heading;
}
.biography {
  grid-area: biography;
}
.peers {
  grid-area: peers;
}
.peers,
.interests {
  display: grid;
  gap: 12px;
}
.note {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 8px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
}
.note h2 {
  font-size: 20px;
  line-height: 26px;
}
/* The yearbook quote. The rule is --link at 45%. */
.quote {
  border-left: 2px solid var(--link-rule);
  padding-left: 20px;
  font-style: italic;
}
.bullets {
  list-style: "·   ";
  padding-left: 22px;
  display: grid;
  gap: 8px;
}
.bullets li::marker {
  color: var(--muted);
}

@media (max-width: 599px) {
  main.about {
    padding-bottom: 40px;
  }
  .note {
    padding-top: 28px;
  }
  .intro {
    grid-template-columns: minmax(0, 1fr) 96px;
    grid-template-areas: "heading heading" "biography portrait" "peers peers";
    column-gap: 28px;
    row-gap: 20px;
  }
  .peers {
    margin-top: 16px;
  }
}

/* The portrait, with the next three photos fanned behind it. */
.portrait {
  --shadow: 0 1px 2px rgb(22 23 27 / 10%), 0 8px 20px -8px rgb(22 23 27 / 30%);
  grid-area: portrait;
  margin-top: 7px;
}
.portrait img {
  width: 100%;
  aspect-ratio: 160 / 213;
  object-fit: cover;
}
.portrait figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 20px;
}

/* Three photos peek out from behind the portrait like a hand of cards,
   turning on its bottom edge and lifting so no corner drops onto the
   caption. They stay inside the column gap and the right margin. */
.fan {
  position: relative;
  display: block;
  width: 100%;
  background: none;
  cursor: pointer;
}
/* Photos can't be selected like text: a click that drags a little would
   otherwise tint them with the yellow selection colour. */
.fan,
.print,
.focus img {
  -webkit-user-select: none;
  user-select: none;
}
.fan img {
  position: relative;
  box-shadow: var(--shadow);
}
.fan img:not(:last-child) {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
  translate: 0 var(--lift);
  rotate: var(--turn);
}
.fan :nth-last-child(2) {
  --turn: -7deg;
  --lift: -12px;
}
.fan :nth-last-child(3) {
  --turn: 7deg;
  --lift: -12px;
}
.fan :nth-last-child(4) {
  --turn: 14deg;
  --lift: -24px;
}
.fan:is(:hover, :focus-visible) :nth-last-child(2) {
  --turn: -9deg;
  --lift: -15px;
}
.fan:is(:hover, :focus-visible) :nth-last-child(3) {
  --turn: 9deg;
  --lift: -15px;
}
.fan:is(:hover, :focus-visible) :nth-last-child(4) {
  --turn: 16deg;
  --lift: -28px;
}
.portrait:has(.fan:is(:hover, :focus-visible)) figcaption {
  color: var(--ink);
}

/* Narrow windows have a 24px margin, so the fan leans into the column gap. */
@media (max-width: 839px) {
  .fan :nth-last-child(2) {
    --turn: -10deg;
    --lift: -14px;
  }
  .fan :nth-last-child(3) {
    --turn: -5deg;
    --lift: -8px;
  }
  .fan :nth-last-child(4) {
    --turn: 4deg;
    --lift: -6px;
  }
  .fan:is(:hover, :focus-visible) :nth-last-child(2) {
    --turn: -11deg;
    --lift: -16px;
  }
  .fan:is(:hover, :focus-visible) :nth-last-child(3) {
    --turn: -6deg;
    --lift: -10px;
  }
  .fan:is(:hover, :focus-visible) :nth-last-child(4) {
    --turn: 5deg;
    --lift: -8px;
  }
}

/* The sheet: paper over the whole page. Photos wrap in loose rows sized by
   their own shape, and it scrolls when they outgrow the screen. */
.sheet {
  --shadow:
    0 1px 2px rgb(22 23 27 / 10%), 0 12px 28px -10px rgb(22 23 27 / 30%);
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  color: var(--ink);
}
.sheet::backdrop {
  background: none;
}
:root:has(.sheet[open]) {
  overflow: hidden;
}

.close {
  position: fixed;
  top: 24px;
  right: 32px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-inline: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  cursor: pointer;
}
.close span {
  font-size: 20px;
}

.pile {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: 6px 12px;
  min-height: 100%;
  padding: 88px 64px;
}

/* Behind the photos: bare paper closes the sheet, or puts a picked photo
   back once one is picked. It lies on the pile rather than fixed to the
   window, so the wheel over it scrolls the sheet. It lies over the photos'
   boxes and under the photos, which are nudged and tilted off their boxes,
   so a click beside a photo lands on paper. */
.paper {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: none;
}
.pile:has(:checked) .paper[type="button"],
.pile:not(:has(:checked)) .paper[type="reset"] {
  display: none;
}

.item {
  position: relative;
}
.radio {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

/* Each photo's size, nudge and tilt come from its file name. */
.print {
  position: relative;
  z-index: 1;
  display: block;
  height: calc(181px + var(--size) * 25px);
  aspect-ratio: var(--ratio);
  translate: calc(var(--x) * 26px) calc(var(--y) * 22px);
  rotate: calc(var(--turn) * 8deg);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.print img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.me {
  z-index: 2;
}
/* A stack, photos of one event: the next two lie askew behind the first,
   turned on their middles one each way, so they show on every side of it;
   a little further on hover. Its margin keeps them off the photos round it. */
.stack {
  margin: 24px;
}
.stack .print img {
  position: relative;
}
.stack .print img:not(:last-child) {
  position: absolute;
  inset: 0;
  rotate: var(--angle);
  box-shadow: var(--shadow);
}
.stack .print :nth-last-child(2) {
  --angle: -10deg;
}
.stack .print :nth-last-child(3) {
  --angle: 10deg;
}
.stack .print:hover :nth-last-child(2) {
  --angle: -12deg;
}
.stack .print:hover :nth-last-child(3) {
  --angle: 12deg;
}
.print:hover {
  z-index: 3;
  rotate: 0deg;
  box-shadow:
    0 1px 2px rgb(22 23 27 / 12%),
    0 20px 36px -12px rgb(22 23 27 / 38%);
}
.radio:focus-visible + .print {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.pile:has(:checked) .print img {
  opacity: 0.3;
}

/* A picked photo comes forward, straight and large, with its caption on a
   slip of paper over its corner, above any photo lifted by hover. */
.focus {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  padding: 88px 64px;
  pointer-events: none;
}
.radio:checked ~ .focus {
  display: grid;
}
.focus figure {
  position: relative;
}
.radio:checked ~ .focus figure {
  pointer-events: auto;
}
/* Sized from the photo's shape rather than the file, so the frame (and the
   caption on it) is in place before the photo arrives. */
.focus img {
  width: min(640px, 100vw - 128px, min(100svh - 176px, 600px) * var(--ratio));
  max-width: none;
  aspect-ratio: var(--ratio);
  background: var(--mat);
  box-shadow:
    0 2px 4px rgb(22 23 27 / 10%),
    0 32px 64px -20px rgb(22 23 27 / 45%);
}
.focus figcaption,
.slip {
  width: max-content;
  max-width: min(300px, 90%);
  padding: 16px 20px 18px;
  background: var(--field);
  box-shadow:
    0 1px 2px rgb(22 23 27 / 10%),
    0 16px 32px -12px rgb(22 23 27 / 35%);
  rotate: -2deg;
  font-size: 16px;
  font-style: italic;
  line-height: 25px;
}
.focus figcaption {
  position: absolute;
  right: -40px;
  bottom: -28px;
}

/* A picked stack fans all its photos out over the sheet, evenly along a
   gentle arc, with its caption on a slip across their foot; bare paper folds
   them back up. A photo picked from the fan comes forward like any other,
   and bare paper then puts it back in the fan. */
.spread {
  --step: 0.62; /* from one photo to the next, in photo heights */
  --room: 128px;
  --h: min(400px, 100svh - 280px, (100vw - var(--room)) / (0.75 + (var(--n) - 1) * var(--step)));
  position: fixed;
  inset: 0;
  z-index: 4;
  display: none;
  place-content: center;
  justify-items: center;
}
.stack:has(:checked) .spread {
  display: grid;
}
.back {
  position: fixed;
  inset: 0;
  background: none;
}
.spread:has(.hand :checked) button.back,
.spread:not(:has(.hand :checked)) label.back {
  display: none;
}
.hand {
  display: grid;
}
.hand .photo {
  display: contents;
}
.card {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  height: var(--h);
  aspect-ratio: var(--ratio);
  translate: calc(var(--k) * var(--step) * var(--h)) calc(var(--k) * var(--k) * var(--h) / 20);
  rotate: calc(var(--k) * 6deg);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card:hover {
  z-index: 2;
  rotate: 0deg;
  box-shadow:
    0 1px 2px rgb(22 23 27 / 12%),
    0 20px 36px -12px rgb(22 23 27 / 38%);
}
.radio:focus-visible + .card,
.stack:has(> .radio:focus-visible) .card {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.hand:has(:checked) .card img {
  opacity: 0.3;
}
.slip {
  position: relative;
  z-index: 3;
  max-width: min(300px, 100vw - 48px);
  margin-top: -24px;
}
.spread:has(.hand :checked) .slip {
  visibility: hidden;
}

@media (max-width: 599px) {
  .portrait {
    margin-top: 0;
  }
  .portrait figcaption {
    font-size: 11px;
    line-height: 18px;
  }
  .fan :nth-last-child(2),
  .fan:is(:hover, :focus-visible) :nth-last-child(2) {
    --turn: -12deg;
    --lift: -14px;
  }
  .fan :nth-last-child(3),
  .fan:is(:hover, :focus-visible) :nth-last-child(3) {
    --turn: -6deg;
    --lift: -7px;
  }
  .fan :nth-last-child(4),
  .fan:is(:hover, :focus-visible) :nth-last-child(4) {
    --turn: 7deg;
    --lift: -8px;
  }
  .close {
    top: 12px;
    right: 16px;
  }
  .pile {
    align-content: flex-start;
    gap: 4px 6px;
    padding: 72px 10px 40px;
  }
  .print {
    height: calc(135px + var(--size) * 17px);
    translate: calc(var(--x) * 10px) calc(var(--y) * 10px);
    rotate: calc(var(--turn) * 7deg);
  }
  .stack {
    margin: 16px;
  }
  .focus {
    padding: 72px 24px;
  }
  .focus img {
    width: min(100vw - 48px, (100svh - 200px) * var(--ratio));
  }
  .spread {
    --step: 0.45;
    --room: 48px;
  }
  .focus figcaption {
    right: -8px;
    bottom: -32px;
  }
  .focus figcaption,
  .slip {
    padding: 14px 18px 16px;
    font-size: 15px;
    line-height: 23px;
  }
}

/* Motion: the fan opens, the sheet fades in and out, the photos drop onto
   it one after another (all of them within 400ms), and a picked photo rises
   and fades back into the pile. */
@media (prefers-reduced-motion: no-preference) {
  .fan img,
  .portrait figcaption {
    transition:
      translate 220ms ease-out,
      rotate 220ms ease-out,
      color 220ms ease-out;
  }
  .sheet {
    transition:
      opacity 200ms ease-out,
      display 200ms allow-discrete,
      overlay 200ms allow-discrete;
  }
  /* data-closing: js/fade-out.js holds the close while this plays. */
  .sheet:not([open]),
  .sheet[data-closing] {
    opacity: 0;
    pointer-events: none;
  }
  .print {
    --delay: calc(min(25ms, 400ms / var(--count)) * var(--i));
    transition:
      opacity 300ms ease-out var(--delay),
      scale 500ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--delay),
      translate 500ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--delay),
      rotate 160ms ease-out,
      box-shadow 160ms ease-out;
  }
  .print img,
  .card img {
    transition: opacity 200ms ease-out;
  }
  .stack .print img {
    transition:
      opacity 200ms ease-out,
      rotate 220ms ease-out;
  }
  .focus,
  .spread {
    transition: display 220ms allow-discrete;
  }
  /* A stack's fan opens out of a pile in the middle, and folds back into
     it. */
  .card {
    transition:
      opacity 220ms ease-out,
      translate 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
      rotate 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
      box-shadow 160ms ease-out;
  }
  .slip {
    transition: opacity 220ms ease-out;
  }
  .stack:not(:has(:checked)) :is(.card, .slip) {
    opacity: 0;
  }
  .stack:not(:has(:checked)) .card {
    translate: 0 0;
    rotate: 0deg;
  }
  .focus figure {
    transition:
      opacity 220ms ease-out,
      scale 220ms ease-out;
  }
  .radio:not(:checked) ~ .focus figure {
    opacity: 0;
    scale: 0.94;
  }
  @starting-style {
    .sheet[open] {
      opacity: 0;
    }
    .sheet[open] .print {
      opacity: 0;
      scale: 0.6;
      translate: 24vw -24vh;
    }
    .radio:checked ~ .focus figure {
      opacity: 0;
      scale: 0.94;
    }
    .stack:has(:checked) :is(.card, .slip) {
      opacity: 0;
    }
    .stack:has(:checked) .card {
      translate: 0 0;
      rotate: 0deg;
    }
  }
}
