/* ==========================================================================
   naclerio.eu – site styles
   ========================================================================== */

/* ---------- Fonts: Jost, self-hosted (no requests to Google) ---------- */
@font-face {
  font-family: "Jost";
  src: url("../fonts/jost-300.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("../fonts/jost-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("../fonts/jost-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* Palette: greys and black only */
  --paper: #f4f4f4;     /* page background */
  --ink: #000;          /* text, logo, structural lines */
  --graphite: #4d4d4d;  /* secondary text, 7.7:1 on paper */
  --mist: #c9c9c9;      /* decorative lines only */
  --white: #fff;        /* illustrations only (the arcade rabbit) */

  /* Jost has no Greek glyphs: Ω and other Greek letters fall back to the next fonts */
  --font: "Jost", "Avenir Next", "Futura", "Century Gothic", system-ui, sans-serif;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --wrap: 78rem;
  --ease: cubic-bezier(.65, 0, .25, 1);

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  overflow-x: clip; /* safety net: the page must never scroll sideways */
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
main { flex: 1 0 auto; }
a { color: inherit; }
strong { font-weight: 500; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 200;
  background: var(--ink); color: var(--paper);
  padding: .5rem 1rem; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---------- Header ---------- */
.site-header { position: relative; }
.header-inner {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding-block: 1.25rem;
}
.brand { display: block; }
.brand-logo { width: auto; height: 48px; }
.nav-list {
  display: flex; flex-wrap: wrap;
  gap: .25rem clamp(1rem, 2.4vw, 2rem);
  margin: 0; padding: 0; list-style: none;
}
.nav-list a {
  display: inline-block;
  padding-block: .35rem;
  text-decoration: none;
  letter-spacing: .01em;
}
.nav-list a:hover,
.nav-list a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
}
.header-line {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px; background: var(--ink);
  transform-origin: left center;
}

/* ---------- Hero ---------- */
.hero-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 21rem);
  align-items: end;
  gap: 3rem var(--gutter);
  min-height: min(80svh, 50rem);
  padding-block: clamp(3rem, 9vh, 6rem);
}
.hero-diagonal {
  position: absolute; z-index: 0;
  top: 0; bottom: 0;
  left: 40%;
  /* explicit width: an absolutely positioned SVG would otherwise be as wide as it is tall */
  width: calc(56% - var(--gutter)); height: 100%;
  max-width: none;
  overflow: visible;
  pointer-events: none;
}
.hero-diagonal line { stroke: var(--mist); stroke-width: 1; }
.hero-main, .hero-aside { position: relative; z-index: 1; }

.hero-main { padding-left: clamp(1.25rem, 3vw, 2.5rem); }
.hero-rule, .aside-rule {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--ink);
}
h1 {
  margin: 0;
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -.015em;
}
.title-prefix {
  display: block; width: max-content;
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  line-height: 1;
  letter-spacing: .01em;
  margin-bottom: .9rem;
}
.title-name { display: block; font-size: clamp(3.25rem, 10.5vw, 8.75rem); }
.title-name > span { display: block; }
.hero-lead {
  max-width: 34ch;
  margin: 1.75rem 0 0;
  font-size: clamp(1.125rem, 1.6vw, 1.375rem);
  line-height: 1.45;
  color: var(--graphite);
}
.hero-motto { font-style: italic; max-width: none; }
.hero-aside {
  padding-left: 1.5rem;
  color: var(--graphite);
  font-size: 1rem;
}
.hero-aside p { margin: 0 0 1rem; }
.hero-aside p:last-child { margin-bottom: 0; }
.hero-aside a {
  color: var(--ink);
  text-underline-offset: .25em;
  text-decoration-thickness: 1px;
}

