/*
  HOMEPAGE — hero + printed sheets.
  The sheets' resting layout is the plain CSS grid below (the "organized"
  state). js/home.js only adds a transform on top of it: at scroll 0 each
  sheet is pulled out to a scattered spot on the light box, and it glides
  back into its grid cell as the hero scrolls away. No JS = clean grid.
*/

/* transparent so the light-box background (.lightbox, components.css) shows through */
body.home { background: transparent; }

/* the nav is solid light-box surface, so prints scroll cleanly under it
   (a fade let them show through its lower half) */
.home .site-nav { background: var(--lightbox-surface); }

.home {
  /* the grid's margin starts inside the light-box frame */
  --page-margin: calc(var(--frame-width) + var(--grid-margin));
}

.home main {
  padding: 0 var(--page-margin);
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: calc(var(--frame-width) + var(--nav-height) + clamp(24px, 9vh, 120px));
  z-index: var(--z-title);
  pointer-events: none;
}

.hero__title > span {
  display: block;
  animation: rise 1100ms var(--ease-smooth) both;
}
.hero__title > span + span { animation-delay: 90ms; }

/* the letters of the title (split by js/home.js): the S and G travel
   into the logo, scaled from their top-left; the rest lift away */
.hero__word { display: inline-block; }
.hero__letter {
  display: inline-block;
  transform-origin: 0 0;
  will-change: transform, opacity;
}
/* the cut-outs that blow away turn about their own middle (the S and G
   keep scaling from their top-left) */
.hero__letter:not(.hero__cap) { transform-origin: 50% 50%; }

/* the hero sits above the nav so the travelling title passes over the
   nav's paper fade instead of under it (pointer-events stay off) */
.hero { z-index: calc(var(--z-nav) + 1); }

/* the homepage logo starts hidden and is revealed as the title arrives
   (inline opacity from js/home.js); a keyboard user can still reach it */
.home .logo-button:focus-visible { opacity: 1 !important; }

.hero__role {
  margin-top: clamp(28px, 7vh, 72px);
  font-size: var(--text-small-size);
  font-weight: 400;
  color: var(--text-soft);
  animation: rise 1100ms var(--ease-smooth) 220ms both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(0.35em); }
}

/* ---------- sheets: the organized grid ---------- */
/*
  Gallery wall (kept as designed, not forced onto the 8 columns): two
  equal columns, every print the same size (4:3). It sits inside the
  shared page margins. Images crop to fit (object-fit: cover), so any
  source image lands uniform.
*/
.sheets {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(32px, 9vw, 120px);
  row-gap: clamp(48px, 8vw, 104px);
  padding: clamp(24px, 6vh, 64px) clamp(0px, 3vw, 48px) clamp(96px, 16vh, 200px);
  max-width: 1320px;
  margin: 0 auto;
  scroll-margin-top: calc(var(--frame-width) + var(--nav-height));
}

.sheet {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
  z-index: var(--z-paper-front);
  --ratio: 4 / 3;
}

.sheet__link {
  display: block;
  cursor: pointer;
}

/* the printed paper itself (a tall print, data-tall, gets an inline
   height while it's in the hero pile: js/home.js stretch()) */
.sheet__paper {
  position: relative;
  aspect-ratio: var(--ratio);
  background: var(--color-white);
  overflow: hidden;
  box-shadow: var(--shadow-paper);
  transform: rotate(var(--rest-rot, 0deg));
  transition:
    transform var(--duration-base) var(--ease-smooth),
    box-shadow var(--duration-base) ease;
  animation: deal 1000ms var(--ease-smooth) both;
  animation-delay: calc(240ms + var(--i, 0) * 70ms);
}

/* inner printed edge, sits over the image */
.sheet__paper::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: var(--inset-paper);
  pointer-events: none;
}

.sheet__paper img,
.sheet__paper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
}

/* placeholder / title-card print (no image yet) */
.sheet__paper--card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-blush);
}
.sheet__paper--card span {
  font-family: var(--font-mono);
  font-size: var(--text-label-size);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-strong);
}

.sheet__link:hover .sheet__paper,
.sheet__link:focus-visible .sheet__paper {
  transform: translateY(-4px) rotate(calc(var(--rest-rot, 0deg) * -1));
  box-shadow: var(--shadow-paper-lift);
}

/* award tag: pinned over the print's top-left corner, slightly askew,
   lands with the caption and lifts with the print on hover */
.sheet__link { position: relative; }
.sheet__award {
  position: absolute;
  top: -10px;
  left: -12px;
  z-index: 2;
  transform: rotate(-4deg);
  opacity: var(--settle, 1);
  transition: transform var(--duration-base) var(--ease-smooth);
  /* deals in with its print, a beat after it */
  animation: deal 1000ms var(--ease-smooth) both;
  animation-delay: calc(420ms + var(--i, 0) * 70ms);
}
.sheet__link:hover .sheet__award,
.sheet__link:focus-visible .sheet__award {
  transform: translateY(-4px) rotate(-4deg);
}
/* stamped a touch carelessly: hangs a few px off the print's top-left
   corner. Difference only shows over the print, so the bit that misses
   the paper fades into the light box, like ink that didn't catch */
