/* =============================================================================
   Alessandro Amadio — Archivio Isometrico
   Contract with the JS: main.js toggles .is-open, .is-hidden, .is-current and
   .is-lit, plus .is-locked on <html>; timeline.js owns the canvas inside .stage,
   fills .stage-track with .stage-step sections, and toggles .is-visible on the
   floating plot label. The scene has no CSS geometry at all — every board, grid
   and volume is a three.js object. What CSS owns here is the page scroll that
   drives it, and the HUD around it.
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', ui-monospace, 'SF Mono', monospace;

  --accent: #ff4500;
  --accent-soft: rgba(255, 69, 0, 0.16);

  /* The project sheet is paper in both schemes — it is a printed sheet, not a
     panel — so its surface never joins the switch. */
  --sheet-bg: #ffffff;
  --sheet-text: #10161c;
  --sheet-muted: #6b7883;
  --sheet-line: #e8ecef;

  --radius: 16px;
  --radius-lg: 24px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------------------------------------------------------------- schemes --- */
/* html[data-theme] is written before the first paint by the inline script in
   index.html, and thereafter by js/theme.js. Without JavaScript the attribute
   never appears and the studio dark below stands as the default — which is why
   the dark scheme is on bare :root as well as on its own attribute.

   Everything that differs between the two lives here and nowhere else. A colour
   written straight into a rule below is a colour that cannot switch. */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #0b0f12;
  --bg-deep: #070a0d;
  --panel: rgba(18, 24, 31, 0.88);
  --panel-solid: #12181f;
  --panel-hover: #1b232c;

  --text: #f0f4f8;
  --text-muted: #8c9ba5;
  --text-dim: #5f6d78;
  --strong: #ffffff;
  /* Accent as small text. Orange on ink clears AA on its own; on paper it does
     not, so the light scheme burns it down until it does. */
  --accent-text: #ff4500;

  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.05);
  --hover-wash: rgba(255, 255, 255, 0.08);

  --chip-bg: rgba(10, 14, 18, 0.9);
  --chip-text: #ffffff;
  --menu-scrim: rgba(8, 11, 15, 0.3);
  --menu-body: #d0d6dc;

  --stage-sheet: url('/assets/bg-dark.svg');
  --stage-vignette: rgba(0, 0, 0, 0.55);
  /* Depth of field: the sheet sits behind the deck, so it is thrown out of focus
     and stops competing with it. Turn it down to 0px for a sharp background —
     with the unit. It is multiplied inside a calc() that has to stay a length:
     a bare 0 makes calc(0 * -4) a number, inset falls back to auto, and the
     sheet collapses to nothing. Both schemes carry their own value. */
  --stage-blur: 0px;

  --shadow-panel: 0 20px 40px rgba(0, 0, 0, 0.4);
  --shadow-float: 0 25px 60px rgba(0, 0, 0, 0.45);
}

