/* ==========================================================================
   Marco Basile — site styles
   Pale blue field, navy display type, overlapping photo collage.
   No framework.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */

:root {
  --sky:       #dde8fb;   /* the page itself */
  --sky-deep:  #c9dbf7;   /* the circle behind the hero words */
  --navy:      #16247e;   /* display type */
  --ink:       #23305c;   /* body copy */
  --muted:     #5f6d9c;
  --rule:      #c2d3f0;
  --rule-soft: #d4e0f6;
  --surface:   #ffffff;   /* cards, pills and rows that sit on the field */
  --on-navy:   #ffffff;   /* text on a navy fill */
  --sky-rgb:   221, 232, 251;  /* --sky as a triplet, for translucent fades */
  --shadow:    rgba(22, 36, 126, 0.08);

  color-scheme: light;

  --r-tile: 22px;
  --r-soft: 14px;
  --r-pill: 999px;

  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --page: 78rem;
  --bar-h: 4.25rem;

  --step--1: 0.875rem;
  --step-0:  1.0625rem;
  --step-1:  1.25rem;
  --step-2:  1.5rem;
  --step-3:  2rem;
  --step-4:  clamp(2.25rem, 5vw, 3.5rem);
  --step-5:  clamp(2.75rem, 7.5vw, 5.5rem);
}

/* Dark: the same blue, at night. Follows the system unless the reader has
   picked a theme with the toggle (stored as data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky:       #0d1330;
    --sky-deep:  #1a2350;
    --navy:      #dbe4ff;
    --ink:       #c2cbe8;
    --muted:     #8d99c6;
    --rule:      #2c3768;
    --rule-soft: #222c58;
    --surface:   #151d42;
    --on-navy:   #0d1330;
    --sky-rgb:   13, 19, 48;
    --shadow:    rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky:       #0d1330;
  --sky-deep:  #1a2350;
  --navy:      #dbe4ff;
  --ink:       #c2cbe8;
  --muted:     #8d99c6;
  --rule:      #2c3768;
  --rule-soft: #222c58;
  --surface:   #151d42;
  --on-navy:   #0d1330;
  --sky-rgb:   13, 19, 48;
  --shadow:    rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* --- Reset -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font-family: Figtree, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { margin: 0; color: var(--navy); font-weight: 600; line-height: 1.1; letter-spacing: -0.025em; }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.15em; }
li { margin-bottom: 0.3em; }

a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--navy); }

:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--navy); color: var(--on-navy); padding: 0.6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* --- Layout primitives -------------------------------------------------- */

.wrap { max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }

.spread {
  display: grid;
  gap: 0.75rem 3rem;
  grid-template-columns: 1fr;
  padding-block: clamp(3.5rem, 8vw, 6.5rem);
}
@media (min-width: 62rem) {
  .spread { grid-template-columns: 12rem 1fr; gap: 0 4rem; }
  .spread__label { position: sticky; top: calc(var(--bar-h) + 2.5rem); align-self: start; }
}

.spread__label h2 { font-size: var(--step-2); font-weight: 600; }
.spread__label p { margin: 0.5rem 0 0; font-size: var(--step--1); color: var(--muted); line-height: 1.5; }

.prose { max-width: var(--measure); }

/* A white card is how content sits on the blue field. */
.card {
  background: var(--surface);
  border-radius: var(--r-tile);
  padding: clamp(1.5rem, 4vw, 2.75rem);
}

/* --- Top bar ------------------------------------------------------------ */

.bar {
  position: sticky; top: 0; z-index: 40;
  height: var(--bar-h);
  display: flex; align-items: center;
  background: rgba(var(--sky-rgb), 0.85);
  backdrop-filter: saturate(1.5) blur(12px);
}
.bar > .wrap { display: flex; align-items: center; gap: 1.5rem; width: 100%; }

.bar__name {
  font-size: var(--step-1);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.03em;
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}

