/* Francesco Picella — personal site. Dark, single page, content first.
   Layout: centred column (62rem), round portrait + name on top, anchor nav, sections with figure/text rows.
   Accent: a "plasma" colormap ramp (the colormap of every plot on this site). */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --fg: #e8e7e3;
  --muted: #9ba1ab;
  --rule: #2a2f3a;
  --accent: #fca636;          /* plasma, warm end */
  --accent-2: #e16462;        /* plasma, middle */
  --accent-3: #9c179e;        /* plasma, cold end */
  --plasma: linear-gradient(90deg, #0d0887, #6a00a8, #b12a90, #e16462, #fca636, #f0f921);
  --sans: "Alegreya Sans", Optima, Candara, "Segoe UI", "Gill Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 1.125rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.wrap {
  max-width: 62rem; margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: .15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
b { font-weight: 700; }
p { margin: 0 0 .8rem; }
ul { padding-left: 1.2rem; margin: 0 0 .8rem; }
li { margin-bottom: .3rem; }
.muted { color: var(--muted); font-size: .95em; }
img { max-width: 100%; height: auto; display: block; }

/* ---- hero ---- */
.hero {
  display: grid; grid-template-columns: auto 1fr; gap: 1.2rem 2.4rem; align-items: center;
  padding-block: 3rem 1.5rem;
}
.portrait { display: block; width: 220px; height: 220px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--surface); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent-2); }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-fallback { display: grid; place-items: center; width: 100%; height: 100%; font-size: 3.6rem; font-weight: 700; letter-spacing: .05em;
  background: var(--plasma); color: #0f1115; -webkit-background-clip: unset; }
.portrait.small { width: 56px; height: 56px; box-shadow: 0 0 0 2px var(--rule); }
.portrait.small .portrait-fallback { font-size: 1rem; }
.hero-text { min-width: 0; }
h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.05; font-weight: 700; margin: 0 0 .6rem; letter-spacing: -.01em; text-wrap: balance;
}
h1::after { content: ""; display: block; width: 7rem; height: 4px; margin-top: .55rem; border-radius: 2px; background: var(--plasma); }
.affil { color: var(--muted); margin-bottom: 1rem; display: flex; align-items: center; gap: .7rem; }
.affil .logo { width: 44px; height: 44px; border-radius: 6px; flex: none; }
.intro { max-width: 40rem; }
.iconlinks { display: flex; flex-wrap: wrap; gap: .5rem .55rem; margin-top: .4rem; }
.iconlinks a {
  font-size: .95rem; font-weight: 500; padding: .25rem .8rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--fg);
}
.iconlinks a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.ribbon { margin-top: 1rem; padding: .5rem .9rem; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 6px 6px 0; font-size: 1rem; }
.ribbon a { font-weight: 600; }

/* ---- nav ---- */
.topnav {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem 1.6rem;
  padding-block: .9rem; margin-bottom: 1rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-weight: 500;
}
.topnav a { color: var(--fg); }
.topnav a:hover { color: var(--accent); text-decoration: none; }

/* ---- sections ---- */
section { padding-block: 1.6rem 1rem; }
h2 {
  font-size: 1.7rem; font-weight: 700; margin: 0 0 1rem; line-height: 1.15;
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding-bottom: .35rem; border-bottom: 1px solid var(--rule);
}
.totop { font-size: .8rem; font-weight: 400; color: var(--muted); }
h3 { font-size: 1.2rem; font-weight: 700; margin: 0 0 .35rem; line-height: 1.25; text-wrap: balance; }
h3 a { color: var(--fg); }
h3 a:hover { color: var(--accent); }

/* news */
.news { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.news-item { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; }
.news-item time { color: var(--accent); font-weight: 500; font-size: .95rem; padding-top: .15rem; white-space: nowrap; }
.news-item > div { min-width: 0; }
.news-item p:last-child { margin-bottom: 0; }
.media { margin: .5rem 0 0; max-width: 34rem; }
.media img, .media video { border-radius: 6px; border: 1px solid var(--rule); width: 100%; }
.media figcaption, .fig figcaption, .card figcaption { color: var(--muted); font-size: .9rem; margin-top: .4rem; }
.yt { position: relative; aspect-ratio: 16/9; max-width: 100%; border-radius: 6px; overflow: hidden; background: var(--surface); border: 1px solid var(--rule); }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt[data-id] { cursor: pointer; }
.yt[data-id] img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; aspect-ratio: auto; border: 0; border-radius: 0; }
.yt .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 4rem; height: 4rem; border-radius: 50%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--accent); font-size: 1.6rem; padding-left: .3rem; box-shadow: 0 0 0 2px var(--accent); }
.yt[data-id]:hover .play { background: var(--accent); color: var(--bg); }
.media.narrow { max-width: 20rem; }