:root[data-theme='light'] {
  color-scheme: light;

  --bg: #eef1f4;
  --bg-deep: #e4e9ed;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --panel-hover: #eef2f5;

  --text: #101a22;
  --text-muted: #4a5862;
  --text-dim: #5f6e79;
  --strong: #05080b;
  --accent-text: #c23400;

  --line: rgba(16, 26, 36, 0.14);
  --line-soft: rgba(16, 26, 36, 0.07);
  --hover-wash: rgba(16, 26, 36, 0.06);

  --chip-bg: rgba(255, 255, 255, 0.92);
  --chip-text: #101a22;
  --menu-scrim: rgba(236, 240, 244, 0.42);
  --menu-body: #3d4a55;

  --stage-sheet: url('/assets/bg-light.svg');
  --stage-vignette: rgba(38, 54, 70, 0.16);
  --stage-blur: 0px;

  --shadow-panel: 0 18px 34px rgba(24, 38, 52, 0.13);
  --shadow-float: 0 24px 54px rgba(24, 38, 52, 0.2);
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The page scroll IS the timeline control: one snapped section per year, so a
   gesture moves the deck by exactly one board and never lands between two. */
html {
  height: 100%;
  scroll-snap-type: y mandatory;
  background: var(--bg-deep);
}
html.is-locked { overflow: hidden; }

body {
  min-height: 100%;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 500;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0 0 10px 10px;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 0; }

.text-link { color: var(--accent-text); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.text-link:hover { border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- header --- */
.site-header {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 30;
  width: 320px;
  padding: 18px 20px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-header h1 {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.site-header .role {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 8px;
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s;
}
.menu-toggle:hover { background: var(--hover-wash); }
.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: width 0.3s var(--ease);
}
.menu-toggle span:first-child { width: 20px; }
.menu-toggle span:last-child  { width: 13px; }
.menu-toggle:hover span:last-child { width: 20px; }

/* --------------------------------------------------------- theme toggle --- */
.header-actions { display: flex; align-items: center; gap: 2px; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  padding: 8px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.theme-toggle:hover { background: var(--hover-wash); color: var(--text); }
.theme-icon { width: 100%; height: 100%; }

/* One shape for both states: a disc half in shade, turned over to say which half
   the page is on. The turn is the whole animation — there is no second icon to
   swap in, so nothing can be caught mid-swap. */
.theme-icon > path { transform-origin: 50% 50%; transition: transform 0.45s var(--ease); }
:root[data-theme='light'] .theme-icon > path { transform: rotate(180deg); }

/* ----------------------------------------------------------------- stage --- */
/* The scene stays put while the page scrolls past it. */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  /* Only the colour the sheet fades to, so there is nothing to see in the instant
     before it lands. The sheet itself is .stage-sheet, below. */
  background: var(--bg-deep);
}

/* The survey sheet, drawn by tools/build-bg.js, shown out of focus.
   Its own element rather than a background on .stage, for two reasons: filter
   blurs an element's children too, and the canvas has to stay sharp; and as a
   layer of its own the blur is done once by the compositor instead of by the
   main thread on every paint — which is what makes it affordable under a canvas
   that is redrawing.
   z-index: -1 puts it behind the canvas without the canvas having to be
   positioned: .stage is a stacking context, so it cannot fall further than this. */
.stage-sheet {
  position: absolute;
  /* Wider than the stage on every side. blur() reads the transparent pixels past
     an element's edge, so a sheet cut to the viewport would fade out along all
     four sides; the overhang moves that soft edge off-screen. */
  inset: calc(var(--stage-blur) * -4);
  z-index: -1;
  background: var(--stage-sheet) center / cover no-repeat;
  filter: blur(var(--stage-blur));
  pointer-events: none;
}
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 55% at 50% 45%, transparent 40%, var(--stage-vignette) 100%);
}
.stage-canvas { display: block; width: 100%; height: 100%; }

/* One finger scrolls the years, as it always did; two fingers are ours, so a pinch
   zooms the deck instead of the document. Once zoomed there is cropped board to
   reach, so the stage takes the single finger too and drags with it — timeline.js
   hands back whatever travel the board cannot absorb, and the page scrolls on. */
.stage, .stage-canvas { touch-action: pan-y; }
.stage.is-zoomed, .stage.is-zoomed .stage-canvas { touch-action: none; }
.stage.is-zoomed { cursor: grab; }
.stage.is-zoomed:active { cursor: grabbing; }

/* Scroll length and nothing else: it must never intercept a pointer. */
.stage-track { position: relative; z-index: 1; pointer-events: none; }
.stage-step {
  height: 100vh;
  height: 100svh;
  scroll-snap-align: start;
}

/* No WebGL? Say so, rather than showing a void — the card below still works. */
body[data-stage='unsupported'] .stage::before {
  content: 'Questo browser non supporta WebGL. L’archivio resta consultabile dall’elenco in basso e dal menu.';
  position: absolute;
  inset: auto 24px 50% 24px;
  max-width: 460px;
  margin: 0 auto;
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------------- HUD --- */
/* One fixed layer over the scene. It is transparent to the pointer; only the
   controls inside it take clicks, so a drag anywhere else reaches the canvas. */
.hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

/* Floating plot name. HTML, not a texture, so it stays crisp at any zoom;
   timeline.js projects the plot's anchor point and writes left/top. */
.plot-label {
  position: fixed;
  z-index: 2;
  padding: 6px 11px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--chip-text);
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.plot-label.is-visible { opacity: 1; }

/* ------------------------------------------------------------- year card --- */
/* What stands on the board in focus, in text. Also the keyboard route into it. */
.year-card {
  position: absolute;
  left: 24px;
  bottom: 28px;
  width: min(348px, calc(100vw - 48px));
  padding: 18px 20px 14px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

.year-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.year-card-kicker {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.year-card-year {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--accent-text);
}
.year-card-meta {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.year-card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}
.year-card-list button {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 11px 4px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: color 0.25s var(--ease), padding-left 0.25s var(--ease);
}
.year-card-list li:last-child button { border-bottom: none; }
.year-card-list button:hover,
.year-card-list button.is-lit { color: var(--strong); padding-left: 8px; }
.year-card-list button[aria-expanded='true'] { color: var(--accent-text); }

.project-index {
  flex: 0 0 auto;
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  transition: color 0.25s var(--ease);
}
.year-card-list button:hover .project-index,
.year-card-list button.is-lit .project-index,
.year-card-list button[aria-expanded='true'] .project-index { color: var(--accent-text); }

.project-lines { display: flex; flex-direction: column; gap: 2px; }
.project-name { font-size: 0.85rem; font-weight: 500; line-height: 1.3; }
.project-kind {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ------------------------------------------------------------- year rail --- */
/* Every year at once: where you are on the deck, and a way to jump. */
.year-rail {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
}
.year-rail-item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 7px 2px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.year-rail-item:hover { color: var(--text); }
.year-rail-item.is-current { color: var(--accent-text); }

.year-rail-tick {
  display: block;
  width: 16px;
  height: 1px;
  background: currentColor;
  transition: width 0.4s var(--ease), height 0.4s var(--ease);
}
.year-rail-item.is-current .year-rail-tick { width: 36px; height: 2px; }

.year-rail-year { opacity: 0.5; transition: opacity 0.3s var(--ease); }
.year-rail-item:hover .year-rail-year { opacity: 0.85; }
.year-rail-item.is-current .year-rail-year { opacity: 1; font-weight: 700; }

/* -------------------------------------------------------- stage controls --- */
.stage-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 100px;
  pointer-events: none;
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.stage-hint.is-hidden { opacity: 0; transform: translateX(-50%) translateY(8px); }

.zoom-controls {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.zoom-controls button {
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent-text);
  background: var(--panel-solid);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.zoom-controls button:hover:not(:disabled) { background: var(--panel-hover); color: var(--text); }
.zoom-controls button:disabled { color: var(--text-dim); cursor: default; }
.zoom-controls .zoom-reset { color: var(--text); font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.05em; }
/* Lit only while there is a view to come back from. */
.zoom-controls .zoom-reset.is-active { color: var(--accent-text); }

/* ------------------------------------------------------------- side sheet --- */
.sheet {
  position: fixed;
  top: 20px; right: 20px; bottom: 20px;
  z-index: 100;
  width: min(450px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  background: var(--sheet-bg);
  color: var(--sheet-text);
  /* Invisible over the dark scheme, and the only thing separating paper from
     paper over the light one. */
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  /* Animating transform (not `right`) so it also slides on the mobile layout,
     where the original animated a property it never changed. */
  transform: translateX(calc(100% + 32px));
  visibility: hidden;
  transition: transform 0.5s var(--ease), visibility 0s linear 0.5s;
}
.sheet.is-open {
  transform: translateX(0);
  visibility: visible;
  /* La misura si anima solo a scheda aperta: chiusa deve gia' essere della
     larghezza ricordata, senza una transizione che parte fuori campo. */
  transition: transform 0.5s var(--ease), visibility 0s,
              width 0.45s var(--ease), height 0.45s var(--ease), top 0.45s var(--ease);
}

/* --- modalita' lettura -----------------------------------------------------
   Appena aperta la scheda e' una colonna da scorrere. Espansa e' una doppia
   pagina da leggere: misura piu' larga, corpo piu' grande e — quando c'e' spazio
   per due colonne — il modello accanto al testo invece che sopra. */
.sheet.is-expanded {
  width: min(1080px, calc(100vw - 40px));
}
.sheet.is-expanded .viewer { height: 40vh; }
.sheet.is-expanded .sheet-content { padding: 32px 30px; }

@media (min-width: 900px) {
  .sheet.is-expanded { flex-direction: row; }
  .sheet.is-expanded .viewer {
    flex: 1 1 54%;
    height: auto;
    min-width: 0;
    border-bottom: none;
    border-right: 1px solid var(--sheet-line);
  }
  .sheet.is-expanded .sheet-content {
    flex: 1 1 46%;
    min-width: 0;
    gap: 26px;
    /* Spazio in alto per i pulsanti, che galleggiano sopra questa colonna. */
    padding: 60px 44px 44px;
  }
  .sheet.is-expanded .project-title h2 { font-size: 1.85rem; }
  .sheet.is-expanded .project-category { font-size: 0.74rem; }
  .sheet.is-expanded .metadata-grid { gap: 20px; padding: 22px 0; }
  .sheet.is-expanded .meta-item dd { font-size: 0.95rem; }
  .sheet.is-expanded .project-abstract p { font-size: 1rem; line-height: 1.8; }
}

/* --- pulsanti -------------------------------------------------------------- */
.sheet-tools {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.sheet-tool {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--sheet-text);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.sheet-tool:hover { background: #eef1f3; transform: scale(1.06); }

/* Due icone nello stesso SVG: lo stato premuto le scambia, cosi' il pulsante
   mostra sempre la mossa che sta per fare, non quella appena fatta. */
.tool-icon {
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool-icon .icon-in { display: none; }
[aria-pressed='true'] .tool-icon .icon-out { display: none; }
[aria-pressed='true'] .tool-icon .icon-in { display: inline; }

/* 3D viewer panel */
.viewer {
  position: relative;
  flex: 0 0 auto;
  height: 250px;
  background: radial-gradient(circle at 50% 40%, #ffffff 0%, #e9edf1 100%);
  border-bottom: 1px solid var(--sheet-line);
  touch-action: none; /* OrbitControls handles the gestures here */
}
.viewer-canvas { display: block; width: 100%; height: 100%; }

.viewer-label {
  position: absolute;
  bottom: 12px; left: 16px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sheet-muted);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 100px;
  pointer-events: none;
}

.viewer-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--sheet-muted);
  background: rgba(244, 246, 248, 0.92);
}
.viewer-status[hidden] { display: none; }
.viewer-status[data-state='error'] { color: #b3401a; }

.viewer-tools {
  position: absolute;
  bottom: 12px; right: 12px;
  display: flex;
  gap: 8px;
}
.viewer-tool {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  color: var(--sheet-text);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.viewer-tool:hover { background: #ffffff; transform: scale(1.08); }

/* Solo quando il modello ha tutto lo schermo: su un riquadro di 250px sarebbe
   rumore, e li' il testo della scheda dice gia' cosa fare. */
.viewer-hint { display: none; }

/* --- tutto schermo ---------------------------------------------------------
   La classe la mette js/main.js su #modelViewer dopo averlo spostato in coda al
   <body>. Il fullscreen nativo viene chiesto in aggiunta, dove esiste; questa
   regola e' cio' che fa funzionare la modalita' dove non esiste (iOS Safari). */
.viewer.is-immersive {
  position: fixed;
  inset: 0;
  z-index: 300;
  height: auto;
  border: none;
  border-radius: 0;
  background: radial-gradient(circle at 50% 42%, #ffffff 0%, #dfe5ea 100%);
  animation: viewer-in 0.32s var(--ease);
}
@keyframes viewer-in {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.viewer.is-immersive .viewer-tools {
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  bottom: auto;
}
.viewer.is-immersive .viewer-tool { width: 44px; height: 44px; }
.viewer.is-immersive .tool-icon { width: 20px; height: 20px; }

.viewer.is-immersive .viewer-label {
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 24px;
  font-size: 0.68rem;
}

.viewer.is-immersive .viewer-hint {
  display: block;
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: var(--sheet-muted);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 100px;
  pointer-events: none;
}

.sheet-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.project-category {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}
.project-title h2 {
  margin-top: 6px;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.metadata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--sheet-line);
  border-bottom: 1px solid var(--sheet-line);
}
.meta-item { display: flex; flex-direction: column; gap: 4px; }
.meta-item dt {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sheet-muted);
}
.meta-item dd { font-size: 0.875rem; font-weight: 600; }

.project-abstract h3 {
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sheet-muted);
}
.project-abstract p { font-size: 0.9rem; line-height: 1.65; color: #3d4750; }

/* ------------------------------------------------------------------ menu --- */
.full-menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 5vw, 60px) clamp(24px, 6vw, 80px);
  background: var(--menu-scrim);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0s linear 0.4s;
}
.full-menu.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s var(--ease), visibility 0s;
}

.menu-close {
  position: absolute;
  top: 28px; right: 28px;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  line-height: 1;
  color: var(--strong);
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, color 0.2s;
}
.menu-close:hover { transform: scale(1.12); color: var(--accent-text); }

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(30px, 5vw, 60px);
  width: 100%;
  max-width: 1300px;
  margin-top: 40px;
}

.menu-nav { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.menu-nav button {
  font-family: var(--font-sans);
  font-size: clamp(1.15rem, 2.4vw, 1.8rem);
  font-weight: 300;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s, transform 0.3s var(--ease);
}
.menu-nav button:hover,
.menu-nav button.is-current { color: var(--strong); transform: translateX(10px); }

.menu-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 60vh;
  padding-left: 40px;
  border-left: 1px solid var(--line);
  color: var(--menu-body);
  overflow-y: auto;
}
.menu-content h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.menu-content p { font-size: 0.95rem; font-weight: 300; line-height: 1.65; }
.menu-content strong { color: var(--strong); font-weight: 500; }

.archive-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.archive-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.archive-item:last-child { border-bottom: none; }
.archive-item strong { color: var(--strong); font-weight: 500; }
.archive-place {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.archive-meta { font-size: 0.82rem; color: var(--text-muted); }

.menu-footer {
  padding-top: 36px;
  margin-top: 32px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --------------------------------------------------------------- noscript --- */
.noscript-note {
  position: fixed;
  inset: auto 24px 24px 24px;
  z-index: 400;
  padding: 16px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------ responsive --- */
@media (max-width: 900px) {
  .menu-grid { grid-template-columns: 1fr; }
  .menu-content {
    padding-left: 0;
    padding-top: 20px;
    border-left: none;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 768px) {
  .site-header { top: 16px; left: 16px; right: 16px; width: auto; }

  /* The card keeps its list, but the board needs the middle of a phone screen, so
     it sits low and shows about two projects before it scrolls. */
  .year-card {
    left: 16px; right: 16px; bottom: 16px;
    width: auto;
    padding: 14px 16px 10px;
  }
  .year-card-list { max-height: 148px; overflow-y: auto; overscroll-behavior: contain; }
  .year-card-year { font-size: 1.25rem; }

  /* Only the year you are on is spelled out; the rest stay ticks. */
  .year-rail { right: 12px; top: 44%; }
  .year-rail-item { position: relative; padding: 6px 0; }
  .year-rail-year { display: none; }
  .year-rail-item.is-current .year-rail-year {
    display: block;
    position: absolute;
    right: 46px;
    font-size: 0.62rem;
  }

  /* Kept — a pinch needs a way back, and one thumb reaches the left edge. The rail
     sits on the opposite edge at the same height, so the two never meet. */
  .zoom-controls { left: 12px; }
  .zoom-controls button { width: 44px; height: 44px; }  /* thumb-sized */
  .stage-hint { bottom: auto; top: 104px; padding: 7px 13px; font-size: 0.6rem; }

  .sheet {
    top: auto;
    left: 16px; right: 16px; bottom: 16px;
    width: auto;
    height: 76vh;
    transform: translateY(calc(100% + 24px));
  }
  .sheet.is-open { transform: translateY(0); }

  /* Espansa, su un telefono, vuol dire tutto lo schermo: mentre la scheda e' su
     non c'e' altro da leggere comunque. */
  .sheet.is-expanded {
    top: 16px;
    height: auto;
    width: auto;
  }

  .viewer { height: 210px; }
  .sheet.is-expanded .viewer { height: 44vh; }
  .metadata-grid { gap: 14px; }

  /* Su schermo stretto l'etichetta finirebbe addosso al suggerimento. */
  .viewer.is-immersive .viewer-label { display: none; }
  .viewer.is-immersive .viewer-hint { font-size: 0.56rem; letter-spacing: 0.05em; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* Snapping is a layout guarantee, not motion — but the proximity variant lets a
     reader park between two boards instead of being pulled onto one. */
  html { scroll-snap-type: y proximity; }
  .sheet { transition: transform 0.01ms, visibility 0s; }
  .viewer.is-immersive { animation: none; }
}
