/* =====================================================================
   Giovanni Borraccia — personal site
   Palette: warm paper & deep emerald
   ===================================================================== */

:root {
  --bg:        #FBFBFC;   /* cool near-white */
  --bg-alt:    #F2F3F5;   /* card / panel */
  --surface:   #FFFFFF;
  --ink:       #16181D;   /* near-black — primary text */
  --ink-soft:  #565A61;   /* secondary text */
  --ink-faint: #8B9098;   /* meta / captions */
  --gold:      #16181D;   /* "accent" is ink — monochrome */
  --gold-deep: #000000;
  --line:      #E4E6E9;   /* hairlines */
  --line-soft: #EEF0F2;

  --maxw:  960px;         /* wide band (hero, nav, sections align to this) */
  --measure: 44em;        /* readable text column cap */
  --pad: clamp(1.25rem, 5vw, 2.5rem);
  --gutter: max(var(--pad), calc((100% - var(--maxw)) / 2));
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --shadow: 0 1px 2px rgba(35,39,44,.05), 0 10px 30px rgba(35,39,44,.07);
}

[data-theme="dark"] {
  --bg:        #0E0F12;
  --bg-alt:    #16181C;
  --surface:   #16181C;
  --ink:       #F0F1EF;
  --ink-soft:  #A9ADB2;
  --ink-faint: #71767C;
  --gold:      #F0F1EF;
  --gold-deep: #FFFFFF;
  --line:      #24272C;
  --line-soft: #1B1E22;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 36px rgba(0,0,0,.45);
}

/* ------------------------------- reset ------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}
a { color: inherit; }
img { max-width: 100%; }

/* -------------------------------- nav -------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .85rem var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav__brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}
.nav__links { display: flex; gap: 1.35rem; }
.nav__links a {
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  position: relative;
  transition: color .2s ease;
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -4px;
  width: 0; height: 2px;
  background: var(--gold);
  transition: width .22s ease;
}
.nav__links a:hover { color: var(--ink); }
.nav__links a:hover::after { width: 100%; }

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: border-color .2s, color .2s, transform .2s;
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold); transform: rotate(20deg); }

/* -------------------------------- hero ------------------------------- */
.hero {
  padding: clamp(3rem, 7vw, 5.5rem) var(--gutter) clamp(1.75rem, 4vw, 2.75rem);
  display: grid;
  grid-template-columns: 1fr clamp(220px, 26vw, 300px);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.hero__eyebrow {
  display: flex;
  align-items: center;
  gap: .8rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin: 0 0 1.1rem;
}
.hero__eyebrow::before {
  content: "";
  width: 34px;
  height: 2px;
  background: var(--gold);
  flex: none;
}
.hero__name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.8rem, 7vw, 4.4rem);
  line-height: 1.0;
  letter-spacing: -.02em;
  margin: 0 0 1.5rem;
}
.hero__tagline {
  font-size: clamp(1.05rem, 2.4vw, 1.28rem);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 32em;
  margin: 0 0 1.9rem;
}
.hero__tagline strong { color: var(--ink); font-weight: 600; }
.hero__tagline a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
.hero__figure { margin: 0; }
.hero__figure img {
  display: block;
  width: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.hero__links { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn {
  font-family: var(--sans);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  padding: .62rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .2s, background .2s, transform .12s;
}
.btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn--primary:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }

/* --------------------------- announcement ---------------------------- */
.announce {
  padding: 0 var(--gutter) clamp(2rem, 5vw, 3.25rem);
}
.announce__inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 6%, var(--surface));
}
.announce__dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 18%, transparent);
}
.announce p { margin: 0; color: var(--ink-soft); font-size: .92rem; line-height: 1.5; }
.announce strong { color: var(--ink); font-weight: 600; }

/* ------------------------------ sections ----------------------------- */
.section {
  padding: clamp(2.5rem, 6vw, 4rem) var(--gutter);
  border-top: 1px solid var(--line);
}
.section__head {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  margin-bottom: 1.8rem;
}
.section__num {
  font-family: var(--serif);
  font-size: .95rem;
  color: var(--ink-faint);
  font-weight: 600;
}
.section__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -.01em;
  margin: 0;
}
.subhead {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 2.6rem 0 1.1rem;
}

.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.15rem; color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose p:last-child { margin-bottom: 0; }

/* ------------------------------- papers ------------------------------ */
.paper { padding: 1.4rem 0; border-bottom: 1px solid var(--line-soft); max-width: var(--measure); }
.paper:last-child { border-bottom: none; }