.bar__nav ul { display: flex; gap: clamp(0.9rem, 2.4vw, 2rem); list-style: none; margin: 0; padding: 0; }
.bar__nav a {
  font-size: var(--step-0);
  color: var(--ink);
  text-decoration: none;
  padding-block: 0.3rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.bar__nav a:hover { color: var(--navy); }
.bar__nav a[aria-current="true"] { color: var(--navy); border-bottom-color: var(--navy); }

.bar__toggle {
  display: none;
  background: none; border: 0; font: inherit;
  color: var(--navy); font-weight: 600;
  padding: 0.4rem 0.1rem; cursor: pointer;
}

.theme-toggle {
  flex: none;
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  background: var(--surface); border: 0; border-radius: 50%;
  color: var(--navy); cursor: pointer;
}
.theme-toggle:hover { background: var(--navy); color: var(--on-navy); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
/* Show the moon in light mode (click for dark), the sun in dark mode. */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

@media (max-width: 47.99rem) {
  .bar__toggle { display: block; }
  .bar__nav {
    position: absolute; inset: var(--bar-h) 0 auto 0;
    background: var(--sky); display: none;
    box-shadow: 0 12px 24px var(--shadow);
  }
  .bar__nav[data-open="true"] { display: block; }
  .bar__nav ul { flex-direction: column; gap: 0; padding: 0.5rem var(--gutter) 1.25rem; }
  .bar__nav a { display: block; padding: 0.65rem 0; border-bottom: 0; }
}

/* --- Hero: the collage -------------------------------------------------- */

.hero { position: relative; padding-block: 1rem 3rem; }

.stage {
  position: relative;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
  /* On small screens the words come first and the images follow. */
  display: flex;
  flex-direction: column-reverse;
}

.tile { margin: 0; overflow: hidden; border-radius: var(--r-tile); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile--round { border-radius: 50%; }

.hero__words { position: relative; z-index: 3; }

.hero__name {
  font-size: var(--step-5);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.95;
}
.hero__lede {
  max-width: 30rem;
  margin: 1.25rem 0 0;
  font-size: var(--step-1);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--navy);
}
.hero__meta { margin: 1.25rem 0 0; font-size: var(--step-0); color: var(--muted); max-width: 28rem; }

.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2rem;
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--navy);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}
.cta svg { flex: none; transition: transform 0.25s ease; }
.cta:hover svg { transform: translateX(5px); }
@media (prefers-reduced-motion: reduce) { .cta svg { transition: none; } }

/* Small screens: the collage becomes a plain band of images below the words. */
.stage__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 2.5rem;
}
.stage__grid .tile--a { grid-row: span 2; }
.stage__grid .tile--a img { aspect-ratio: 3 / 5; }
.stage__grid .tile--a { grid-row: span 2; }
.stage__grid .tile--b img,
.stage__grid .tile--c img { aspect-ratio: 4 / 3; }
.stage__grid .tile--d { display: none; }

/* The circle fades into the page on its right edge, so the headline
   stays legible whatever photo sits behind it. */
.tile--d { position: relative; }
.tile--d::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(100deg, rgba(var(--sky-rgb), 0) 45%, rgba(var(--sky-rgb), 0.92) 88%);
}

/* Wide screens: overlapping composition. */
@media (min-width: 62rem) {
  .hero { padding-block: 1.5rem 4rem; }

  .stage { display: block; min-height: 36rem; }

  .stage__grid { display: block; margin: 0; }
  .stage__grid .tile { position: absolute; }
  .stage__grid .tile--d { display: block; }

  .tile--a { left: 0;  top: 0;      width: 19rem; height: 28rem; }
  /* Grows with the page, but stays clear of the headline below it and the
     right-hand tile at the narrowest wide-screen width. */
  .tile--b { left: 40%; top: -0.5rem; width: min(24rem, 28%); height: auto; aspect-ratio: 16 / 9; }
  /* Narrows on smaller laptops so it never runs into the headline. */
  .tile--c { right: 0; top: 0;      width: min(17rem, 23%); height: auto; aspect-ratio: 17 / 27; }
  .tile--d { left: 11%; top: 13rem; width: 23rem; height: 23rem; z-index: 2; }

  .hero__words {
    position: absolute;
    left: 36%;
    top: 16.5rem;
    width: min(26rem, 36%);
  }
  .hero__name { font-size: clamp(2.5rem, 4.4vw, 3.9rem); }
  .hero__lede { font-size: var(--step-1); }
}

