/* The only stylesheet for the site.
   Colors and sizes are variables below; change them here to restyle everything.
   Per-page tweaks: each <body> has class "page-<name>" (e.g. .page-projects, .project-hapo),
   or add a `style:` block to that page's front matter. */

:root {
  --bg: #fdfdfc;
  --surface: #ffffff;
  --text: #1c1d1f;
  --muted: #62656b;
  --border: #e4e4e1;
  --accent: #2f5bd3;
  --accent-soft: #eef2fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 4px 14px rgb(0 0 0 / 5%);
  --wrap: 760px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1b1c1f;
    --text: #e8e8e6;
    --muted: #9a9ca1;
    --border: #2c2d31;
    --accent: #8aa8ff;
    --accent-soft: #1e2438;
    --shadow: none;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; padding-block: 2.5rem 4rem; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 2rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.3rem; margin: 2.5rem 0 1rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.35rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.prose > :last-child { margin-bottom: 0; }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem; padding-block: 1rem;
}
/* The name and nav links are pill buttons: shaded on hover, filled with the accent on the current page. */
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.site-header nav a, .site-name {
  color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500;
  padding: 0.35rem 0.85rem; border: 1px solid transparent; border-radius: 999px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.site-name { font-weight: 700; font-size: 1.1rem; color: var(--text); margin-left: -0.85rem; }
.site-header nav a:hover, .site-name:hover { color: var(--text); background: var(--border); }
.site-header nav a:active, .site-name:active { background: var(--muted); color: var(--bg); }
.site-header nav a:focus-visible, .site-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.site-header nav a[aria-current], .site-name[aria-current] {
  color: var(--accent); background: var(--accent-soft); border-color: var(--accent);
}
.site-header nav a[aria-current] { font-weight: 600; }
.site-header nav a[aria-current]:hover, .site-name[aria-current]:hover { background: var(--accent-soft); color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .site-header nav a, .site-name { transition: none; } }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding-block: 1.25rem; }
.site-footer a { color: inherit; }

/* ---------- buttons ---------- */
.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 0; }
.btn {
  display: inline-block; padding: 0.3rem 0.8rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.85rem; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent); color: var(--bg); }

/* ---------- home ---------- */
.intro h1 { margin-bottom: 0.25rem; font-size: 2.3rem; }
.tagline { color: var(--muted); font-size: 1.1rem; margin-bottom: 1.25rem; }
/* Updates timeline (home). Each <li> draws its dot (::after) and the progress segment down to the next dot (::before);
   .timeline::before is the faint track behind it all. With JS, .tl-js holds the recent updates' animation paused until .tl-play. */
