/* ==========================================================================
   bfraboni.github.io: one stylesheet for every page.
   Keeps the original palette: slate blue banner, light blue accents,
   Ubuntu font, soft grey text, framed thumbnails.
   ========================================================================== */

:root {
  --brand: #516482;        /* banner, headings */
  --accent: #90aad8;       /* dates, labels */
  --link: #3d6fb4;
  --text: #555;
  --strong: #333;
  --muted: #888;
  --line: #ddd;
  --bg: #fff;
  --code-bg: #f6f7f9;
  --glow: rgba(0, 140, 186, 0.5);
  --radius: 4px;
  --measure: 850px;
  --font: "Ubuntu", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Ubuntu Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 4rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
main.wide { max-width: 1060px; }

/* ---------- Header (the original blue banner) ---------- */
.site-header {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem 1.5rem;
  padding-top: .6rem;
  padding-bottom: .6rem;
}
.site-title {
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  text-decoration: none;
  text-shadow: 0 0 3px var(--brand);
  letter-spacing: .01em;
}
.site-nav { display: flex; flex-wrap: wrap; gap: .1rem 1rem; }
.site-nav a {
  color: #e6ecf6;
  text-decoration: none;
  font-weight: 500;
  font-size: .95rem;
}
.site-nav a:hover { color: #fff; text-decoration: underline; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 { color: var(--brand); font-weight: 700; line-height: 1.25; }
h1 { font-size: 2rem; margin: 1.5rem 0 1rem; }
h2 { font-size: 1.6rem; margin: 2.2rem 0 .8rem; }
h3 { font-size: 1.2rem; margin: 1.6rem 0 .5rem; }
h4 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }

/* home page section headings: underlined like the old Markdeep look */
.section > h2 { border-bottom: 2px solid var(--brand); padding-bottom: .2rem; }

p { margin: .6rem 0 1rem; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
strong, b { color: var(--strong); font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); }

.label { color: var(--accent); font-weight: 700; }

/* ---------- Media ---------- */
img, video, svg, iframe { max-width: 100%; }
img, video { height: auto; }
figure { margin: 1.5rem 0; text-align: center; }
figure img, figure video { display: block; margin: 0 auto; }
figcaption { font-size: .92rem; color: var(--muted); margin-top: .5rem; text-align: justify; }
.framed, .thumb {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 5px;
  background: #fff;
}
a:hover > .framed, a:hover > .thumb, .material:hover img { box-shadow: 0 0 2px 1px var(--glow); }
.video { position: relative; aspect-ratio: 16 / 9; margin: 1.5rem auto; max-width: 720px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

/* Image grids: a row of equal images that wraps on small screens */
.grid { display: grid; gap: 6px; margin: 1rem 0; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.grid img { width: 100%; display: block; border-radius: 2px; }
.grid figcaption, .grid .cap { font-size: .8rem; text-align: center; color: var(--muted); }
@media (max-width: 640px) { .grid { --cols: 3 !important; } }

/* ---------- About ---------- */
.about-body { display: flex; align-items: center; gap: 32px; }
.portrait {
  flex: none;
  width: 200px;
  height: 200px;
  object-fit: cover;
  border: 2px solid var(--line);
  border-radius: 50%;
  padding: 5px;
  transform: rotate(5deg);
}
.about-text > p:first-child { margin-top: 0; }
.about-text > p:last-child { margin-bottom: 0; }
.social { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.2rem; margin: 1.4rem 0 0; padding: 0; list-style: none; }
.social a { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; color: var(--strong); }
.social img { width: 20px; height: 20px; object-fit: contain; filter: grayscale(1); }

/* ---------- Publication list ---------- */
.pub { display: flex; gap: 18px; align-items: flex-start; margin: 0 0 1.4rem; }
.pub-thumb { flex: 0 0 auto; }
.pub-thumb img {
  width: 96px; height: 96px; object-fit: cover; display: block;
  border: 2px solid var(--line); border-radius: var(--radius); padding: 4px; background: #fff;
}
.pub-thumb:hover img { box-shadow: 0 0 2px 1px var(--glow); }
.pub-body { flex: 1; min-width: 0; }
.pub-title { margin: 0 0 .15rem; font-size: 1.02rem; color: var(--strong); }
.pub-title a { color: inherit; }
.pub-authors { font-style: italic; }
.pub-authors strong { font-style: italic; }
.pub-venue { color: var(--muted); font-size: .95rem; }
.pub-links { display: flex; flex-wrap: wrap; gap: .35rem; margin: .35rem 0 0; }
.chip {
  display: inline-block;
  font-size: .82rem;
  line-height: 1.5;
  padding: .05rem .55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand);
  background: #fff;
}
.chip:hover { text-decoration: none; border-color: var(--accent); box-shadow: 0 0 2px 1px var(--glow); }

/* BibTeX: <details> on paper pages, toggled <div> in the publication list */
details.bibtex { margin-top: .35rem; }
.bibtex[hidden] { display: none; }
.bibtex > summary {
  display: inline-block;
  cursor: pointer;
  font-size: .82rem;
  padding: .05rem .55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand);
  list-style: none;
  user-select: none;
}
.bibtex > summary::-webkit-details-marker { display: none; }
.bibtex > summary::before { content: "▸ "; }
.bibtex[open] > summary::before { content: "▾ "; }
.bibtex-toggle { font-family: inherit; cursor: pointer; user-select: none; }
.bibtex-toggle::before { content: "▸ "; }
.bibtex-toggle[aria-expanded="true"]::before { content: "▾ "; }
.bibtex-box { position: relative; margin-top: .5rem; }
.bibtex-box pre { margin: 0; }
.bibtex .copy {
  position: absolute; top: .4rem; right: .4rem;
  font: 500 .78rem var(--font);
  color: var(--brand); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .1rem .5rem; cursor: pointer;
}
.bibtex .copy:hover { border-color: var(--accent); }

/* Animated figures (assets/js/pi-anim.js) */
.pi-anim svg { display: block; width: 100%; height: auto; }
.pi-anim-controls { display: flex; justify-content: center; gap: .4rem; margin-top: .4rem; }
.pi-anim-controls .chip { font-family: inherit; cursor: pointer; }

/* ---------- Project tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: .5rem 0 1.5rem; }
.tile { position: relative; display: block; aspect-ratio: 1; color: #fff; }
.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border: 2px solid var(--line); border-radius: var(--radius); padding: 5px; background: #fff;
}
a.tile:hover img { box-shadow: 0 0 2px 1px var(--glow); }
.tile.wip img { border-style: dashed; }
.tile .tip {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  background: rgba(0, 0, 0, .65); color: #fff;
  font-size: .82rem; line-height: 1.3; text-align: center;
  padding: .3rem .4rem; border-radius: 6px;
  opacity: 0; transition: opacity .15s ease;
  pointer-events: none;
}
.tile:hover .tip, .tile:focus .tip { opacity: 1; }
@media (hover: none) { .tile .tip { opacity: 1; } }

/* ---------- Timeline lists (teaching, experience, education) ---------- */
.timeline { list-style: none; padding: 0; margin: .5rem 0 1.5rem; }
.timeline > li { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0 1rem; margin-bottom: .8rem; }
.timeline .when { color: var(--accent); font-weight: 700; }
.timeline .where { font-style: italic; }
.timeline .tags {
  display: inline-block; margin-top: .25rem;
  font: .88rem/1.4 var(--mono); color: var(--muted);
  background: var(--code-bg); border-radius: var(--radius); padding: .15rem .5rem;
}
.timeline ul { margin: 0; padding-left: 1.1rem; }
@media (max-width: 640px) { .timeline > li { grid-template-columns: 1fr; } }

/* ---------- Paper (project) pages ---------- */
.paper-title { text-align: center; margin: 2rem 0 1rem; font-size: 2.1rem; }
.paper-authors, .paper-affiliations, .paper-venue { text-align: center; margin: .3rem 0; }
.paper-authors { font-size: 1.15rem; display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1.6rem; }
.paper-authors a { color: var(--brand); font-weight: 500; }
.paper-affiliations { color: var(--brand); font-size: .92rem; display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1.6rem; }
.paper-venue { color: var(--muted); }
.paper > p:not([class]) { text-align: justify; }
.materials { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem 1.5rem; margin: 1.5rem 0; }
.material { display: flex; flex-direction: column; align-items: center; width: 150px; text-align: center; font-size: .88rem; color: var(--text); }
.material img { height: 180px; width: auto; object-fit: contain; border: 2px solid var(--line); border-radius: var(--radius); padding: 5px; background: #fff; margin-bottom: .35rem; }
.material:hover { text-decoration: none; }

/* ---------- Notes (long technical pages) ---------- */
.note .meta { color: var(--muted); font-size: .9rem; margin-top: -.5rem; }
.note img { display: block; margin: 1rem auto; }
.note p > img:only-child { max-width: 65%; }
.note table img { margin: 0 auto; max-width: 100%; }
#markdown-toc {
  border-left: 3px solid var(--brand);
  background: var(--code-bg);
  padding: .8rem 1rem .8rem 2rem;
  margin: 1rem 0 2rem;
  font-size: .93rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
#markdown-toc ul { padding-left: 1.2rem; }
#markdown-toc::before { content: "Contents"; display: block; margin-left: -1rem; font-weight: 700; color: var(--brand); }
.references p, .ref { font-size: .92rem; }
.ref:target { background: #fff8d6; }
.center { text-align: center; }

/* Tables */
table { border-collapse: collapse; margin: 1rem auto; max-width: 100%; display: block; overflow-x: auto; }
th, td { padding: .35rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--brand); text-align: left; border-bottom: 2px solid var(--brand); }
table.plain td, table.plain th { border: 0; padding: 2px; }

/* Code */
code, pre { font-family: var(--mono); font-size: .92em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .3em; border-radius: 3px; }
pre {
  background: var(--code-bg);
  border: 1px solid #e3e6ea;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  overflow-x: auto;
  line-height: 1.45;
}
pre code { background: none; padding: 0; }
div.highlight, figure.highlight { margin: 1rem 0; text-align: left; }

/* Rouge syntax colors (close to the old GitHub-like theme) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: #969896; font-style: italic; }
.highlight .cp, .highlight .cpf { color: #63a35c; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kt, .highlight .kc { color: #a71d5d; }
.highlight .o, .highlight .ow { color: #a71d5d; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sc, .highlight .sx { color: #183691; }
.highlight .m, .highlight .mf, .highlight .mi, .highlight .mh, .highlight .il { color: #0086b3; }
.highlight .nf, .highlight .nc, .highlight .nn { color: #795da3; }
.highlight .nb, .highlight .bp { color: #0086b3; }

/* Math */
.katex { font-size: 1.08em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .2rem 0; margin: .8rem 0; }

/* Before/after image comparison (mvpt19) */
.compare { margin: 20px auto; position: relative; padding: 5px; border: 1px solid #adadad; border-radius: 3px; }
.compare .compared { visibility: hidden; position: absolute; }
.magnifier { position: absolute; border: 1px solid #000; border-radius: 20px; box-shadow: 0 0 1px 0 black inset, 0 0 1px 0 black; width: 200px; height: 200px; overflow: hidden; margin: 20px; display: none; z-index: 2; }
.compare-settings { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px; }
.compare-setting { padding: 5px; border: 1px solid #adadad; border-radius: 5px; display: flex; align-items: center; }
.range-container { display: flex; align-items: center; border: 1px solid #0099cc; border-radius: 5px; box-shadow: 0 0 1px 0 #0099cc inset; margin: 0 5px; position: relative; }
.play, .pause { box-sizing: border-box; height: 1em; width: 1em; border-color: transparent transparent transparent #202020; transition: 100ms all ease; cursor: pointer; }
.play { border-style: solid; border-width: .5em 0 .5em 1em; }
.pause { border-style: double; border-width: 0 0 0 1em; }
.compare canvas { display: block; width: 100%; height: auto; cursor: crosshair; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; padding: 1.2rem 0 2rem; text-align: center; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .site-title { font-size: 1.6rem; }
  .site-nav { gap: .1rem .8rem; }
  .portrait { width: 150px; height: 150px; }
  .about-body { flex-direction: column; gap: 18px; }   /* portrait above the text */
  .pub-thumb img { width: 64px; height: 64px; }
  .pub { gap: 12px; }
  .note p > img:only-child { max-width: 100%; }
  .paper-title { font-size: 1.6rem; }
}

@media print {
  .site-header { position: static; }
  .site-nav, .bibtex .copy, .site-footer { display: none; }
}

/* keep author-chosen colors on emphasized words (e.g. <span style="color:…">**orange**</span>) */
span[style] > strong, span[style] > em { color: inherit; }
/* vector figures: 60% of the text width, full width on phones */
.note p > img[src$=".svg"]:only-child { width: 60%; max-width: 60%; }
@media (max-width: 640px) { .note p > img[src$=".svg"]:only-child { width: 100%; max-width: 100%; } }

/* render gallery: equal tiles aligned on the image top, caption under each */
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1rem; margin: 1.5rem 0; align-items: start; }
.gallery figure { margin: 0; }
.gallery img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 2px; }
.gallery figcaption { text-align: left; font-size: .85rem; margin-top: .4rem; }
@media (max-width: 640px) { .gallery { grid-template-columns: 1fr; } }