/* --- About -------------------------------------------------------------- */

.about__grid { display: grid; gap: 2.5rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 45rem) { .about__grid { grid-template-columns: minmax(0, 1fr) 14rem; gap: 3rem; } }

.portrait { border-radius: 50%; aspect-ratio: 1; object-fit: cover; width: 100%; }

.facts { list-style: none; margin: 2rem 0 0; padding: 0; max-width: var(--measure); }
.facts li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule-soft);
  margin: 0;
  font-size: var(--step--1);
}
.facts li:first-child { border-top: 1px solid var(--rule-soft); }
.facts .k { color: var(--muted); }
@media (max-width: 30rem) { .facts li { grid-template-columns: 1fr; gap: 0.1rem; } }

/* --- CV ----------------------------------------------------------------- */

.cv__cols { display: grid; gap: clamp(2rem, 4vw, 3rem); grid-template-columns: 1fr; }
@media (min-width: 56rem) { .cv__cols { grid-template-columns: 1fr 1fr; } }

.cv__head { font-size: var(--step-1); font-weight: 600; color: var(--navy); margin-bottom: 1.5rem; }
.cv__head:not(:first-child) { margin-top: 2.75rem; }

.entry { margin-bottom: 1.75rem; }
.entry h4 { font-size: var(--step-1); font-weight: 600; }
.entry__when { font-size: var(--step--1); color: var(--muted); margin: 0.3rem 0 0.5rem; font-variant-numeric: tabular-nums; }
.entry__where { font-size: var(--step--1); color: var(--muted); }
.entry p, .entry li { font-size: var(--step--1); line-height: 1.55; }
.entry ul { padding-left: 1.05em; }

/* --- Work index --------------------------------------------------------- */

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 2rem; padding: 0; }
.filters button {
  font: inherit;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: var(--r-pill);
  padding: 0.45rem 1.1rem;
  cursor: pointer;
}
.filters button:hover { color: var(--navy); }
.filters button[aria-pressed="true"] { background: var(--navy); color: var(--on-navy); }

/* Work items are cards in a grid. Each card tilts towards the pointer
   (--rx/--ry set in site.js) with a soft glare at --gx/--gy. */
.index {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
  perspective: 1100px;
}
@media (min-width: 40rem) { .index { grid-template-columns: 1fr 1fr; } }
.index li { margin: 0; }

.index a {
  --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 50%;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "thumb thumb"
    "year  kind"
    "title title";
  align-content: start;
  height: 100%;
  background: var(--surface);
  border-radius: var(--r-tile);
  overflow: hidden;
  text-decoration: none;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  box-shadow: 0 4px 12px var(--shadow);
}
.index a:hover { color: inherit; box-shadow: 0 22px 40px rgba(0, 0, 0, 0.3); }
.index a:hover .index__title { color: var(--navy); }
.index a::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.22), transparent 55%);
  transition: opacity 0.25s ease;
}
.index a:hover::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .index a, .index a::after { transition: none; } }

