/* ==================================================================
   gallery.css — a room's photo gallery: the stack of three in an open
   row is a deck in a hand, and "see more" deals it onto a table.
   Same paper, ink and pen as style.css, and its tokens throughout.
   js/gallery.js measures and sets state; everything that moves is a
   transition or a keyframe in this file.
   ================================================================== */

:root {
  /* the table, laid by gallery.js (layTable) from these, all unitless.
     A print of any shape has the picture area a 3:2 one has, so a
     portrait weighs what a landscape does, and the three from the stack
     are the same size as the rest: they lie first, on top, and turn less. */
  --table-across: 4.6;      /* about this many 3:2 prints span the table's width */
  --tilt-min: 6;           /* degrees either way a print lies off straight ... */
  --tilt-max: 18;           /* ... up to this */
  --tilt-straight: 0.12;    /* the share laid nearly straight (under 2.5 degrees) */
  --lead-tilt-min: 3;       /* the leads turn less, like the stack they came from */
  --lead-tilt-max: 9;
  --print-size-vary: 0.08;  /* a print, lead or not, is up to this much larger or smaller */
  --print-chin: 1;          /* the band below the picture, in mattes: 1 is an even matte all round, like the stack the prints are dealt from */
  --print-tuck: 0.12;       /* the most of a picture's height the prints laid over it may cover */
  --print-tuck-lead: 0.06;  /* and the leads, from above */
  --table-lean: 0.02;       /* px of height a print gives up to lie a px further left */
  --table-jitter: 0.1;      /* how loosely, in print heights, a print takes the highest place */
  --table-tries: 3;         /* seeds tried; the shortest table is kept */
  --table-huddle: 0.45;     /* a room of a row or two is laid this many prints wider than its rows, in the middle */
  --video-size: 1.25;       /* a video's frame has this many times a print's picture area: room for its controls */
  --print-lift: 26px;       /* the shadow under a print as it rises to the pointer */
  --print-hold-reach: 6px;  /* how far past where it lies the pointer may stray from a print it has raised */

  /* the deal: each print leaves the deck one step after the last. The whole
     deal is capped, so a full table steps faster rather than taking longer. */
  --deal-flight: 460ms;     /* one print, deck to table */
  --deal-step: 60ms;        /* between one print leaving and the next */
  --deal-cap: 620ms;        /* the most the steps may add up to */
  --deal-wait: 70ms;        /* the top print lifts, then the rest follow */
  --deal-land: cubic-bezier(0.2, 1.32, 0.36, 1);   /* past its place and back: the settle */
  /* the gather, the same moves run quicker: going back should feel snappy */
  --gather-flight: 280ms;
  --gather-step: 24ms;
  --gather-cap: 160ms;
  --gather-wait: 0ms;

  /* the index clearing off the table, and coming back */
  --clear: 340ms;
  --clear-step: 26ms;       /* row by row, outward from the open one */
  --clear-pull: 26vw;       /* how far a row is pulled before it is gone */
  --clear-ease: cubic-bezier(0.5, 0, 0.85, 0.5);
  /* the table's words wait until the rows near the top have been pulled */
  --words-wait: calc(var(--clear) + 4 * var(--clear-step));

  /* a print picked up for a closer look */
  --hold-wash: 92%;         /* how far the paper comes up over the table behind it */
  --hold-matte: 0.5;        /* how thick its matte is in hand, of what the print grown whole would have: the picture takes the rest */
}

/* The page is always tall enough to scroll on the index and not always in a
   small gallery; holding the gutter keeps the two the same width, so the
   stack and the prints that take its place line up. */
html { scrollbar-gutter: stable; }

/* ---------- the way in: the stack of an open row ------------------ */
.card__stack.has-more { cursor: pointer; }
.card__more {
  position: absolute; inset: 0; z-index: 4;
  pointer-events: none;
  border-radius: var(--frame-radius);
  text-decoration: none;
}
.card__more:focus-visible { outline-offset: 8px; border-radius: var(--frame-radius); }
/* The "see more" cursor, parked on the top print's corner for touch, for
   reduced motion and for the keyboard, where there is no such cursor. It
   stays inside the print, so the pointer over it is always in the see-more
   state and the inverting disc never crosses it. */
.card__more__disc {
  position: absolute; right: 0.7rem; bottom: 0.7rem;
  display: flex; align-items: center; justify-content: center;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--pen); color: var(--on-pen-text);
  font: 500 0.6875rem/1.05 var(--sans);
  letter-spacing: calc(var(--track-cursor) * 0.001em);
  white-space: pre-line; text-align: center;
  opacity: 0; scale: 0.6;
  transition: opacity var(--quick), scale var(--soft) var(--ease);
}
.card.is-settled .card__more__disc { opacity: 1; scale: 1; }
body.has-cursor .card__more:not(:focus-visible) .card__more__disc { opacity: 0; scale: 0.6; }
/* The stack's prints are on the table: the gallery's own copies took their
   places on the same frame, so the stack is never seen to go. */
.card__stack.is-dealt { visibility: hidden; }

/* ---------- the index, cleared off the table ----------------------
   Held still at the scroll it was left at while the table is dealt over
   it. The rows are pulled off to the right, outward from the open one;
   the rail goes left and the header up; what is left fades with the
   sheet. The same rules run backwards on the way home. */