/* ---------- Section index ---------- */
.index { padding-block: clamp(2rem, 6vh, 4rem) clamp(4rem, 10vh, 7rem); }
.index-list { margin: 0; padding: 0; list-style: none; }
.index-list li { position: relative; }
.index-line {
  position: absolute; left: 0; right: 0; top: 0;
  height: 1px; background: var(--ink);
  transform-origin: left center;
}
.index-line--end { top: auto; bottom: 0; }
.index-item {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(0, 1.4fr);
  align-items: baseline;
  gap: .5rem 2rem;
  padding-block: 1.6rem;
  text-decoration: none;
}
.index-name {
  font-size: clamp(1.75rem, 3.4vw, 2.75rem);
  font-weight: 300;
  line-height: 1.1;
}
.index-desc { color: var(--graphite); max-width: 52ch; }
.index-item:hover .index-name {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .15em;
}

/* ---------- Inner pages ---------- */
.page { padding-block: clamp(3rem, 8vh, 5rem) clamp(4rem, 10vh, 7rem); }
.page-head {
  position: relative;
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  border-left: 2px solid var(--ink);
  margin-bottom: clamp(2rem, 5vh, 3rem);
}
.page-head h1 { font-size: clamp(2.5rem, 6.5vw, 5rem); }
.page-lead {
  max-width: 40ch;
  margin: 1.25rem 0 0;
  font-size: clamp(1.125rem, 1.6vw, 1.375rem);
  line-height: 1.45;
  color: var(--graphite);
}
/* Quotation under the page title */
.page-quote { margin: 1.5rem 0 0; max-width: 46ch; }
.page-quote blockquote { margin: 0; }
.page-quote blockquote p {
  margin: 0;
  font-size: clamp(1.125rem, 1.8vw, 1.5rem);
  font-weight: 300;
  line-height: 1.4;
}
.page-quote figcaption {
  margin-top: .5rem;
  font-size: .9375rem;
  color: var(--graphite);
}
.page-quote cite { font-style: italic; }

.prose { max-width: 68ch; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-weight: 400; font-size: 1.5rem; line-height: 1.25; margin: 2.5rem 0 .75rem; }
.prose a { text-underline-offset: .2em; text-decoration-thickness: 1px; }

/* ---------- About page (Chi sono) ---------- */
.profile-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "num" "text" "media";
  gap: .75rem;
  padding-block: 1.75rem;
  border-top: 1px solid var(--ink);
}
.profile-row:last-child { border-bottom: 1px solid var(--ink); }
.profile-number {
  grid-area: num;
  font-weight: 300;
  font-size: 2rem;
  line-height: 1;
  color: var(--graphite);
}
.profile-text {
  grid-area: text;
  max-width: 62ch;
  padding-left: 1.25rem;
  border-left: 2px solid var(--ink);
}
.profile-text h2 {
  margin: 0 0 .5rem;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.2;
}
.profile-text p { margin: 0 0 .6rem; line-height: 1.55; }
.profile-text p:last-child { margin-bottom: 0; }
.profile-media { grid-area: media; margin: 0; }
.profile-media img { width: 100%; height: auto; }

@media (min-width: 56rem) {
  .profile-row {
    grid-template-columns: 4.5rem minmax(0, 1fr) 18rem;
    grid-template-areas: "num text media";
    align-items: start;
    gap: 0 2.5rem;
  }
  .profile-number { padding-top: .1rem; }
  .profile-media { padding-top: .3rem; }
}

/* ---------- Publications index ---------- */
.pub-filters {
  display: flex; flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 1.25rem; padding: 0;
  list-style: none;
}
.pub-filters[hidden] { display: none; }
.pub-filters button {
  font: inherit; font-size: .9375rem;
  color: var(--ink); background: transparent;
  border: 1px solid var(--ink);
  padding: .3rem .9rem;
  cursor: pointer;
}
.pub-filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.pub-index {
  margin: 0; padding: 0; list-style: none;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.pub-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: .1rem;
  padding-block: .7rem;
}
.pub-row + .pub-row { border-top: 1px solid var(--mist); }
.pub-row[hidden] { display: none; }
.pub-type, .pub-source { font-size: .875rem; color: var(--graphite); }
.pub-title {
  text-decoration-color: var(--mist);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}
