/* Vision and Learning Lab — site styles */
:root {
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #5d6470;
  --faint: #8b919c;
  --line: #e5e7eb;
  --card: #f5f6f8;
  --accent: #21518d;      /* UC Merced navy (logo #0f2d52), lightened in the same hue */
  --accent-2: #d9ac28;    /* UC Merced gold (from the official logo) */
  --danger: #b42318;
  --radius: 10px;
  --max: 1120px;
  --space: 1.5rem;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Dark theme: opt-in via the header toggle (saved in localStorage). */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1115;
    --fg: #e8eaee;
    --muted: #a3a9b4;
    --faint: #737a86;
    --line: #262a32;
    --card: #181b21;
    --accent: #6aa8f0;
    --accent-2: #e0b84a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--fg); font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand .logo { height: 34px; width: auto; }
.brand .logo-dark { display: none; }
html[data-theme="dark"] .brand .logo-light { display: none; }
html[data-theme="dark"] .brand .logo-dark { display: block; }
.brand .divider { width: 1px; height: 26px; background: var(--line); }
.brand .mark { font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand .mark { color: var(--accent); font-weight: 800; }
.brand .sub { color: var(--faint); font-weight: 450; font-size: .9rem; }
.nav { display: flex; gap: .25rem; align-items: center; }
.theme-toggle { border: 1px solid var(--line); background: transparent; color: var(--muted); width: 34px; height: 34px;
  border-radius: 999px; cursor: pointer; display: grid; place-items: center; margin-left: .35rem; padding: 0; }
.theme-toggle:hover { color: var(--fg); background: var(--card); }
.theme-toggle svg { width: 17px; height: 17px; }
.nav a { color: var(--muted); padding: .4rem .75rem; border-radius: 999px; font-size: .95rem; }
.nav a:hover { color: var(--fg); background: var(--card); text-decoration: none; }
.nav a.active { color: var(--fg); background: var(--card); font-weight: 600; }
@media (max-width: 640px) { .brand .logo { height: 26px; } .brand .divider, .brand .mark { display: none; } .nav a { padding: .4rem .55rem; } }

main { padding: 2.5rem 0 4rem; min-height: 60vh; }
h1, h2, h3 { letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; margin: 0; }
.section { margin-top: 3rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--line); padding-bottom: .6rem; margin-bottom: 1.25rem; }
.section-head .more { font-size: .9rem; }
.muted { color: var(--muted); }
.empty { color: var(--faint); font-style: italic; padding: 1rem 0; }

/* ---------- home ---------- */
.intro { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 3rem; align-items: start; }
@media (max-width: 860px) { .intro { grid-template-columns: 1fr; gap: 2rem; } }
.intro.no-news { grid-template-columns: 1fr; }
.news.is-hidden ul, .news.is-hidden .empty { opacity: .45; }
.news .hidden-note { font-size: .8rem; color: var(--faint); margin: -.2rem 0 .5rem; }
.news-tools { gap: .4rem; }
.intro .lede { font-size: 1.12rem; color: var(--muted); max-width: 46rem; margin: .75rem 0 0; white-space: pre-line; }
.intro .kicker { color: var(--accent); font-weight: 600; font-size: .9rem; letter-spacing: .04em; text-transform: uppercase; }
.news h2 { font-size: 1.05rem; margin-bottom: .75rem; }
.news ul { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; }
.news li { display: grid; grid-template-columns: 4.6rem 1fr auto; gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--line); font-size: .95rem; }
.news li:first-child { border-top: 0; }
.news time { color: var(--faint); font-variant-numeric: tabular-nums; font-size: .88rem; padding-top: .1rem; }
.news .txt a { word-break: break-word; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 1.25rem; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
.card { display: block; color: var(--fg); }
.card:hover { text-decoration: none; }
.card .media { border-radius: var(--radius); overflow: hidden; background: var(--card); aspect-ratio: 16 / 9; }
.card .media img, .card .media video { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .media img, .card:hover .media video { transform: scale(1.03); }
.card h3 { font-size: 1rem; font-weight: 600; margin: .7rem 0 .2rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card:hover h3 { color: var(--accent); }
.card .meta { font-size: .85rem; color: var(--muted); }

/* ---------- publications ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 1.25rem 0 0; }
.toolbar input[type=search] { flex: 1 1 260px; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.toolbar .count { color: var(--faint); font-size: .9rem; }
.chip { border: 1px solid var(--line); background: var(--bg); padding: .4rem .8rem; border-radius: 999px; cursor: pointer; font-size: .9rem; color: var(--muted); }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.year { font-size: 1rem; color: var(--faint); font-weight: 600; margin: 1.75rem 0 .25rem; font-variant-numeric: tabular-nums; }
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding: .95rem 0; border-top: 1px solid var(--line); align-items: start; }
.pub.has-media { grid-template-columns: minmax(0, 1fr) 240px; padding: 1.1rem 0; }
.pub .body { grid-column: 1; grid-row: 1; }
.pub .media { grid-column: 2; grid-row: 1; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--card); position: relative; }
.year + .pubs .pub:first-child { border-top: 0; }
.pub .media img, .pub .media video { width: 100%; height: 100%; object-fit: cover; }
/* Auto teasers (paper figures): show the whole figure, letterboxed on white. */
.media.contain { background: #fff; }
.pub .media.contain img, .card .media.contain img { object-fit: contain; padding: 4px; }
.card:hover .media.contain img { transform: none; }
.pub .title { font-weight: 600; font-size: 1.04rem; line-height: 1.35; }
.pub .authors { color: var(--muted); font-size: .93rem; margin-top: .25rem; }
.pub .authors b { color: var(--fg); font-weight: 600; }
.pub .links { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; margin-top: .45rem; font-size: .9rem; }
.pub .venue { color: var(--fg); font-weight: 600; font-size: .85rem; background: var(--card); padding: .1rem .5rem; border-radius: 5px; }
.pub .links a { font-weight: 500; }
.pub.is-hidden { opacity: .45; }
@media (max-width: 640px) {
  .pub.has-media { grid-template-columns: 1fr; gap: .7rem; }
  .pub .media { grid-column: 1; grid-row: 1; }   /* media on top on phones */
  .pub.has-media .body { grid-row: 2; }
}

/* ---------- people ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.75rem 1.25rem; }
.people-grid.compact { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1.4rem 1rem; }
.person { text-align: center; position: relative; }
.person .photo { width: 120px; height: 120px; margin: 0 auto .7rem; border-radius: 50%; overflow: hidden; background: var(--card);
  display: grid; place-items: center; color: var(--faint); font-weight: 700; font-size: 1.6rem; border: 1px solid var(--line); }
.people-grid.compact .person .photo { width: 96px; height: 96px; font-size: 1.3rem; }
.person .photo img { width: 100%; height: 100%; object-fit: cover; }
.person a:hover .photo { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.person .name { font-weight: 600; font-size: .98rem; line-height: 1.3; }
.person .role { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.person .topic { color: var(--faint); font-size: .82rem; margin-top: .15rem; line-height: 1.35; }
.faculty-row { display: flex; flex-wrap: wrap; gap: 2.5rem; }
.faculty { display: flex; gap: 1.5rem; align-items: center; text-align: left; }
.faculty .photo { width: 150px; height: 150px; margin: 0; flex: none; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0 2.5rem; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem; }
.site-footer .lab { color: var(--fg); font-weight: 600; }
.site-footer .links a { color: var(--muted); margin-right: 1rem; }
.site-footer .loc a { color: var(--muted); }
.admin-link { color: var(--faint); background: none; border: 0; padding: 0; cursor: pointer; font-size: .85rem; }
.admin-link:hover { color: var(--accent); }

/* ---------- admin controls ---------- */
.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 7px; padding: .35rem .75rem; font-size: .85rem; cursor: pointer; line-height: 1.3; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: .15rem .5rem; font-size: .78rem; }
.edit-bar { display: none; gap: .35rem; flex-wrap: wrap; }
body.editing .edit-bar { display: flex; }
body.editing .edit-only { display: inline-flex; }
.edit-only { display: none; }
.person .edit-bar { justify-content: center; margin-top: .45rem; }
.pub .edit-bar { margin-top: .5rem; }
.card-wrap { position: relative; }

.admin-dock { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: flex; align-items: center; gap: .6rem;
  background: var(--fg); color: var(--bg); border-radius: 999px; padding: .45rem .55rem .45rem 1rem; font-size: .85rem;
  box-shadow: 0 8px 28px rgba(0,0,0,.25); }
.admin-dock .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.admin-dock .btn:hover { color: var(--bg); border-color: var(--bg); }
.admin-dock .dot { width: 8px; height: 8px; border-radius: 50%; background: #3ccf6e; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10,12,16,.55); z-index: 100; display: grid; place-items: center; padding: 1rem; }
.modal { background: var(--bg); color: var(--fg); width: min(640px, 100%); max-height: calc(100vh - 2rem); overflow: auto;
  border-radius: 14px; padding: 1.4rem 1.5rem; box-shadow: 0 24px 60px rgba(0,0,0,.35); border: 1px solid var(--line); }
.modal h3 { margin: 0 0 1rem; font-size: 1.15rem; }
.field { margin-bottom: .9rem; }
.field > label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=url], .field select, .field textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: .78rem; color: var(--faint); margin-top: .25rem; }
.field .check { display: flex; gap: .5rem; align-items: center; font-size: .92rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.links-editor .lrow { display: grid; grid-template-columns: 9rem 1fr auto; gap: .4rem; margin-bottom: .4rem; }
.links-editor input { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); width: 100%; }
.media-editor { display: grid; grid-template-columns: 160px 1fr; gap: .8rem; align-items: start; }
.media-editor .preview { aspect-ratio: 16/9; background: var(--card); border-radius: 7px; overflow: hidden; display: grid; place-items: center; color: var(--faint); font-size: .8rem; }
.media-editor .preview.round { aspect-ratio: 1; border-radius: 50%; width: 110px; }
.media-editor .preview img, .media-editor .preview video { width: 100%; height: 100%; object-fit: cover; }
.media-editor .ctrls { display: flex; flex-direction: column; gap: .4rem; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }
.modal .err { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin-top: .25rem; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: .55rem 1rem; border-radius: 8px; z-index: 200; font-size: .9rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); color: #fff; }

/* arXiv pickers */
.pick-list { display: flex; flex-direction: column; gap: .5rem; }
.pick-paper { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: .6rem .75rem; cursor: pointer; }
.pick-paper:hover { border-color: var(--accent); }
.pick-paper.exact { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }
.pick-paper .pt { font-weight: 600; font-size: .95rem; }
.pick-paper .pm { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.badge { display: inline-block; margin-left: .5rem; padding: 0 .4rem; border-radius: 4px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 600; }
.pick-figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.pick-fig { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .35rem; cursor: pointer; display: flex; flex-direction: column; gap: .3rem; }
.pick-fig:hover { border-color: var(--accent); }
.pick-fig.suggested { border: 2px solid var(--accent); }
.pick-fig img { width: 100%; aspect-ratio: 16/9; object-fit: contain; }
.pick-fig span { font-size: .75rem; color: #555; }
