/* Colors. The site is always dark for now (data-theme="dark" in layouts/baseof.html); the first block is light. */
:root {
  --bg: #ffffff;
  --text: #1c2026;
  --muted: #5f6672;
  --line: #e4e6ea;
  --accent: #1f5a85;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15181c;
  --text: #e6e8eb;
  --muted: #a3a9b3;
  --line: #2a2f36;
  --accent: #7fb3dc;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 "Source Serif 4", Georgia, serif;
}
@keyframes fade-in { from { opacity: 0; } }

/* Smooth page changes: the old page blends into the new one instead of flashing blank,
   and the top bar stays put. (Chrome, Edge, Safari; Firefox gets the fade just below.) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.top { view-transition-name: top-bar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.2s; }
/* Firefox can't blend pages, so there the content (not the top bar) fades in on arrival
   and fades out when you click a link (site.js adds "leaving"). */
.no-blend main, .no-blend footer { animation: fade-in 0.2s ease-out; }
.no-blend.leaving main, .no-blend.leaving footer { opacity: 0; transition: opacity 0.15s ease-in; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

/* The particle tracks behind the page (drawn by particles.js). Raise opacity to make them stronger.
   100lvh is the screen height with a phone's address bar hidden, so the tracks don't jump when the
   bar slides in and out while scrolling (100vh is for older browsers that don't know lvh). */
#tracks { position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100lvh; z-index: -1; opacity: var(--tracks, 0.75); pointer-events: none; }
/* The brightness slider for the tracks, bottom left: faint until you point at it.
   Hidden on phones (no room). It fits under the footer text. */
.tracks-slider { position: fixed; left: 1rem; bottom: 1rem; z-index: 5; display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.95rem; opacity: 0.3; transition: opacity 0.2s; }
.tracks-slider:hover, .tracks-slider:focus-within { opacity: 1; }
.tracks-slider input { width: 5.5rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
@media (max-width: 40rem) { .tracks-slider { display: none; } }
h1, h2, h3, nav, footer, .date, .links, .toc, .rot-btn, .rot-toast { font-family: "IBM Plex Sans", Helvetica, sans-serif; }
h1 { font-size: 2.4rem; line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.65rem; line-height: 1.3; margin-top: 2.5rem; }
h3 { font-size: 1.25rem; margin-top: 1.8rem; }
li { margin-bottom: 0.6rem; }
img { max-width: 100%; }

/* Top bar */
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.top { font-size: 1.25rem; } /* top bar text size */
.top .name { font-family: "IBM Plex Sans", sans-serif; font-weight: 600; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.top nav a { color: var(--muted); text-decoration: none; }
@media (max-width: 40rem) { .top nav { gap: 0.25rem 0.8rem; font-size: 1rem; } }
/* Brainrot menu names have emoji, so they're wider: on phones, shrink them with the screen so
   all five still fit on one line (even on a small 320px-wide phone). */
@media (max-width: 40rem) { html.rot .top nav { font-size: min(1rem, 4.2vw); column-gap: min(0.6rem, 2.2vw); } }
.top nav a:hover, .top nav a.current { color: var(--text); }
/* A line slides in under a menu item on hover, and stays under the page you are on */
.top nav a { position: relative; }
.top nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s;
}
.top nav a:hover::after, .top nav a.current::after { transform: scaleX(1); }

/* Page column */
.page { max-width: 46rem; margin: 0 auto; padding: 2.5rem 1.25rem 1rem; }
.date { color: var(--muted); font-size: 0.875rem; margin: 0 0 2rem; }

/* Home page: photo, name and links in a left column that stays put while you scroll */
.home { max-width: 60rem; margin: 0 auto; padding: 2.5rem 1.25rem 1rem; display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 3rem; }
.profile { position: sticky; top: 2rem; align-self: start; }
.profile h1 { font-size: 2rem; margin: 1rem 0 0.25rem; }
.profile .where { font: 0.95rem "IBM Plex Sans", sans-serif; color: var(--muted); margin: 0 0 1rem; }
.profile .bio { color: var(--muted); font: 0.9rem/1.6 "IBM Plex Sans", sans-serif; margin: 0 0 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.profile .links a { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.6rem; }
.profile .links svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; color: var(--muted); }
.profile .links a:hover svg { color: var(--accent); }
.profile img { width: 9rem; height: 9rem; border-radius: 50%; object-fit: cover; border: 3px solid var(--bg); display: block; }
.home-main > :first-child h2 { margin-top: 0.5rem; }
/* A ring in the particle colors around the photo; it spins when you hover */
.avatar { position: relative; display: inline-block; padding: 3px; border-radius: 50%; isolation: isolate; }
.avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: conic-gradient(#e0a000, #f2711c, #e0399b, #2f80ed, #e0a000);
}
.avatar:hover::before { animation: spin 3s linear infinite; }

/* Brainrot sunglasses on the profile picture. Hidden normally, sitting on my eyes in brainrot mode.
   Turning brainrot on drops them down from above; turning it off sends them flying off to the left.
   left/top/width are measured on the photo: move or resize them here. */
.shades { position: absolute; left: 29.4%; top: 46.5%; width: 39.6%; z-index: 1; display: none; pointer-events: none; transform-origin: 70% 50%; overflow: visible; }
html.rot .shades, html.shades-off .shades { display: block; }
html.shades-on .shades { animation: shades-on 1.6s cubic-bezier(0.2, 0.6, 0.35, 1) both; }
html.shades-off .shades { animation: shades-off 0.6s cubic-bezier(0.55, 0, 1, 0.45) both; }
@keyframes shades-on {
  0%   { transform: translateY(-60vh); }
  88%  { transform: translateY(0); }
  94%  { transform: translateY(-4px); }  /* a small settle at the end */
  100% { transform: translateY(0); }
}
@keyframes shades-off {
  0%   { transform: none; }
  100% { transform: translate(-100vw, -3rem) rotate(-30deg); }
}
/* As they land: a glint sweeps across the lenses, then a sparkle twinkles on the corner.
   (Sizes here are in the glasses' own grid squares, not screen pixels.) */
.shades .glint { transform: translateX(-8px); }
.shades .sparkle { transform: scale(0); transform-box: fill-box; transform-origin: center; }
html.shades-on .shades .glint { animation: shades-glint 0.55s ease-in-out 1.45s both; }
html.shades-on .shades .sparkle { animation: shades-sparkle 0.7s ease-out 1.75s both; }
html.shades-on .shades .sparkle.second { animation-delay: 1.95s; }
@keyframes shades-glint { to { transform: translateX(36px); } }
@keyframes shades-sparkle {
  50%  { transform: scale(1.2) rotate(45deg); }
  100% { transform: scale(0) rotate(90deg); }
}
@media (prefers-reduced-motion: reduce) {
  html.shades-on .shades, html.shades-on .shades .glint, html.shades-on .shades .sparkle { animation: none; }
  html.shades-off .shades { display: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Narrow screens: one column, profile on top, nothing sticky */
@media (max-width: 52rem) {
  .home { display: block; }
  .profile { position: static; margin-bottom: 2rem; }
  /* All four links on one line: "Google Scholar" becomes "Scholar", and the row shrinks with the screen */
  .profile .links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9em; font-size: min(1.0625rem, 4vw); }
  .profile .links a { margin: 0; gap: 0.4em; }
  .profile .links svg { width: 1.05em; height: 1.05em; }
  .profile .links .long { display: none; }
}
@media (max-width: 40rem) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.45rem; }
}

/* News list on the home page */
.news h2 { margin-top: 1rem; }
.news ul { list-style: none; padding: 0; margin: 0; }
.news li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.news strong { font: 600 0.85rem "IBM Plex Sans", sans-serif; color: var(--muted); }
.news-archive h2 { margin-top: 2.2rem; }   /* the year headings on /news/ */

/* Short lists on the home page (research, teaching): bold title, one line under it */
.items { list-style: none; padding: 0; }
.items li { padding: 0.75rem 0; border-top: 1px solid var(--line); margin: 0; color: var(--muted); }
.items strong { display: block; color: var(--text); font-family: "IBM Plex Sans", sans-serif; }

/* "Current research": a picture on the left, title and a line or two on the right */
.research { list-style: none; padding: 0; }
.research li { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: 1.25rem; align-items: start; padding: 1rem 0; border-top: 1px solid var(--line); margin: 0; color: var(--muted); }
.research img, .research .no-image { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #fff; border-radius: 6px; border: 1px solid var(--line); box-sizing: border-box; }
.research .no-image { display: grid; place-items: center; padding: 0.5rem; text-align: center; background: linear-gradient(135deg, var(--accent), #6c3d91); color: white; font: 600 0.85rem "IBM Plex Sans", sans-serif; }
.research strong { display: block; color: var(--text); font-family: "IBM Plex Sans", sans-serif; }
.research p { margin: 0; }
.research small { display: block; margin-top: 0.25rem; font: 0.75rem "IBM Plex Sans", sans-serif; }
.research small p { display: inline; }
@media (max-width: 40rem) { .research li { grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.9rem; } .research .no-image { font-size: 0.7rem; } }

/* Wider column for picture grids; stacked sections on the home page sit closer together */
.wide { max-width: 60rem; }
.page + .page { padding-top: 0; }

/* Picture cards (home, Projects, Blog) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 2rem 1.5rem; }
.card { color: var(--text); text-decoration: none; }
.card img, .card .no-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  transition: transform 0.2s;
}
.card .no-image {
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
  background: linear-gradient(135deg, var(--accent), #6c3d91);
  color: white;
  font: 600 1.2rem "IBM Plex Sans", sans-serif;
  text-align: center;
}
.card:hover img, .card:hover .no-image { transform: translateY(-3px); }
.card h3 { margin: 0.75rem 0 0.25rem; }
.card:hover h3 { color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.card .date { margin: 0 0 0.25rem; }

/* Paper list, like Kai's: journal and year on the left, title and authors on the right */
.page.pubs { max-width: 60rem; } /* the paper list gets the full width */
.papers { list-style: none; padding: 0; }
.papers li { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 1.5rem; align-items: start; padding: 1.1rem 0; border-top: 1px solid var(--line); margin: 0; }
.papers .venue { font: 0.85rem/1.35 "IBM Plex Sans", sans-serif; color: var(--muted); }
.papers .venue b { display: block; color: var(--text); font-weight: 600; margin-bottom: 0.15rem; }
.papers .pt { margin: 0 0 0.3rem; font-weight: 600; line-height: 1.35; color: var(--text); }
.papers .au { margin: 0 0 0.3rem; font: 0.9rem/1.5 "IBM Plex Sans", sans-serif; color: var(--muted); }
.papers .links { display: block; margin-top: 0.35rem; font: 0.85rem "IBM Plex Sans", sans-serif; }
.papers .links a { margin-right: 0.6rem; text-decoration: none; }
.papers .tags { display: block; margin-top: 0.1rem; }
.papers .tags .badge { border-radius: 6px; line-height: 1.35; padding: 0.15rem 0.5rem; } /* long awards wrap neatly */
.papers .links a:hover { text-decoration: underline; }
/* Phones: journal and year on one line above the title */
@media (max-width: 40rem) {
  .papers li { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .papers .venue b { display: inline; margin-right: 0.4rem; }
  .papers .links, .papers .tags { display: inline; margin-left: 0.6rem; }
}

/* Your name in author lists: bold and underlined so it stands out */
.pubs li strong, .papers .au strong { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Small labels on talks: Oral, Poster, and gold ones for awards */
.badge {
  display: inline-block;
  margin: 0.3rem 0.3rem 0 0;
  padding: 0.05rem 0.55rem;
  border-radius: 1rem;
  background: var(--line);
  color: var(--muted);
  font: 500 0.75rem "IBM Plex Sans", sans-serif;
}
.badge.award { background: #fff3cd; color: #8a5a00; }
[data-theme="dark"] .badge.award { background: #4a3b10; color: #ffd772; }

/* 3D prints gallery: photos in a grid, each with a caption */
.gallery { columns: 3 16rem; column-gap: 1.25rem; margin-top: 2rem; }
.gallery figure { break-inside: avoid; margin: 0 0 1.25rem; }
.gallery img { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; transition: transform 0.2s; }
.gallery a:hover img { transform: translateY(-3px); }
.gallery figcaption { margin-top: 0.4rem; color: var(--muted); font: 0.85rem "IBM Plex Sans", sans-serif; }

/* The picture at the top of a project page, and pictures inside pages. The top picture is at most
   40% of the window tall, so the links under it show without scrolling. It keeps its shape (never cropped). */
.cover { display: block; max-width: 100%; max-height: 40vh; width: auto; border-radius: 6px; border: 1px solid var(--line); margin: 1rem 0 1.5rem; }
article img { border-radius: 6px; }

/* Blog post: contents list in the left margin on wide screens */
.post { max-width: 60rem; display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 3rem; }
.toc { position: sticky; top: 2rem; align-self: start; font-size: 0.85rem; }
.toc p { color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; }
.toc a { display: block; color: var(--muted); text-decoration: none; margin-bottom: 0.5rem; line-height: 1.35; }
.toc a:hover { color: var(--text); }
.toc a.sub { padding-left: 0.9rem; }
.toc a.active { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.toc .top-link { display: inline; margin-left: 0.5rem; text-transform: none; letter-spacing: 0; }
html { scroll-behavior: smooth; }
article h2, article h3 { scroll-margin-top: 1.5rem; }
@media (max-width: 52rem) {
  .post { display: block; }
  .toc { display: none; }
}

/* The 404 page for broken links */
.lost { text-align: center; padding-top: 5rem; }
.lost .big {
  margin: 0;
  font: 800 6rem/1 "IBM Plex Sans", sans-serif;
  background: linear-gradient(90deg, #e0a000, #f2711c, #e0399b, #2f80ed);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

footer {
  max-width: 60rem;
  margin: 0 auto;
  margin-top: 3rem;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
/* Keep the footer text clear of the brightness slider in the bottom-left corner. On wide screens the
   footer already starts far enough in; on narrower ones its text is pushed right past the slider. */
@media (min-width: 40.01rem) {
  footer { box-sizing: border-box; max-width: 62.5rem; padding-left: max(1.25rem, 9rem - max(0px, (100vw - 62.5rem) / 2)); }
}

/* ---------- Brainrot mode ---------- */
:root { --rainbow: linear-gradient(90deg, #ff2d95, #ffb400, #2ee66b, #00b3ff, #9b5cff); }

/* The buttons in the bottom right corner: white inside, rainbow border */
.rot-bar { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; display: flex; gap: 0.5rem; align-items: center; }
.rot-btn {
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  border: 2px solid transparent;
  border-radius: 2rem;
  background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--rainbow) border-box;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.4;
  animation: rainbow 4s linear infinite;
  transition: transform 0.15s;
}
.rot-btn:hover { transform: scale(1.08) rotate(-3deg); }
.rot-btn input { position: absolute; opacity: 0; }
.rot-btn b { display: inline-block; animation: wiggle 2.5s infinite; }
.rot-btn .on, html.rot .rot-btn .off { display: none; }
html.rot .rot-btn .on { display: inline; }

/* The small clips button only shows while brainrot mode is on */
.rot-btn.small { display: none; animation: none; }
html.rot .rot-btn.small { display: inline-block; }
.rot-btn.small:has(input:not(:checked)) { opacity: 0.5; text-decoration: line-through; }

/* While it is on: rainbow button and headings, brain cursor */
html.rot .rot-btn:not(.small) { background: var(--rainbow) border-box; color: white; }
html.rot h1, html.rot h2, html.rot .top .name {
  background: var(--rainbow);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  animation: rainbow 3s linear infinite;
}
html.rot #tracks { opacity: calc(var(--tracks, 0.75) + 0.17); } /* brighter particle tracks; particles.js colors them rainbow */
html.rot body { cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><text y='26' font-size='26'>🧠</text></svg>") 16 16, auto; }

/* The message that pops up, and the emoji that fly out of the button */
.rot-toast {
  position: fixed;
  left: 50%;
  top: 30%;
  z-index: 30;
  padding: 0.8rem 1.4rem;
  border-radius: 1rem;
  background: #111;
  color: white;
  font-size: 1.6rem;
  font-weight: 800;
  white-space: nowrap;
  animation: pop 1.8s forwards;
}
@media (max-width: 40rem) { .rot-toast { top: 60%; } } /* lower on phones, clear of the name and photo */
.rot-emoji { position: fixed; z-index: 30; font-size: 1.8rem; animation: fly 1.2s ease-out forwards; }

/* The clips that fade in and out. They sit in the background: above the particle tracks
   (same layer, but later in the page) and under the text. They stay see-through too. */
#clips img {
  position: fixed;
  z-index: -1;
  max-width: 30vw;
  max-height: 40vh;
  opacity: 0;
  transition: opacity 0.8s;
}
#clips img.show { opacity: 0.35; }

.rot-toast, .rot-emoji, #clips img { pointer-events: none; }

@keyframes rainbow { to { filter: hue-rotate(360deg); } }
@keyframes wiggle { 80% { transform: rotate(-20deg) scale(1.3); } 90% { transform: rotate(20deg) scale(1.3); } }
@keyframes pop {
  0% { transform: translateX(-50%) scale(0.3); opacity: 0; }
  15% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  25% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -40px); opacity: 0; }
}
@keyframes fly { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

/* For people who turned on "reduce motion" on their computer */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
  #clips, .rot-emoji { display: none; }
}
