/* -------------------------------------------------------------------- */
/* Tokens                                                                */
/* -------------------------------------------------------------------- */
:root {
  --bg: #ffffff;
  --ink: #15140f;
  --ink-soft: rgba(21, 20, 15, 0.56);
  --ink-faint: rgba(21, 20, 15, 0.14);
  --display: "hagrid", "Instrument Serif", "Times New Roman", serif;
  --ui: "Helvetica Neue", Helvetica, Arial, sans-serif;

  --gallery-gap: clamp(32px, 6vw, 84px);
  --gallery-pad: clamp(16px, 3vw, 40px);
  /* loader frame size AND .hero__cursor's rest size both derive from this
     one value (see below) so the loader's last frame keeps landing exactly
     on .hero__cursor regardless of viewport — see the mobile override
     further down for why this needs to shrink on phones. */
  --hero-img-base: 300px;
  --footer-h: 140px;
  --footer-fade-h: 28px;
  /* shared between .footer's own bottom padding and .footer__top's bottom
     offset, so the copyright line and the "Beam me up" button always sit on
     the same baseline even if this ever changes */
  --footer-pad-b: 30px;
}

/* everything black becomes white and everything white becomes black — a
   straight swap of the two base tokens. Only site chrome (backgrounds,
   text, borders) is themed this way; actual photos are never inverted,
   same as how dark mode works everywhere else, otherwise every photo
   would render as a color negative. */
html.dark-mode {
  --bg: #15140f;
  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.56);
  --ink-faint: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  scroll-behavior: auto;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.lightbox-open {
  overflow: hidden;
}

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

