:root {
  --bg: #F7F3EA; --fg: #14302A; --fg2: #2F3F3A; --muted: #5E6B64;
  --gold: #9C7A3C; --gold-light: #D9BC82; --line: #DDD3C0; --forest: #14302A;
  --underline: rgba(156, 122, 60, .45);
}
/* Night mode */
:root[data-theme="dark"] {
  --bg: #0F1D18; --fg: #F1EBDD; --fg2: #D2CBBB; --muted: #9AA59E;
  --gold: #D9BC82; --line: #2A3D36; --forest: #0A1511;
  --underline: rgba(217, 188, 130, .45);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg2);
  font: 400 16.5px/1.8 "Source Sans 3", sans-serif; -webkit-font-smoothing: antialiased;
  display: grid; grid-template-columns: 380px 1fr; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
b { font-weight: 600; color: var(--fg); }
.i { width: 18px; height: 18px; flex: none; }
.caps { font-size: 11px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); }

/* Sidebar */
.side {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  background: var(--forest); color: #EFE6D2; padding: clamp(18px, 5vh, 52px) 44px clamp(14px, 3.5vh, 36px);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.portrait { width: clamp(84px, 19vh, 190px); height: clamp(84px, 19vh, 190px); border-radius: 50%; overflow: hidden; outline: 1px solid var(--gold-light); outline-offset: 8px; flex: none; }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }
.side h1 { font-weight: 300; font-size: clamp(27px, 3.8vh, 38px); line-height: 1.15; color: #FBF7EE; margin: clamp(14px, 3.4vh, 34px) 0 clamp(4px, 1vh, 10px); }
.side .caps { color: var(--gold-light); }
.orn { color: var(--gold-light); letter-spacing: .9em; padding-left: .9em; font-size: 10px; margin-top: clamp(6px, 1.4vh, 14px); }
.menu { margin-top: clamp(12px, 3.4vh, 34px); width: 100%; text-align: left; }
.menu a { display: flex; align-items: center; gap: 16px; padding: clamp(5px, 1.2vh, 12px) 6px; border-top: 1px solid rgba(217, 188, 130, .22);
  font-size: clamp(15px, 1.7vh, 17px); color: #FBF7EE; transition: color .25s, padding-left .25s; }
.menu a .i { color: var(--gold-light); }
.menu a:hover { color: var(--gold-light); padding-left: 12px; }
.menu a.on { color: var(--gold-light); }
.social { margin-top: auto; padding-top: clamp(10px, 3vh, 30px); display: flex; gap: 12px; }
.social a { width: clamp(34px, 4.2vh, 42px); height: clamp(34px, 4.2vh, 42px); border: 1px solid rgba(217, 188, 130, .45); border-radius: 50%;
  display: grid; place-items: center; color: var(--gold-light); transition: .25s; }
.social a:hover { background: var(--gold-light); color: var(--forest); }

/* Content */
.content { display: flex; flex-direction: column; min-height: 100vh; padding: 80px 96px 0; }
main { flex: 1; max-width: 680px; }
.page { animation: rise .7s ease both; }
.page[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
h2 { font-weight: 300; font-size: 56px; line-height: 1.1; color: var(--fg); margin: 0 0 30px; }
p { margin: 0 0 16px; }
.just { text-align: justify; }
.link { border-bottom: 1px solid var(--underline); transition: border-color .25s; }
.link:hover { border-color: var(--gold); }
.block { margin-top: 46px; }
.block .caps { display: block; margin-bottom: 14px; font-size: 15.5px; letter-spacing: .24em; }

.news-list { max-height: 290px; overflow-y: auto; border-bottom: 1px solid var(--line); padding-right: 10px;
  scrollbar-width: thin; scrollbar-color: var(--gold-light) transparent; }
.news-list::-webkit-scrollbar { width: 4px; }
.news-list::-webkit-scrollbar-thumb { background: var(--gold-light); border-radius: 4px; }
.news .row:first-child { border-top-color: var(--line); }
.news .row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.news .row span:first-child { color: var(--gold); font-weight: 500; }

.logos { display: flex; align-items: center; flex-wrap: wrap; gap: 44px; }
.logos img { height: var(--h); width: auto; object-fit: contain; mix-blend-mode: multiply;
  filter: grayscale(1); opacity: .7; transition: filter .35s, opacity .35s; }
.logos a:hover img { filter: none; opacity: 1; }

.note { color: var(--muted); margin-top: -14px; }
.note a { color: var(--gold); }
.pub { display: grid; grid-template-columns: 70px 1fr; gap: 20px; padding: 24px 0; border-top: 1px solid var(--line); }
.pub:last-child { border-bottom: 1px solid var(--line); }
.pub .year { font-size: 22px; font-weight: 300; color: var(--gold); }
.pub h3, .entry h3 { font-weight: 500; font-size: 19px; line-height: 1.4; color: var(--fg); margin: 0 0 6px; }
.pub .authors, .pub .venue { margin: 0; font-size: 15.5px; }
/* Logos are sized by visual area, not equal height, since the source files differ in shape;
   Lyon's file also has white margins (~20% of its height), so it is scaled up and the margin cropped. */
.lg-unige { --h: 37px; }
.lg-bell { --h: 48px; }
.lg-polimi { --h: 39px; }
.lg-lyon { --h: 59px; margin: -6px 0; }
.entry > img.lg-lyon { margin: -1px 0; }
.pub .authors b { border-bottom: 1px solid var(--underline); }
.pub .venue { font-style: italic; color: var(--muted); }
.pub .more { margin-top: 8px; display: flex; gap: 18px; align-items: center; }
.pub .more span { font-size: 13px; color: var(--muted); }
.pub .more a { font-size: 11px; font-weight: 600; letter-spacing: .25em; text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--gold); }

.entry { display: grid; grid-template-columns: 100px 1fr; gap: 24px; padding: 24px 0; border-top: 1px solid var(--line); align-items: start; }
.entry:last-child { border-bottom: 1px solid var(--line); }
.entry > img { height: calc(var(--h) * .75); width: auto; max-width: 100px; margin-top: 4px; object-fit: contain; mix-blend-mode: multiply; filter: grayscale(1); opacity: .75; transition: .35s; }
.entry:hover > img { filter: none; opacity: 1; }
.entry .row { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.entry h3 { margin: 0; }
.entry .when { color: var(--gold); font-weight: 500; font-size: 15px; white-space: nowrap; }
.entry .where { color: var(--muted); font-size: 15px; }
.entry p { margin: 6px 0 0; font-size: 15.5px; }

.plain { list-style: none; padding: 0; margin: 0; }
.plain { border-top: 1px solid var(--line); padding-top: 4px; }
.plain li { padding: 8px 0 8px 22px; position: relative; }
.plain li::before { content: ""; position: absolute; left: 4px; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.plain .item { display: block; font-weight: 500; color: var(--fg); }
.plain .detail { display: block; color: var(--muted); font-size: 15.5px; }
.plain .meta { color: var(--muted); font-weight: 400; font-size: 15.5px; margin-left: 4px; }
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; border: 1px solid var(--gold); color: var(--gold);
  font-size: 11px; font-weight: 600; letter-spacing: .28em; text-transform: uppercase; transition: .25s; }
.btn:hover { background: var(--gold); color: var(--bg); }
.cv-frame { width: 100%; height: 80vh; border: 1px solid var(--line); margin-top: 24px; background: #fff; }

footer { max-width: 680px; margin-top: 70px; padding: 22px 0 28px; border-top: 1px solid var(--line);
  font-size: 13px; letter-spacing: .06em; color: var(--muted); }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 40px 24px 28px; }
  .portrait { width: 150px; height: 150px; }
  .side h1 { font-size: 32px; margin-top: 26px; }
  .menu { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 26px; }
  .menu a { border: 1px solid rgba(217, 188, 130, .3); border-radius: 999px; padding: 6px 14px; font-size: 15px; gap: 8px; }
  .menu a:hover { padding-left: 14px; }
  .social { margin-top: 22px; padding-top: 0; }
  .content { padding: 44px 22px 0; }
  h2 { font-size: 44px; }
  .just { text-align: left; }
  .news .row, .pub, .entry { grid-template-columns: 1fr; gap: 6px; }
  .logos { gap: 28px; }
}

/* Home and night/day buttons */
.tools { position: fixed; top: 22px; right: 26px; z-index: 20; display: flex; gap: 10px; }
.tools a, .tools button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--bg); color: var(--gold); border: 1px solid var(--line); padding: 0; transition: .25s; }
.tools a:hover, .tools button:hover { border-color: var(--gold); background: var(--gold); color: var(--bg); }
.tools .sun { display: none; }
:root[data-theme="dark"] .tools .sun { display: block; }
:root[data-theme="dark"] .tools .moon { display: none; }
body, .side, .tools a, .tools button { transition: background-color .35s, color .35s, border-color .35s; }

/* Logos on the dark background: inverted gray; on hover inverted back to approximate colour */
:root[data-theme="dark"] .logos img, :root[data-theme="dark"] .entry > img { mix-blend-mode: screen; filter: grayscale(1) invert(1); opacity: .75; }
:root[data-theme="dark"] .logos a:hover img, :root[data-theme="dark"] .entry:hover > img { filter: invert(1) hue-rotate(180deg); opacity: 1; }
:root[data-theme="dark"] .side { border-right: 1px solid var(--line); }
:root[data-theme="dark"] .btn:hover { color: var(--bg); }

@media (max-width: 900px) {
  .tools { position: absolute; top: 14px; left: 14px; right: 14px; justify-content: space-between; pointer-events: none; }
  .tools a, .tools button { pointer-events: auto; width: 36px; height: 36px; }
}

/* Certificates */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 30px; }
.filters button { font: inherit; font-size: 13px; letter-spacing: .04em; padding: 6px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--fg2); transition: .25s; }
.filters button:hover { border-color: var(--gold); color: var(--gold); }
.filters button.on { background: var(--gold); border-color: var(--gold); color: var(--bg); }
.certs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px 22px; }
.cert { margin: 0; }
.cert[hidden] { display: none; }
.cert .frame { display: block; width: 100%; aspect-ratio: 4 / 3; padding: 10px; cursor: zoom-in; position: relative;
  background: #FBF8F1; border: 1px solid var(--gold); outline: 1px solid var(--gold); outline-offset: -7px;
  box-shadow: 0 10px 26px -18px rgba(20, 48, 42, .55); transition: transform .3s, box-shadow .3s; }