.sheet__award--stamp {
  top: -7px;
  left: -9px;
  width: clamp(72px, 22%, 150px);
  transform: rotate(-8deg);
}
.sheet__link:hover .sheet__award--stamp,
.sheet__link:focus-visible .sheet__award--stamp {
  transform: translateY(-4px) rotate(-8deg);
}

/* ---------- references: little cards on the light box (js/home.js, js/references-data.js) ---------- */
/* scattered at the top of the page, faded out (inline opacity) before the
   grid settles. Each links to MindCloud; hover lifts it a touch and shows a
   quiet "References" label above it (the first card peeks up from the
   bottom edge, so a label under it would be off screen). */
.ref {
  position: absolute;
  z-index: var(--z-paper-back);   /* always under the prints */
  transform: rotate(var(--tilt, 0deg));
  will-change: transform, opacity;
  background: var(--color-white);
  box-shadow: var(--shadow-paper);
  color: inherit;
  text-decoration: none;
  transition: translate var(--duration-base) var(--ease-smooth);
}
.ref--image { padding: 6px; }
.ref--image img { display: block; width: 100%; height: auto; }
/* no image yet: a plain grey card */
.ref--blank { padding: 0; aspect-ratio: var(--ratio, 4 / 5); background: var(--color-missing); }
.ref--note {
  padding: 12px 14px 16px;
  font-size: var(--text-label-size);
  line-height: 1.4;
  color: var(--text-soft);
}
.ref__label {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 8px;
  font-size: var(--text-label-size);
  line-height: 1;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  translate: 0 3px;
  transition: opacity var(--duration-fast) ease, translate var(--duration-base) var(--ease-smooth);
  pointer-events: none;
}
.ref:hover,
.ref:focus-visible { translate: 0 -4px; }
.ref:hover .ref__label,
.ref:focus-visible .ref__label { opacity: 1; translate: 0 0; }
/* phones: no room on the light box, so no refs */
@media (max-width: 640px) { .ref { display: none; } }

/* caption: fades in as the sheet lands (--settle set by home.js) */
/* number | title | role. The title wraps inside its own column, so a long
   name stays lined up to the right of the number; the role sits flush with
   the print's right edge, lighter */
.sheet__caption {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 16px;
  align-items: start;
  margin-top: var(--space-item);
  opacity: var(--settle, 1);
}
.sheet__num { color: var(--color-ink); }
.sheet__title { color: var(--text-soft); }
.sheet__role { color: var(--text-soft); text-align: right; }   /* as dark as the title */

@keyframes deal {
  from { opacity: 0; translate: 12vw 4vh; rotate: 6deg; }
}

/* ---------- footer ---------- */

.home .site-footer {
  padding: 0 var(--page-margin) calc(var(--frame-width) + 24px);
  background: none;
  border: 0;
}

/* ---------- tablet ---------- */
@media (max-width: 1024px) {
  .sheets { column-gap: 40px; padding-left: 0; padding-right: 0; }
}

/* ---------- phone: one column ---------- */
@media (max-width: 640px) {
  .hero { min-height: 92svh; }
  .sheets { grid-template-columns: 1fr; }
  .sheets { row-gap: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero__title > span, .hero__role, .sheet__paper, .sheet__award { animation: none; }
  .sheet { transform: none !important; }
}

/* ---------- sort (js/home.js SORT) ----------
   The print-stack button: an ink chip fixed at the bottom centre, dealt
   onto the screen with the prints as the page loads. Hover fans the prints
   out like a hand of cards. Open: the page drops behind frosted dark glass
   and the categories rise up the middle as a stack of paper strips, one
   after another, big enough to hit easily. */
.work-sort {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--frame-width) + 24px + env(safe-area-inset-bottom, 0px));
  z-index: 960;                  /* over the frame and nav, under the contact popup */
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  animation: sort-in 800ms var(--ease-smooth) 240ms both;
}
.work-sort > * { pointer-events: auto; }
@keyframes sort-in {
  from { opacity: 0; transform: translateY(28px) scale(0.85); }
}

/* the frosted dark glass the page falls behind while the menu is open */
.work-sort__veil {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(16, 14, 12, 0.5);
  -webkit-backdrop-filter: blur(14px) saturate(0.85);
  backdrop-filter: blur(14px) saturate(0.85);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-base) ease, visibility 0s linear var(--duration-base);
}
.is-sorting .work-sort__veil {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--duration-base) ease;
}

/* LIGHTS OFF (the default; add ?menu=glass to the URL for the frosted
   glass instead): opening the menu switches the light table off. The page
   fades to deep black in 0.2s with a soft click (js/home.js), the prints
   sink to faint dark ghosts, and only the paper strips stay lit. */