/* projects */
.project { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.4rem 2rem; padding-block: 1.2rem 1.6rem; border-bottom: 1px solid var(--rule); scroll-margin-top: 1rem; }
.project:last-child { border-bottom: 0; }
.project-text { min-width: 0; }
.project-text p:last-child { margin-bottom: 0; }
.project .tag { color: var(--accent); font-size: .95rem; margin-top: -.2rem; }
.project-figs { display: grid; gap: 1rem; align-content: start; }
.project-figs .fig figcaption { display: block; }
.ga img { border-color: var(--accent-3); }
.logo-fig img { width: 60%; max-width: 260px; margin-inline: auto; border-radius: 50%; border: 0; background: #fff; }
.offers .card img { object-fit: cover; }
.todo { color: var(--accent); border-bottom: 1px dashed var(--accent); }
.project .fig.wide { grid-column: 1 / -1; margin-top: .4rem; }
.project .fig.wide img { background: #fff; }

/* research rows: figure left, text right; alternate on even rows */
.row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1.4rem 2rem; align-items: center; padding-block: 1.1rem; border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row:nth-child(even) .fig { order: 2; }
.row-text { min-width: 0; }
.row-text p:last-child { margin-bottom: 0; }
.fig { margin: 0; }
.fig img, .fig video { border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); width: 100%; display: block; }
.fig figcaption { display: block; }

/* publications */
.pub { display: grid; grid-template-columns: 11rem 1fr; gap: 1.4rem; padding-block: 1.1rem; border-bottom: 1px solid var(--rule); align-items: start; }
.pub:last-child { border-bottom: 0; }
.pub > div { min-width: 0; }
.thumb { margin: 0; }
.thumb img { border-radius: 4px; border: 1px solid var(--rule); background: var(--surface); }
.cite { color: var(--muted); font-size: .95rem; margin-bottom: 0; }
.cite a { font-size: .85rem; padding: 0 .4rem; border: 1px solid var(--rule); border-radius: 3px; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1.2rem; }
.card { margin: 0; min-width: 0; }
.card img, .card video { aspect-ratio: 4/3; object-fit: cover; width: 100%; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); }

/* internship offers */
.offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.4rem; margin-top: .6rem; }
.offers .card img { aspect-ratio: 1 / 1.414; object-fit: contain; }
.offers .card a { display: block; }

/* contact */
.contact { display: grid; gap: .5rem; }
address { font-style: normal; }
.at { color: var(--muted); }

/* placeholders until the real pictures are dropped in assets/ */
.missing img { display: none; }
.missing { position: relative; }
.missing::before {
  content: attr(data-placeholder); display: grid; place-items: center; text-align: center; padding: 1rem;
  min-height: 7rem; aspect-ratio: 4/3; border-radius: 6px; border: 1px dashed var(--rule);
  background: repeating-linear-gradient(135deg, var(--surface) 0 10px, var(--surface-2) 10px 20px);
  color: var(--muted); font-size: .85rem;
}
.fig.missing::before, .thumb.missing::before, .media.missing::before, .card.missing::before { content: "image to add"; }
.offers .card.missing::before { aspect-ratio: 1 / 1.414; content: "poster to add"; }
.card.missing a { display: none; }
.yt[data-placeholder] iframe[src*="VIDEO_ID"] { display: none; }
.yt[data-placeholder]:has(iframe[src*="VIDEO_ID"])::before { content: attr(data-placeholder); position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }

/* footer */
footer { display: flex; align-items: center; gap: 1rem; margin-top: 2rem; padding-block: 1.5rem 2.5rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .9rem; }
footer p { margin: 0; }

/* ---- phone ---- */
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding-top: 2rem; }
  .portrait { width: 170px; height: 170px; }
  h1::after { margin-inline: auto; }
  .iconlinks { justify-content: center; }
  .news-item { grid-template-columns: 1fr; gap: .1rem; }
  .row, .pub, .project { grid-template-columns: 1fr; }
  .affil { flex-direction: column; }
  .row:nth-child(even) .fig { order: 0; }
  .thumb { max-width: 14rem; }
}
