/* =================================================================
   style.css: Maurizio Petrelli

   1. Colours         5. Hero               9. Books
   2. Base            6. Sections           10. Timelines
   3. Layout          7. About              11. Publications
   4. Navigation      8. Research, funding, 12. Contact, footer, utilities
                         REALISE and REALI3SE
   ================================================================= */


/* 1. COLOURS ------------------------------------------------------
   Basalt and pumice. Pages are light (pumice); any element with
   class="dark" switches to basalt: the navigation, the hero, the
   footer, and whichever <section> you mark in index.html.
   The hero figure reads --ink, --muted and --paper from wherever it
   sits, so it works on light or dark.
   ------------------------------------------------------------------ */

:root {
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --margin-col: 12.5rem;
  --measure: 40rem;

  /* Type scale: about 1.2 between steps, around an 18 px text size */
  --fs-meta: 0.8125rem;    /* 13 px: captions, dates, authors, footer */
  --fs-ui: 0.9375rem;      /* 15 px: navigation, links, buttons, tables */
  --fs-body: 1.125rem;     /* 18 px: running text and titles in lists */
  --fs-h3: 1.3125rem;      /* 21 px: headings inside sections, hero text */
  --fs-title: 1.625rem;    /* 26 px: book and project titles, years */
  --fs-h2: 2rem;           /* 32 px: section headings */

  /* Pumice: light pages */
  --paper: #F4F4F1;
  --paper-2: #E8E8E3;
  --ink: #1C2026;
  --muted: #575E67;
  --rule: #D8D8D2;
  --link: #2B5A88;

  /* Basalt: used inside class="dark" */
  --basalt: #1C2026;
  --basalt-2: #262B32;
  --basalt-ink: #F2F0EB;
  --basalt-muted: #A8AEB6;
  --basalt-rule: #343A43;
  --basalt-link: #9CC3EE;
}

.dark {
  --paper: var(--basalt);
  --paper-2: var(--basalt-2);
  --ink: var(--basalt-ink);
  --muted: var(--basalt-muted);
  --rule: var(--basalt-rule);
  --link: var(--basalt-link);
  background: var(--paper);
  color: var(--ink);
}


/* 2. BASE ---------------------------------------------------------- */

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

html {
  background: var(--paper);
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-body);
  line-height: 1.62;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures contextual;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
}

/* Light text on basalt looks heavier than dark text on pumice */
.dark {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Even line lengths: balanced headings, and no single word left alone
   on the last line of a paragraph */
h1, h2, h3, h4 {
  text-wrap: balance;
}

p, li, dd {
  text-wrap: pretty;
}

h1, h2, h3, p, ol, ul, dl, dd, figure {
  margin: 0;
}

ol, ul {
  padding: 0;
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--link);
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

/* Links to other websites: script.js adds the class "external", opens them
   in a new tab and wraps their last word in .external-tail, which draws the
   small box-and-arrow icon in the link's own colour. Keeping the last word
   and the icon together stops the icon from wrapping onto a line alone. */
.external-tail {
  white-space: nowrap;
}

.external-tail.long {
  white-space: normal;
}

.external-tail::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 0.3em;
  vertical-align: -0.12em;
  background-color: currentColor;
  opacity: 0.75;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 2.5H2.5v7h7V7'/%3E%3Cpath d='M7 1.75h3.25V5M10.25 1.75 5.5 6.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 2.5H2.5v7h7V7'/%3E%3Cpath d='M7 1.75h3.25V5M10.25 1.75 5.5 6.5'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

/* Smaller in the publication titles, where the type is larger */
.pub-year cite .external-tail::after {
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.28em;
  vertical-align: 0;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

.num {
  font-family: var(--sans);
  font-variant-numeric: lining-nums tabular-nums;
}


/* 3. LAYOUT -------------------------------------------------------- */

.wrap {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
}

.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: var(--fs-ui);
}

.skip-link:focus {
  top: 0.75rem;
}


/* 4. NAVIGATION ---------------------------------------------------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--rule);
}

.site-nav .wrap {
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 4rem;
}

.brand,
.brand:hover {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 1.4rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  font-family: var(--sans);
  font-size: var(--fs-ui);
}

.nav-links a {
  display: block;
  padding: 0.25rem 0;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a[aria-current="true"] {
  color: var(--ink);
}

.nav-links a[aria-current="true"] {
  text-decoration: underline;
  text-underline-offset: 0.4em;
}

@media (max-width: 760px) {
  .site-nav .wrap {
    flex-wrap: wrap;
    gap: 0;
    padding-top: 0.6rem;
    padding-bottom: 0.5rem;
  }

  .nav-links {
    width: 100%;
    margin-left: 0;
    padding-top: 0.35rem;
  }
}


/* 5. HERO ---------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
  min-height: calc(100vh - 4rem);
  padding-top: 3.5rem;
  padding-bottom: 4.5rem;
}

.hero h1 {
  font-size: clamp(3.1rem, 7vw, 5.6rem);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.hero h1 span {
  display: block;
}

.hero-role {
  margin-top: 1.4rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: var(--fs-h3);
  font-weight: 300;
  line-height: 1.4;
  font-style: italic;
}

.hero-lead {
  max-width: 31rem;
  margin-top: 1.4rem;
  font-size: var(--fs-h3);
  line-height: 1.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--ink);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: var(--fs-ui);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
}

.btn-solid,
.btn-solid:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-solid:hover {
  opacity: 0.88;
}

.btn-line,
.btn-line:hover {
  color: var(--ink);
}

.btn-line:hover {
  background: var(--rule);
}

.hero-figure canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  cursor: crosshair;
  touch-action: pan-y;
}

.hero-figure figcaption {
  max-width: 42rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  line-height: 1.5;
}

.figure-readout {
  min-height: 1.5em;
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: lining-nums;
}

.figure-note {
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    padding-top: 2.5rem;
  }
}


/* 6. SECTIONS ------------------------------------------------------
   Each <section class="section"> spans the full width; inside it,
   .section-grid puts the heading in a left margin column and the
   content on the right. Add "dark" to a section for a basalt band. */

.section-grid {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  gap: 3rem;
  padding-top: 5rem;
  padding-bottom: 5rem;
  border-top: 1px solid var(--rule);
}

/* No hairline where the colour already changes */
.section:first-child .section-grid,
.dark .section-grid,
.dark + .section .section-grid {
  border-top: 0;
}

/* Two dark sections in a row keep a hairline between them */
.dark + .dark .section-grid {
  border-top: 1px solid var(--rule);
}

.section-grid > h2 {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  font-size: var(--fs-h2);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

@media (max-width: 860px) {
  .section-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }

  .section-grid > h2 {
    position: static;
  }
}

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

.content-wide {
  max-width: 52rem;
}

.content > * + * {
  margin-top: 1.1rem;
}

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

h3 {
  font-size: var(--fs-h3);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.content > .sub {
  margin-top: 3rem;
  font-size: var(--fs-body);
  font-weight: 500;
}

.note {
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-ui);
  line-height: 1.55;
}

.content > .note {
  margin-top: 2.75rem;
}

/* Now */
.now-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3rem 2.5rem;
  max-width: 60rem;
}