.index.is-frozen { position: fixed; left: 0; right: 0; }
/* a room's address is loading (set in the head of index.html) */
.is-room .index { display: none; }
.index.is-away { opacity: 0; pointer-events: none; }
.index.is-away .top { translate: 0 -160%; }
.index.is-away .rail { translate: calc(-100% - var(--gutter)) 0; }
.index.is-away .work__list > li { translate: var(--clear-pull) 0; opacity: 0; }
/* the sheet itself thins out under the last of the rows, so nothing of it
   is left when the table's title arrives where they were */
.index.is-clearing { transition: opacity var(--clear) linear calc(var(--clear) / 2); }
.index.is-returning { transition: opacity var(--quick) linear; }
.index.is-clearing .top,
.index.is-clearing .rail,
.index.is-clearing .work__list > li {
  transition: translate var(--clear) var(--clear-ease) calc(var(--away, 0) * var(--clear-step)),
              opacity var(--clear) var(--clear-ease) calc(var(--away, 0) * var(--clear-step));
}
.index.is-returning .top,
.index.is-returning .rail,
.index.is-returning .work__list > li {
  transition: translate var(--gather-flight) var(--ease) calc(var(--away, 0) * var(--clear-step)),
              opacity var(--soft) var(--ease) calc(var(--away, 0) * var(--clear-step));
}
/* set down in the away state with nothing easing, so the return has a
   clean place to start from */
.index.is-set, .index.is-set * { transition: none !important; }

/* ---------- the gallery: rail and body, like every section -------- */
.gallery {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: var(--gutter);
  padding: 1.75rem var(--gutter) clamp(4rem, 10vh, 7rem);
  max-width: 82rem;
  margin: 0 auto;
  min-height: 100vh;
  --gallery-head: 4.5rem;   /* the row the way back sits in, where the header was */
  /* The table runs the full width of the page, under the rail as well as
     the body: it reaches back across the rail and the gap from the body
     column. */
  --table-reach: calc(var(--rail) + var(--gutter));
}
.gallery.is-frozen { position: fixed; left: 0; right: 0; width: 100%; }
/* The side column runs the height of the table so the way back can stay
   with the visitor. The rail itself is not sticky here: it holds pen marks,
   and a sticky box would trap them under the cursor. */
.gallery__side { display: flex; flex-direction: column; align-items: flex-start; }
.gallery__back { position: sticky; top: 1.75rem; z-index: 3; background: var(--paper); }   /* above the pile, which is a stack of its own */
.can-hover .gallery__back:hover, .gallery__back:focus-visible { background: var(--pen); }
/* the arrow leads the label here, pointing back the way the visitor came */
.gallery__back { gap: 0; white-space: nowrap; }
.gallery__back .btn__arrow { transition: width var(--quick) var(--ease), opacity var(--quick) var(--ease), margin var(--quick) var(--ease); }
.can-hover .gallery__back:hover .btn__arrow, .gallery__back:focus-visible .btn__arrow { margin-right: 0.45rem; }
/* Once it has ridden down past the baseline of the title's last line
   (gallery.js sets is-compact) the way back folds to a disc: the label
   closes up and the arrow stays open and drawn, so the arrow alone says
   Back over the prints. The label is shut, not taken out of the line, so
   the disc is exactly as tall as the pill and still reads out its name. */
.gallery__back {
  transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease),
              border-color var(--quick) var(--ease), transform var(--quick) var(--ease),
              padding var(--soft) var(--ease), box-shadow var(--soft) var(--ease);
}
.gallery__back > span {
  display: block; overflow: hidden;
  max-width: var(--back-label-w, 12rem);   /* the label's own width, from gallery.js */
  /* opening, the words wipe in behind the widening edge */
  transition: max-width var(--soft) var(--ease), opacity var(--soft) var(--ease);
}
.gallery__back.is-compact {
  /* as wide as the pill is tall: the arrow's 18px and the rest either side */
  padding-left: calc((1.02rem + 0.92rem * 1.2 - 18px) / 2);
  padding-right: calc((1.02rem + 0.92rem * 1.2 - 18px) / 2);
  border-color: var(--ink);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow-ink) 12%, transparent),
              0 6px 14px -6px color-mix(in srgb, var(--shadow-ink) 34%, transparent);
}
.can-hover .gallery__back.is-compact:hover, .gallery__back.is-compact:focus-visible, .gallery__back.is-compact:active { border-color: var(--pen); }
.gallery__back.is-compact > span {
  max-width: 0; opacity: 0;
  transition: max-width var(--soft) var(--ease), opacity var(--quick) var(--ease);
}
.gallery .gallery__back.is-compact .btn__arrow { width: 18px; opacity: 1; margin-right: 0; }
.gallery__rail { position: static; align-self: stretch; margin-top: calc(var(--gallery-head) - 2.2rem); }
.gallery__rail .mark-word { font-style: normal; color: var(--ink); margin: 0 0.6em 0 0.35em; }
.gallery__rail .mark-word svg { left: -0.6em; top: -0.3em; width: calc(100% + 1.2em); height: calc(100% + 0.55em); }
.gallery__rail .mark--circle path { stroke-width: 1.7; }
/* the words thin out as they come up to the way back, so they never pass
   under it (gallery.js sets --rail-clear on the cue and the note). On the
   note's words and its mark one by one, never the note itself, which
   would hold the pen's circle under the cursor. */
.gallery__rail .rail__cue,
.gallery__rail .rail__note > span:not(.mark-word),
.gallery__rail .mark-word > * { opacity: var(--rail-clear, 1); }
/* A gap a hair longer than the line, as on the camera: with "1" alone the
   next dash starts exactly at the line's end and its round cap sits there
   as a dot while the mark waits to be drawn. */