.pub-title:hover { text-decoration-color: var(--ink); }
.pub-empty { color: var(--graphite); }

@media (min-width: 56rem) {
  .pub-row {
    grid-template-columns: 11rem minmax(0, 1fr) 10rem;
    gap: 0 1.5rem;
    align-items: baseline;
  }
  .pub-source { text-align: right; }
}

/* ---------- Article pages ---------- */
.article-back { margin: 0 0 1.5rem; font-size: .9375rem; }
.article-back a { color: var(--graphite); text-decoration: none; }
.article-back a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }
.article .page-head h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
.article-meta { margin: .75rem 0 0; color: var(--graphite); }
.article-layout { display: grid; gap: 2rem; }
.article-video { margin: 0 0 2.5rem; max-width: 56rem; }
.article-video video { display: block; width: 100%; height: auto; aspect-ratio: auto 16 / 9; background: var(--ink); }
.article-figure { margin: 0; }
.article-figure img { width: auto; max-width: 100%; height: auto; max-height: 34rem; }
.article-body p { margin: 0 0 1rem; }
.article-body h2 { margin: 2rem 0 .75rem; }
.article-body video { display: block; width: 100%; max-width: 46rem; height: auto; aspect-ratio: auto 16 / 9; background: var(--ink); }
@media (min-width: 56rem) {
  .article-layout:has(.article-figure) { grid-template-columns: minmax(0, 1fr) 20rem; gap: 3rem; }
  .article-figure img { width: 100%; max-height: none; }
}

/* Press clippings: a grid of thumbnails, each opens the full scan */
.press-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 1.5rem;
  margin: 0; padding: 0; list-style: none;
}
.press-list a { display: block; color: inherit; text-decoration: none; }
.press-list img { width: 100%; height: auto; border: 1px solid var(--mist); }
.press-list figure { margin: 0; }
.press-list figcaption { margin-top: .5rem; font-size: .875rem; line-height: 1.4; color: var(--graphite); }
.press-list a:hover figcaption { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }

.press-list--wide { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }

/* Two images side by side (e.g. front and back) */
.figure-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  max-width: 36rem;
  margin: 1.5rem 0;
}
.figure-pair figure { margin: 0; }
.figure-pair img { width: 100%; height: auto; }
.figure-pair figcaption { margin-top: .4rem; font-size: .875rem; color: var(--graphite); }
.article-body blockquote {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--ink);
  color: var(--graphite);
  font-style: italic;
}

.figure-pair--wide { max-width: 46rem; align-items: start; }
.figure-caption { margin: -.75rem 0 1.5rem; font-size: .875rem; color: var(--graphite); }

/* Quotations with author */
.quote { margin: 0 0 1.5rem; }
.quote blockquote { margin: 0; padding-left: 1.25rem; border-left: 1px solid var(--ink); }
.quote blockquote p { margin: 0; font-style: italic; }
.quote figcaption { margin-top: .4rem; padding-left: 1.25rem; font-size: .9375rem; color: var(--graphite); }

/* Long text that opens on request (no JavaScript needed) */
.reading { margin: 1rem 0 0; border-top: 1px solid var(--mist); border-bottom: 1px solid var(--mist); }
.reading summary { cursor: pointer; padding: .75rem 0; }
.reading summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.reading-text { padding-bottom: 1rem; }
.reading-signature { color: var(--graphite); font-style: italic; }

/* Credits (promoter, partners, sponsor) */
.credits {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .25rem 1.25rem;
  margin: 1.5rem 0 0;
}
.credits dt { color: var(--graphite); }
.credits dd { margin: 0; }
@media (max-width: 36rem) { .credits { grid-template-columns: 1fr; } .credits dd { margin-bottom: .5rem; } }

