/* ============================================================================
   PORTFOLIO SITE STYLES
   ----------------------------------------------------------------------------
   Academic personal-site layout: a centered 860px column, a bio/photo header,
   and a publication-style project list. Full project write-ups open beside the
   list on wide screens and as a full-screen reader on narrow screens.
   ========================================================================== */

/* Full STIX Two Math (OFL): OpenType MATH table + mathematical italic. */
@font-face {
  font-family: "STIX Two Math";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("../assets/fonts/STIXTwoMath-Regular.woff2") format("woff2");
}

:root {
  --ink: #222222;
  --ink-soft: #555555;
  --muted: #6b6b6b;
  --paper: #ffffff;
  --soft: #f6f6f6;
  --line: #e5e5e5;
  --link: #1772d0;
  --link-hover: #f09228;

  --list-width: 860px;    /* centered column width on desktop */
  --content-max: 700px;   /* readable measure inside a write-up */
  --split-dur: 0.2s;
  --split-ease: cubic-bezier(0.45, 0, 0.55, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover,
a:focus {
  color: var(--link-hover);
}

/* List pages scroll inside their columns; the paper page scrolls normally. */
body.page-list { overflow: hidden; height: 100vh; }
body.page-paper { overflow: auto; height: auto; min-height: 100vh; }

html, body { scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }

/* ---------------------------------------------------------------------------
   SHARED LIST SHELL
   ------------------------------------------------------------------------- */

.list-wrap {
  position: absolute;
  inset: 0;
  background: var(--paper);
}

.list-col {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 46px max(24px, calc((100% - var(--list-width)) / 2)) 72px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  scrollbar-width: none;
}
.list-col::-webkit-scrollbar { display: none; }

.list-title {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
}

.subpage-head {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.back-link {
  color: var(--muted);
  font-weight: 500;
}
.back-link:hover { color: var(--link); }

/* ---------------------------------------------------------------------------
   PROFILE HEADER
   ------------------------------------------------------------------------- */

.profile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 34px;
  align-items: start;
}

.profile-name {
  margin: 0 0 16px;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-align: center;
}

.hero-bio {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.65;
}

.profile-links {
  margin: 0;
  font-size: 14px;
  text-align: center;
}
.profile-links .sep { color: #b0b0b0; }

.profile-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.profile-photo img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 240px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  background: var(--soft);
  transition: opacity 0.18s ease;
}
.profile-photo img.is-loading { opacity: 0.35; }

.randomize {
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: #ececec;
  color: #333;
  font: inherit;
  font-size: 12.5px;
  line-height: 1;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.randomize:hover { background: #dddddd; color: #000; }
.randomize:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------------------------------------------------------------------------
   PROJECT LIST
   ------------------------------------------------------------------------- */

.home-section { margin: 0; }
.home-section > h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.3;
}

.tiles { display: flex; flex-direction: column; }

.tile {
  display: grid;
  grid-template-columns: 30% minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.tile:first-child { border-top: 1px solid var(--line); }
.tile:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.tile.selected { background: #f7faff; }
.tile:hover h3 {
  text-decoration: underline;
  text-decoration-color: var(--link);
  text-underline-offset: 2px;
}

.tile-text { min-width: 0; }

.tile h3 {
  margin: 0 0 3px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.tile-meta {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.4;
}

.tile .summary {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #333;
}

.tile-links {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.tile-links a { color: var(--link); }
.tile-links a:hover { color: var(--link-hover); }

.empty-state {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---- media boxes (project thumbnails, video posters) ---- */

/* Each box takes its own item's aspect ratio (set from the media's intrinsic
   size in main.js). No shared 4:3 crop: the full image/video is always shown. */
.media-box {
  position: relative;
  width: 100%;
  aspect-ratio: var(--media-aspect, 4 / 3);
  overflow: hidden;
  isolation: isolate;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 4px;
  background: var(--soft);
}
.media-box > img,
.media-box > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The humanoid clip is nearly square (640x600); trim its tile height a little
   further than the rest so it does not tower over the landscape thumbnails.
   Only the tile is affected — the detail pane keeps the full frame. */
.tile[data-id="humanoid"] .media-box { aspect-ratio: 4 / 3; }
.tile[data-id="humanoid"] .media-box > video { object-fit: cover; }

.media-tag {
  position: relative;
  z-index: 2;
  padding: 3px 10px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  background: var(--paper);
}
.media-tag::before { content: "\275A\275A  "; }
.tile.playing .media-tag::before { content: "\25B6  "; }

/* ---------------------------------------------------------------------------
   FOOTER
   ------------------------------------------------------------------------- */

.site-footer {
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------------------
   DETAIL PANE (full-screen reader, slides in from the right)
   ------------------------------------------------------------------------- */

.detail-pane {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--paper);
  visibility: hidden;
  transform: translateX(100%);
  transition: transform var(--split-dur) var(--split-ease),
    visibility 0s linear var(--split-dur);
}
body.detail-open .detail-pane {
  visibility: visible;
  transform: translateX(0);
  transition: transform var(--split-dur) var(--split-ease), visibility 0s;
}

.detail-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.detail-scroll::-webkit-scrollbar { display: none; }

.detail-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 46px 48px 80px;
}

.detail-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 16px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.detail-close:hover { color: var(--ink); }

.detail-back {
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  z-index: 7;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.detail-back:hover { color: var(--ink); background: var(--soft); }

.detail-inner h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
}
.detail-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 15px;
}
.detail-meta {
  margin-bottom: 18px;
  font-size: 13.5px;
  color: var(--muted);
}
.detail-meta-line { margin: 0 0 10px; }
.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 2px;
}
.detail-link-btn { display: inline-block; }
.detail-media {
  width: 100%;
  height: auto;
  margin: 6px 0 18px;
  border-radius: 4px;
}

/* typography inside write-up bodies (rendered from `body` HTML in data.js) */
.detail-inner p { margin: 0 0 1em; }
.detail-inner h2 {
  margin: 1.6em 0 0.5em;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
}
.detail-inner h3 {
  margin: 1.3em 0 0.4em;
  font-size: 16px;
  font-weight: 600;
}
.detail-inner ul,
.detail-inner ol { margin: 0 0 1em; padding-left: 1.35em; }
.detail-inner li { margin: 0 0 0.35em; }
.detail-inner img,
.detail-inner video { max-width: 100%; }
.detail-body video {
  width: 100%;
  height: auto;
  display: block;
  margin: 0.75em 0 0.4em;
}
.detail-caption {
  margin: 0 0 1.2em;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------------------
   BLOG
   ------------------------------------------------------------------------- */

.blog-tile {
  display: block;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.blog-tile:first-child { border-top: 1px solid var(--line); }
.blog-tile .date {
  font-size: 12.5px;
  color: var(--muted);
}
.blog-tile h3 {
  margin: 2px 0 6px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}
.blog-tile:hover h3 {
  text-decoration: underline;
  text-decoration-color: var(--link);
  text-underline-offset: 2px;
}

.blog-open {
  margin: 0;
  max-height: calc(var(--preview-lines, 3) * 1.55em);
  overflow: hidden;
  font-size: 14px;
  color: #333;
}

.post-view {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  background: var(--paper);
}
body.post-open .post-view { display: block; }
body.post-open .list-col { visibility: hidden; }

/* ---------------------------------------------------------------------------
   PAPER PAGE — standalone HTML of a write-up (single column)
   ------------------------------------------------------------------------- */

.page-paper .corner-nav {
  position: static;
  display: block;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 0;
  text-align: center;
}
.page-paper .nav-name { font-size: 20px; font-weight: 500; }

.paper-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 24px 90px;
}
.paper-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13.5px;
}
.paper-wrap > h1,
.paper-masthead h1 {
  margin: 0 0 10px;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
}
.paper-byline {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--muted);
}
.paper-links {
  margin: 0 0 28px;
  font-size: 14px;
}
.paper-links a { margin-right: 14px; }
.paper-wrap .paper-h,
.paper-wrap h2.paper-h {
  margin: 2em 0 0.7em;
  font-size: 21px;
  font-weight: 600;
}
.paper-wrap h3.paper-sub {
  margin: 1.6em 0 0.5em;
  font-size: 17px;
  font-weight: 600;
}
.paper-wrap p { margin: 0 0 1em; }
.paper-wrap ul,
.paper-wrap ol { margin: 0 0 1em; padding-left: 1.3em; }
.paper-wrap li { margin: 0 0 0.4em; }
.paper-wrap figure { margin: 1.4em 0 1.6em; }
.paper-wrap figure img { width: 100%; height: auto; display: block; }
.paper-wrap figcaption,
.paper-wrap figure p {
  margin-top: 0.5em;
  color: var(--muted);
  font-size: 13.5px;
}
.paper-wrap table { width: 100%; margin: 0.6em 0 1.2em; }
.paper-wrap th,
.paper-wrap td {
  text-align: left;
  padding: 4px 8px 4px 0;
  vertical-align: top;
}

/* MathML: do not set `display: block` or overflow on <math> itself — that
   overrides the UA `math` inner display type and stacks glyphs in Chromium.
   Isolate from `* { box-sizing: border-box }` and body line-height. */
.paper-eq {
  overflow-x: auto;
  max-width: 100%;
  margin: 1.15em 0;
  text-align: center;
}
.paper-wrap math {
  font-family: "STIX Two Math", math, serif;
  font-size: 1.05em;
  line-height: normal;
  text-indent: 0;
}
.paper-wrap math,
.paper-wrap math * { box-sizing: content-box; }
.paper-wrap math[display="block"] { margin-block: 0.15em; }
.paper-wrap section[role="doc-bibliography"] ul { padding-left: 0; }
.paper-wrap section[role="doc-bibliography"] li {
  margin: 0 0 0.55em;
  padding-left: 2.2em;
  text-indent: -2.2em;
}

/* ---------------------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------------------- */

/* Tighter spacing on smaller screens. */
@media (max-width: 980px) {
  .list-col {
    padding: 32px 20px 60px;
  }

  .detail-inner { padding: 64px 20px 60px; }
  .post-view .detail-inner { padding-top: 64px; }
}

@media (max-width: 700px) {
  .list-col {
    padding: 26px 18px 50px;
    gap: 24px;
  }

  .profile {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .profile-name {
    text-align: left;
    font-size: 28px;
    margin-bottom: 12px;
  }
  .profile-links { text-align: left; }
  .profile-photo { align-items: flex-start; }
  .profile-photo img { max-width: 220px; }

  .tile {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .paper-wrap { padding: 16px 18px 72px; }
  .page-paper .corner-nav { padding: 22px 18px 0; }
}

/* respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .list-col,
  .detail-pane,
  .tile,
  .blog-tile,
  .profile-photo img,
  .randomize { transition: none; }
}