.index__thumb {
  grid-area: thumb;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--sky-deep);
}
/* A paper's first page: show the title block, not the middle. */
.index__thumb--page { object-position: top; background: #fff; }
.index__year { grid-area: year; padding: 1rem 0 0 1.25rem; font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; }
.index__kind { grid-area: kind; padding: 1rem 1.25rem 0 0; font-size: var(--step--1); color: var(--muted); text-align: right; }
.index__title { grid-area: title; padding: 0.35rem 1.25rem 1.25rem; font-size: var(--step-1); font-weight: 600; color: var(--navy); letter-spacing: -0.02em; line-height: 1.25; }
.index__note { display: block; font-size: var(--step--1); font-weight: 400; color: var(--muted); margin-top: 0.3rem; line-height: 1.4; letter-spacing: 0; }

/* --- Contact ------------------------------------------------------------ */

.contact__links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.contact__links li { margin: 0; }
.contact__links a {
  display: inline-block;
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 0.5rem 1.2rem;
  font-size: var(--step-0);
  font-weight: 500;
  text-decoration: none;
}
.contact__links a:hover { background: var(--navy); color: var(--on-navy); }

/* --- Footer ------------------------------------------------------------- */

.foot { padding-block: 2rem 3.5rem; font-size: var(--step--1); color: var(--muted); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; }

/* --- Detail pages ------------------------------------------------------- */

.detail__head { padding-block: clamp(1.5rem, 5vw, 3rem) clamp(1.75rem, 4vw, 2.5rem); }
.detail__crumb { font-size: var(--step--1); color: var(--muted); margin-bottom: 1rem; }
.detail__crumb a { text-decoration: none; }
.detail__crumb a:hover { text-decoration: underline; }
.detail__event { font-size: var(--step-0); color: var(--muted); margin-bottom: 0.75rem; }
.detail__title { font-size: var(--step-4); font-weight: 600; letter-spacing: -0.035em; line-height: 1.08; max-width: 22ch; }

.detail__body { display: grid; gap: 2rem; grid-template-columns: 1fr; padding-bottom: clamp(2.5rem, 6vw, 4rem); }
@media (min-width: 62rem) { .detail__body { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2.5rem; } }

.gallery { margin: 0; }
.gallery__strip {
  display: flex; gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  padding-bottom: 0.5rem;
}
.gallery__strip > * { flex: 0 0 100%; scroll-snap-align: start; margin: 0; }
.gallery__strip img { width: 100%; border-radius: var(--r-tile); }
.gallery--single .gallery__strip { overflow: visible; }

.gallery__nav { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: var(--step--1); color: var(--muted); }
.gallery__nav button {
  font: inherit;
  background: var(--surface);
  border: 0;
  border-radius: 50%;
  width: 2.25rem; height: 2.25rem;
  cursor: pointer;
  color: var(--navy);
  line-height: 1;
}
.gallery__nav button:hover { background: var(--navy); color: var(--on-navy); }
.gallery__nav button[disabled] { opacity: 0.4; cursor: default; background: var(--surface); color: var(--navy); }
.gallery__count { font-variant-numeric: tabular-nums; }

.frame {
  position: relative;
  overflow: hidden;
  padding-top: 56.25%;
  margin-bottom: 1.25rem;
  background: var(--sky-deep);
  border-radius: var(--r-soft);
}
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.detail__side {
  background: var(--surface);
  border-radius: var(--r-tile);
  padding: clamp(1.5rem, 3vw, 2.25rem);
  align-self: start;
}
.detail__side h3 { font-size: var(--step-1); font-weight: 600; margin-bottom: 1rem; }
.detail__side p { font-size: var(--step--1); line-height: 1.6; }

.resources { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.resources li { margin: 0; border-top: 1px solid var(--rule-soft); }
.resources a { display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; font-size: var(--step--1); font-weight: 500; text-decoration: none; }
.resources a:hover { color: var(--navy); }
.resources .what { color: var(--muted); font-weight: 400; }

/* First page of a paper, cropped to its top half; opens the PDF. */
.paper-preview {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--r-tile);
  background: #fff;            /* paper is white in both themes */
  text-decoration: none;
}
.paper-preview img {
  width: 100%;
  aspect-ratio: 5 / 4;
  object-fit: cover;
  object-position: top;
  transition: transform 0.3s ease;
}
.paper-preview::after {         /* fade the cut edge */
  content: "";
  position: absolute; inset: auto 0 0 0; height: 40%;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff 85%);
}
.paper-preview__hint {
  position: absolute; z-index: 1; left: 50%; bottom: 1.25rem;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #16247e; color: #fff;
  border-radius: var(--r-pill);
  padding: 0.5rem 1.2rem;
  font-size: var(--step--1); font-weight: 600;
}
.paper-preview:hover img { transform: scale(1.02); }
@media (prefers-reduced-motion: reduce) { .paper-preview img { transition: none; } }

.license { margin: 1.25rem 0 0; font-size: var(--step--1); color: var(--muted); line-height: 1.5; }

