/*
  Luca Castaldo: site styles.
  index.html holds the content; this file only controls how it looks.

  Layout idea: a left "hanging" column carries the structure (name,
  section titles, CV dates); the text column to its right carries the content.
*/

/* ---------- Fonts (self-hosted, so no requests go to Google or other third parties) ---------- */

@font-face {
  font-family: "LM Roman 17";            /* Latin Modern: the Computer Modern of LaTeX */
  src: url("fonts/lmroman17-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pagella";                /* TeX Gyre Pagella: a Palatino */
  src: url("fonts/texgyrepagella-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pagella";
  src: url("fonts/texgyrepagella-italic.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  --paper: #ffffff;
  --ink: #1c1e21;
  --ink-soft: #5b616a;
  --accent: #1d4e89;
  --accent-line: rgba(29, 78, 137, 0.4);

  --display: "LM Roman 17", "Latin Modern Roman", "CMU Serif", Georgia, serif;
  --text: "Pagella", "TeX Gyre Pagella", "Palatino Linotype", Palatino, "Book Antiqua", serif;

  --hang: 9.75rem;   /* width of the hanging column */
  --gap: 2.25rem;
  --measure: 36rem;  /* width of the text column (about 65 characters) */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181c;
    --ink: #e6e4df;
    --ink-soft: #a3a8b0;
    --accent: #9cbdf0;
    --accent-line: rgba(156, 189, 240, 0.45);
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.125rem;
  line-height: 1.6;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--accent-line);
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection {
  background: var(--accent-line);
}

/* ---------- The two-column frame ---------- */

.band {
  display: grid;
  grid-template-columns: [hang-start] var(--hang) [hang-end text-start] minmax(0, var(--measure)) [text-end];
  column-gap: var(--gap);
  justify-content: center;
  padding-inline: 1.5rem;
}

.band > * {
  grid-column: text;
}

.band > .hang,
.band > .dated {
  grid-column: hang-start / text-end;
}

/* ---------- Header ---------- */

.masthead {
  padding-top: 5.5rem;
}

.masthead h1 {
  grid-row: 1;
  margin: 0 0 1.1rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 1.6rem + 2.4vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.005em;
}

.masthead nav {
  grid-row: 1;
  justify-self: end;
  align-self: start;
  display: flex;
  gap: 1.4rem;
  padding-top: 0.35rem;
  font-size: 1rem;
}

.masthead nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

.masthead nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: currentColor;
}

.role {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Sections ---------- */

main {
  padding-bottom: 6rem;
}

.intro {
  padding-top: 2.75rem;
}

.contact {
  margin-top: 1.25rem;
}

/* Space below the Email and Office lines (between them and the next line) */
.contact,
.office {
  margin-bottom: 0.35rem;
}

section {
  scroll-margin-top: 1.5rem;
}

h2 {
  margin: 4.75rem 0 0.5rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1.1;
}

h3 {
  margin: 2.25rem 0 1rem;
  font-family: var(--text);
  font-weight: 400;
  font-size: 1.4rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.07em;
  line-height: 1.4;
}

h2 + h3 {
  margin-top: 1.25rem;
}

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

/* ---------- Publications ---------- */

.pubs > li {
  margin-bottom: 1.2rem;
  line-height: 1.5;
}

.pubs cite {
  font-style: normal;
}

.details {
  display: block;
  margin-top: 0.1rem;
  font-size: 1rem;
  color: var(--ink-soft);
}

/* "Full CV available upon request" under the CV title */
.cv-note {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- CV: entries with dates in the hanging column ---------- */

.dated > li {
  display: grid;
  grid-template-columns: [hang-start] var(--hang) [hang-end text-start] minmax(0, var(--measure)) [text-end];
  column-gap: var(--gap);
  align-items: baseline;
  margin-bottom: 0.7rem;
  line-height: 1.5;
}

.when {
  grid-column: hang-start / hang-end;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-variant-numeric: oldstyle-nums tabular-nums;
  white-space: nowrap;
}

.what {
  grid-column: text-start / text-end;
}

.what ul {
  margin-top: 0.2rem;
}

.what a {
  white-space: nowrap;   /* keep names like Karl-Georg Niebergall on one line */
}

.grants > li {
  margin-bottom: 0.7rem;
  line-height: 1.5;
}

/* ---------- AXIOMS page ---------- */

.masthead h1 a {
  color: inherit;
  text-decoration: none;
}

.masthead nav a[aria-current="page"] {
  color: var(--ink);
}

.project h2 {
  margin-top: 3.5rem;
  text-align: center;
}

.subtitle {
  margin-bottom: 2.5rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* Extra space between the project description and the list below it */
.project > p + .dated,
.project > p + h3 {
  margin-top: 2rem;
}

.band > .subtitle {
  grid-column: hang-start / text-end;   /* centred across the full width, like the title */
  text-align: center;
  text-wrap: balance;
}

/* Project description: a block centred under the title, lines still left-aligned */
.project > p:not(.subtitle) {
  grid-column: hang-start / text-end;
  justify-self: center;
  width: 100%;
  max-width: 36rem;        /* 32 rem or so one gets narrower than the subtitle, so it is visibly inset on both sides */
  text-align: justify;     /* straight edges on both sides, like an abstract in LaTeX */
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Funding/Host/Duration list: text column lined up with the description above.
   The description is 36rem wide and centred in 48rem, so it starts 6rem in:
   4.5rem for the labels + 1.5rem gap = 6rem. */
.project .dated > li {
  grid-template-columns: [hang-start] 4.5rem [hang-end text-start] minmax(0, 36rem) [text-end];
  column-gap: 1.5rem;
}

/* Headings and publication list on the AXIOMS page: same centred 36rem column as the description */
.project > h3,
.project > .pubs {
  grid-column: hang-start / text-end;
  justify-self: center;
  width: 100%;
  max-width: 36rem;
}

/* "Publications" on the AXIOMS page: a section title hanging on the left, as on the main page */
.project h2.section {
  margin-top: 4.75rem;
  text-align: left;
}

.project h2.section + .pubs {
  margin-top: 1.5rem;
}

/* EU funding block: same centred 36rem column as the description */
.funding > div {
  grid-column: hang-start / text-end;
  justify-self: center;
  width: 100%;
  max-width: 36rem;
}

.funding {
  padding-bottom: 4rem;
}

.funding > div {
  padding-top: 2rem;
  border-top: 1px solid rgba(128, 128, 128, 0.3);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.funding img {
  display: block;
  height: 3rem;
  width: auto;
  margin-bottom: 1rem;
}

/* Placeholders still to be filled in: shown in yellow */
.todo {
  padding: 0 0.25em;
  border-radius: 2px;
  background: #fff1a8;
  color: #1c1e21;
}

/* ---------- Narrow screens: one column, dates above entries ---------- */

@media (max-width: 54rem) {
  .band {
    display: block;
    padding-inline: 1.25rem;
  }

  .masthead {
    padding-top: 2.75rem;
  }

  .masthead nav {
    justify-self: start;
    margin-top: 1.25rem;
    padding-top: 0;
  }

  .dated > li {
    display: block;
    margin-bottom: 1rem;
  }

  .when {
    display: block;
    white-space: normal;
  }

  h2 {
    margin-top: 3.5rem;
  }
}

/* ---------- Print ---------- */

@media print {
  :root {
    --paper: #fff;
    --ink: #000;
    --ink-soft: #333;
    --accent: #000;
  }

  body {
    font-size: 10.5pt;
  }

  .masthead {
    padding-top: 0;
  }

  .masthead nav {
    display: none;
  }

  a {
    text-decoration: none;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  li {
    break-inside: avoid;
  }
}