/* Photo gallery: horizontal strip */
.gallery { margin-top: 3rem; }
.gallery h2 { margin: 0 0 .25rem; font-weight: 400; font-size: 1.5rem; }
.gallery-hint { margin: 0 0 1rem; font-size: .875rem; color: var(--graphite); }
.gallery-strip {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: .75rem;
}
.gallery-strip:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.gallery-list { display: flex; gap: 1rem; margin: 0; padding: 0; list-style: none; }
.gallery-list li { flex: 0 0 auto; scroll-snap-align: start; }
.gallery-list img { display: block; width: auto; height: clamp(12rem, 40vh, 22rem); max-width: none; }
.article-pdf { margin: 2rem 0 0; }
.article-pdf a { text-underline-offset: .2em; text-decoration-thickness: 1px; }

/* ---------- University timeline ---------- */
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: .25rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--ink);
}
.timeline-item:last-child { border-bottom: 1px solid var(--ink); }
.timeline-date { margin: 0; color: var(--graphite); font-size: 1rem; }
.timeline-body { max-width: 62ch; }
.timeline-body h3 {
  margin: 0 0 .35rem;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.3;
}
.timeline-meta, .timeline-thesis, .timeline-download { margin: 0 0 .35rem; }
.timeline-meta { color: var(--graphite); }
.timeline-thesis cite { font-style: italic; }
.timeline-download { margin-bottom: 0; }
.timeline-download a { text-underline-offset: .2em; text-decoration-thickness: 1px; }
.page-crossref { margin: 1.75rem 0 0; color: var(--graphite); }
.page-crossref a { color: var(--ink); text-underline-offset: .2em; text-decoration-thickness: 1px; }

@media (min-width: 56rem) {
  .timeline-item { grid-template-columns: 9rem minmax(0, 1fr); gap: 0 2.5rem; }
  .timeline-date { padding-top: .15rem; }
}

/* ---------- Arcade link (Didattica) ---------- */
.arcade-link {
  display: block;
  max-width: 40rem;
  margin: clamp(3rem, 10vh, 6rem) auto;
  color: inherit;
  text-decoration: none;
}
.arcade-scene { width: 100%; height: auto; overflow: hidden; }
.px-ink { fill: var(--ink); }
.px-white { fill: var(--white); }
.px-mist { fill: var(--mist); }
.px-graphite { fill: var(--graphite); }

/* Default = final frame (also shown with reduced motion) */
.arcade-rabbit-dive, .arcade-burrow { opacity: 0; }
.arcade-coin-flip, .arcade-coin-hover { transform-box: fill-box; transform-origin: center; }

@media (prefers-reduced-motion: no-preference) {
  .arcade-rabbit-move { animation: arcade-run 2.2s steps(91) .3s both; }
  .arcade-rabbit-hop  { animation: arcade-hop .22s linear .3s 10 both; }
  .arcade-rabbit-dive { animation: arcade-dive .4s steps(4) 2.6s both; }
  .arcade-burrow      { animation: arcade-vanish .4s steps(4) 3s both; }
  .arcade-coin        { animation: arcade-rise .4s steps(1) 3.3s both; }
  .arcade-coin-flip   { animation: arcade-flip .8s steps(1) 3.7s both; }
  .arcade-text        { animation: arcade-blink .4s steps(1) 4.4s 3 both; }

  /* On hover or keyboard focus: the coin spins and the text blinks */
  .arcade-link:hover .arcade-coin-hover,
  .arcade-link:focus-visible .arcade-coin-hover { animation: arcade-flip .8s steps(1) infinite; }
  .arcade-link:hover .arcade-text-hover,
  .arcade-link:focus-visible .arcade-text-hover { animation: arcade-blink .8s steps(1) infinite; }
}
@keyframes arcade-run { from { transform: none; } to { transform: translateX(91px); } }
@keyframes arcade-hop {
  0%, 49% { transform: translateY(-3px); }
  50%, 100% { transform: none; }
}
@keyframes arcade-dive {
  from { opacity: 1; transform: none; }
  to { opacity: 1; transform: translateY(16px); }
}
@keyframes arcade-vanish { from { opacity: 1; } to { opacity: 0; } }
@keyframes arcade-rise {
  0% { opacity: 0; transform: translateY(8px); }
  1% { opacity: 1; transform: translateY(8px); }
  25% { transform: translateY(6px); }
  50% { transform: translateY(4px); }
  75% { transform: translateY(2px); }
  100% { opacity: 1; transform: none; }
}
@keyframes arcade-flip {
  0% { transform: none; }
  25% { transform: scaleX(.5); }
  50% { transform: scaleX(.15); }
  75% { transform: scaleX(.5); }
  100% { transform: none; }
}
@keyframes arcade-blink {
  0% { opacity: 0; }
  50%, 100% { opacity: 1; }
}

