/* =========================================================
   Luigi Iovino — personal academic website
   One scrolling page. Typeset in Computer Modern (self-hosted).
   ========================================================= */

/* ---------- Fonts ---------- */
@font-face { font-family: "CMU Serif"; src: url("../fonts/cmu-serif-500-roman.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "CMU Serif"; src: url("../fonts/cmu-serif-500-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "CMU Serif"; src: url("../fonts/cmu-serif-700-roman.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "CMU Serif"; src: url("../fonts/cmu-serif-700-italic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "CMU Sans Serif"; src: url("../fonts/cmu-sans-serif-500-roman.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "CMU Sans Serif"; src: url("../fonts/cmu-sans-serif-700-roman.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --paper: #ffffff;
  --ink: #1d1d1f;
  --muted: #5d636e;
  --rule: #e2e4e9;

  --ultra: #1e3fae;        /* links and interactive things */
  --miro: #3164b4;         /* the painting's blue: ERC band */
  --miro-red: #c23f35;     /* the painting's red */
  --night: #1c1620;        /* the painting's black */
  --sky-tint: #e8eefa;     /* light-blue sections */
  --tint: #f3f5fb;         /* hover and boxes on white */

  --serif: "CMU Serif", "Latin Modern Roman", Georgia, "Times New Roman", serif;
  --sans: "CMU Sans Serif", "Latin Modern Sans", "Helvetica Neue", Arial, sans-serif;

  --gutter: 1.5rem;
  --header-h: 4.6rem;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.55;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }

h1, h2, h3, h4 { font-weight: 400; line-height: 1.2; margin: 0; text-wrap: balance; }
p { margin: 0 0 1em; }
figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

a {
  color: var(--ultra);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  text-decoration-skip-ink: none;
  text-decoration-color: color-mix(in srgb, var(--ultra) 35%, transparent);
}
a:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--ultra); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--miro-red); color: #fff; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--paper); padding: .5rem 1rem; }
.skip-link:focus { left: 1rem; top: 1rem; }

.wrap { max-width: 52rem; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Header (sticky) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-inner {
  max-width: 76rem; margin: 0 auto;
  padding: 0.9rem var(--gutter);
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.35rem 2rem; flex-wrap: wrap;
}
.brand { font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--miro-red); }
.site-nav { display: flex; gap: 1.6rem; }
.site-nav a {
  font-family: var(--sans); font-size: 1rem;
  color: var(--ink); text-decoration: none;
  padding: 0.25rem 0; border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--miro-red); }
.site-nav a.is-active { color: var(--ink); border-bottom-color: var(--miro-red); }

section[id] { scroll-margin-top: var(--header-h); }