.gallery__rail .mark--table path { stroke-dasharray: 1 1.01; }

.gallery__body { position: relative; padding-top: var(--gallery-head); min-width: 0; }   /* (the format and role are placed in its head) */
.gallery__title {
  font: 400 calc(clamp(2.5rem, 5.6vw, 4.9rem) * var(--title-fit, 1))/1.02 var(--serif);
  letter-spacing: calc(var(--track-hero) * 0.001em);
  text-wrap: balance;
}
/* The title's row, with a camera drawn in the pen at its far end. The
   camera keeps its own place in the row, so the title wraps before it
   rather than under it. Its body sits on the first line's capitals. It is
   a sibling of the title, not inside it: the title rises on the deal, and
   a pen mark must not be inside anything that moves. */
.gallery__head {
  --title-size: clamp(2.5rem, 5.6vw, 4.9rem);   /* the size .gallery__title is set in */
  display: flex; align-items: flex-start; justify-content: space-between;
  column-gap: clamp(1rem, 3vw, 2.5rem);
}
.mark--camera {
  flex: none; display: block; overflow: visible;
  height: var(--title-size); width: auto; aspect-ratio: 130 / 98;
  margin-top: calc(var(--title-size) * -0.14);
}
/* drawn the way a hand would: the body, the finder on top, the lens, its
   glint, the shutter button, and the flash going off last */
/* (the gap a hair longer than the line, or a stroke waiting its turn shows
   its round cap as a dot at the end, where the next dash would begin) */
.mark--camera path { stroke-width: 2; stroke-dasharray: 1 1.01; }
.mark--camera path:nth-child(1) { transition-delay: 0ms; transition-duration: 380ms; }
.mark--camera path:nth-child(2) { transition-delay: 320ms; transition-duration: 160ms; }
.mark--camera path:nth-child(3) { transition-delay: 440ms; transition-duration: 280ms; }
.mark--camera path:nth-child(4) { transition-delay: 680ms; transition-duration: 90ms; }
.mark--camera path:nth-child(5) { transition-delay: 740ms; transition-duration: 110ms; }
.mark--camera path:nth-child(6) { transition-delay: 860ms; transition-duration: 70ms; }
.mark--camera path:nth-child(7) { transition-delay: 900ms; transition-duration: 70ms; }
.mark--camera path:nth-child(8) { transition-delay: 940ms; transition-duration: 70ms; }
body.has-cursor .mark--camera { position: relative; z-index: 10000; }
/* Sealed, the camera steps back down with the accents in style.css, but
   that reset list does not reach into this file, so it is reset here
   beside the rule that lifts it. Nothing else sets a z-index on it, so
   plain auto is where it rests. */
body.has-cursor.is-sealed .mark--camera { z-index: auto; }
.gallery.is-gathering .mark--camera { opacity: 0; }
/* a phone's title needs the whole width: a long one would break for it */
@media (max-width: 40em) { .mark--camera { display: none; } }
/* The room's format and role, in the row the way back sits in, each on a
   line of its own with its name before it: side by side while the row has
   the width for both, the role under the format when it has not, and from
   there the two scale down together (gallery.js sets --meta-fit from what
   the wider needs) so neither ever breaks into two lines. The row is as
   tall as the pill, and its first line centres on it whatever is under
   it. It lies in the space the body leaves for the row above the title,
   out of the flow, and a second line fits there too, so the title never
   moves for it. (After the title in the markup: a phone has no such row,
   and there they go under the title, in the flow.) */
.gallery__meta {
  --pill-h: calc(1.02rem + 0.92rem * 1.2 + 2px);   /* the way back's padding, line and border (.btn) */
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; flex-wrap: wrap; align-content: flex-start; align-items: baseline;
  column-gap: clamp(1.5rem, 4vw, 3rem); row-gap: 0.1rem;
  min-height: var(--pill-h);
  padding-top: calc((var(--pill-h) - 1lh) / 2);
  margin: 0;
  font-size: calc(0.8125em * var(--meta-fit, 1));
  letter-spacing: calc(var(--track-card-fields) * 0.001em);
}
.gallery__meta > div { display: flex; align-items: center; column-gap: 0.5em; white-space: nowrap; }
.gallery__meta dt { color: var(--ink-2); }
.gallery__meta dd { margin: 0; color: var(--ink); }
/* The brief in full, under the title and above the prints. */
.gallery__fields {
  max-width: var(--measure); margin: 1.6rem 0 2.4rem;
  letter-spacing: calc(var(--track-card-fields) * 0.001em);
}
.gallery__fields div + div { margin-top: 0.9rem; }
/* The Brief label is set like the rail cue, in the muted ink the label
   had before, so the two read as one kind of heading. */
.gallery__fields dt {
  font: 500 0.8125rem/1.3 var(--sans);
  letter-spacing: calc(var(--track-cue) * 0.001em);
  color: var(--ink-2);
}
.gallery__fields dd { margin-top: 0.15rem; }
.gallery.is-dealing .gallery__meta,
.gallery.is-dealing .gallery__fields { animation: rise 420ms var(--ease) var(--words-wait) backwards; }
.gallery.is-gathering .gallery__meta,
.gallery.is-gathering .gallery__fields { opacity: 0; transition: opacity var(--quick) linear; }
.gallery:focus, .gallery:focus-visible { outline: none; }   /* focused by script on arrival, not by the visitor */