/* ---------- 404 page ---------- */
.not-found { text-align: center; }
.nf-scene { width: 100%; max-width: 44rem; height: auto; margin: 0 auto 2rem; overflow: visible; }
.nf-title { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 1rem; }
.nf-text { max-width: 46ch; margin: 0 auto 1.75rem; color: var(--graphite); }
.nf-links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: .5rem 1.75rem;
  margin: 0; padding: 0; list-style: none;
}
.nf-links a { text-underline-offset: .25em; text-decoration-thickness: 1px; }
@media (prefers-reduced-motion: no-preference) {
  .nf-hop { animation: arcade-hop .3s linear 4 both; }
  .nf-b2 .nf-hop { animation-delay: .6s; }
  .nf-b3 .nf-hop { animation-delay: 1.1s; }
  .nf-b4 .nf-hop { animation-delay: 1.6s; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--mist); }
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 1rem;
  padding-block: 1.75rem;
  font-size: .9375rem;
  color: var(--graphite);
}
.footer-inner p { margin: 0; }
.footer-links {
  display: flex; align-items: center;
  gap: .5rem;
  margin: 0; padding: 0; list-style: none;
}
.footer-links a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem;
  color: var(--ink);
}
.footer-links a:hover { color: var(--graphite); }
.footer-icon { width: 1.25rem; height: 1.25rem; fill: currentColor; }
.footer-icon--line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.intro-skip {
  font: inherit; font-size: .9375rem;
  color: var(--ink); background: transparent;
  border: 1px solid var(--ink);
  padding: .45rem 1rem;
  cursor: pointer;
}
.intro-skip:hover { background: var(--ink); color: var(--paper); }

/* ---------- Mobile ---------- */
@media (max-width: 48rem) {
  .hero-inner { grid-template-columns: 1fr; min-height: 0; }
  .hero-diagonal { left: 50%; width: 50%; }
  .hero-aside { max-width: 30rem; }
  .index-item { grid-template-columns: 1fr; }
}

/* ---------- Intro (only with JS and without reduced motion) ---------- */
.intro-curtain { display: none; }
html.intro { overflow: hidden; }
html.intro .intro-curtain {
  display: block;
  position: fixed; inset: 0; z-index: 100;
  background: var(--paper);
}
.intro-piece {
  position: fixed; z-index: 101;
  color: var(--ink);
  overflow: visible;
  pointer-events: none;
  will-change: transform, opacity;
}
.intro-skip {
  position: fixed; z-index: 102;
  right: var(--gutter);
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom, 0px));
}

html.intro [data-reveal] {
  opacity: 0;
  transition: opacity .6s ease, transform .7s cubic-bezier(.2, .7, .2, 1);
}
html.intro [data-reveal="rise"] { transform: translateY(.75rem); }
html.intro [data-reveal="target"] { transition: opacity .3s linear; }
html.intro [data-reveal="line"] {
  opacity: 1;
  transform: scaleX(0);
  transition: transform .9s var(--ease);
}
html.intro [data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html.intro .intro-curtain, .intro-piece, .intro-skip { display: none !important; }
  html.intro [data-reveal] { opacity: 1 !important; transform: none !important; }
}