/* ---------- Cover page: the painting with the name laid over it ---------- */
.cover-page { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.hero {
  /* How far the name starts to the left of the painting. The text switches
     from ink to white exactly at this distance, where the painting begins. */
  --out: clamp(12rem, 20vw, 18rem);
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem var(--gutter) 3rem;
}
.hero-art { padding-left: var(--out); }
.art-frame {
  position: relative;
  width: min(calc(100vw - 2 * var(--gutter) - var(--out)),
             calc((100svh - var(--header-h) - 8.5rem) * 4 / 3),
             58rem);
}
.art-frame img {
  display: block; width: 100%; height: auto;
  aspect-ratio: 4 / 3; object-fit: cover;
  background: var(--tint);
}
.hero-art figcaption {
  font-family: var(--sans); font-size: 0.85rem; color: var(--muted);
  text-align: right; margin-top: 0.6rem;
}
.hero.is-fallback figcaption { visibility: hidden; }

.hero-text {
  position: absolute; z-index: 2;
  left: calc(-1 * var(--out)); bottom: 1.4rem;
  white-space: nowrap;
}
.hero-name {
  font-size: calc(var(--out) * 0.26);
  line-height: 1.1;
  letter-spacing: -0.012em;
}
.hero-role {
  margin: 0.55rem 0 0;
  font-size: max(1.1rem, calc(var(--out) * 0.095));
  line-height: 1.5;
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero:not(.is-fallback) .hero-name,
  .hero:not(.is-fallback) .hero-role {
    background: linear-gradient(90deg, var(--ink) 0 var(--out), #fff var(--out) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}

/* ---------- Sections ---------- */
.section { padding: 6rem 0 5rem; }
.tinted { background: var(--sky-tint); --rule: #cdd8ee; --tint: #dde6f8; }
.section-title { font-size: 2.6rem; letter-spacing: -0.01em; margin-bottom: 2.2rem; width: fit-content; }
.section-title::before {
  content: ""; display: block;
  width: max(100%, 7rem); height: 6px; border-radius: 3px;
  background: var(--miro-red); margin-bottom: 1.1rem;
  transform-origin: left center;
}
.js .section-title::before { transform: scaleX(0); transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s; }
.js .section-title.in::before { transform: scaleX(1); }
.section-note { font-family: var(--sans); color: var(--muted); font-size: 1rem; margin: -1.4rem 0 2.2rem; }

.group-title {
  font-family: var(--sans); font-weight: 700; font-size: 1.35rem;
  color: var(--miro-red);
  margin: 3rem 0 0.5rem;
}
.group-title:first-of-type { margin-top: 0; }

/* ---------- Papers ---------- */
.paper {
  position: relative;
  padding: 1.35rem 1.1rem 1.3rem;
  margin: 0 -1.1rem;
  border-bottom: 1px solid var(--rule);
  border-radius: 3px;
  scroll-margin-top: calc(var(--header-h) + 1rem);
  transition: background-color 0.2s ease;
}
.paper:last-child { border-bottom: 0; }
.paper.has-panel { cursor: pointer; }
.paper.has-panel:hover { background: var(--tint); box-shadow: inset 3px 0 0 var(--miro-red); }

.paper-title { font-size: 1.3rem; line-height: 1.28; margin-bottom: 0.35rem; }
.paper-toggle {
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.paper.has-panel:hover .paper-toggle { color: var(--ultra); }

.paper-authors, .paper-venue { margin: 0 0 0.1rem; color: var(--muted); }
.paper-authors a { color: inherit; }
.paper-authors a:hover { color: var(--ultra); }
.paper-venue em { color: var(--ink); }

.paper-links {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0.25rem 1.3rem; margin-top: 0.55rem;
  font-family: var(--sans); font-size: 0.95rem;
}
.paper-hint {
  margin-left: auto;
  font-family: var(--sans); font-size: 0.95rem; color: var(--muted);
}
.paper.has-panel:hover .paper-hint { color: var(--miro-red); }

/* Without JavaScript the abstract simply shows under each paper */
.paper-more { margin-top: 1rem; }
.js .paper-more,
.js .panel-source { display: none; }

/* Abstract, set like LaTeX's abstract environment */
.abstract {
  font-size: 0.95em; line-height: 1.55;
  text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.abstract::before {
  content: "Abstract";
  display: block; text-align: center;
  font-weight: 700; font-size: 0.95em; margin-bottom: 0.45rem;
}
.abstract p:last-child { margin-bottom: 0; }

/* ---------- ERC band ---------- */
.band { background: var(--miro); color: #fff; }
.band a { color: #fff; }
.band-kicker {
  font-family: var(--sans); font-size: 1rem; color: rgba(255, 255, 255, 0.85);
  margin-bottom: 0.9rem;
}
.band-title { font-size: clamp(2rem, 4.2vw, 2.9rem); line-height: 1.15; max-width: 26ch; margin-bottom: 1.3rem; }
.band-lede { max-width: 40rem; font-size: 1.2rem; color: rgba(255, 255, 255, 0.93); }

.band-bars {
  display: grid; gap: 2rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 2.6rem;
}
.band-bars span {
  height: 6px; border-radius: 3px;
  background: var(--miro-red);
  transform-origin: left center;
}
.band-bars span:nth-child(2) { background: var(--night); }
.band-bars span:nth-child(3) { background: #fff; }
.js .band-bars span { transform: scaleX(0); transition: transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1); }
.js .band-bars span:nth-child(2) { transition-delay: 0.15s; }
.js .band-bars span:nth-child(3) { transition-delay: 0.3s; }
.js .band-bars.in span { transform: scaleX(1); }

.band-actions { margin: 2.8rem 0 0; }
.band-button {
  font-family: var(--sans); font-size: 1.02rem; font-weight: 700;
  color: #fff; background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.85); border-radius: 3px;
  padding: 0.7rem 1.2rem; cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.band-button:hover { background: #fff; color: var(--miro); }
.band :focus-visible { outline-color: #fff; }

/* ---------- Teaching ---------- */
.program {
  display: block; width: 100%; max-width: 44rem;
  margin-top: 3rem; padding: 1.4rem 1.6rem 1.3rem;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: var(--paper);
  border: 0; border-left: 6px solid var(--miro-red); border-radius: 0 4px 4px 0;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
.program:hover { box-shadow: 0 6px 24px -14px rgba(16, 24, 56, 0.45); }
.program:hover .program-title { color: var(--ultra); }
.program-role { display: block; font-family: var(--sans); font-weight: 700; font-size: 1.05rem; color: var(--miro-red); margin-bottom: 0.35rem; }
.program-title { display: block; font-size: 1.5rem; line-height: 1.25; transition: color 0.2s ease; }
.program-hint { display: block; margin-top: 0.7rem; font-family: var(--sans); font-size: 0.95rem; color: var(--ultra); }
.program-hint::after { content: " +"; color: var(--miro-red); font-weight: 700; }

/* Button-style link inside a side panel */
.panel-actions { margin-top: 1.6rem; }
.panel-button {
  display: inline-block;
  font-family: var(--sans); font-weight: 700; font-size: 1rem;
  color: #fff; background: var(--miro);
  padding: 0.7rem 1.25rem; border-radius: 3px;
  text-decoration: none;
}
.panel-button:hover { background: var(--ultra); color: #fff; }
.courses { display: grid; gap: 2.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.course-group .group-title { margin: 0 0 0.3rem; }
.course { padding: 1rem 0; border-top: 1px solid var(--rule); }
.course h4 { font-size: 1.25rem; margin-bottom: 0.3rem; }
.course p { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--muted); }
.course .paper-links { margin-top: 0.4rem; }

/* ---------- About: large photo beside the bio ---------- */
.about-section {
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  display: flex; align-items: center;
  padding: 4.5rem 0;
}
/* The photo sits on the right; the text runs beside it and, once the photo
   ends, continues underneath it across the full width */
.about {
  width: 100%; max-width: 60rem; margin: 0 auto; padding: 0 var(--gutter);
  display: flow-root;
}
.about.no-photo { max-width: 44rem; }
.about-photo { float: right; width: min(26rem, 42%); margin: 0.4rem 0 1.25rem 3.25rem; }
.about-text .section-title,
.about-text .interests { display: flow-root; }
/* Black-and-white cutout on a transparent background, shown whole */
.about-photo img { display: block; width: 100%; height: auto; }
.about-text p { font-size: 1.05em; }
.interests { padding-top: 1rem; border-top: 1px solid var(--rule); }

.contact {
  margin: 1.6rem 0 0;
  display: grid; grid-template-columns: max-content 1fr; gap: 0.55rem 1.5rem;
}
.contact dt { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); padding-top: 0.15rem; }
.contact dd { margin: 0; }
.cv-link { font-weight: 700; }

/* ---------- Footer ---------- */
.color-band { display: flex; height: 6px; }
.color-band span:nth-child(1) { flex: 3; background: var(--miro); }
.color-band span:nth-child(2) { flex: 1.4; background: var(--miro-red); }
.color-band span:nth-child(3) { flex: 0.8; background: var(--night); }
.footer-inner {
  max-width: 76rem; margin: 0 auto; padding: 1.6rem var(--gutter) 2.4rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 2rem;
  font-family: var(--sans); font-size: 0.9rem; color: var(--muted);
}
.footer-inner p { margin: 0; }

/* ---------- Side panel ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(16, 24, 56, 0.42);
  opacity: 0; transition: opacity 0.3s ease;
}
.scrim.open { opacity: 1; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(36rem, 100vw);
  background: var(--paper);
  box-shadow: -24px 0 60px -30px rgba(16, 24, 56, 0.55);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(102%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0.25, 1);
}
.panel.open { transform: translateX(0); }
.panel-bar {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.85rem 2rem;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-bottom: 1px solid var(--rule);
}
.panel-kind { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); }
.panel-close {
  font-family: var(--sans); font-size: 0.95rem; font-weight: 700;
  color: var(--ink); background: none; border: 1px solid var(--rule); border-radius: 3px;
  padding: 0.4rem 0.8rem; cursor: pointer;
}
.panel-close:hover { color: var(--ultra); border-color: var(--ultra); }
.panel-body { padding: 1.6rem 2rem 3.5rem; }
.panel-body .paper-title,
.panel-body .panel-title { font-size: 1.65rem; line-height: 1.22; margin-bottom: 0.6rem; }
.panel-body .paper-links { margin-bottom: 1.8rem; }
.panel-body .paper-more { display: block; margin: 0; }
.panel-body .abstract { font-size: 1rem; }
.panel-heading { font-weight: 700; font-size: 1.15rem; margin: 1.8rem 0 0.6rem; }
.panel-list { list-style: disc; padding-left: 1.2rem; }
.panel-list li { margin-bottom: 0.6rem; }
.panel-links li { margin-bottom: 0.4rem; }
.facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.25rem;
  margin: 0.5rem 0 0; padding: 1rem 1.1rem; background: var(--tint); border-radius: 4px;
}
.facts dt { font-family: var(--sans); font-size: 0.92rem; color: var(--muted); padding-top: 0.12rem; }
.facts dd { margin: 0; font-size: 1rem; }
.acknowledgement {
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--rule);
  font-size: 0.92rem; color: var(--muted);
}

/* ---------- Reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease, background-color 0.2s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Tablets ---------- */
@media (max-width: 60rem) {
  .about { column-gap: 2.5rem; }
}

/* ---------- Phones ---------- */
@media (max-width: 46rem) {
  :root { --gutter: 1.15rem; --header-h: 5.75rem; }
  body { font-size: 1.125rem; }

  .header-inner { padding: 0.7rem var(--gutter) 0.45rem; flex-direction: column; align-items: flex-start; }
  .brand { font-size: 1.25rem; }
  .site-nav { gap: 1.25rem; }
  .site-nav a { font-size: 1rem; display: inline-block; padding: 0.3rem 0; }

  /* Cover: painting edge to edge, name in white on its lower edge, title below */
  .hero { padding: 0 0 2.5rem; flex-direction: column; align-items: stretch; justify-content: flex-start; }
  .hero-art { padding-left: 0; width: 100%; position: relative; }
  .art-frame { width: 100%; }
  /* Phones: name, title and university all on the lower part of the painting;
     the caption just under the painting on the right */
  .hero-text {
    position: absolute; left: var(--gutter); right: var(--gutter); bottom: 0.85rem;
    white-space: normal;
  }
  .hero-name { font-size: clamp(2.3rem, 10.5vw, 2.9rem); margin: 0; }
  .hero-role { font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin: 0.3rem 0 0; }
  .hero-art figcaption { margin: 0.4rem var(--gutter) 0; text-align: right; font-size: 0.72rem; }
  .hero:not(.is-fallback) .hero-name { background: none; color: #fff; -webkit-text-fill-color: #fff; }
  .hero:not(.is-fallback) .hero-role { background: none; color: var(--ink); -webkit-text-fill-color: var(--ink); }

  .section { padding: 4rem 0 3.5rem; }
  .section-title { font-size: 2.15rem; margin-bottom: 1.6rem; }
  .section-note { margin-top: -1rem; }

  .paper { padding: 1.15rem 0.75rem 1.15rem; margin: 0 -0.75rem; }
  .paper-title { font-size: 1.22rem; }
  .paper-hint { margin-left: 0; }

  .band-lede { font-size: 1.08rem; }

  .courses { grid-template-columns: minmax(0, 1fr); gap: 2rem; }

  /* About: a small portrait beside the title, the bio below */
  .about-section { min-height: 0; display: block; padding: 2.6rem 0 3.5rem; }
  .about {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8.5rem;
    column-gap: 1rem; row-gap: 0; align-items: end;
  }
  .about.no-photo { grid-template-columns: minmax(0, 1fr); }
  .about-text { display: contents; }
  .about-text > * { grid-column: 1 / -1; }
  .about-text > .section-title { grid-column: 1; grid-row: 1; margin-bottom: 0; align-self: end; }
  .about-photo { float: none; width: auto; grid-column: 2; grid-row: 1; margin: 0; }
  .about-text > .section-title + p { margin-top: 1.6rem; }
  .contact { grid-template-columns: 1fr; gap: 0.1rem; }
  .contact dt { padding-top: 0.6rem; }
  .contact dt:first-child { padding-top: 0; }

  .band-bars { gap: 1rem; }
  .program { padding: 1.2rem 1.1rem; }
  .program-title { font-size: 1.3rem; }

  .panel-bar { padding: 0.75rem 1.15rem; }
  .panel-body { padding: 1.3rem 1.15rem 3rem; }
  .panel-body .paper-title, .panel-body .panel-title { font-size: 1.45rem; }
  .abstract { text-align: left; }
  .facts { grid-template-columns: 1fr; gap: 0.05rem; }
  .facts dt { padding-top: 0.5rem; }
  .facts dt:first-child { padding-top: 0; }
}

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .js .section-title::before, .js .band-bars span { transform: none; }
}
@media print {
  .site-header, .scrim, .panel, .band-actions, .paper-hint { display: none !important; }
  .js .paper-more { display: block; }
  .js .reveal { opacity: 1; transform: none; }
  .band { background: none; color: var(--ink); }
  .band a, .band-lede { color: var(--ink); }
}

.nb { white-space: nowrap; }

/* Without JavaScript the ERC details show inside the blue band */
html:not(.js) .band-actions { display: none; }
html:not(.js) .band .panel-source { margin-top: 2.5rem; }
html:not(.js) .band .facts { background: rgba(255, 255, 255, 0.1); }
html:not(.js) .band .facts dt,
html:not(.js) .band .acknowledgement { color: rgba(255, 255, 255, 0.78); }

/* The painting's three colours along the top of the page */
.site-header .color-band { height: 5px; }
@media (max-width: 46rem) {
  .group-title { font-size: 1.22rem; margin-top: 2.4rem; }
}

/* Phone cover: the sections listed under the painting */
.cover-index { display: none; }
@media (max-width: 46rem) {
  .cover-index { display: block; margin: 2.2rem var(--gutter) 0; border-top: 1px solid var(--rule); }
  .cover-index a {
    display: flex; align-items: center; gap: 0.9rem;
    padding: 0.85rem 0; border-bottom: 1px solid var(--rule);
    font-size: 1.45rem; color: var(--ink); text-decoration: none;
  }
  .cover-index a::before {
    content: ""; width: 1.4rem; height: 5px; border-radius: 3px; background: var(--miro-red); flex: none;
  }
  .cover-index a:nth-child(2)::before { background: var(--miro); }
  .cover-index a:nth-child(3)::before { background: var(--night); }
  .cover-index a:nth-child(4)::before { background: var(--miro-red); }
}
