@font-face {
  font-family: "Margherita";
  src: url("assets/margherita-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

/* Phase 5K · 5J with a shorter opening fade, both texts in chapter 2 and the story chapter. */
:root {
  --cream: #f6ecd6;
  --ink: #301907;
  --field-open: #e9b346;
  --field-offer: #1f3d31;
  --field-sand: #ebd5aa;
  /* Chapter 5 and footer only: owner decision, the one colour outside P5. */
  --field-sage: #9caf88;
  --sand-ink: #2a1606;
  --accent: #e9b346;
  --gutter: clamp(1.125rem, 5vw, 5rem);
  --header: 5.4rem;
  --display: "Margherita", Georgia, serif;
  --body: "DM Sans", system-ui, sans-serif;
  /* Distance from the shell's edge to the viewport edge. Resolves against the nearest section container. */
  --bleed: calc((100cqw - min(100cqw - 2 * var(--gutter), 91rem)) / 2);
  --ease: cubic-bezier(.22, .7, .2, 1);
  /* Opening sequence and logo: one easing, one anchor box shared by overlay and header logo.
     The box is not painted: it centres the logo, and --tab-w is also a nav column below 48rem. */
  --ease-apertura: cubic-bezier(0.19, 1, 0.22, 1);
  --apertura-hold: .35s;
  --apertura-contract: 1.2s;
  --tab-w: 11rem;
  --tab-h: calc(var(--header) * 1.25); /* docked at 0.8 it is exactly the header height */
  --logo-w: 16.875rem;
  /* Chapter rhythm (chapters 2-5): field padding, and the space between a title and what follows. */
  --chapter-space: clamp(4rem, 10svh, 7rem);
  --title-space: clamp(2.5rem, 6svh, 4rem);
  /* Framed photos only; full-bleed photos and color fields stay square. */
  --radius-photo: 0.875rem;
  /* Chapter buttons and the header button. */
  --radius-pill: 999px;
  background: var(--cream);
  color: var(--ink);
  color-scheme: light;
  font-family: var(--body);
  font-synthesis: none;
  scroll-padding-block-start: var(--header);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, figure, dl, dd, ol { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.shell { inline-size: min(100% - 2 * var(--gutter), 91rem); margin-inline: auto; }

/* Every chapter is a size container so cq units can reach the viewport edge without a horizontal scrollbar. */
main > section { container-type: inline-size; overflow-x: clip; }

.skip-link {
  position: fixed;
  z-index: 10;
  inset: .75rem auto auto var(--gutter);
  padding: .65rem 1rem;
  background: var(--cream);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

/* ---- Header (same structure and sizes as the accepted baseline) ---- */
.header {
  position: sticky;
  z-index: 5;
  inset-block-start: 0;
  background: var(--cream);
  border-block-end: 1px solid var(--accent);
}
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(.65rem, 2vw, 1.65rem);
  min-block-size: calc(var(--header) - 1px);
  font-size: .9375rem;
  font-weight: 650;
}
.nav a { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: clamp(.75rem, 3vw, 2.75rem); }
.nav-links a { display: inline-flex; align-items: center; min-block-size: 2.75rem; inline-size: fit-content; }
.nav-links a:hover { color: var(--field-offer); text-decoration: underline; text-underline-offset: .27em; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  padding: .55rem 1.1rem;
  background: var(--field-offer);
  border: 1px solid var(--field-offer);
  color: var(--cream);
  font-weight: 700;
  text-decoration: none;
}
.button:focus-visible { outline-color: var(--ink); }
.nav-links { grid-column: 1; grid-row: 1; }
.nav-visit { grid-column: 3; grid-row: 1; justify-self: end; white-space: nowrap; }

/* ---- Logo: top centre of the header. Large only when JS can reduce it on scroll. ---- */
.logo-tab {
  position: absolute;
  inset-block-start: 0;
  left: calc(50% - var(--tab-w) / 2);
  inline-size: var(--tab-w);
  block-size: var(--tab-h);
  transform: scale(.8);
  transform-origin: top center;
}
.tab-js .logo-tab { transform: none; }
.tab-js .logo-tab.is-docked { transform: scale(.8); }
/* The link is the drawing's bounding box (.514 x .326 of --logo-w), centred where the 5I tab centred it. */
.brand {
  position: absolute;
  top: calc((var(--tab-h) - var(--logo-w) * .326) / 2);
  left: calc(50% - var(--logo-w) * .257);
  inline-size: calc(var(--logo-w) * .514);
  block-size: calc(var(--logo-w) * .326);
}
/* Rounded only while focused, so the corners of the box stay clickable. The ink ring sits on a cream
   band: ink reads on the header, the cream keeps it visible where it falls on the photo. */
.brand:focus-visible {
  border-radius: calc(var(--logo-w) * .09);
  outline-color: var(--ink);
  outline-offset: 6px;
  box-shadow: 0 0 0 10px var(--cream);
}
/* The logo file has wide transparent margins: centre the drawing, not the file. The margins take no
   clicks, and are clipped because they hold near-invisible pixels (alpha 1-3 of 255). */
.brand img, .apertura-box img {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  inline-size: var(--logo-w);
  max-inline-size: none;
  block-size: auto;
  transform: translate(-52.2%, -50.2%);
  clip-path: inset(2% 20% 2% 24%);
  pointer-events: none;
}

/* ---- Opening sequence overlay (decorative; only under html.apertura-on) ---- */
.apertura { display: none; }

/* ---- Type ---- */
.label { font-size: .8125rem; font-weight: 750; line-height: 1.4; letter-spacing: .105em; text-transform: uppercase; }
h1, h2 { font-family: var(--display); font-weight: 700; font-synthesis: none; letter-spacing: -.024em; }
h2 span { display: block; }
.text-link { display: inline-flex; align-items: center; min-block-size: 2.75rem; font-weight: 700; text-underline-offset: .24em; }
.text-link:hover { text-decoration-thickness: 2px; }

/* ---- Photo frame: rectangle; framed photos get --radius-photo further down ----
   .frame-media is a fixed aspect-ratio box. The photo is an <img> inside .frame-slot and fills it
   with object-fit: cover, so layout never depends on the file. The field color is the loading fallback.
   Photos are placeholders: the chip says so on every frame. */
.frame { min-inline-size: 0; }
.frame-media {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .3rem;
  inline-size: 100%;
  padding: clamp(1.75rem, 2.8vw, 2.5rem);
  background: var(--frame-bg, var(--field-sand));
  color: var(--frame-ink, var(--sand-ink));
}
.frame-slot { position: absolute; inset: 0; overflow: hidden; }
.frame-slot > img { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
/* Crop focus per placeholder photo, so the subject stays inside the narrower box. */
.ritual-frame img { object-position: 36% 50%; }
.fig-interior img { object-position: 50% 35%; }
/* Solid chip, bottom left (bottom right on the opening): placeholder label, plus the frame's title on 04 and 05. */
.frame-chip {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .3rem;
  margin-block-start: auto;
  padding: .35rem .6rem;
  background: var(--cream);
  color: var(--ink);
}
.frame-label { font-size: .875rem; font-weight: 500; line-height: 1.4; }
.frame-media strong { font: 700 clamp(1.25rem, 1.7vw, 1.5rem)/1 var(--display); letter-spacing: -.024em; }
.frame figcaption { margin-block-start: .65rem; font-size: .9375rem; line-height: 1.4; }

/* ---- 1 · Opening ---- */
.hero { border-block-end: 1px solid var(--ink); }
.hero-grid {
  --title-size: clamp(4.25rem, min(19vw, calc((100svh - var(--header)) * .31)), 22rem);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-block-size: calc(100svh - var(--header));
  padding-block: clamp(2rem, 6svh, 4.5rem) 0;
}
.hero-message, .hero-support, .hero-link { position: relative; z-index: 1; }
.hero-message .label { margin-block-end: clamp(.75rem, 2svh, 1.5rem); }
.hero h1 { font-size: var(--title-size); line-height: .86; }
/* Mask for the reveal: each word group is a clipping window; the inner span slides inside it.
   Two lines from 48rem, three below: the <br> elements choose the breaks, the text stays whole words. */
.hero h1 .line { display: inline-block; vertical-align: top; overflow: hidden; padding: .14em .06em .04em 0; margin: -.14em -.06em -.04em 0; }
.hero h1 .line > span { display: block; }
.br-stretto { display: none; }
.hero-support { margin-block-start: auto; padding-block-start: 2rem; max-inline-size: 24ch; font-size: clamp(1.1rem, 1.65vw, 1.5rem); line-height: 1.35; }
.hero-link { margin-block-end: clamp(1.5rem, 4svh, 3rem); gap: .65rem; }
.hero-link::before { content: ""; inline-size: 1.6rem; block-size: 1px; background: currentColor; }
/* The photo fills the whole opening, edge to edge; the text sits on top of it in cream. */
.hero-frame {
  position: absolute;
  z-index: 0;
  inset-block: 0;
  inset-inline: calc(-1 * var(--bleed));
  inline-size: auto;
  block-size: auto;
}
.hero-frame { --frame-bg: var(--field-offer); --frame-ink: var(--cream); }
.hero-frame .frame-media { block-size: 100%; }
/* Keeps the cup below the title where the box is wider than the photo. */
.hero-frame img { object-position: 50% 0%; }
/* Scrim: --ink as rgb with alpha. Holds cream text above 4.5:1 even over a white photo pixel. */
.hero-frame .frame-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgb(48 25 7 / .82) 0%, rgb(48 25 7 / .73) 50%, rgb(48 25 7 / .68) 70%, rgb(48 25 7 / .08) 100%);
}
.hero-frame .frame-chip { align-self: flex-end; }
.hero .label, .hero h1 .line, .hero-support, .hero-link { color: var(--cream); }

/* ---- Chapters 2-5: centred, one huge uppercase title each ----
   Chapters 2 and 4 size the title on the viewport (13cqi, 18cqi below 48rem), one word group per line.
   Chapters 3 and 5 fit the longest line: 6.3em, 2.824em and 2.498em are widths measured in Margherita
   uppercase at this tracking, so they must be re-measured if a title changes. */
main h2 { line-height: .85; padding-block-end: .08em; text-transform: uppercase; text-align: center; }
.ritual, .story { --ch-size: min(13cqi, 22rem); }
.ritual { background: var(--cream); }
/* Cream field, as chapter 2; the empty photo frame is sand so it still reads. */
.story { background: var(--cream); }
.ritual h2, .story h2 { font-size: var(--ch-size); }
/* More than .85 here: the grave accent of CAFFÈ would run into the line above. */
.ritual h2 { line-height: .96; }
.ritual-grid, .story-grid, .visit-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-block: var(--chapter-space);
}
.ritual-copy, .story-copy {
  max-inline-size: 34ch;
  font-size: clamp(1.125rem, 1.6vw, 1.45rem);
  line-height: 1.48;
}
.ritual-copy + .ritual-copy { margin-block-start: 1.25rem; }

/* ---- 2 · Al banco ----
   Three equal 2:3 photos. A side photo rotated 14deg is 1.333 times as wide as its box. From 48rem
   the overlap is slightly negative, leaving a small gap (about .043 x --fan-w); below, edges just touch. */
.fan {
  --fan-w: min(22cqi, 21rem);
  --fan-overlap: calc(var(--fan-w) * -.02);
  --fan-drop: calc(var(--fan-w) * .236);
  display: flex;
  justify-content: center;
  align-self: stretch;
  padding-block: calc(var(--fan-w) * .1) calc(var(--fan-w) * .34);
}
.fan-photo { flex: none; inline-size: var(--fan-w); }
.fan-photo .frame-media { aspect-ratio: 2 / 3; padding: .5rem; }
.fan-mid { position: relative; z-index: 1; }
.fan-left, .fan-right { translate: 0 var(--fan-drop); }
.fan-left { rotate: -14deg; margin-inline-end: calc(var(--fan-w) * .1666 - var(--fan-overlap)); }
.fan-right { rotate: 14deg; margin-inline-start: calc(var(--fan-w) * .1666 - var(--fan-overlap)); }
/* Side chips sit clear of the overlap and of the screen edge. */
.fan-left .frame-chip { align-self: flex-end; margin-inline-end: var(--fan-overlap); }
.fan-right .frame-chip { margin-inline-start: var(--fan-overlap); }
.fan-mid img { object-position: 36% 50%; }
.fan-right img { object-position: 40% 50%; }
.ritual .label { margin-block: var(--title-space) 1.25rem; }
.title-block { position: relative; align-self: stretch; }
/* Two small labels level with the first title line ("IL" is .558em wide). */
.flank {
  position: absolute;
  inset-block-start: calc(var(--ch-size) * .48);
  translate: 0 -50%;
  font-size: .8125rem;
  font-weight: 750;
  letter-spacing: .105em;
  text-transform: uppercase;
}
.flank-left { inset-inline-end: calc(50% + var(--ch-size) * .28 + 2rem); }
.flank-right { inset-inline-start: calc(50% + var(--ch-size) * .28 + 2rem); }
.mark { inline-size: .75rem; block-size: .75rem; margin-block: 2rem; background: var(--accent); rotate: 45deg; }
.actions { display: flex; justify-content: center; gap: .75rem; margin-block-start: 2rem; }
.actions .button { white-space: nowrap; }

/* ---- Lettering band between chapters 2 and 3: the shopfront fascia, sand with green lettering ---- */
.band { background: var(--field-sand); color: var(--field-offer); overflow: clip; }
.band-track {
  display: flex;
  inline-size: max-content;
  gap: .5em;
  margin-inline-start: -.35em;
  padding-block: .05em .02em;
  font: 700 clamp(5rem, 13vw, 13rem)/1 var(--display);
  letter-spacing: .01em;
  text-transform: uppercase;
  white-space: nowrap;
}
.band-track span { display: inline-flex; align-items: center; gap: .5em; }
.band-track span::after { content: ""; inline-size: .3em; block-size: .3em; background: currentColor; }

/* ---- 3 · Momenti della giornata ----
   Part A: full-height photo with the title in two parts (clean gap between them, no emblem).
   Part B: second full-bleed photo, same scrim, that slides over part A. */
/* Paint containment keeps the sticky layer from shifting the opening's text antialiasing (1/255). */
.moments-section { contain: paint; }
.day-photo {
  position: relative;
  display: grid;
  place-items: center;
  block-size: calc(100svh - var(--header));
  min-block-size: 22rem;
  background: var(--field-offer);
  color: var(--cream);
}
.day-frame { position: absolute; inset: 0; --frame-bg: var(--field-offer); }
.day-frame .frame-media { block-size: 100%; padding: 1rem var(--gutter) 4rem; }
/* Flat scrim: --ink as rgb with alpha. Holds cream above 4.5:1 even over a white photo pixel. */
.day-frame .frame-slot::after { content: ""; position: absolute; inset: 0; background: rgb(48 25 7 / .68); }
.day-frame img { object-position: 50% 35%; }
.day-frame figcaption {
  position: absolute;
  inset: auto var(--gutter) 1rem var(--gutter);
  inline-size: fit-content;
  margin: 0;
  padding: .35rem .6rem;
  background: var(--cream);
  color: var(--ink);
}
.day-photo h2 {
  position: relative;
  display: flex;
  justify-content: center;
  gap: .85em;
  font-size: min(calc((100cqi - 2 * var(--gutter)) / 6.5), 22rem);
  white-space: nowrap;
}
.day-field {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-block-size: calc(100svh - var(--header));
  padding: var(--chapter-space) var(--gutter);
  background: var(--field-offer);
  color: var(--cream);
  text-align: center;
}
/* Part B background: full-bleed, square. Chip bottom left, below the line of the selected moment. */
.day-back { position: absolute; inset: 0; --frame-bg: var(--field-offer); }
.day-back .frame-media { block-size: 100%; padding: .5rem var(--gutter); }
/* Same flat scrim as part A: cream stays above 4.5:1 even over a white photo pixel. */
.day-back .frame-slot::after { content: ""; position: absolute; inset: 0; background: rgb(48 25 7 / .68); }
.day-show {
  position: relative;
  --day-size: min(calc((100cqi - 2 * var(--gutter)) * .9 / 2.824), 27svh, 22rem);
  --day-overlap: .36;
  --day-hold: clamp(11rem, min(24cqi, 34svh), 22rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.day-title {
  font: 700 var(--day-size)/.85 var(--display);
  /* Cap for the provisional line: its longest row, "ALLA VOLTA.", is about 4.001em. */
  font-size: min(var(--day-size), calc((100cqi - 2 * var(--gutter)) * .9 / 4.001));
  letter-spacing: -.024em;
  text-transform: uppercase;
}
/* Empty box with the size of the 5H overlapping photo, so title, labels and line do not move. */
.day-show::after {
  content: "";
  inline-size: var(--day-hold);
  aspect-ratio: 4 / 3;
  margin-block-start: calc(-1 * var(--day-size) * var(--day-overlap));
}

/* Without JS (or without :has): all three moments, stacked. */
.moments { position: relative; list-style: none; display: grid; row-gap: 1.5rem; margin: var(--title-space) 0 0; padding: 0; }
.moment { display: grid; justify-items: center; row-gap: .35rem; }
.moment-radio { display: none; }
.moment-time { font-size: .875rem; font-weight: 750; line-height: 1.4; letter-spacing: .105em; text-transform: uppercase; }
.moment-line { font: 700 clamp(1.75rem, 3vw, 2.5rem)/1.1 var(--display); letter-spacing: -.012em; }

/* With JS (.tab-js): labels in a row on top, one line below. Selection is native radios and CSS only. */
@supports selector(:has(*)) {
  .tab-js .day-field { padding-block: 6rem 6.5rem; }
  .tab-js .moments {
    position: absolute;
    inset: 2rem var(--gutter) 3rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(1.25rem, 5cqi, 4rem);
    margin: 0;
  }
  .tab-js .moment { display: block; }
  .tab-js .moment-radio { display: block; position: absolute; inset: 0; inline-size: 100%; block-size: 100%; margin: 0; opacity: 0; cursor: pointer; }
  .tab-js .moment-time { position: relative; display: inline-flex; align-items: center; min-block-size: 2.75rem; cursor: pointer; }
  .tab-js .moment-time:has(:checked) span { text-decoration: underline var(--accent); text-decoration-thickness: 3px; text-underline-offset: .5em; }
  .tab-js .moment-time:has(:focus-visible) { outline: 2px solid currentColor; outline-offset: 4px; }
  /* The three lines share one place under the photo, at the bottom of the list's box. */
  .tab-js .moment-line { position: absolute; inset: auto 0 0; visibility: hidden; }
  .tab-js .moment:has(:checked) .moment-line { visibility: visible; }
}

/* ---- Rounded corners: the framed photos (fan and story) ---- */
:is(.fan-photo, .fig-story) :is(.frame-media, .frame-slot) { border-radius: var(--radius-photo); }

/* ---- 4 · La storia ----
   The frame is empty and the text block is a placeholder: both are reserved for a photo and the
   venue's history text, supplied by the client. Nothing here is to be filled in by guesswork. */
.story h2 { margin-block: 1.25rem var(--title-space); }
.fig-story { inline-size: min(30cqi, 30rem); --frame-bg: var(--field-sand); --frame-ink: var(--ink); }
.fig-story .frame-media { aspect-ratio: 2 / 3; padding: .75rem; }
/* Room for about five lines (5 x 1.48). */
.story-note { margin-block-start: 2rem; }
.story-copy { inline-size: min(100%, 34ch); min-block-size: 7.4em; margin-block-start: 1rem; }

/* ---- 5 · Visita: the footer of the page. The targa carries the practical information. ---- */
.visit { border-block-start: 1px solid var(--ink); background: var(--field-sage); }
.visit h2 {
  margin-block: 1.25rem var(--title-space);
  font-size: min(calc((100cqi - 2 * var(--gutter)) * .94 / 2.498), 36svh, 22rem);
  color: var(--field-offer);
}
.visit .button { margin-block-start: var(--title-space); }
.targa {
  inline-size: min(100%, 40rem);
  padding: clamp(.6rem, 1vw, .85rem);
  background: var(--field-offer);
  color: var(--cream);
  border-radius: 1.25rem;
}
.targa-inner { padding: clamp(1.5rem, 3vw, 2.75rem); border: 1px solid var(--accent); border-radius: .65rem; }
.targa h3 { margin: 0 0 1.25rem; font: 700 clamp(2rem, 3.6vw, 3.5rem)/1 var(--display); letter-spacing: -.024em; }
.targa dl { border-block-start: 1px solid var(--accent); }
.targa dl > div {
  display: grid;
  justify-items: center;
  gap: .35rem;
  padding-block: clamp(1rem, 2.2svh, 1.4rem);
  border-block-end: 1px solid var(--accent);
}
.targa dt { color: var(--accent); font-size: .8125rem; font-weight: 700; letter-spacing: .105em; text-transform: uppercase; }
.targa dd { margin: 0; font-size: clamp(1.15rem, 1.8vw, 1.6rem); line-height: 1.3; }

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 0 var(--gutter) 1.25rem;
  background: var(--field-sage);
  color: var(--ink);
  font-size: .8125rem;
  text-align: center;
}

/* ---- 5L · Chapter buttons, fan photos, logo ----
   Hover only with a fine pointer. Movement uses the individual translate and scale properties, so
   the existing transforms (logo centring, docking) are left alone. The visit button and the header
   button invert to ink instead of amber. */
main .button, .nav-visit { border-radius: var(--radius-pill); }
main .button:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.visit .button:focus-visible { background: var(--ink); border-color: var(--ink); color: var(--cream); }
@media (hover: hover) and (pointer: fine) {
  main .button:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }
  .visit .button:hover, .nav-visit:hover { background: var(--ink); border-color: var(--ink); color: var(--cream); }
}
@media (prefers-reduced-motion: no-preference) {
  main .button, .nav-visit { transition: background-color .35s var(--ease-apertura), border-color .35s var(--ease-apertura), color .35s var(--ease-apertura), translate .35s var(--ease-apertura), scale .15s var(--ease-apertura); }
  main .button:focus-visible { translate: 0 -2px; }
  main .button:active, .nav-visit:active { scale: .98; }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  main .button:hover, .nav-visit:hover { translate: 0 -2px; }

  /* Fan: the side photos already rest on translate (--fan-drop), so the rise is added to it.
     The empty story frame has no hover: when a photo is added there, give it this same one. */
  .fan-photo { transition: translate .6s var(--ease-apertura); }
  .fan-mid:hover { translate: 0 -.5rem; }
  :is(.fan-left, .fan-right):hover { translate: 0 calc(var(--fan-drop) - .5rem); }
  .fan-photo .frame-slot > img { transition: scale .6s var(--ease-apertura); }
  .fan-photo:hover .frame-slot > img { scale: 1.05; }

  /* Logo: origin 0 0 is where the centring transform puts the drawing's centre, so it grows in place. */
  .brand img { transform-origin: 0 0; transition: scale .5s var(--ease-apertura); }
  .brand:hover img { scale: 1.04; }
}

/* ---- 48rem to 64rem: the third nav link moves right of the tab so nothing runs under it ---- */
@media (min-width: 48rem) and (max-width: 63.99rem) {
  :root { --tab-w: 9.5rem; }
  .nav { grid-template-columns: auto auto minmax(0, 1fr) auto auto; column-gap: .75rem; font-size: .875rem; }
  .nav-links { display: contents; }
  .nav-links a { grid-row: 1; white-space: nowrap; }
  .nav-links a:nth-child(1) { grid-column: 1; }
  .nav-links a:nth-child(2) { grid-column: 2; }
  .nav-links a:nth-child(3) { grid-column: 4; }
  .nav-visit { grid-column: 5; }
}

/* Short, wide windows (phones in landscape): keep the previous title size, never smaller than 5E. */
@media (min-width: 48rem) and (max-width: 63.99rem) and (max-height: 34rem) {
  .hero-grid { --title-size: 15.5vw; }
}

/* ---- Below 48rem ---- */
@media (max-width: 47.99rem) {
  :root { --header: 4.1rem; --tab-w: min(7rem, 27.8vw); --logo-w: calc(var(--tab-w) * 1.75); }
  .skip-link { padding-block: .75rem; }
  .nav { grid-template-columns: minmax(0, 1fr) var(--tab-w) minmax(0, 1fr); column-gap: 0; font-size: .875rem; }
  .nav-links a { white-space: nowrap; }
  .nav-extra { display: none !important; }
  .nav-visit { padding-inline: .45rem; }

  .hero-grid {
    --title-size: clamp(4.25rem, min(calc((100vw - 2 * var(--gutter)) * .43), 22svh), 19.5rem);
    min-block-size: 88svh;
    padding-block: 1.65rem 0;
  }
  .br-stretto { display: inline; }
  .br-largo { display: none; }
  .hero-support { margin-block-start: 0; padding-block-start: 1.1rem; font-size: 1.0625rem; }
  .hero-link { margin-block-end: 1.5rem; }
  /* Vertical scrim. The dark part follows the title size, so it stays behind title, line and link. */
  .hero-frame { --scrim-end: calc(10.5rem + 2.58 * var(--title-size)); }
  .hero-frame .frame-slot::after { background: linear-gradient(to bottom, rgb(48 25 7 / .78) 0%, rgb(48 25 7 / .78) var(--scrim-end), rgb(48 25 7 / .2) 100%); }

  /* The opening's photo padding (it places the placeholder chip): as in 5G. */
  .hero-frame .frame-media { padding: 1.1rem; }

  /* Chapters 2-5 */
  .ritual, .story { --ch-size: 18cqi; }
  .fan { --fan-w: 44cqi; --fan-overlap: 0px; --fan-drop: calc(var(--fan-w) * .12); }
  .fan .frame-media { padding: .35rem; }
  .fan .frame-chip { max-inline-size: min-content; padding: .25rem .35rem; }
  .fan .frame-label { font-size: .75rem; }
  .flank { display: none; }

  .band-track { font-size: clamp(5.5rem, 30vw, 9rem); padding-block: .06em 0; }

  .day-show { --day-overlap: .22; }
  .day-show { --day-hold: 60cqi; }
  .moment-line { font-size: 2rem; }

  .fig-story { inline-size: 74cqi; }

  .targa { inline-size: 100%; }
  .targa dl > div { padding-block: .85rem; }
}

@media (max-width: 22rem) {
  :root { --tab-w: 5.25rem; }
  .nav { font-size: .8125rem; }
  .nav-visit { padding-inline: .35rem; }
  .actions .button { padding-inline: .6rem; font-size: .875rem; }
  .fan .frame-chip { padding-inline: .2rem; }
  .fan .frame-label { font-size: .6875rem; }
}

/* Chapter 3, part A: one row would be small in an upright window, so the two parts stack. */
@media (max-aspect-ratio: 1/1) {
  .day-photo h2 { flex-direction: column; gap: .55em; font-size: min(calc((100cqi - 2 * var(--gutter)) * .8 / 2.824), 20svh); }
}

/* ---- Motion: three gestures plus the chapter titles; everything lives inside the no-preference gate ---- */
@media (prefers-reduced-motion: no-preference) {
  /* Opening: the title is unmasked once, line by line. Pure CSS, runs on load.
     With the sequence it starts 0.5s after the contraction does; a skip jumps to the final state. */
  .hero h1 .line > span { animation: mask-up 1.15s var(--ease) both; animation-delay: calc(var(--title-start, 0s) + var(--line-delay, 0s)); }
  .hero h1 .line:nth-of-type(n + 3) > span { --line-delay: .12s; }
  @media (max-width: 47.99rem) {
    .hero h1 .line:nth-of-type(n + 2) > span { --line-delay: .12s; }
  }
  .apertura-titolo { --title-start: calc(var(--apertura-hold) + .5s); }
  .apertura-saltata .hero h1 .line > span { animation: none; }
  @keyframes mask-up { from { transform: translateY(104%); } to { transform: translateY(0); } }

  /* Opening sequence: the amber field contracts to an ellipse around the large logo (clip-path), the logo
     travels with it (transform) and the field fades out as it lands. The ellipse encloses the whole drawing, crown included. */
  .apertura-on .apertura {
    --end-rx: calc(var(--logo-w) * .35);
    --end-ry: calc(var(--logo-w) * .22);
    display: block;
    position: fixed;
    z-index: 20;
    inset: 0;
    background: var(--field-open);
    animation: apertura-campo var(--apertura-contract) var(--ease-apertura) var(--apertura-hold) both;
  }
  .apertura-logo {
    position: absolute;
    inset: 0;
    transform-origin: 50% calc(var(--tab-h) / 2);
    animation: apertura-logo var(--apertura-contract) var(--ease-apertura) var(--apertura-hold) both;
  }
  .apertura-box { position: absolute; top: 0; left: calc(50% - var(--tab-w) / 2); inline-size: var(--tab-w); block-size: var(--tab-h); overflow: visible; }
  /* The header logo stays hidden while the overlay logo travels, or it would show through the fading field. */
  .apertura-on .logo-tab .brand img { visibility: hidden; }
  /* The shape contracts over the whole duration (clip-path only at 0% and 100%). Only the field color
     fades, never the logo, from 20% to 50% of --apertura-contract after --apertura-hold:
     start .35 + .20 x 1.2 = .59s; transparent .35 + .50 x 1.2 = .95s; end .35 + 1.2 = 1.55s after load.
     One animation, so its animationend removes the overlay (index.html). */
  @keyframes apertura-campo {
    0% { clip-path: inset(0 0 0 0 round 0px / 0px); background-color: var(--field-open); }
    20% { background-color: var(--field-open); animation-timing-function: linear; }
    50% { background-color: transparent; }
    100% {
      clip-path: inset(calc(var(--tab-h) / 2 - var(--end-ry)) calc(50% - var(--end-rx)) calc(100% - var(--tab-h) / 2 - var(--end-ry)) calc(50% - var(--end-rx)) round var(--end-rx) / var(--end-ry));
      background-color: transparent;
    }
  }
  @keyframes apertura-logo {
    from { transform: translateY(calc(50% - var(--tab-h) / 2)) scale(1.2); }
    to { transform: translateY(0) scale(1); }
  }

  /* Logo tab: reduces and returns with the same easing. */
  .logo-tab { transition: transform 1s var(--ease-apertura); }

  /* Photo frames: a clip reveal, once, when the frame enters (.in is added by motion.js). */
  .motion [data-reveal] .frame-media { clip-path: inset(0 0 100% 0 round var(--radius-photo)); transition: clip-path 1.8s var(--ease); }
  .motion [data-reveal].in .frame-media { clip-path: inset(0 round var(--radius-photo)); }

  /* Chapter titles: the same clip reveal. The h2 is observed, its span is clipped; the negative
     insets keep accents and descenders, which overhang the tight line box. */
  .motion h2[data-reveal] > span { clip-path: inset(-.2em -.1em calc(100% + .2em) -.1em); transition: clip-path 1.8s var(--ease-apertura); }
  .motion h2[data-reveal].in > span { clip-path: inset(-.2em -.1em); }

  /* Lettering band: slow horizontal drift tied to scroll (--drift is set by motion.js). */
  .motion .band-track { transform: translate3d(var(--drift, 0px), 0, 0); will-change: transform; }
}

/* Chapter 3, part A holds while part B slides over it. Native sticky, no scroll script. Not under reduced
   motion, and not in very short windows, where the bottom captions would be covered before being seen. */
@media (prefers-reduced-motion: no-preference) and (min-height: 30rem) {
  .day-photo { position: sticky; inset-block-start: var(--header); }
}