/* Citation card: sits under the paper preview. */
.paper-preview + .cite { margin-top: 1.25rem; }
.cite {
  background: var(--surface);
  border-radius: var(--r-tile);
  padding: clamp(1.5rem, 3vw, 2.25rem);
  align-self: start;
}
.cite h3 { font-size: var(--step-1); font-weight: 600; margin-bottom: 1rem; }
.cite__authors { font-size: var(--step-0); line-height: 1.6; }
.cite__authors strong { color: var(--navy); font-weight: 600; }
.cite dl { margin: 1.5rem 0 0; }
.cite dl > div {
  display: grid; grid-template-columns: 7rem 1fr; gap: 1rem;
  padding: 0.6rem 0; border-top: 1px solid var(--rule-soft);
  font-size: var(--step--1);
}
.cite dt { color: var(--muted); }
.cite dd { margin: 0; }
@media (max-width: 30rem) { .cite dl > div { grid-template-columns: 1fr; gap: 0.1rem; } }

.chapters { list-style: none; margin: 0; padding: 0; counter-reset: ch; }
.chapters > li { counter-increment: ch; margin-bottom: 2rem; }
.chapters h3 { font-size: var(--step-1); font-weight: 600; margin-bottom: 0.9rem; }
.chapters h3::before {
  content: counter(ch, decimal-leading-zero);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.7rem;
  font-weight: 500;
}
.chapters--grid { display: grid; gap: 0 2.5rem; grid-template-columns: 1fr; padding-bottom: 2rem; }
@media (min-width: 56rem) { .chapters--grid { grid-template-columns: 1fr 1fr; } }

.back-link { display: inline-block; margin-top: 0.5rem; font-size: var(--step-0); font-weight: 500; }

/* --- 3D effects ----------------------------------------------------------
   Driven by site.js. Pointer effects only exist with a mouse; the scroll
   reveal works everywhere. Readers who ask for less motion get none.    */

/* Hero collage in layers: each photo moves by its own depth. The circle
   is "closest", so it moves the other way and furthest. */
@media (min-width: 62rem) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .stage__grid .tile {
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  }
  .tile--a { transform: translate3d(calc(var(--px, 0) * -14px), calc(var(--py, 0) * -10px), 0); }
  .tile--b { transform: translate3d(calc(var(--px, 0) * -26px), calc(var(--py, 0) * -18px), 0); }
  .tile--c { transform: translate3d(calc(var(--px, 0) * -18px), calc(var(--py, 0) * -12px), 0); }
  .tile--d {
    transform: translate3d(calc(var(--px, 0) * 24px), calc(var(--py, 0) * 16px), 0);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
  }
}

/* Portrait and event galleries tilt towards the pointer. */
.portrait,
.gallery__strip {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.25s ease;
}
.portrait { box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25); }
.gallery__strip { border-radius: var(--r-tile); }

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  /* A paper's first page lies back on the desk and stands up on hover. */
  .paper-preview {
    transform: perspective(1400px) rotateX(12deg) rotateZ(-1.5deg);
    transform-origin: 50% 100%;
    box-shadow: 0 34px 50px -16px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.5s ease;
  }
  .paper-preview:hover {
    transform: perspective(1400px) translateY(-4px);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.3);
  }

  /* Buttons lift off the page. */
  :is(.filters button, .contact__links a, .gallery__nav button, .theme-toggle) {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  }
  :is(.filters button, .contact__links a, .gallery__nav button:not([disabled]), .theme-toggle):hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
  }
  .resources a { transition: transform 0.2s ease; }
  .resources a:hover { transform: translateX(4px); }
}

/* Blocks rise into place on scroll. site.js adds .fx-pre only when it can
   also reveal them, so without JavaScript nothing is ever hidden. */
.fx-pre {
  opacity: 0;
  transform: perspective(1000px) rotateX(12deg) translateY(40px);
  transform-origin: 50% 0;
}
.fx-pre.fx-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--fx-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .portrait, .gallery__strip { transform: none; transition: none; }
  .fx-pre { opacity: 1; transform: none; }
}