.timeline {
  --tl-x: 7px;            /* line's center, from the left edge */
  --tl-y: 0.6rem;         /* dot's center, from the top of each item */
  --tl-step: 0.32s;       /* time for the progress line to travel between two dots */
  position: relative; padding-top: 1.4rem;
}
.timeline::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--tl-x) - 1px); width: 2px;
  background: var(--border);
  -webkit-mask-image: linear-gradient(transparent, #000 1.4rem, #000 calc(100% - 1.5rem), transparent);
  mask-image: linear-gradient(transparent, #000 1.4rem, #000 calc(100% - 1.5rem), transparent);
}
.tl-list { list-style: none; margin: 0; padding: 0; }
.tl-list > li, .tl-more > summary { position: relative; padding: 0 0 1.15rem 2rem; }
.tl-list > li::before, .tl-more[open] > summary::before {
  content: ""; position: absolute; z-index: 0; left: calc(var(--tl-x) - 1px); width: 2px;
  top: var(--tl-y); bottom: calc(-1 * var(--tl-y));
  background: var(--accent); transform-origin: bottom;
}
.tl-list:last-child > li:last-child::before { content: none; }
.tl-list > li::after, .tl-more > summary::after {
  content: ""; position: absolute; z-index: 1; width: 13px; height: 13px; border-radius: 50%;
  left: calc(var(--tl-x) - 6.5px); top: calc(var(--tl-y) - 6.5px);
  background: var(--accent); border: 2px solid var(--accent); box-shadow: 0 0 0 4px var(--bg);
}
.tl-list time {
  display: block; font-size: 0.8rem; line-height: calc(2 * var(--tl-y)); letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); font-variant-numeric: tabular-nums;
}
.tl-list > li > span { display: block; margin-top: 0.1rem; }
.tl-now time { color: var(--accent); font-weight: 600; }
.tl-now::after { box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-now time::before {    /* pulsing ring on the newest dot */
  content: ""; position: absolute; width: 13px; height: 13px; border-radius: 50%;
  left: calc(var(--tl-x) - 6.5px); top: calc(var(--tl-y) - 6.5px);
  border: 2px solid var(--accent); opacity: 0; animation: tl-pulse 2.4s ease-out infinite;
}
.tl-more > summary {
  list-style: none; cursor: pointer; width: fit-content;
  font-size: 0.9rem; line-height: calc(2 * var(--tl-y)); color: var(--muted);
}
.tl-more > summary::-webkit-details-marker { display: none; }
.tl-more > summary::after { background: var(--bg); border-color: var(--border); transition: border-color 0.15s; }
.tl-more > summary:hover { color: var(--accent); }
.tl-more > summary:hover::after, .tl-more[open] > summary::after { border-color: var(--accent); }
.tl-chevron { display: inline-block; margin-left: 0.35rem; transition: transform 0.2s; }
.tl-more[open] .tl-chevron { transform: rotate(180deg); }

/* Only the recent updates animate; the earlier ones (inside .tl-more) always show filled in. */
.tl-js > .tl-list > li::before {
  animation: tl-fill var(--tl-step) linear both paused; animation-delay: calc((var(--d) - 1) * var(--tl-step));
}
.tl-js > .tl-list > li::after {
  animation: tl-dot 0.45s ease-out both paused; animation-delay: calc(var(--d) * var(--tl-step));
}
.tl-js .tl-now time::before { animation-delay: calc(var(--d) * var(--tl-step) + 0.4s); animation-play-state: paused; }
.tl-js > .tl-play > li::before, .tl-js > .tl-play > li::after, .tl-js .tl-play time::before { animation-play-state: running; }
@keyframes tl-fill { from { transform: scaleY(0); } }
@keyframes tl-dot {
  from { background: var(--bg); border-color: var(--border); transform: scale(0.8); }
  60% { transform: scale(1.3); }
}
@keyframes tl-pulse { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tl-now time::before { animation: none; opacity: 0; } }

/* Photo gallery: uncropped photos in justified rows (equal height per row, edges flush with the column). */
.gallery { display: grid; gap: 0.5rem; }
.gallery-row { display: flex; gap: 0.5rem; }
.gallery-row a { flex-basis: 0; min-width: 0; }
.gallery img { display: block; width: 100%; height: auto; border-radius: 6px; transition: opacity 0.15s; }
.gallery a:hover img { opacity: 0.88; }
.plain-list { padding-left: 1.1rem; }
.plain-list li { margin-bottom: 0.4rem; }

/* ---------- project cards ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-img img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #fff; border-bottom: 1px solid var(--border); }
.card-body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; flex: 1; }
.card-title { font-size: 1.05rem; margin: 0 0 0.5rem; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }
.card-summary { font-size: 0.92rem; color: var(--muted); }
.card-summary p { margin: 0; }
.card-summary a { color: inherit; }
.card .buttons { margin-top: auto; padding-top: 0.9rem; }

/* ---------- papers ---------- */
.papers { list-style: none; padding: 0; margin: 0; }
.paper { padding: 0.9rem 0; border-bottom: 1px solid var(--border); }
.paper:last-child { border-bottom: none; }
.paper-title { font-weight: 600; color: var(--text); text-decoration: none; }
.paper-title:hover { color: var(--accent); }
.paper-cite { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.paper-links { display: flex; gap: 1rem; font-size: 0.85rem; margin-top: 0.3rem; }

/* ---------- detail pages ---------- */
.back { font-size: 0.9rem; margin-bottom: 1.5rem; }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--accent); }
.hero { margin: 0 0 1.5rem; }
.hero img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.hero figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }
.lead { font-size: 1.08rem; }
.cite { color: var(--muted); }
.note { color: var(--muted); font-size: 0.95rem; margin-top: 1rem; }
.status { font-size: 0.9rem; font-weight: 500; margin-top: 0.5rem; }
.detail .prose { margin-top: 2rem; }
.related { margin-top: 2.5rem; border-top: 1px solid var(--border); }
.related-project { display: flex; align-items: center; gap: 1rem; text-decoration: none; font-weight: 600; }
.related-project img { width: 120px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- simple lists (prototypes, courses) ---------- */
.entries { list-style: none; padding: 0; margin: 0; }
.entry { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.entry:last-child { border-bottom: none; }
.entry p { margin-bottom: 0.3rem; }
.entry .muted { font-size: 0.9rem; }

/* ---------- resume ---------- */
/* The PDF breaks out of the 760px text column: up to 1200px wide, centered, 20px gutter on small screens. */
.pdf {
  display: block; width: min(1200px, 100vw - 40px); height: 90vh;
  margin: 0.5rem 0 0 calc(50% - min(600px, 50vw - 20px));
  border: 1px solid var(--border); border-radius: var(--radius);
}

/* ---------- goo banner (bottom of the home page, above the footer; static/js/blob.js) ---------- */
.goo-banner { position: relative; border-top: 1px solid var(--border); line-height: 0; }
.goo-banner canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 320 / 45; image-rendering: pixelated;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.goo-banner canvas.over-goo { cursor: grab; }
.goo-banner canvas.grabbing { cursor: grabbing; }
.goo-help {
  position: absolute; right: 10px; bottom: 8px; width: 24px; height: 24px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font: 600 13px/1 var(--font); cursor: pointer; opacity: 0.8;
}
.goo-help:hover, .goo-help[aria-expanded="true"] { opacity: 1; color: var(--accent); border-color: var(--accent); }
.goo-overlay {
  position: absolute; z-index: 10; bottom: calc(100% + 6px); right: 10px; width: min(380px, calc(100% - 20px));
  padding: 0.8rem 1rem; line-height: 1.45; font-size: 0.85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 24px rgb(0 0 0 / 14%);
}
.goo-overlay p { margin: 0 0 0.5rem; }
.goo-overlay .goo-sub, .goo-overlay .goo-foot { color: var(--muted); }
.goo-overlay .goo-foot { margin: 0; }
.goo-bars { list-style: none; padding: 0; margin: 0 0 0.6rem; display: grid; gap: 0.2rem; }
.goo-bars li { display: grid; grid-template-columns: 8.5rem 1fr 2.5rem; align-items: center; gap: 0.6rem; padding: 0 0.3rem; border-radius: 5px; }
.goo-bars li.now { background: var(--accent-soft); font-weight: 600; }
.goo-bars li.off { color: var(--muted); opacity: 0.6; }
.goo-bar { height: 0.5rem; background: var(--border); border-radius: 999px; overflow: hidden; }
.goo-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.4s ease; }
.goo-bars li.up .goo-bar i { background: #2fa36b; }
.goo-bars li.down .goo-bar i { background: #d9534f; }
.goo-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.goo-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  h1 { font-size: 1.6rem; }
  .intro h1 { font-size: 1.9rem; }
  .cards { grid-template-columns: 1fr; }
  .gallery-row { display: grid; gap: 0.5rem; }  /* one full-width photo per line on phones */
  .site-header .wrap { flex-direction: column; align-items: flex-start; }
  .site-header nav { margin-left: -0.85rem; }  /* line up the first button's text with the name */
  .goo-bars li { grid-template-columns: 7.5rem 1fr 2.2rem; gap: 0.4rem; }
}