/* click-to-open abstracts */
.paper__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  cursor: pointer;
  list-style: none;
}
.paper__summary::-webkit-details-marker { display: none; }
.paper__head { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.paper__chevron {
  flex: none;
  width: 9px; height: 9px;
  margin-top: .55rem;
  border-right: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  transform: rotate(45deg);
  transition: transform .22s ease, border-color .22s ease;
}
.paper[open] .paper__chevron { transform: rotate(-135deg); }
.paper__summary:hover .paper__chevron { border-color: var(--ink); }
.paper__summary:hover .paper__title { color: var(--ink-soft); }
.paper__cue {
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.paper[open] .paper__cue { visibility: hidden; }
.paper__reveal { padding-top: 1rem; }
.paper--featured {
  max-width: var(--measure);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.6rem 1.7rem 1.6rem 2rem;
  box-shadow: var(--shadow);
  position: relative;
}
.paper--featured::before {
  content: "";
  position: absolute;
  left: 0; top: 1.6rem; bottom: 1.6rem;
  width: 3px;
  border-radius: 3px;
  background: var(--gold);
}
.paper__flag {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}
.paper__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.28rem;
  line-height: 1.25;
  margin: 0;
  transition: color .2s ease;
}
.paper__meta { font-size: .88rem; color: var(--ink-faint); margin: 0; }
.paper__abstract { color: var(--ink-soft); margin: 0 0 1rem; font-size: .97rem; }
.paper__links { display: flex; flex-wrap: wrap; gap: .5rem; }

.link-pill {
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  padding: .3rem .75rem;
  border-radius: 100px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  transition: border-color .2s, color .2s;
}
.link-pill:hover { border-color: var(--gold); color: var(--gold-deep); }

/* ------------------------------ timeline ----------------------------- */
.cv__download { margin: 0 0 1rem; }
.timeline { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.timeline__item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 1.2rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.timeline__item:last-child { border-bottom: none; }
.timeline__date {
  font-size: .84rem;
  font-weight: 500;
  color: var(--ink-faint);
  padding-top: .1rem;
  font-variant-numeric: tabular-nums;
}
.timeline__date em { font-style: normal; opacity: .8; }
.timeline__item--org .timeline__body { display: flex; gap: 1.25rem; align-items: flex-start; }
.orglogo {
  flex: none;
  width: 106px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.orglogo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: grayscale(1) opacity(.68);
  transition: filter .25s ease;
}
.timeline__item--org:hover .orglogo img { filter: grayscale(0) opacity(1); }
[data-theme="dark"] .orglogo img { filter: grayscale(1) invert(1) opacity(.82); }
[data-theme="dark"] .timeline__item--org:hover .orglogo img { filter: grayscale(1) invert(1) opacity(1); }
.orglogo--text {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: .04em;
  color: var(--ink-faint);
  transition: color .25s ease;
}
.timeline__item--org:hover .orglogo--text { color: var(--ink); }
.timeline__detail { min-width: 0; }
.timeline__role { font-weight: 600; margin: 0 0 .1rem; }
.timeline__org { color: var(--ink-soft); margin: 0; font-size: .95rem; }
.timeline__note { color: var(--ink-faint); margin: .35rem 0 0; font-size: .9rem; line-height: 1.5; }

/* ------------------------------- skills ------------------------------ */
.skills { max-width: var(--measure); }
.skills p { margin: 0 0 .7rem; color: var(--ink-soft); font-size: .95rem; }
.skills__label {
  display: inline-block;
  min-width: 118px;
  font-weight: 600;
  color: var(--ink);
  font-size: .82rem;
  letter-spacing: .02em;
}

/* ----------------------------- publications -------------------------- */
.pubs { list-style: none; counter-reset: pub; margin: 0; padding: 0; max-width: var(--measure); }
.pubs__item {
  position: relative;
  padding: 1.1rem 0 1.1rem 2.2rem;
  border-bottom: 1px solid var(--line-soft);
  counter-increment: pub;
}
.pubs__item:last-child { border-bottom: none; }
.pubs__item::before {
  content: counter(pub);
  position: absolute;
  left: 0; top: 1.15rem;
  font-family: var(--serif);
  font-size: .9rem;
  color: var(--gold);
  font-weight: 600;
}
.pubs__title { font-weight: 600; margin: 0 0 .3rem; line-height: 1.35; }
.pubs__cite { color: var(--ink-soft); font-size: .92rem; margin: 0 0 .6rem; }
.pubs__links { margin: 0; }

/* ------------------------------ contact ------------------------------ */
.contact { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.6rem 2rem; max-width: 720px; }
.contact__col { min-width: 0; }
.contact__label {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 .4rem;
}
.contact__col p { margin: 0; color: var(--ink-soft); line-height: 1.6; overflow-wrap: anywhere; }
.contact__col a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; overflow-wrap: anywhere; }

/* ------------------- reading-position rail --------------------------- */
.rail { display: none; }
@media (min-width: 1140px) {
  .rail {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    left: clamp(1.25rem, calc((100vw - var(--maxw)) / 2 - 44px), 4.5rem);
    z-index: 40;
  }
}
.rail a {
  display: flex;
  align-items: center;
  gap: .8rem;
  height: 12px;
  text-decoration: none;
}
/* the tick */
.rail a::before {
  content: "";
  flex: none;
  width: 16px;
  height: 1.5px;
  background: var(--ink-faint);
  opacity: .45;
  transition: width .25s ease, background .25s ease, opacity .25s ease;
}
/* the label — hidden unless active or hovered */
.rail a::after {
  content: attr(data-label);
  white-space: nowrap;
  font-family: var(--sans);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .25s ease, transform .25s ease, color .25s ease;
}
.rail a:hover::before,
.rail a.is-active::before {
  width: 30px;
  background: var(--ink);
  opacity: 1;
}
.rail a:hover::after,
.rail a.is-active::after {
  opacity: 1;
  transform: none;
  color: var(--ink);
}

/* ------------------------------- footer ------------------------------ */
.footer {
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  color: var(--ink-faint);
}
.footer a { color: var(--ink-faint); text-decoration: none; }
.footer a:hover { color: var(--gold); }

/* ---------------------------- responsive ----------------------------- */
@media (max-width: 720px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
  }
  .hero__figure { order: -1; justify-self: start; width: 128px; }
  .nav__brand { font-size: .95rem; }
  .nav__links { gap: .9rem; }
  .nav__links a { font-size: .72rem; }
  .timeline__item { grid-template-columns: 1fr; gap: .3rem; }
  .timeline__date { padding-top: 0; }
  .announce__inner { align-items: flex-start; flex-direction: column; gap: .6rem; }
}
@media (max-width: 420px) {
  .nav { gap: .6rem; }
  .nav__links { display: none; }
}

/* ------------------------- reveal on scroll -------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(14px); }
  .reveal.is-visible { opacity: 1; transform: none; transition: opacity .6s ease, transform .6s ease; }
}
