/* ==========================================================
   Colors and fonts (light + dark)
   ========================================================== */

:root {
  --font-head: "Source Serif 4", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1b2433;
  --muted: #5a6577;
  --border: #e1e7ef;
  --accent: #4c62d8;        /* main blue-violet */
  --accent-soft: #e9edfc;
  /* sky blue → violet top bar */
  --bar-bg: linear-gradient(100deg, #c2e5f5 0%, #cbc4fb 100%);
  --bar-text: #22306a;
  --radius: 10px;
  --peach: #ffe4d2;         /* "what to eat" picker: light peach */
  --peach-ink: #b5592a;
}
:root[data-theme="dark"] {
  --bg: #11161d;
  --surface: #182029;
  --text: #e6eaf0;
  --muted: #9aa6b6;
  --border: #29333f;
  --accent: #9eaef6;
  --accent-soft: #232a4b;
  --bar-bg: linear-gradient(100deg, #1c2c58 0%, #2a2762 100%);
  --bar-text: #dfe3fb;
  --peach: #4a3026;
  --peach-ink: #ffc8a6;
}

/* ==========================================================
   Base
   ========================================================== */

:root {
  --topbar-h: 60px;
  --sidebar-w: 280px;
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }

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

html { scroll-padding-top: calc(var(--topbar-h) + 32px); }

/* no rubber-band bounce at the top/bottom of the page */
html, body { overscroll-behavior-y: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; margin: 0; }
h2 { font-size: 1.75rem; margin-bottom: 1rem; }
h3 { font-size: 1.2rem; margin: 2rem 0 .75rem; }

p { margin: 0 0 1rem; }
.muted { color: var(--muted); }

/* ==========================================================
   Top bar + tabs
   ========================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  --bar-tail: 44px;   /* how far the fade reaches below the bar */
}
/* The bar has no hard bottom edge. Two layers sit behind its content:
   ::before = page background (hides content scrolling underneath),
   ::after  = the bar color, which starts fading halfway down the bar
              and dissolves into the page below it. */
.topbar::before,
.topbar::after {
  content: "";
  position: absolute;
  inset: 0 0 calc(-1 * var(--bar-tail)) 0;
  z-index: -1;
  pointer-events: none;
}
.topbar::before {
  background: var(--bg);
  -webkit-mask-image: linear-gradient(to bottom, #000 var(--topbar-h), rgb(0 0 0 / .6) calc(var(--topbar-h) + 12px), rgb(0 0 0 / .2) calc(var(--topbar-h) + 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 var(--topbar-h), rgb(0 0 0 / .6) calc(var(--topbar-h) + 12px), rgb(0 0 0 / .2) calc(var(--topbar-h) + 28px), transparent);
}
.topbar::after {
  background: var(--bar-bg);
  --fade: linear-gradient(to bottom,
    #000 30%,
    rgb(0 0 0 / .92) 37%,
    rgb(0 0 0 / .74) 47%,
    rgb(0 0 0 / .5) 59%,
    rgb(0 0 0 / .28) 72%,
    rgb(0 0 0 / .12) 84%,
    rgb(0 0 0 / .03) 94%,
    transparent);
  -webkit-mask-image: var(--fade);
  mask-image: var(--fade);
}
.topbar-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.45rem;
  color: var(--bar-text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.tabs {
  margin-left: auto;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--bar-text);
  opacity: .8;
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
}
.tabs a:hover { opacity: 1; background: color-mix(in srgb, var(--surface) 55%, transparent); text-decoration: none; }
.tabs a[aria-current="page"] { opacity: 1; color: var(--accent); background: var(--surface); }

.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .fa-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .fa-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .fa-moon { display: none; }

/* ==========================================================
   Two-column layout with sticky sidebar
   ========================================================== */

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 24px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

/* Fixed (not sticky) so it never moves while the page scrolls.
   Its left edge lines up with the 1200px-wide centered layout. */
.sidebar {
  position: fixed;
  top: calc(var(--topbar-h) + 40px);
  /* 8px side padding gives the link hover highlight room without overflowing */
  left: max(16px, calc((100vw - 1200px) / 2 + 16px));
  width: calc(var(--sidebar-w) + 16px);
  padding: 0 8px;
  /* stop above the like button in the bottom-left corner */
  max-height: calc(100vh - var(--topbar-h) - 40px - 84px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.avatar {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--accent-soft);
}
.name { font-size: 1.7rem; margin: 16px 0 2px; }
.role { font-weight: 600; margin: 0 0 8px; }
.affil { color: var(--muted); margin: 0 0 2px; font-size: .95rem; }
.affil i { width: 18px; text-align: center; margin-right: 6px; }

.links { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px solid var(--border); padding-top: 12px; }
.links li { margin: 0; }
.links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  overflow-wrap: anywhere;
}
.links a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.links i { width: 20px; text-align: center; font-size: 1.1rem; color: var(--accent); }

/* ==========================================================
   Content
   ========================================================== */

/* At least one screen tall, so the footer sits at the bottom on short tabs */
.content {
  grid-column: 2;
  min-width: 0;
  min-height: calc(100vh - var(--topbar-h) - 32px - 24px);
  display: flex;
  flex-direction: column;
}
.panel { animation: fade .25s ease; margin-bottom: 40px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .9rem;
  font-weight: 600;
}

.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 6px 0; }
.date { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 18px 20px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.tl-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tl-desc { margin: 4px 0 0; font-size: .95rem; }

/* Publications */
.pubs { list-style: none; padding: 0; margin: 0; }
.pub {
  padding: 18px 20px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pub-title { font-family: var(--font-head); font-weight: 600; font-size: 1.08rem; line-height: 1.4; }
.pub-authors { color: var(--muted); font-size: .95rem; margin-top: 4px; }
.pub-authors b { color: var(--text); }
.pub-venue { font-size: .95rem; margin-top: 2px; }
.pub-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.chip:hover { background: var(--accent-soft); text-decoration: none; }
.bib {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .8rem;
  line-height: 1.5;
  overflow-x: auto;
}

/* Cards (projects, hobbies) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.card h3:last-child { margin-bottom: 0; }
.card h3 i { color: var(--accent); margin-right: 6px; }
.card p:last-child { margin-bottom: 0; }
.card-links { font-weight: 600; font-size: .95rem; }
.card-meta { color: var(--muted); font-size: .88rem; margin: -4px 0 8px; }
.cards.stack { grid-template-columns: 1fr; }
.card-photo { display: block; width: 100%; border-radius: 8px; margin-top: 10px; }

/* ==========================================================
   Hobbies: photo gallery (staggered, grows on hover)
   ========================================================== */

/* Masonry in reading order (left to right, then down).
   main.js sets each photo's grid-row span from its width/height. */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 8px;
  gap: 14px;
}
.photo {
  position: relative;
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgb(0 0 0 / .06);
  transition: transform .3s ease, box-shadow .3s ease;
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 18px 12px 8px;
  background: linear-gradient(transparent, rgb(0 0 0 / .55));
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s ease;
}
.photo:hover {
  position: relative;
  z-index: 2;
  transform: translateY(-6px) scale(1.07);
  box-shadow: 0 16px 32px rgb(0 0 0 / .18);
}
.photo:hover figcaption { opacity: 1; }

/* Hobbies: 2 x 2 landscape photo cards, label over the bottom of each photo */
.hobby-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.hobby-row li {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--accent-soft);
  box-shadow: 0 2px 8px rgb(0 0 0 / .06);
  transition: transform .25s ease, box-shadow .25s ease;
}
.hobby-row li:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgb(0 0 0 / .16); }
.hobby-row img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}
.hobby-row li:hover img { transform: scale(1.05); }
.hobby-row span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 30px 10px 10px;
  background: linear-gradient(transparent, rgb(0 0 0 / .62));
  color: #fff;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.1rem;
  text-align: center;
}

