/* =====================================================================================================
   Design D + Polo carried to the other tabs (2026-11-27). Loaded site-wide from _quarto.yml (css:).
   The home page and the Practical Notes pages (body.notes-page) are left out by their selectors.
   Pages are told apart with :has() on their own section ids, so no .qmd file had to change.
   Colours mirror the variables at the top of custom.scss; keep the two in step.
   ===================================================================================================== */
:root {
  --ink: #1E2C3E; --teal: #396780; --teal-d: #2B5068; --red: #B3212B; --steel: #556274;
  --pale-blue: #DCE7EE; --pale-red: #F6DEDC; --pale-grey: #E3E6EC;
  --shd: rgba(36, 36, 38, .22); --shd-hi: rgba(57, 103, 128, .42);
  --dots: repeating-linear-gradient(90deg, rgba(30, 44, 62, .32) 0 4px, transparent 4px 10px);
  --dots-v: repeating-linear-gradient(180deg, rgba(30, 44, 62, .30) 0 4px, transparent 4px 10px);
}

/* ---- every tab: titles, section headings, lead, table of contents ------------------------------- */
body:not(.notes-page) main.content:not(:has(.home)) #title-block-header {
  padding-bottom: .9rem; margin-bottom: 1.6rem;
  background: var(--dots) left bottom / 100% 4px no-repeat;
}
body:not(.notes-page) main.content:not(:has(.home)) #title-block-header .title::before {
  content: "niccolo.ink /"; display: block; margin-bottom: .2rem;
  font: 400 .7rem/1.4 "IBM Plex Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--steel);
}
body:not(.notes-page) main.content:not(:has(.home)) section.level2 > h2 {
  display: flex; align-items: center; gap: .6rem;
  border-bottom: 0; padding-bottom: .5rem; margin-top: 2.2rem;
  background: var(--dots) left bottom / 100% 4px no-repeat;
}
/* a snake bead (ring) before every section heading */
body:not(.notes-page) main.content:not(:has(.home)) section.level2 > h2::before {
  content: ""; flex: none; width: 10px; height: 10px; box-sizing: border-box;
  border: 2px solid var(--red); background: var(--pale-red);
}
body:not(.notes-page) main.content:not(:has(.home)) .lead {
  border-left: 4px solid var(--teal); padding: .15rem 0 .15rem 1rem;
}
body:not(.notes-page) #TOC .nav-link.active, body:not(.notes-page) #TOC a.active {
  color: var(--ink) !important; font-weight: 600;
  background: linear-gradient(var(--red), var(--red)) left center / 4px 4px no-repeat; padding-left: .7rem;
}
/* bead bullets for ordinary lists */
body:not(.notes-page) main.content:not(:has(.home)) section.level2 > ul,
body:not(.notes-page) main.content:not(:has(.home)) section.level3 > ul { list-style: none; padding-left: 1.2rem; }
body:not(.notes-page) main.content:not(:has(.home)) section.level2 > ul > li,
body:not(.notes-page) main.content:not(:has(.home)) section.level3 > ul > li { position: relative; margin: .35rem 0; }
body:not(.notes-page) main.content:not(:has(.home)) section.level2 > ul > li::before,
body:not(.notes-page) main.content:not(:has(.home)) section.level3 > ul > li::before {
  content: ""; position: absolute; left: -1.15rem; top: .55em; width: 8px; height: 8px; box-sizing: border-box;
  border: 2px solid var(--red);
}

/* ---- cards: hover lift everywhere, whole card clickable when it has one main link -------------- */
.course-card, .area, .offer-block, .selected-pub, .contact-route { transition: transform .1s steps(2), box-shadow .1s steps(2); }
.course-card:hover, .selected-pub:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shd-hi) !important; }
/* a "stretched" link: its ::after covers the whole card, so a tap anywhere on the card follows it */
.course-card a[href^="http"]::after,
.selected-pub a[href*="research.qmd"]::after, .selected-pub a[href*="research.html"]::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
}
.selected-pub a:not([href*="research"]) { position: relative; z-index: 2; }   /* the doi link stays its own target */