/* ---------- the table ----------------------------------------------
   Prints strewn on a table by hand, dense and every which way, each
   picture mostly in view. gallery.js lays them (layTable): it sets each
   print's width, where it lies (left, top), how far it turns (--tilt, in
   degrees) and how high in the pile it sits (--z), and the table's height.
   The table runs the full width of the page, under the rail as well, and
   the prints are laid clear of the rail's words. Every print is laid out
   where it rests, so the deal measures exactly where each comes to rest. */
.gallery__pile {
  /* the pile is a stack of its own, so however high it is piled it stays
     under the way back and the dialogs. It holds the table and the paper
     that comes up over it while a print is in hand (see "a print picked
     up"): one stack for both, so the paper lies between the pile and the
     print above it. */
  position: relative; z-index: 1;
  margin: clamp(1.75rem, 4vw, 3rem) 0 0 calc(-1 * var(--table-reach));
}
.gallery__table {
  position: relative;   /* the prints lie on it, in the pile's stack, not one of its own */
  --frame-pad: clamp(7px, 0.55vw + 4.5px, 13px);
  --frame-radius: clamp(6px, 0.4vw + 4px, 10px);
}
.gallery__print {
  --frame-shadow: 12px;
  --rot: calc(var(--tilt, 0) * 1deg);
  --rot-hover: 0deg;
  position: absolute; left: 0; top: 0;
  width: 14rem;   /* until it is laid */
  z-index: var(--z, 1);
  /* the classic print: the deep band below is what the next one lies on */
  padding-bottom: calc(var(--frame-pad) * var(--print-chin));
  /* seventy-eight standing layers is a lot of memory; a print is promoted
     while it moves and not before */
  will-change: auto;
  /* (picking up and putting down is the one number --held easing; see
     "a print picked up") */
  transition: var(--photo-transition),
              --held var(--soft) var(--ease), opacity var(--soft) var(--ease),
              z-index 0s linear var(--soft);
}
/* Under the pointer or the keyboard a print straightens and rises to the
   top of the pile. A click leaves focus on its button; that alone should
   not keep it raised. It rises at once, before it straightens and grows,
   or it would do both under the prints that lie over it and then jump
   through them; it is only on the way down that the pile waits for it to
   lie back first, and then it stays on top of the pile (gallery.js moves
   its --z there as it is let go: see onTop). One put down under the
   pointer is still on its way down from above the paper, so it stays up
   there until it lands, on the frame it lands (as one stepped off does:
   see is-going). Each raised print lies one above the one raised before
   it (--lift, counted by gallery.js), so the pointer going straight from
   one print onto the next puts the new one on top while the old one lies
   back down. */
.can-hover .gallery__print:hover, .gallery__print.is-lit,
.gallery__print:has(:focus-visible) {
  --up: calc(5000 + min(var(--lift, 0), 3000));
  z-index: calc(var(--up) + (9001 + var(--hz, 0) - var(--up)) * min(1, var(--held) * 1000000));
  --frame-shadow: var(--print-lift);
  transition-delay: 0s;
}
/* (A phone goes on calling a tapped print hovered, so only a hover the
   device can do keeps the focus a tap leaves from lying back down: else
   one put down by a tap lies straight, grown, and under its neighbours.) */
.gallery__print:focus-within:not(:has(:focus-visible)):not(.can-hover :hover):not(.is-lit) {
  --rot: calc(var(--tilt, 0) * 1deg); --zoom: 1; z-index: var(--z, 1);
}
.gallery__print:has(:focus-visible) { outline: 2px solid var(--pen-deep); outline-offset: 4px; }
.gallery__lift {
  display: block; width: 100%;
  cursor: pointer; touch-action: manipulation;
  border-radius: calc(var(--frame-radius) * 0.4);
}
/* The print wears the ring, so the button inside takes none. It has to
   say so only where :has() is understood, else a browser without it
   drops the print's rule and would leave a keyboard visitor with no
   ring at all. */
@supports selector(:has(*)) {
  .gallery__lift:focus-visible { outline: none; }
}
/* What the pointer is over is a print where it lies, not where it has
   turned to. Under the pointer a print straightens and grows; tested
   against its own frame, a pointer resting near an edge or a corner fell
   off it as it turned, it lay back down under the pointer, rose again, and
   the two took turns. So the print itself takes no pointer and its
   button's ::before does: a footprint turned back by however far the print
   has turned (--tilt less --rot, the zoom undone), which stays where the
   print lies while the print moves over it. A raised print's footprint
   reaches a little further (--print-hold-reach), so the lean toward the
   pointer cannot tip its edge out from under it either. In hand it is the
   print as it is shown. (The button, not the print, so a press is still
   the button's: its focus, its cursor, the keyboard's.) */
.gallery__print { overflow: visible; pointer-events: none; }
.gallery__lift, .gallery__lift::before { --rot: inherit; --zoom: inherit; }
.gallery__lift::before {
  content: ""; position: absolute; inset: -1px;   /* the print's border box */
  pointer-events: auto;
  transform: rotate(calc(var(--tilt, 0) * 1deg - var(--rot))) scale(calc(1 / var(--zoom)));
}
.can-hover .gallery__print:hover .gallery__lift::before { inset: calc(-1px - var(--print-hold-reach)); }
.gallery__print.is-held .gallery__lift::before { transform: none; }
/* The crop holds the picture's place before its file arrives, and lets a
   print leave the stack wearing the stack's crop (see the deal below). */