button {
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

/* -------------------------------------------------------------------- */
/* Loader                                                                */
/* -------------------------------------------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loader__stack {
  position: relative;
  width: 300px;
  height: 300px;
}

.loader__img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  width: auto;
  height: auto;
  box-shadow: 0 12px 34px rgba(21, 20, 15, 0.16);
}

.loader__img--landscape { max-width: var(--hero-img-base); max-height: var(--hero-img-base); }
.loader__img--portrait,
.loader__img--square { max-width: calc(var(--hero-img-base) * 0.75); max-height: var(--hero-img-base); }

/* Frames don't all sit at this base size: playLoader() gives each one an
   inline transform that scales it up to 1.5x and lifts it towards
   .hero__cursor's resting spot, frame by frame, so the last one lands
   there exactly (.hero__cursor's own width below is this same base x 1.5,
   whatever that base currently resolves to). */

/* -------------------------------------------------------------------- */
/* Brand logo — fades in as the hero name blurs, stays put while scrolling */
/* -------------------------------------------------------------------- */
/* Two full-colour files (a black-letter glow for light backgrounds, a
   white-letter glow for dark ones) stacked in the same box — unlike the old
   single white-on-transparent file, these have real colour in the glow, so
   a CSS `invert(1)` would turn the orange cyan instead of just flipping
   light/dark. Which one shows is decided purely by `html.dark-mode` below;
   nothing here needs the theme-toggle JS to know about the logo on this. */
.brand-logo {
  display: block;
  position: fixed;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  /* smaller + tucked closer to the corner on phones: the gallery's own
     gutter (9.5% of viewport, gallery is centred at 81% width) is nowhere
     near big enough at these widths to fit the desktop 32px/56px sizing
     without the logo sitting on top of grid photos as they scroll past —
     this keeps a real, if tighter, gap instead */
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
}

@media (min-width: 1300px) {
  /* at this width the 9.5% gutter is comfortably wider than 32px + 56px +
     the required 30px clearance, so the original, bigger sizing fits */
  .brand-logo {
    top: 32px;
    left: 32px;
    width: 56px;
    height: 56px;
  }
}

.brand-logo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.brand-logo__img--light { display: block; }
html.dark-mode .brand-logo__img--light { display: none; }
html.dark-mode .brand-logo__img--dark { display: block; }

/* On the homepage the logo fades in via scroll (see main.js) and only past
   1300px — below that it would collide with the gallery grid, which starts
   appearing around there. Pages that don't have that scroll-driven hero (or
   a gallery to collide with) don't need to wait for anything — the logo is
   just visible right away, at every width, and links back to the homepage.
   That's not just cosmetic here: on profile.html this logo is the ONLY way
   back to the homepage, so it can't be allowed to disappear on phones/
   tablets the way the homepage's own copy deliberately does. */
.brand-logo-link .brand-logo {
  display: block;
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

/* -------------------------------------------------------------------- */
/* Dark mode toggle                                                     */
/* -------------------------------------------------------------------- */
.theme-toggle {
  position: fixed;
  top: clamp(16px, 3vw, 32px);
  right: clamp(16px, 3vw, 32px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px;
}

/* half-white / half-black circle, fixed colours on purpose (not the --ink /
   --bg tokens) so it reads the same "light half, dark half" regardless of
   which theme is currently active — it's the icon, not a state indicator.
   27px = the old pill's 24px height x 1.5, then x 0.75. */
.theme-toggle__circle {
  position: relative;
  width: 27px;
  height: 27px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #000;
  overflow: hidden;
}

.theme-toggle__circle::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  background: #000;
}

.theme-toggle__labels {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.15;
}

.theme-toggle__label {
  font-family: var(--ui);
  font-size: 1.12rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  transition: color 0.2s ease;
}

/* whichever word names the active state reads in full colour, the other
   stays muted — the only state cue now that there's no sliding thumb */
.theme-toggle__label--light { color: var(--ink); }
html.dark-mode .theme-toggle__label--light { color: var(--ink-soft); }
html.dark-mode .theme-toggle__label--dark { color: var(--ink); }

/* -------------------------------------------------------------------- */
/* Hero                                                                  */
/* -------------------------------------------------------------------- */
.hero {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

/* Re-centers the name + cursor image within the space that's actually
   still "hero" now that the gallery peeks up into the bottom of the
   viewport — shifted up by half the peek height (computed in JS,
   syncHeroSpacer) so it centers in the visible area above the peek
   instead of the full 100vh. Having its own `transform` also makes this
   the containing block for .hero__cursor's absolute centering, so both
   move together as one unit. */
.hero__content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(calc(var(--hero-peek, 0px) / -2));
}

.hero__cursor {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: calc(var(--hero-img-base) * 1.5);
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

.hero__cursor img {
  width: 100%;
  height: auto;
  box-shadow: 0 20px 50px rgba(21, 20, 15, 0.2);
}

.hero__cursor--portrait { width: calc(var(--hero-img-base) * 1.125); }

.hero__name {
  position: relative;
  z-index: 2;
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-style: normal;
  font-size: clamp(2.34rem, 8.1vw, 7.2rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
  color: var(--ink);
  opacity: 0;
  filter: blur(0px);
  pointer-events: none;
}

.hero__name span { display: block; }

/* pushes the gallery down one viewport height so it can scroll up and
   over the fixed hero */
.hero-spacer { height: 95vh; }

/* On phones the 300px loader/cursor was wider than the hero name itself —
   .hero__name's font-size is pinned at its clamp() floor across this whole
   width range, so its rendered width stays ~flat too, which is what lets a
   single fixed value here work safely without needing its own vw-tied
   formula. Chosen with a comfortable margin under that floor-state name
   width (measured ~286px at 390px viewport); 207px = that x 0.9, a further
   10% narrower per his ask. */
@media (max-width: 640px) {
  :root { --hero-img-base: 207px; }
}

/* -------------------------------------------------------------------- */
/* Profile page — simple centered statement, logo/toggle/footer shared   */
/* -------------------------------------------------------------------- */
.profile-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  /* left padding matches .brand-logo's own `left: 32px`, so the text block
     starts exactly on the logo's left edge */
  padding: clamp(140px, 16vh, 220px) 32px calc(var(--footer-h) + 40px);
}

@media (max-width: 1299px) {
  /* .brand-logo itself sits at left: 16px below the 1300px breakpoint (see
     that rule), not the 32px this page's own padding above assumes — so
     anywhere under that same 1300px point (not just phone widths — this
     was still wrong on tablets/landscape too, at up to 640px it only fixed
     part of the range) the text block was starting 16px to the right of
     the logo instead of lining up with it. Matching this query to the
     logo's own breakpoint exactly, rather than picking an unrelated one of
     my own, is what keeps the two from drifting apart like this again. */
  .profile-hero { padding-left: 16px; }
}

/* base gap = the (halved) space under the title; the intro -> columns gap
   needs to stay twice that, so .profile-hero__cols adds the difference
   back as its own margin */
.profile-hero__content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(50px, 3.5vh, 70px);
}

.profile-hero__title {
  margin: 0;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 40px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-align: left;
}

.profile-hero__intro {
  margin: 0;
  font-family: var(--ui);
  font-weight: 400;
  font-size: 35px;
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--ink);
  text-align: left;
  max-width: 90%;
}

@media (max-width: 640px) {
  .profile-hero__title { font-size: 36px; } /* 40px x 0.9 */
  .profile-hero__intro { font-size: 26.25px; } /* 35px x 0.75 */
}

.profile-hero__cols {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: clamp(40px, 6vw, 100px);
  align-items: flex-start;
  margin-top: clamp(50px, 3.5vh, 70px);
}

@media (max-width: 1024px) {
  .profile-hero__cols {
    grid-template-columns: 1fr;
    gap: clamp(30px, 4vh, 60px);
  }
}

.profile-hero__col-title {
  margin: 0;
  font-family: var(--ui);
  font-weight: 600;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-align: left;
  white-space: pre-line;
}

/* col-title's clamp() sits pinned at its 1.3rem (20.8px) floor across this
   whole width range, so that's the base this 10% is taken from. Placed
   after the base rule on purpose — same specificity, so source order is
   what decides the tie regardless of the media condition. */
@media (max-width: 640px) {
  .profile-hero__col-title { font-size: 22.88px; } /* 20.8px x 1.1 */
}

.profile-hero__col-text {
  margin: 0;
  font-family: var(--ui);
  font-weight: 400;
  font-size: clamp(1.25rem, 1.7vw, 1.875rem);
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--ink);
  text-align: left;
  text-indent: 150px;
  max-width: 100%;
}