/* ---- Research ---------------------------------------------------------------------------------- */
main.content:has(#result-lce) { counter-reset: result; }
main.content:has(#result-lce) .result {
  counter-increment: result;
  background: #fff; border: 1.5px solid var(--ink); box-shadow: 3px 3px 0 var(--shd);
  padding: 1.2rem 1.4rem 1rem; margin: 0 0 1.6rem; border-top: 1.5px solid var(--ink);
}
main.content:has(#result-lce) .result h3::before {
  content: "Result " counter(result, decimal-leading-zero); display: block; margin-bottom: .3rem;
  font: 400 .7rem/1.4 "IBM Plex Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--red);
}

/* ---- Teaching ---------------------------------------------------------------------------------- */
main.content:has(#current-courses) .course-card { padding-top: 0; overflow: visible; }
main.content:has(#current-courses) .course-card::before {
  content: "Course · 2026/27"; display: block; margin: 0 -1.25rem .8rem; padding: .3rem 1.25rem;
  background: var(--pale-blue); border-bottom: 1.5px solid var(--ink);
  font: 400 .7rem/1.4 "IBM Plex Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-d);
}
main.content:has(#current-courses) .course-card a[href^="http"] { font-weight: 600; }

/* ---- Industrial collaboration ------------------------------------------------------------------ */
main.content:has(.area-grid) .area { padding-top: 0; }
main.content:has(.area-grid) .area::before {
  content: ""; display: block; height: 10px; margin: 0 -1.25rem .9rem; border-bottom: 1.5px solid var(--ink);
}
main.content:has(.area-grid) .area:nth-child(3n+1)::before { background: var(--pale-blue); }
main.content:has(.area-grid) .area:nth-child(3n+2)::before { background: var(--pale-red); }
main.content:has(.area-grid) .area:nth-child(3n+3)::before { background: var(--pale-grey); }
main.content:has(.area-grid) { counter-reset: offer; }
main.content:has(.area-grid) .offer-block {
  counter-increment: offer; display: grid; grid-template-columns: 3rem 1fr; column-gap: 1rem;
}
main.content:has(.area-grid) .offer-block > * { grid-column: 2; }
main.content:has(.area-grid) .offer-block::before {
  content: counter(offer, decimal-leading-zero); grid-column: 1; grid-row: 1 / span 20; align-self: start;
  font: 400 1.6rem/1 "IBM Plex Mono", monospace; color: var(--teal); padding-top: .1rem;
}
.contact-cta {
  border: 1.5px solid var(--ink) !important; border-left-width: 1.5px !important; background: var(--pale-red) !important;
  box-shadow: 3px 3px 0 var(--shd);
}

/* ---- Publications ------------------------------------------------------------------------------ */
main.content:has(#pub-list) { counter-reset: sel; }
main.content:has(#pub-list) .selected-pub { counter-increment: sel; padding-left: 3.6rem; }
main.content:has(#pub-list) .selected-pub::before {
  content: counter(sel, decimal-leading-zero); position: absolute; left: 1.1rem; top: 1rem;
  font: 400 1.3rem/1 "IBM Plex Mono", monospace; color: var(--teal);
}
.topic-chip { box-shadow: 2px 2px 0 var(--shd); font-family: "IBM Plex Mono", monospace; font-size: .74rem !important; letter-spacing: .03em; }
.topic-chip[aria-pressed="true"] { background: var(--ink) !important; color: #fff !important; border-color: var(--ink) !important; }
/* each row of the full list: tap anywhere on it to open the paper */
.pub { position: relative; padding-left: .6rem !important; padding-right: .6rem !important; transition: background .1s steps(2); }
.pub:hover { background: rgba(220, 231, 238, .45); }
.pub .pub-title a::after { content: ""; position: absolute; inset: 0; }
.pub a:not(.pub-title a) { position: relative; z-index: 1; }

/* ---- Contact ----------------------------------------------------------------------------------- */
main.content:has(.contact-routes) .contact-route { padding-top: 0; }
main.content:has(.contact-routes) .contact-route h4 {
  margin: 0 -1.25rem .8rem !important; padding: .45rem 1.25rem; border-bottom: 1.5px solid var(--ink);
}
#students h4 { background: var(--pale-blue); }
#research h4 { background: var(--pale-red); }
#industry h4 { background: var(--pale-grey); }

/* ---- Public engagement and CV: a dotted timeline ----------------------------------------------- */
main.content:has(#for-the-public) section.level3,
main.content:has(#positions) section.level2 > p:has(> strong:first-child) {
  position: relative; padding-left: 1.4rem;
  background: var(--dots-v) 4px 0 / 4px 100% no-repeat;
}
main.content:has(#for-the-public) section.level3 > h3::before,
main.content:has(#positions) section.level2 > p:has(> strong:first-child)::before {
  content: ""; position: absolute; left: 0; top: .45em; width: 12px; height: 12px; box-sizing: border-box;
  border: 2px solid var(--ink); background: var(--pale-blue);
}
main.content:has(#positions) section.level2 > p:has(> strong:first-child) { margin-bottom: 1.1rem; }