.gallery__crop {
  display: block; position: relative; overflow: hidden;
  /* its own shape, so a picture not yet asked for (an img with no src,
     which draws its alt text) is laid at its true size and not as tall
     as the words wrap to on a narrow print */
  aspect-ratio: var(--ratio, 3 / 2);
  border-radius: calc(var(--frame-radius) * 0.4);
  background: color-mix(in srgb, var(--ink) 7%, var(--matte));
}
/* (no easing of their own outside the deal: picked up, the crop and the
   picture follow the frame's --held from one frame to the next) */
.gallery__crop img { border-radius: 0; }
/* no alt text or broken frame standing in the matte while the file is on
   its way: the picture comes up into it once it is in. The leads too, on
   a cold load of a room's address, where nothing is in yet. Dealt from
   the stack, a lead wearing the stack's own picture is the stack: that
   file is in already, and it must never fade (gallery.js marks it
   is-from-stack for the deal). One carrying a ghost (below) has the ghost
   over it and comes up under it like the rest. */
.gallery__crop img { transition: opacity var(--soft) var(--ease); }
.gallery__print:not(.is-from-stack):not(.is-loaded) .gallery__crop img { opacity: 0; }
/* When the stack's prints are not this room's photos, each of the three
   carries the stack's picture over its own and lets it go in flight. */
.gallery__ghost { position: absolute; inset: 0; height: 100% !important; opacity: 0; }

/* ---------- a video on the table ------------------------------------
   A room's videos (content.js names them) are dealt after the three from
   the stack, where a fourth pick would lie: a frame each, laid nearly
   straight and a little larger than a print, with nothing laid over its
   picture (gallery.js keeps the pile off it). On the table it is a print
   like the rest: it rises under the pointer, and its button picks it up;
   the player under the glass takes no press (nor the focus: gallery.js
   keeps it inert) until the frame is in hand. Then the presses are the
   player's, and the matte round it puts the frame down. */
/* (The crop stands beside the button now, not inside it: an iframe, a
   live part, is no child for a button. The button keeps the act, and
   the crop casts the same box it cast in the button: the print's width
   casts it, its ratio, at the print's top, the empty button drawing
   nothing and taking no height of its own. No rule here names the
   button as the crop's parent, so none moves for the change.) */
.gallery__print--video .gallery__crop { background: var(--ink); }
.gallery__print--video .gallery__crop iframe {
  position: absolute; inset: 0;
  /* in hand, laid out at the size it is shown at: see --hold-k below */
  width: 100%; height: 100%;
  display: block; border: 0; border-radius: 0;
  pointer-events: none;
  transition: opacity var(--soft) var(--ease);
}
.gallery__print--video.is-held .gallery__crop iframe { pointer-events: auto; }
.gallery__print--video:not(.is-loaded) .gallery__crop iframe { opacity: 0; }
.gallery.is-dealing .gallery__print--video .gallery__crop iframe,
.gallery.is-gathering .gallery__print--video .gallery__crop iframe {
  transition: scale var(--deal-flight) var(--ease) var(--d), opacity var(--deal-flight) var(--ease) var(--d);
}

/* ---------- the deal, and the gather --------------------------------
   gallery.js puts each print on screen at the start of its flight (on a
   stack print's exact box, or on the deck) with no transition, then lets
   go; these rules carry it to its place. --i is the print's turn and --n
   how many are being dealt, so the stagger is one line of calc. Only what
   is on screen is dealt; the rest is simply there. */
.gallery.is-set .gallery__print, .gallery.is-set .gallery__print * { transition: none !important; }
.gallery.is-dealing .gallery__print,
.gallery.is-gathering .gallery__print {
  --d: calc(var(--deal-wait) + var(--i, 0) * min(var(--deal-step), var(--deal-cap) / var(--n, 1)));
  transition: var(--photo-transition),
              translate var(--deal-flight) var(--ease) var(--d),
              scale var(--deal-flight) var(--deal-land) var(--d),
              rotate var(--deal-flight) var(--deal-land) var(--d),
              --rot var(--deal-flight) var(--ease) var(--d),
              opacity 70ms linear var(--d);
}
.gallery.is-dealing .gallery__crop img,
.gallery.is-gathering .gallery__crop img {
  transition: scale var(--deal-flight) var(--ease) var(--d), opacity var(--deal-flight) var(--ease) var(--d);
}
/* Under a ghost, a lead's own picture comes up at once as its file comes
   in: the ghost over it is the one fading, and two fades crossing would
   let the matte show through the middle of the flight. */
.gallery.is-dealing .gallery__crop:has(> .gallery__ghost) > img:not(.gallery__ghost) {
  transition: scale var(--deal-flight) var(--ease) var(--d), opacity 0s;
}
/* a lead's picture moves from the stack's even matte to its own place */
.gallery.is-dealing .gallery__crop,
.gallery.is-gathering .gallery__crop {
  transition: scale var(--deal-flight) var(--ease) var(--d), translate var(--deal-flight) var(--ease) var(--d);
}
/* Gathering is the deal run backwards, last print first, with no bounce:
   each slides under the deck and is gone as it gets there. It runs on the
   gather's own, quicker timings, so every rule above it speeds up too. */
.gallery.is-gathering {
  --deal-flight: var(--gather-flight);
  --deal-step: var(--gather-step);
  --deal-cap: var(--gather-cap);
  --deal-wait: var(--gather-wait);
}
.gallery.is-gathering .gallery__print {
  transition: translate var(--deal-flight) var(--ease) var(--d),
              scale var(--deal-flight) var(--ease) var(--d),
              rotate var(--deal-flight) var(--ease) var(--d),
              --rot var(--deal-flight) var(--ease) var(--d),
              opacity 90ms linear calc(var(--d) + var(--deal-flight) - 90ms);
}
.gallery.is-gathering { pointer-events: none; }
/* (the back and the rail by name: on a phone their column is display:
   contents, which has no opacity of its own) */