.lights-off .work-sort__veil {
  background: rgba(6, 5, 4, 0.93);
  -webkit-backdrop-filter: grayscale(1) brightness(0.6);
  backdrop-filter: grayscale(1) brightness(0.6);
}
/* one quick, smooth switch: 0.2s each way */
.lights-off .work-sort__veil { transition: opacity 200ms ease, visibility 0s linear 200ms; }
.lights-off.is-sorting .work-sort__veil { transition: opacity 200ms ease; }

/* the button. Its dark chip is a separate layer (.work-sort__chip, laid
   on the page itself) so it can blend with "difference" against whatever
   is behind it; the prints sit on top, unblended. */
.work-sort__toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  color: var(--color-ink);
  cursor: pointer;
  transform-origin: 50% 100%;   /* grows up from its base */
  transition: transform var(--duration-base) var(--ease-smooth);
}
.work-sort__toggle:hover,
.work-sort__toggle:focus-visible { transform: translateY(-6px) scale(1.2); }
.work-sort__toggle:active { transform: translateY(-6px) scale(1.12); }

/* the chip: 20% smaller than the button, 80% opacity, difference blend;
   it follows the button's hover (rise + grow from the button's base) */
.work-sort__chip {
  position: fixed;
  left: 50%;
  bottom: calc(var(--frame-width) + 24px + env(safe-area-inset-bottom, 0px) + 8.4px);
  z-index: 955;
  width: 67.2px;
  height: 67.2px;
  margin-left: -33.6px;
  border-radius: 14px;
  background: var(--color-ink);
  opacity: 0.8;
  mix-blend-mode: difference;
  pointer-events: none;
  transform-origin: 50% calc(100% + 8.4px);
  transition: transform var(--duration-base) var(--ease-smooth);
  /* the entrance uses translate / scale / opacity, leaving transform free
     for the hover */
  animation: chip-in 800ms var(--ease-smooth) 240ms both;
}
@keyframes chip-in {
  from { opacity: 0; translate: 0 28px; scale: 0.85; }
}
body:has(.work-sort__toggle:hover) .work-sort__chip,
body:has(.work-sort__toggle:focus-visible) .work-sort__chip { transform: translateY(-6px) scale(1.2); }
body:has(.work-sort__toggle:active) .work-sort__chip { transform: translateY(-6px) scale(1.12); }
.work-sort__toggle svg { width: 60px; height: 60px; overflow: visible; }
.work-sort__toggle rect {
  fill: var(--color-white);
  stroke: var(--color-ink);
  stroke-width: 0.8;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform var(--duration-base) var(--ease-smooth);
}
.work-sort__toggle:hover .work-sort__p1,
.work-sort__toggle:focus-visible .work-sort__p1,
.work-sort.is-open .work-sort__p1 { transform: rotate(-16deg) translateX(-2px); }
.work-sort__toggle:hover .work-sort__p3,
.work-sort__toggle:focus-visible .work-sort__p3,
.work-sort.is-open .work-sort__p3 { transform: rotate(16deg) translateX(2px); }

/* the categories: a stack of paper strips above the button */
.work-sort__menu {
  position: absolute;
  bottom: calc(100% + 22px);
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
  visibility: hidden;
  transition: visibility 0s linear var(--duration-base);
}
.work-sort.is-open .work-sort__menu { visibility: visible; transition: none; }
.work-sort__opt {
  min-width: 260px;
  padding: 14px 36px;
  font-size: calc(var(--text-label-size) * 2);
  text-align: center;
  white-space: nowrap;
  color: var(--color-ink);
  background: var(--color-white);
  box-shadow: none;   /* flat strips, no glow */
  cursor: pointer;
  opacity: 0;
  transform: translateY(24px) rotate(var(--tilt, 0deg));
  transition: opacity var(--duration-fast) ease, transform var(--duration-base) var(--ease-smooth), background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}
.work-sort__opt:nth-child(odd) { --tilt: -1.2deg; }
.work-sort__opt:nth-child(even) { --tilt: 1deg; }
.work-sort.is-open .work-sort__opt {
  opacity: 1;
  transform: rotate(var(--tilt, 0deg));
  transition-delay: calc(var(--r, 0) * 45ms);   /* nearest the button rises first */
}
.work-sort.is-open .work-sort__opt:hover,
.work-sort.is-open .work-sort__opt:focus-visible {
  transform: translateY(-3px) rotate(0deg) scale(1.03);
  transition-delay: 0ms;
}
/* the view showing now: an ink strip */
.work-sort__opt[aria-pressed="true"] { background: var(--color-ink); color: var(--color-white); }

@media (max-width: 420px) {
  .work-sort__opt { min-width: 220px; padding: 12px 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .work-sort, .work-sort__chip { animation: none; }
  .work-sort__veil, .work-sort__menu, .work-sort__opt, .work-sort__toggle, .work-sort__toggle rect { transition: none; }
}
