/* The globe with floating prints (assets/photo-globe.js), used by the Gallery and by Home, and the Gallery's own moving parts
   (the large print, the entrance, Globe to Grid). Every value comes from tokens.css. Loaded after site.css. */

/* The stage takes a drag anywhere. Sideways touches turn the globe; up-and-down touches scroll the page. */
.stage { position: relative; height: var(--stage-h); overflow: hidden; overflow: clip; cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.stage.is-dragging, .stage.is-dragging .pin { cursor: grabbing; }
.stage canvas, .pins { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pins-back { z-index: 0; }
.stage canvas { z-index: 1; }
.pins-front { z-index: 2; }
/* The sphere's own box (photo-globe.js): a square exactly the sphere's size, holding the canvas, which overflows it to fill the stage. */
.stage .sphere { position: absolute; z-index: 1; pointer-events: none; }
/* Beside the large print, the Gallery's stage is inset in the page: the prints at the globe's left limb may reach into the page's
   margin there, as they reach the screen's edge on a phone, instead of being cut off at the stage. Only that side: on the right
   is the large print, and nothing passes the stage's other edges. (Clipped, not hidden, so the stage is never a scroll box and
   nothing in it, a card sliding in included, can widen the page.) */
@media (min-width: 761px) { .gallery .stage { overflow-clip-margin: var(--pad); clip-path: inset(0 0 0 calc(-1 * var(--pad))); } }

/* A print: a small flat polaroid with its place under it, on a paper ground so the name reads over the globe's lines. */
.pin { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: var(--pin-gap); margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: none; opacity: 0; cursor: pointer; will-change: transform, opacity; -webkit-tap-highlight-color: transparent; -webkit-user-drag: none; }
.pin-print { display: block; padding: var(--pin-pad) var(--pin-pad) var(--pin-foot); background: var(--c-print); border: var(--line) solid var(--c-rule-soft); transition: border-color var(--dur) var(--ease); }
.pin img, .deal-card img { display: block; width: var(--pin); height: var(--pin); object-fit: cover; background: var(--c-photo-fill); pointer-events: none; }
.pin-place { min-height: var(--fs-pin); padding: 0 var(--pin-pad); background: var(--c-paper); font-size: var(--fs-pin); line-height: var(--lh-tight); color: var(--c-ink-2); font-variant-caps: all-small-caps; letter-spacing: var(--track-caps); white-space: nowrap; transition: color var(--dur) var(--ease); }
.pin-place:empty { background: none; }
.pin.is-current .pin-print { border-color: var(--c-ink); }
.pin.is-current .pin-place { color: var(--c-ink); }
@media (hover: hover) { .pins-front .pin:hover .pin-print { border-color: var(--c-ink); } .pins-front .pin:hover .pin-place { color: var(--c-ink); } }

/* ---------- Gallery ---------- */

/* The head: on a desktop one row, as on Home (the heading with its note under it, as on Writing; the two figures at the right), the Globe and Grid
   switch on the hairline under it, then the stage, sized to end at the fold (--stage-h), so the globe and the whole large print,
   caption and all, are on the first screen. The layout of these is site.css's; these rules only bring them into one row. */
@media (min-width: 1025px) {
  .gallery-h { grid-column: 1 / span 8; }
  .gallery .stats { grid-column: 9 / -1; }
}
.gallery .modes { margin-top: var(--sp-gallery-modes); }
.globe-ok:not([data-mode="grid"]) .gallery .globe-mode { margin-top: var(--sp-gallery-stage); }

/* The large print. A new photograph fades in over the old one, which stays until the new one is ready, and the frame
   changes shape with it instead of jumping. --ar is the photograph's width over its height. */
@property --ar { syntax: "<number>"; inherits: true; initial-value: .75; }
.viewer { transition: --ar var(--dur-photo) var(--ease), opacity var(--dur) var(--ease); }
/* Held back while the entrance deals: the last card is dealt here as a whole print, paper and all, and becomes this one when it
   lands (at once, as the two are drawn alike); the count and steps fade in as it comes in to land ("landing"), the caption as it lands. */
html[data-deal]:not([data-deal="landed"]) .vw-print { opacity: 0; }
html[data-deal]:not([data-deal="landing"]):not([data-deal="landed"]) .vw-bar { opacity: 0; }
.vw-bar { transition: opacity var(--dur) var(--ease); }
/* The place and the count change with the photograph: the old words (.vw-was) lift away over the new ones (gallery.js). */
.vw-place, .vw-count { position: relative; }
.vw-now { display: block; }
.vw-was { position: absolute; inset: 0; display: flex; align-items: center; padding: inherit; white-space: nowrap; pointer-events: none; }
.vw-photo { position: relative; aspect-ratio: var(--ar, .75); overflow: hidden; contain: paint; background: var(--c-photo-fill); }   /* paint contained: the photograph fading in is drawn on its own layer, and without it that layer could show past the frame for a frame, over the caption */
.vw-print .vw-photo img { position: absolute; inset: 0; box-sizing: border-box; width: 100%; height: 100%; aspect-ratio: auto; padding: var(--sp-3); object-fit: cover; background: none; color: var(--c-paper); font-size: var(--fs-note); line-height: var(--lh-note); }
/* The padding and the light colour are for the description, which shows when the picture cannot (images off, or a failed load):
   it reads light on the dark ground. A loaded picture takes the whole box. */
.vw-print .vw-photo img.is-loaded { padding: 0; }

/* The entrance: cards dealt onto a stack over the globe. Each is a print like those on the globe, larger. */
.deal { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.deal-card { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform, opacity; }
.deal-card .pin-print { padding: calc(var(--pin-pad) * var(--deal-scale)) calc(var(--pin-pad) * var(--deal-scale)) calc(var(--pin-foot) * var(--deal-scale)); }
.deal-card img { width: calc(var(--pin) * var(--deal-scale)); height: calc(var(--pin) * var(--deal-scale)); } /* drawn at its real size, so it is sharp; not a small print scaled up */
/* The last card on its way into the large print, drawn as the large print; and (Globe to Grid and back) a print flying between
   the modes, a print, paper and all, whose box and paper change from the one to the other as it flies. */
.deal-top, .fly-print { position: fixed; left: 0; top: 0; z-index: 20; box-sizing: border-box; margin: 0; overflow: hidden; background: var(--c-print); border: var(--line) solid var(--c-rule-soft); pointer-events: none; will-change: transform, width, height, padding; }
.deal-top img, .fly-print img { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--c-photo-fill); }
/* The caption that rides in a flying print's foot, set exactly as the large print's and a grid print's own, where theirs sits. */
.deal-cap, .fly-cap { position: absolute; left: var(--print-border); right: var(--print-border); bottom: 0; display: flex; align-items: center; min-height: var(--print-foot); padding: 0 var(--line); font-family: var(--f-display); -webkit-text-stroke: var(--stroke-voice) currentColor; font-size: var(--fs-caption); line-height: var(--lh-tight); color: var(--c-ink); white-space: nowrap; }

/* Globe to Grid and back: the mode arriving is there at once, under the prints in flight (html[data-fly], gallery.js), so no frame
   is ever an empty page. */
html.globe-ok[data-fly] .globe-mode, html.globe-ok[data-fly] .grid-mode { animation: none; }
/* Globe to Grid: the prints in front fly to their cells, and the rest arrive quickly. */
.js .gallery .contact .print { transition-duration: var(--dur-mode); }
.gallery .contact img { background-size: cover; background-position: center; color: var(--c-paper); font-size: var(--fs-note); line-height: var(--lh-note); } /* with images off, the description reads light on the dark ground */

/* Phones: a composition of its own, in reading order. The heading, with the Globe and Grid switch at the right of its line; the
   note; the two figures on a row of their own, each over half the page as Grid mode's two columns are, on the hairline that
   closes the head. Then the globe, the hero of the first screen, with the top of the large print under it. The large print keeps
   one height whatever the photograph's shape (its width follows the photograph, centred), so the steps under it, with the count
   between them, never move under the thumb, and the print and its steps fit on one screen under the running head. */
@media (max-width: 760px) {
  .gallery-h { display: contents; }
  .gallery-h .headline { grid-column: 1 / -1; grid-row: 1; justify-self: start; align-self: baseline; }
  .gallery .modes { grid-column: 1 / -1; grid-row: 1; justify-self: end; align-self: baseline; margin-top: 0; border-bottom: 0; }
  .gallery-h .note { grid-column: 1 / -1; grid-row: 2; margin-top: var(--sp-1); }
  .gallery .stats, .home-globe-head .stats { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--gap); margin-top: var(--sp-gallery-stats); }
  .gallery .stats { padding-bottom: var(--sp-gallery-rule); border-bottom: var(--line) solid var(--c-rule-soft); }
  .gallery .stats dt, .home-globe-head .stats dt { white-space: nowrap; }
  .gallery .viewer { row-gap: var(--sp-viewer); scroll-margin: calc(var(--gallery-head-phone) + var(--sp-4)) 0 var(--sp-4); } /* a print chosen on the globe scrolls in clear of the running head */
  .gallery .vw-print { justify-self: center; width: min(100%, calc(var(--viewer-h) * var(--ar, .75) + 2 * var(--print-border) + 2 * var(--line))); }
  .gallery .vw-bar { order: 1; justify-content: center; gap: var(--sp-4); }
  .gallery .vw-steps { display: contents; }
  .gallery .vw-prev { order: -1; }
  .gallery .vw-count { min-width: var(--vw-count-w); text-align: center; }
  .gallery .vw-count .vw-was { justify-content: center; }
}

/* ---------- Home ---------- */

/* The globe below the hero: a head in the Gallery's own words, then the globe, full width. */
.home-globe { border-top: var(--line) solid var(--c-rule-soft); padding-top: var(--sp-section-top); padding-bottom: var(--sp-section-bottom); }
.home-globe-head { align-items: end; }
.home-globe-title { grid-column: 1 / span 6; }   /* the heading and the Gallery's note under it, as Writing above has its own (Keith, 15 November 2026) */
.home-globe-head .headline { margin: 0; }
.home-globe-head .headline a { color: inherit; text-decoration: underline var(--line) transparent; text-underline-offset: var(--underline-offset-title); }
@media (hover: hover) { .home-globe-head .headline a:hover { color: var(--c-ink); text-decoration-color: currentColor; } }
.home-globe .stage { height: var(--home-globe-h); margin-top: var(--sp-5); }
html:not(.js) .home-globe .stage { display: none; }
@media (max-width: 1024px) { .home-globe-title { grid-column: 1 / -1; } }
@media (max-width: 760px) { .home-globe-title { grid-column: 1 / -1; grid-row: 1; } .home-globe-head .stats { grid-row: 2; } } /* the figures under it, as on the Gallery, so the two travel as one */

/* Home to the Gallery and back: the globe's wireframe carries across while the page changes around it. The prints are faded out
   before leaving and fade in after arriving, so nothing shows in two places.
   Only between pages that load this file, only where the browser has cross-document view transitions, never under reduced motion.
   Between these pages and any other (html.vt-plain, transitions.js) none of this is named: the globe and its words leave or
   arrive with their page (site.css, Page transitions). The pages themselves turn as
   every pair of pages does, under the globe as it travels. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  :is(.home-globe-head, .gallery-h) .headline { width: fit-content; } /* each travelling box hugs its words, so the two ends match and nothing is stretched on the way */
  /* What travels is the sphere's own square (photo-globe.js), so at both ends the box is the sphere at its own radius: the two
     pictures of it lie one on the other all the way, and nothing is stretched. */
  html:not(.vt-plain) .stage .sphere { view-transition-name: globe; }
  ::view-transition-group(globe) { animation-duration: var(--dur-carry); animation-timing-function: var(--ease-out); }
  /* Carried from Home (html.carry-in, set by gallery.html): the globe that left is the one seen until it lands, and the Gallery's
     own, drawn beneath it at the same size and on the same view, takes over only then. One globe, all the way. */
  html.carry-in::view-transition-old(globe) { animation: none; }
  html.carry-in::view-transition-new(globe) { animation: none; opacity: 0; }
  /* The heading and the two figures travel with the globe, each as itself, instead of fading out in one place and in at another. */
  html:not(.vt-plain) :is(.home-globe-head, .gallery-h) .headline { view-transition-name: gallery-title; }
  html:not(.vt-plain) :is(.home-globe, .gallery) .stats > div:first-child { view-transition-name: gallery-been; }
  html:not(.vt-plain) :is(.home-globe, .gallery) .stats > div:last-child { view-transition-name: gallery-explored; }
  ::view-transition-group(gallery-title), ::view-transition-group(gallery-been), ::view-transition-group(gallery-explored) { animation-duration: var(--dur-carry); animation-timing-function: var(--ease-out); }
}