.cert .frame::before, .cert .frame::after { content: "◆"; position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 9px; line-height: 1; color: var(--gold); background: var(--bg); padding: 0 6px; }
.cert .frame::before { top: -5px; }
.cert .frame::after { bottom: -5px; }
.cert .frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cert .frame:hover { transform: translateY(-3px); box-shadow: 0 18px 32px -18px rgba(20, 48, 42, .6); }
.cert figcaption { margin-top: 14px; text-align: center; }
.cert .ct { display: block; font-weight: 500; font-size: 15px; color: var(--fg); line-height: 1.4; }
.cert .cm { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 18, 15, .86); display: grid; place-items: center;
  padding: 28px; animation: rise .3s ease both; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 14px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; background: #fff;
  border: 1px solid var(--gold-light); outline: 1px solid var(--gold-light); outline-offset: 6px; margin: 7px; }
.lightbox figcaption { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; color: #F1EBDD; }
.lb-title { font-size: 17px; }
.lb-actions { display: flex; gap: 10px; }
.lightbox .btn { color: var(--gold-light); border-color: var(--gold-light); background: transparent; font-family: inherit; cursor: pointer; }
.lightbox .btn:hover { background: var(--gold-light); color: #0A1511; }
:root[data-theme="dark"] .cert .frame { background: #F4EFE4; }

@media (max-width: 1100px) {
  .certs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .certs { grid-template-columns: 1fr; }
  .lightbox { padding: 14px; }
}

/* Collaboration note (About page) */
.collab { display: flex; align-items: center; gap: 18px; margin-top: 40px; padding: 18px 22px;
  border: 1px solid var(--line); border-left: 3px solid var(--gold); background: rgba(156, 122, 60, .06); }
.collab-icon { width: 30px; height: 30px; flex: none; color: var(--gold); }
.collab p { margin: 0; color: var(--fg); }

/* Very short screens: compact sidebar so it never needs to scroll */
@media (min-width: 901px) and (max-height: 700px) {
  .orn { display: none; }
  .portrait { width: 72px; height: 72px; outline-offset: 5px; }
  .side h1 { font-size: 24px; margin: 12px 0 4px; }
  .menu { margin-top: 10px; }
  .menu a { padding: 4px 6px; font-size: 14.5px; }
  .social { padding-top: 8px; }
}