/* First item: the lecture photograph beside its text, on the same two
   columns as the items below, so every edge lines up */
.now-feature {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2.5rem;
  align-items: start;
}

.now-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
}

.now-photo figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
}

@media (max-width: 760px) {
  .now-grid,
  .now-feature {
    grid-template-columns: minmax(0, 1fr);
  }
}

.now-grid p {
  margin-top: 0.6rem;
  font-size: var(--fs-body);
}

/* Latest news from the project websites, listed by script.js on the
   same two columns as the items above: date, title, then the project */
.now-news {
  grid-column: 1 / -1;
}

.news-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 2.5rem;
  margin-top: 1rem;
}

.news-list li {
  padding: 0.85rem 0 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: var(--fs-body);
  line-height: 1.45;
}

.news-list time,
.news-list .project {
  display: block;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
}

.news-list time {
  margin-bottom: 0.3rem;
}

.news-list .project {
  margin-top: 0.3rem;
}

@media (max-width: 760px) {
  .news-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-top: 0.9rem;
  font-family: var(--sans);
  font-size: var(--fs-ui);
}


/* 7. ABOUT: large portrait beside the biography ------------------- */

/* The text wraps around the portrait */
.about {
  display: flow-root;
  max-width: 48rem;
}

.portrait {
  float: left;
  width: min(20rem, 45%);
  margin: 0.4rem 2.25rem 1rem 0;
}

.portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 2px;
  background: var(--paper-2);
}

.portrait.is-missing img {
  display: none;
}

.portrait.is-missing::before {
  content: "Add portrait.jpg next to index.html";
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  padding: 1rem;
  background: var(--paper-2);
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-ui);
  text-align: center;
}

.about-text > * + * {
  margin-top: 1.1rem;
}

.facts {
  font-family: var(--sans);
  font-size: var(--fs-ui);
  line-height: 1.5;
}

.about-text > .facts {
  margin-top: 2.25rem;
}

.facts div {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
}

.facts dt {
  color: var(--muted);
}

@media (max-width: 600px) {
  .portrait {
    float: none;
    width: auto;
    max-width: 24rem;
    margin: 0 0 1.75rem;
  }
}

@media (max-width: 600px) {
  .facts div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.1rem;
  }
}


/* 8. RESEARCH AND FUNDING ------------------------------------------ */

.topic + .topic {
  margin-top: 3.25rem;
}

.topic p {
  margin-top: 0.75rem;
}

details {
  margin-top: 1rem;
}

summary {
  width: fit-content;
  color: var(--link);
  font-family: var(--sans);
  font-size: var(--fs-ui);
  font-weight: 500;
  cursor: pointer;
}

summary:hover {
  color: var(--ink);
}

.refs {
  margin-top: 0.9rem;
  font-family: var(--sans);
  font-size: var(--fs-ui);
  line-height: 1.5;
}