/* below 1024px the columns stack (see .profile-hero__cols above) and this
   block's own width shrinks from ~860px down to the full, much narrower
   column — the 150px indent was tuned for the wide case and doesn't work
   at any size down here, so it's dropped rather than scaled. Placed after
   the base rule on purpose, same specificity trap as elsewhere in this
   file. */
@media (max-width: 1024px) {
  .profile-hero__col-text { text-indent: 0; }
}

.profile-hero__text {
  width: 100%;
  max-width: none;
  margin: 0;
  text-align: left;
  text-indent: 100px;
  font-family: var(--ui);
  font-weight: 500;
  font-size: clamp(2.5rem, 3.4vw, 3.75rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* -------------------------------------------------------------------- */
/* Gallery                                                               */
/* -------------------------------------------------------------------- */
main { position: relative; z-index: 10; }

.gallery {
  position: relative;
  z-index: 10;
  /* no background here on purpose — the hero name (fixed, behind this
     section) needs to stay visible through the padding/gaps as you scroll */
  /* inset off the full width (on top of the gutter padding below) so every
     photo renders smaller — column width is measured live in JS from this
     element's own clientWidth, so nothing else needs to change. 81% = two
     stacked 10% reductions (90% * 90%). */
  width: 81%;
  margin: 0 auto;
  /* top margin = the same gap used between two portrait photos, plus 30px
     extra breathing room. Bottom gets the same plus the fixed footer's own
     100px, so the last row never sits underneath it. */
  padding-top: calc(var(--gallery-gap) + 30px);
  padding-bottom: calc(var(--gallery-gap) + 30px + var(--footer-h));
  padding-inline: var(--gallery-pad);

  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: var(--gallery-gap);
  /* rows size to their tallest cell (typically a portrait image); a
     shorter landscape cell in the same row centers vertically against
     that row height instead of sitting flush to the top */
  align-items: center;
}

/* one column for the whole phone range — a second column only from tablet
   width up, so a photo never drops below roughly half a phone screen */
@media (min-width: 768px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1921px) {
  .gallery { grid-template-columns: repeat(4, 1fr); }
}

.grid__item {
  width: 100%;
  justify-self: stretch;
  overflow: hidden;
  border-radius: 2px;
  background: var(--ink-faint);
  cursor: pointer;
}

/* Landscape fills the column (its width = the column width). Portrait/square
   are capped so their HEIGHT equals that same column width instead — i.e.
   a landscape's width is a portrait's height — and just sit narrower,
   centered in their column; JS sets the actual px height (--col-width
   isn't a real CSS length, it depends on live container/gap math). */
.grid__item[data-orientation="portrait"],
.grid__item[data-orientation="square"] {
  width: auto;
  justify-self: center;
}

.grid__item__inner {
  width: 100%;
  height: 100%;
}

.grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.6s ease, transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.grid__item img.is-loaded {
  opacity: 1;
  transform: scale(1);
}

/* invisible trigger row at the end of the current batch — spans every
   column so it doesn't read as an empty tile; infinite-scroll watches it */
.gallery__sentinel {
  grid-column: 1 / -1;
  height: 1px;
  pointer-events: none;
}

/* -------------------------------------------------------------------- */
/* Lightbox                                                              */
/* -------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  /* previews are sized by HEIGHT, so every neighbour is the same height at
     the edge no matter its orientation or aspect ratio, and takes whatever
     width follows from that. The side padding reserves room for the widest
     case at however much of that --lb-visible fraction actually shows, so
     the photo never ends up underneath one — driven off the same variables
     the nav buttons themselves use below, so they can never drift out of
     sync again (that mismatch is exactly what let mobile previews overlap
     the photo before). --lb-worst-aspect was 1.5 (a plain 3:2 landscape)
     until a real photo in the set (color-cali-03, 1.6) turned out wider
     than that and overlapped anyway — 1.8 now, with headroom above every
     photo currently in content/works/manifest.json, so a future upload a
     bit wider than today's widest doesn't reopen the same bug. */
  --lb-thumb-h: clamp(80px, 18vh, 200px);
  --lb-visible: 0.75;
  --lb-worst-aspect: 1.8;
  padding: clamp(24px, 6vh, 72px) calc(var(--lb-thumb-h) * var(--lb-worst-aspect) * var(--lb-visible) + 24px);
  background: rgba(21, 20, 15, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  transform: scale(0.96);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox.is-open .lightbox__img {
  transform: scale(1);
}

/* brief dip while the next full-size file decodes, so switching photos
   reads as a cross-fade instead of a hard swap */
.lightbox__img.is-swapping {
  opacity: 0.25;
  transition: opacity 0.2s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Prev/next: a thumbnail of the neighbouring photo, hanging half off the
   edge of the screen so it reads as "there's more this way" rather than as
   a second image competing with the one being viewed. */
.lightbox__nav {
  position: absolute;
  top: 50%;
  z-index: 201;
  /* absolutely positioned, so width: auto shrink-to-fits the thumb inside */
  height: var(--lb-thumb-h);
  width: auto;
  padding: 0;
  opacity: 0.78;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 25% hangs off the edge, so 75% stays visible — that's the fraction the
   lightbox's own side padding is calculated from */
.lightbox__nav--prev { left: 0; transform: translate(calc((var(--lb-visible) - 1) * 100%), -50%); }
.lightbox__nav--next { right: 0; transform: translate(calc((1 - var(--lb-visible)) * 100%), -50%); }

/* slide further into view on hover, so it's clear they're clickable */
.lightbox__nav--prev:hover,
.lightbox__nav--prev:focus-visible { opacity: 1; transform: translate(0, -50%); }
.lightbox__nav--next:hover,
.lightbox__nav--next:focus-visible { opacity: 1; transform: translate(0, -50%); }

.lightbox__thumb {
  height: 100%;
  width: auto;
  display: block;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  /* there isn't room to give the previews their own lane here — they go
     back to overlapping the scrim at the very edge so the photo keeps the
     width it needs */
  .lightbox {
    --lb-thumb-h: 60px;
    /* less of the thumb shows here — screen width is tight enough that the
       75%-visible desktop amount would need more side padding than there's
       room for; the padding above is already deriving itself from this and
       --lb-thumb-h automatically, so it just follows */
    --lb-visible: 0.4;
  }
}

.lightbox__close {
  position: fixed;
  top: clamp(16px, 3vw, 32px);
  right: clamp(16px, 3vw, 32px);
  z-index: 201;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* always light, not tied to --bg — the lightbox scrim behind it stays
     dark in both themes, so this needs a fixed light color to stay visible */
  color: #f5f4f0;
  background: rgba(243, 241, 234, 0.12);
  border: 1px solid rgba(243, 241, 234, 0.32);
  transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox__close svg { width: 18px; height: 18px; }

.lightbox__close:hover {
  background: rgba(243, 241, 234, 0.22);
  transform: scale(1.06);
}

/* -------------------------------------------------------------------- */
/* Footer                                                                */
/* -------------------------------------------------------------------- */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  z-index: 50;
  padding: 0 var(--gallery-pad) var(--footer-pad-b);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
}

/* the "blur behind it" — a single blur layer, masked so its own alpha
   fades smoothly from 0% at the top to 100% at the bottom. Earlier this
   was on a layer that ALSO carried an opaque background-color, which
   simply hid the blur behind a solid fill no matter the blur radius —
   that, not the mask, was why it looked flat. Kept as its own transparent
   layer (no fill) with a separate plain-gradient tint layer on top, this
   mask now gives a genuinely continuous fade with no banding. */
/* "progressive blur" via overlapping masked layers — each span covers the
   FULL fade zone but is only actually visible through a soft sliding
   window in its own mask (transparent → opaque → opaque → transparent),
   shifted down 12.5% from the previous span; six of these, doubling blur
   each time, tile the zone with continuous overlap so the blurs stack up
   smoothly with no hard seams. This is the standard technique for a real
   graduated blur (single-element mask+backdrop-filter isn't enough — a
   flat mask only fades opacity, it can't fade the blur radius itself). */
.footer__blur {
  position: absolute;
  left: 0;
  right: 0;
  /* extends a bit past the viewport's bottom edge — the lowest band's mask
     window still fades in from 0 near its own start, so without this
     overshoot that incomplete fade-in was exactly at the visible bottom
     edge, showing up as a not-quite-blurred seam right where the footer
     meets the viewport */
  bottom: -24px;
  top: calc(-1 * var(--footer-fade-h));
  z-index: -1;
  pointer-events: none;
}

.footer__blur span {
  position: absolute;
  inset: 0;
  display: block;
}

/* mask windows stay in place (bottom to top); blur strength is now
   assigned in reverse (strongest nearest the footer, weakest furthest
   into the gallery) — it was backwards before */
.footer__blur span:nth-child(1) {
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  -webkit-mask-image: linear-gradient(to top, transparent 0%, transparent 0%, black 12.5%, black 25%, transparent 37.5%);
  mask-image: linear-gradient(to top, transparent 0%, transparent 0%, black 12.5%, black 25%, transparent 37.5%);
}
.footer__blur span:nth-child(2) {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  -webkit-mask-image: linear-gradient(to top, transparent 12.5%, black 25%, black 37.5%, transparent 50%);
  mask-image: linear-gradient(to top, transparent 12.5%, black 25%, black 37.5%, transparent 50%);
}
.footer__blur span:nth-child(3) {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to top, transparent 25%, black 37.5%, black 50%, transparent 62.5%);
  mask-image: linear-gradient(to top, transparent 25%, black 37.5%, black 50%, transparent 62.5%);
}
.footer__blur span:nth-child(4) {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  -webkit-mask-image: linear-gradient(to top, transparent 37.5%, black 50%, black 62.5%, transparent 75%);
  mask-image: linear-gradient(to top, transparent 37.5%, black 50%, black 62.5%, transparent 75%);
}
.footer__blur span:nth-child(5) {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  -webkit-mask-image: linear-gradient(to top, transparent 50%, black 62.5%, black 75%, transparent 87.5%);
  mask-image: linear-gradient(to top, transparent 50%, black 62.5%, black 75%, transparent 87.5%);
}
.footer__blur span:nth-child(6) {
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  -webkit-mask-image: linear-gradient(to top, transparent 62.5%, black 75%, black 100%, black 100%);
  mask-image: linear-gradient(to top, transparent 62.5%, black 75%, black 100%, black 100%);
}

.footer::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -24px;
  top: calc(-1 * var(--footer-fade-h));
  z-index: -1;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
  pointer-events: none;
}

html.dark-mode .footer::after {
  background: linear-gradient(to top, rgba(21, 20, 15, 0.6) 0%, transparent 100%);
}

.footer__name {
  margin: 0;
  font-family: var(--ui);
  font-size: 1.425rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* only revealed once the gallery has looped through its full set at least
   once (see main.js) — a shortcut back up once you've "seen it all" */
.footer__top {
  position: absolute;
  left: 50%;
  /* bottom-anchored on the same offset as .footer's own padding, so this
     sits on the exact baseline as the copyright glyph + year — it was
     vertically centred in the whole bar before, which didn't line up */
  bottom: var(--footer-pad-b);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ui);
  font-size: 1.425rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.footer__top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.footer__top svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

/* the arrow beams out through the top and returns from below, on a loop —
   only while the button is actually on screen, so it isn't animating away
   behind opacity: 0 for the whole visit */
.footer__top.is-visible svg {
  animation: beam-up 2s ease-in-out infinite;
}

@keyframes beam-up {
  /* rest for the first half of the cycle... */
  0%, 55% { transform: translateY(0); opacity: 1; }
  /* ...lift out through the top... */
  75% { transform: translateY(-14px); opacity: 0; }
  /* ...cut (still invisible) to below the start... */
  75.01% { transform: translateY(14px); opacity: 0; }
  /* ...and rise back into place */
  100% { transform: translateY(0); opacity: 1; }
}

/* an animation's transform outranks a plain declaration, so hovering has to
   drop the loop outright to hand the arrow back to the transition above */
.footer__top:hover svg {
  animation: none;
  transform: translateY(-2px);
}

@media (max-width: 700px) {
  /* keeps the fixed 100px bar from getting crowded next to name/links */
  .footer__top span { display: none; }

  /* Without the label this was a 28x18 hit area — too small to tap — and it
     floated in the middle of the bar while the name and links sit on the
     bottom line. Give it a proper 44px target on that same line. */
  .footer__top {
    top: auto;
    bottom: 24px;
    transform: translateX(-50%);
    width: 44px;
    height: 44px;
    justify-content: center;
  }

  .footer__top svg {
    width: 22px;
    height: 22px;
  }
}

/* Email + LinkedIn stacked, both right-aligned. align-items: flex-end (not
   a fixed width) is what makes them right-aligned — so when the email
   label grows from "Email me" to "Copy email" on hover, only its LEFT
   edge moves; the right edge (and the hover box) stays pinned to this
   column's edge with no wasted margin. */
.footer__links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.footer__email,
.footer__linkedin {
  display: inline-flex;
  align-items: center;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  white-space: nowrap;
  font-family: var(--ui);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--ink);
  padding: 3px 10px;
  border-radius: 8px;
  background: transparent;
  transition: background-color 0.2s ease;
}

.footer__email,
.footer__linkedin {
  font-size: 22px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer__email:hover,
.footer__email:focus-visible,
.footer__linkedin:hover,
.footer__linkedin:focus-visible {
  background: rgba(21, 20, 15, 0.06);
}

html.dark-mode .footer__email:hover,
html.dark-mode .footer__email:focus-visible,
html.dark-mode .footer__linkedin:hover,
html.dark-mode .footer__linkedin:focus-visible {
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 480px) {
  /* fixed 100px bar has no room to stack — just tighten spacing and let
     the name shrink/ellipsis before anything wraps */
  .footer { padding-inline: 16px; gap: 10px; }
  .footer__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
}

/* all footer text (copyright/year, Beam me up, Email, LinkedIn) plus the
   Light/Dark toggle labels read a touch smaller on phones — kept as one
   group here since they're meant to stay the same size as each other */
@media (max-width: 640px) {
  .footer__name,
  .footer__top {
    font-size: 1.2rem;
  }
  .footer__email,
  .footer__linkedin {
    font-size: 18px;
  }
  .theme-toggle__label {
    font-size: 0.855rem; /* 0.95rem x 0.9, a further 10% down from that */
  }
  .theme-toggle__circle {
    width: 24.3px; /* 27px x 0.9 */
    height: 24.3px;
  }
}

/* -------------------------------------------------------------------- */
/* Motion preferences                                                    */
/* -------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  /* the scroll "wind" skew stays on (it's brief and small); only the
     longer fade/scale-in transition on newly-loaded photos is suppressed */
  .grid__item img { transition: none; }
  /* the arrow's beam-up loop deliberately stays on here — it's small, it
     carries the button's meaning, and he wants it seen */
}