.gallery.is-gathering .gallery__back,
.gallery.is-gathering .gallery__rail,
.gallery.is-gathering .gallery__title { opacity: 0; transition: opacity var(--quick) linear; }
/* a print that was off screen is not gathered; it goes with the words */
.gallery.is-gathering .gallery__print:not(.is-flying) { opacity: 0; transition: opacity var(--quick) linear; }
/* The words arrive under the deal. A keyframe with a backwards fill, so
   nothing is left holding a transform over the pen marks. */
.gallery.is-dealing .gallery__title,
.gallery.is-dealing .gallery__rail > *,
.gallery.is-dealing .gallery__back { animation: rise 420ms var(--ease) var(--words-wait) backwards; }
/* reached by its URL, with no stack to deal from: the page just arrives */
.gallery.is-arriving .gallery__side,
.gallery.is-arriving .gallery__body { animation: rise 420ms var(--ease) backwards; }

/* ---------- a print picked up ----------------------------------------
   It rises off the table to the middle of the screen, straight, as large
   as fits (gallery.js works out where it goes and how large from where it
   lies), and the paper comes up over everything behind it. */
.gallery__scrim {
  position: fixed; inset: 0; z-index: 50;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--soft) var(--ease), visibility 0s var(--soft);
}
.gallery.has-held .gallery__scrim { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
/* The pile is a stack of its own, so the paper that comes up is the
   pile's: while a print is held the whole pile rises over the page, and
   its paper, fixed to the screen, covers the page and the rest of the pile
   alike, with the held print above it. (The scrim outside stays to take a
   press anywhere the pile does not reach.) */
.gallery.has-held .gallery__pile { z-index: 55; }
/* and it goes back down only once the print has landed and the paper is
   gone, or the way back would come up through the paper at the first
   frame of the put-down */
.gallery__pile { transition: z-index 0s linear var(--soft); }
.gallery.has-held .gallery__pile { transition-delay: 0s; }
/* The paper is an element of its own (index.html), not a ::before on the
   table. Safari on iOS 26 holds a fixed box out from under the status bar
   and the tab bar, and paints those two bands itself in the colour of
   whatever fixed element it finds at the screen's edges, blended over the
   page: an empty fixed box the size of the screen with a see-through
   background is read as a dimming layer and the bands take its colour.
   It looks for elements only, never pseudo-elements, so the paper drawn
   as one left the page showing through both bands unwashed. */
.gallery__paper {
  position: fixed; inset: 0; z-index: 9000;
  background: color-mix(in srgb, var(--paper) var(--hold-wash), transparent);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--soft) var(--ease), visibility 0s var(--soft);
}
.gallery.has-held .gallery__paper { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
/* The way back is under the paper with everything else while a print is in
   hand, so a press on it is a press on the paper: it puts the print down,
   and the next press goes back. That next press may come while the paper
   is still going and the pile still up over the way back, so the pile
   takes no press until it is down (gallery.js sets is-landing for that
   long): it goes through to the way back, or to nothing, and never to the
   print that happens to lie under the pointer. */
.gallery.is-landing .gallery__pile,
.gallery.is-landing .gallery__lift::before { pointer-events: none; }
/* The table's pen marks ride above the cursor, which is above the paper
   too, so they step out while a print is in hand, as the paper comes up. */
.mark--table { transition: opacity var(--soft) var(--ease); }
.gallery.has-held .mark--table { opacity: 0; }
/* Picking up and putting down is one number easing, --held: 0 on the
   table, 1 in hand. Everything that moves with it is worked out from it
   on every frame, from the two ends gallery.js measures (all in px): where
   the print goes (--hx, --hy); the frame (--hw by --hh) and its scale
   there, across and down (--hsx, --hsy); the picture in it, its margins
   (--hpl, --hpr, --hpt, --hpb) and size (--hcw by --hch); and how much
   thicker the matte is there (--hm). A print in hand is the same print,
   only nearer, in a thinner matte: grown whole, the matte grew as thick
   as the picture is large, a wide white border round a picture that could
   have had the room. So each side ends at its own margin times --hm, which
   is --hold-matte of what growing whole would make it, the corners with
   it, and the picture grows into what the matte gives up. The frame round
   it is then a hair narrower for its height, or shorter, than the frame
   on the table, so it is scaled a hair more one way than the other; its
   corners are still drawn round on screen, and the picture is never
   stretched. Eased one by one, the frame, the matte and the picture each
   took their own path and the matte swelled half as thick again on the
   way; worked out from one number they cannot drift apart, and a print
   put down halfway up comes back down from where it is. (Frame by frame,
   too, so the picture is drawn at the size it is shown at, not stretched
   from a copy and sharpened at the end.) */
@property --held { syntax: "<number>"; inherits: true; initial-value: 0; }
.gallery__print {
  --hold-sx: calc(1 + (var(--hsx, 1) - 1) * var(--held));
  --hold-sy: calc(1 + (var(--hsy, 1) - 1) * var(--held));
  --hold-m: calc(1 + (var(--hm, 1) - 1) * var(--held));
  /* each side of the matte, on screen, in the frame's own px */
  --hold-l: calc(var(--hpl, 0) * var(--hold-m) / var(--hold-sx));
  --hold-r: calc(var(--hpr, 0) * var(--hold-m) / var(--hold-sx));
  --hold-t: calc(var(--hpt, 0) * var(--hold-m) / var(--hold-sy));
  --hold-b: calc(var(--hpb, 0) * var(--hold-m) / var(--hold-sy));
  --hold-cx: calc((var(--hw, 1) - var(--hold-l) - var(--hold-r)) / var(--hcw, 1));
  --hold-cy: calc((var(--hh, 1) - var(--hold-t) - var(--hold-b)) / var(--hch, 1));
  translate: calc(var(--hx, 0px) * var(--held)) calc(var(--hy, 0px) * var(--held));
  scale: var(--hold-sx) var(--hold-sy);
  /* (the corner grows with the matte, round on screen however the frame is scaled) */
  border-radius: calc(var(--frame-radius) * var(--hold-m) / var(--hold-sx)) / calc(var(--frame-radius) * var(--hold-m) / var(--hold-sy));
}
.gallery__crop {
  translate: calc(((var(--hw, 1) + var(--hold-l) - var(--hold-r)) / 2 - var(--hpl, 0) - var(--hcw, 1) / 2) * 1px)
             calc(((var(--hh, 1) + var(--hold-t) - var(--hold-b)) / 2 - var(--hpt, 0) - var(--hch, 1) / 2) * 1px);
  scale: var(--hold-cx) var(--hold-cy);
  border-radius: calc(var(--frame-radius) * 0.4 * var(--hold-m) / (var(--hold-cx) * var(--hold-sx)))
               / calc(var(--frame-radius) * 0.4 * var(--hold-m) / (var(--hold-cy) * var(--hold-sy)));
}
/* the picture (a video's player with it) covers its window as the window
   is on screen, frame and all */
.gallery__crop img, .gallery__crop iframe {
  --win-x: calc(var(--hold-cx) * var(--hold-sx));
  --win-y: calc(var(--hold-cy) * var(--hold-sy));
  scale: calc(max(var(--win-x), var(--win-y)) / var(--win-x)) calc(max(var(--win-x), var(--win-y)) / var(--win-y));
}
/* In hand, and on the way down, the picture is laid out --hold-k times
   larger (its scale in hand, from gallery.js) on a layer of its own, and
   scaled down by as much: the same size on screen, but drawn at it. Scaled
   up from its size on the table, Safari kept the bitmap it had drawn at
   that size and the print came up soft. (The player the same, below.) */
.gallery__print.is-held .gallery__crop img:not(.gallery__ghost),
.gallery__print.is-going .gallery__crop img:not(.gallery__ghost),
.gallery__print--video .gallery__crop iframe {
  width: calc(100% * var(--hold-k, 1)); height: calc(100% * var(--hold-k, 1));
  max-width: none;   /* past the site-wide img { max-width: 100% } */
  transform-origin: 0 0;
  scale: calc(max(var(--win-x), var(--win-y)) / var(--win-x) / var(--hold-k, 1))
         calc(max(var(--win-x), var(--win-y)) / var(--win-y) / var(--hold-k, 1));
}
.gallery__print.is-held .gallery__crop img:not(.gallery__ghost),
.gallery__print.is-going .gallery__crop img:not(.gallery__ghost) { will-change: transform; }
.gallery__print.is-held {
  --held: 1;
  --rot: 0deg !important; --zoom: 1 !important; --rx: 0deg !important; --ry: 0deg !important;
  --frame-shadow: var(--print-lift);
  /* each print taken up lies over the one going back down (--hz counts) */
  z-index: calc(9001 + var(--hz, 0)) !important;
  transition-delay: 0s;
}
/* Put down, a print is on its way back down from above the paper until
   the frame it lands (gallery.js marks it is-going until then). It stays
   above the paper all the way, and goes under it, into its place in the
   pile (one raised, its raised place), on that same frame, however short
   a step cut its way down: worked out from --held on every frame, never
   held for it on a timer. Left to the pile's own wait (z-index 0s
   var(--soft), on every print), it kept whatever place it had a moment
   before. Put down from under the pointer, it is under it no longer (the
   table takes no press while a print lands), and that place was worked
   out from where --held was headed, not where it was: its place once
   down, under the paper, while the paper was still all but up. The print
   in hand sank behind the paper and came back up through it as the paper
   went: a flash. Above any rule that would place a print on its way down,
   as one in hand is. */
.gallery__print.is-going {
  --aloft: min(1, var(--held) * 1000000);   /* 1 until the frame it lands */
  z-index: calc(var(--up, var(--z, 1)) + (9001 + var(--hz, 0) - var(--up, var(--z, 1))) * var(--aloft)) !important;
  transition-delay: 0s;
}
/* Stepped off with the arrow keys, a print goes back down under paper that
   stays up. It thins as it lands to what the paper leaves of the pile, and
   is the pile again the frame it goes under the paper. */
.gallery.has-held .gallery__print.is-going {
  opacity: calc(100% - (1 - var(--held)) * var(--hold-wash) * var(--aloft));
}
/* the ring the keyboard puts round a print keeps its weight on screen */
.gallery__print:has(:focus-visible) { outline-width: calc(2px / var(--hold-sx)); outline-offset: calc(4px / var(--hold-sx)); }

/* ---------- reduced motion: the pages swap ------------------------- */
@media (prefers-reduced-motion: reduce) {
  .gallery.is-arriving .gallery__side,
  .gallery.is-arriving .gallery__body { animation: none; }
}

/* ---------- responsive --------------------------------------------- */
@media (max-width: 60em) {
  :root { --table-across: 3.8; --tilt-max: 16; }
}
@media (max-width: 40em) {
  /* a phone's table is tidier: about two landscape prints across (three
     or four portraits), turned less */
  :root {
    --table-across: 2.4; --clear-pull: 60vw;
    --tilt-min: 3; --tilt-max: 10; --tilt-straight: 0.2; --lead-tilt-max: 6;
  }
  .gallery {
    display: block; padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    --gallery-head: 1.5rem; --table-reach: 0px;
  }
  /* the way back rides at the top of the screen over the prints */
  .gallery__back { top: calc(0.75rem + env(safe-area-inset-top, 0px)); }
  /* the arrow alone is drawn in the pen here, at rest (the disc stays
     ink); lit or pressed it is the pill's own ink on the pen again. The
     disc rides above the cursor, as the pen marks do, so the pen is never
     turned under it: it is a stack of its own, and would hold the arrow
     there. Under the paper while a print is in hand, and back above only
     once the paper has gone, as the pile is. */
  .gallery .gallery__back .btn__arrow path { stroke: var(--pen); }
  .can-hover .gallery .gallery__back:hover .btn__arrow path,
  .gallery .gallery__back:focus-visible .btn__arrow path,
  .gallery .gallery__back:active .btn__arrow path { stroke: currentColor; }
  body.has-cursor .gallery__back {
    z-index: 10000;
    transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease),
                border-color var(--quick) var(--ease), transform var(--quick) var(--ease),
                padding var(--soft) var(--ease), box-shadow var(--soft) var(--ease),
                z-index 0s linear var(--soft);
  }
  body.has-cursor .gallery.has-held .gallery__back { z-index: 3; transition-delay: 0s; }
  /* Sealed, the way back returns to its own z-index at once: its climb
     to 10000 waits a beat by design, but the drop under the theme pill
     must not wait, so the delay on z-index is lifted while sealed, the
     way the has-held step above handles it. (3 is the z-index it rests
     at unlifted, above the pile, which is a stack of its own.) */
  body.has-cursor.is-sealed .gallery__back { z-index: 3; transition-delay: 0s; }
  .gallery__side { display: contents; }
  .gallery__rail { margin-top: 1.75rem; margin-bottom: 0; }
  /* The rail is one row here: the cue to the left and the note set to the
     right, the two on one baseline (and where the row is too narrow for
     both, the note goes back under the cue). The cue's rule runs on past
     its words, over the note, and the rail cuts it off at its edge: it is
     drawn from the cue, so it rises and thins with it. The rail reaches
     half a rem out to the left so the pen's circle, which lips out past
     the count, is not cut off with it when the note is under the cue. */
  .gallery__rail {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
    column-gap: 1rem; overflow-x: clip;
    margin-left: -0.5rem; padding-left: 0.5rem;
  }
  .gallery__rail .rail__cue { position: relative; }
  .gallery__rail .rail__cue::after {
    content: ""; position: absolute; left: 100%; bottom: 100%; width: 100vw;
    border-top: inherit;
  }
  /* the brief set smaller, for the narrower measure */
  .gallery__fields dd { font-size: 0.875rem; }
  /* the title is on one line here, scaled down to the page's width when
     it needs to be (gallery.js sets --title-fit) */
  .gallery__title { white-space: nowrap; min-width: 0; }   /* (held to the row, so a long one overflows it to be measured) */
  /* the format and role go up beside the way back, in the row it rests in
     at the top of the page, each on a line of its own and set to the
     right, the two lines centred on the pill. They are in the body, under
     the rail: lifted by --meta-lift (gallery.js), and clear of the way
     back, a disc here as wide as it is tall, by a rem. They scale down as
     they do in a desk's row, to a floor, and past it go under the title
     (is-under). */
  .gallery__meta {
    top: calc(-1 * var(--meta-lift, 0px)); right: 0;
    left: calc(var(--pill-h) + 1rem);
    height: var(--pill-h); min-height: 0; padding-top: 0;
    flex-direction: column; flex-wrap: nowrap; justify-content: center; align-items: flex-end;
    row-gap: 0; line-height: 1.3;
  }
  .gallery__meta.is-under {
    position: static; height: auto; margin: 1.4rem 0 0;
    align-items: flex-start; line-height: inherit; row-gap: 0.1rem;
  }
  .gallery__meta.is-under > div { opacity: var(--rail-clear, 1); }
  /* and the title, under it in the one column, thins out line by line as
     it comes up to it, gone half a rem short of its lower edge (the same
     stretch the rail's words thin over), so the disc only lies on prints.
     --title-cut is that edge in the title's own pixels, from gallery.js;
     unset, the whole title is there. (No pen marks inside the title for
     the mask to hold under the cursor.) The mask sits on the words' own
     span, not the title: a mask cuts off whatever lies outside its box,
     and at a 1.02 line height the title's box stops above the descenders
     (the p and y of Chronography). An inline span's box is as tall as the
     font, so the letters bleed out of their line, uncut, with nothing
     moved; gallery.js measures --title-cut from the span's top. */
  .gallery__words {
    -webkit-mask-image: linear-gradient(to bottom, transparent calc(var(--title-cut, -100vh) + 0.5rem), #000 calc(var(--title-cut, -100vh) + 2rem));
    mask-image: linear-gradient(to bottom, transparent calc(var(--title-cut, -100vh) + 0.5rem), #000 calc(var(--title-cut, -100vh) + 2rem));
  }
}