.refs li {
  padding: 0.55rem 0;
  border-top: 1px solid var(--rule);
}

.refs i {
  font-family: var(--serif);
  font-size: 1.07em;
}

.students {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.25rem 2rem;
}

.students strong {
  display: block;
  font-weight: 500;
}

.students span {
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-ui);
}

.grants {
  margin-top: 2rem;
}

.grant {
  display: grid;
  grid-template-columns: 6.25rem minmax(0, 1fr) 10.5rem;
  gap: 0.3rem 1.5rem;
  padding: 1.3rem 0;
  border-top: 1px solid var(--rule);
}

.grant:last-child {
  border-bottom: 1px solid var(--rule);
}

.grant .years {
  padding-top: 0.15rem;
  color: var(--muted);
  font-size: var(--fs-ui);
}

.grant h3 {
  font-size: var(--fs-body);
  line-height: 1.4;
}

.grant h3 b {
  font-weight: 600;
}

.grant p {
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  line-height: 1.5;
}

.grant .amount {
  padding-top: 0.15rem;
  font-size: var(--fs-ui);
  line-height: 1.45;
  text-align: right;
  font-variant-numeric: lining-nums proportional-nums;
}

.amount small {
  display: block;
  color: var(--muted);
  font-size: var(--fs-meta);
}

@media (max-width: 680px) {
  .grant {
    grid-template-columns: minmax(0, 1fr);
  }

  .grant .amount {
    text-align: left;
  }
}


/* REALISE AND REALI3SE (MSCA projects) ----------------------------- */

/* One project after the other, in a single column */
.projects {
  max-width: var(--measure);
  margin-top: 2.5rem;
}

.project + .project {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
}

.project h3 {
  font-size: var(--fs-title);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.project > p {
  margin-top: 0.9rem;
}

.project .facts {
  margin-top: 1.5rem;
}

.project .facts div {
  grid-template-columns: 9.5rem minmax(0, 1fr);
}

@media (max-width: 600px) {
  .project .facts div {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* 9. BOOKS --------------------------------------------------------- */

.book {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 1.75rem;
}

.content > .book + .book {
  margin-top: 3.25rem;
}

.book-year {
  padding-top: 0.2rem;
  color: var(--muted);
  font-size: var(--fs-h2);
  font-weight: 300;
  font-variant-numeric: lining-nums;
  line-height: 1;
}

.book h3 {
  font-size: var(--fs-title);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.subtitle {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: var(--fs-body);
  font-style: italic;
  font-weight: 400;
}

.book p {
  margin-top: 0.9rem;
}

.book .cite {
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  line-height: 1.5;
}

@media (max-width: 600px) {
  .book {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }

  .book-year {
    font-size: var(--fs-title);
  }
}


/* 10. TIMELINES (teaching, service) -------------------------------- */

.timeline li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
  font-size: var(--fs-body);
  line-height: 1.5;
}

.timeline .when {
  padding-top: 0.15rem;
  color: var(--muted);
  font-size: var(--fs-meta);
}

.timeline .where {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
}

.content > h3 + .timeline {
  margin-top: 1rem;
}

@media (max-width: 600px) {
  .timeline li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.1rem;
  }
}


/* 11. PUBLICATIONS ------------------------------------------------- */

.pub-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1.75rem;
}

.pub-search {
  flex: 1 1 18rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
}

.pub-search::placeholder {
  color: var(--muted);
}

.pub-search:focus {
  border-color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 1px var(--ink);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filters button {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-ui);
  cursor: pointer;
}

.filters button:hover {
  border-color: var(--ink);
}

.filters button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.count {
  margin-left: 0.3rem;
  opacity: 0.65;
  font-variant-numeric: lining-nums tabular-nums;
}

.pub-status {
  margin-top: 1.25rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
}

.pub-year {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1.5rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

.pub-year h3 {
  padding-top: 0.15rem;
  font-family: var(--serif);
  font-size: var(--fs-title);
  font-weight: 300;
  font-variant-numeric: lining-nums;
  line-height: 1;
  color: var(--muted);
}

.pub-year ol {
  display: grid;
  gap: 1rem;
}

.pub-year cite {
  display: block;
  font-size: var(--fs-body);
  font-style: normal;
  line-height: 1.45;
}

.pub-year cite a {
  color: var(--ink);
  text-decoration-color: var(--rule);
}

.pub-year cite a:hover {
  color: var(--link);
  text-decoration-color: currentColor;
}

.pub-year p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  line-height: 1.5;
}

.pub-year strong,
.pub-kind {
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 600px) {
  .pub-year {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }
}


/* 12. CONTACT, FOOTER, UTILITIES ----------------------------------- */

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 2rem 3rem;
  max-width: 52rem;
  margin-top: 2rem;
}

address {
  font-style: normal;
}

.contact-lines,
.link-list {
  font-family: var(--sans);
  font-size: var(--fs-ui);
  line-height: 1.8;
}

.contact-lines dt {
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.4;
}

.contact-lines dd + dt {
  margin-top: 0.6rem;
}

.site-footer {
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