.credits { margin-top: 28px; font-size: .8rem; color: var(--muted); }
.credits summary { cursor: pointer; }
.credits ul { margin: 6px 0 0; padding-left: 18px; }

/* ==========================================================
   Hobbies: "What to eat today?" picker
   ========================================================== */

.food-picker {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.food-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.food-list li {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: .92rem;
  transition: transform .15s;
}
.food-list li.on { background: var(--peach); border-color: var(--peach); color: var(--peach-ink); font-weight: 700; transform: scale(1.1); }
.food-result {
  min-height: 3.2rem;
  margin: 20px 0 14px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.food-result .food-name {
  display: inline-block;
  animation: food-pop .25s cubic-bezier(.2, 1.6, .4, 1);
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--peach-ink);
}
@keyframes food-pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.food-btn {
  font: inherit;
  font-weight: 700;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--peach);
  color: var(--peach-ink);
  cursor: pointer;
  transition: transform .15s, filter .15s;
}
.food-btn:hover { filter: brightness(.97); transform: translateY(-1px); }
.food-btn:active { transform: scale(.96); }

.footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: .85rem;
}

/* ==========================================================
   Like button (bottom-left)
   ========================================================== */

.like-btn {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgb(0 0 0 / .08);
  transition: transform .15s, border-color .15s;
}
.like-btn:hover { border-color: #e0245e; transform: translateY(-1px); }
.like-btn i { color: #e0245e; font-size: 1.1rem; }
.like-btn[aria-pressed="true"] { cursor: default; }
.like-btn.pop i { animation: pop .4s ease; }
@keyframes pop { 50% { transform: scale(1.45); } }

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 860px) {
  .topbar-inner { padding: 0 16px; gap: 10px; }
  .brand { display: none; }
  .tabs { margin-left: 0; flex: 1; }

  .layout { grid-template-columns: 1fr; gap: 32px; padding: 24px 16px 96px; }
  .content { grid-column: auto; min-height: 0; }
  .sidebar {
    position: static;
    width: auto;
    padding: 0;
    max-height: none;
    overflow: visible;
    padding-bottom: 0;
    display: grid;
    grid-template-columns: 120px 1fr;
    column-gap: 18px;
    align-items: start;
  }
  .avatar { grid-row: span 4; }
  .name { margin-top: 0; font-size: 1.4rem; }
  .links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .links a span { display: inline; }

  .news li { grid-template-columns: 1fr; gap: 0; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .like-btn { left: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
