/* ===========================================================================
   Yingxuan Ma — portfolio
   Two columns: a fixed index on the left, a continuous media stream on the
   right. Everything is set in one neo-grotesque at two sizes: very large for
   the name, very small for everything else.
   =========================================================================== */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #8c8c8c;
  --faint: #c9c9c9;
  --rule: #e8e8e8;
  --field: #f2f2f2;          /* letterbox behind media while it loads */
  --sel: #0a0a0a;

  --gutter: clamp(16px, 2.1vw, 32px);
  --col: 34%;                 /* width of the fixed index column */
  --micro: 10.5px;            /* captions, meta */
  --small: 11.5px;            /* index entries */
  --body: 13px;               /* project text */

  --font: "Helvetica Neue", Helvetica, Inter, -apple-system, BlinkMacSystemFont,
          "Segoe UI", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0b0b0b;
  --fg: #f2f2f2;
  --muted: #7d7d7d;
  --faint: #4a4a4a;
  --rule: #232323;
  --field: #151515;
  --sel: #f2f2f2;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--sel); color: var(--bg); }

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 8px 12px;
  background: var(--fg);
  color: var(--bg);
  font-size: var(--micro);
}
.skip:focus { left: 0; }

/* --- left column ---------------------------------------------------------- */

.index {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--col);
  height: 100vh;
  padding: var(--gutter);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 20;
  background: var(--bg);
  scrollbar-width: none;
}
.index::-webkit-scrollbar { display: none; }

.index-inner {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--gutter) * 2);
}

.wordmark {
  margin: 0 0 0.5em;
  font-size: clamp(30px, 4.6vw, 76px);
  font-weight: 600;
  line-height: 0.86;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}
.wordmark a:hover { text-decoration: none; }

.role {
  margin: 0 0 2.4em;
  max-width: 30ch;
  font-size: var(--small);
  line-height: 1.5;
  color: var(--muted);
}

/* index of works */

.toc-group { margin-bottom: 1.9em; }

.toc-label {
  margin: 0 0 0.75em;
  font-size: var(--micro);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-list li { margin: 0; }

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  padding: 1.5px 0;
  font-size: var(--small);
  line-height: 1.55;
  color: var(--fg);
  transition: color 0.18s ease, opacity 0.18s ease;
}
.toc-link:hover { text-decoration: none; }

.toc-num {
  flex: none;
  width: 1.4em;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  transition: color 0.18s ease;
}

.toc-year {
  margin-left: auto;
  padding-left: 1em;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  transition: color 0.18s ease;
}

/* dim the rest of the list while one entry is under the cursor */
.toc:hover .toc-link { color: var(--faint); }
.toc:hover .toc-link:hover { color: var(--fg); }
.toc:hover .toc-link:hover .toc-num,
.toc:hover .toc-link:hover .toc-year { color: var(--muted); }

/* the project currently in view */
.toc-link.is-active .toc-title {
  box-shadow: inset 0 -1px 0 currentColor;
}
.toc-link.is-active .toc-num { color: var(--fg); }

/* info block, pinned to the bottom of the column */

.info {
  margin-top: auto;
  padding-top: 2.6em;
  font-size: var(--small);
  line-height: 1.55;
}

.info p { margin: 0 0 1em; max-width: 34ch; }
.info .about { color: var(--muted); }

.info-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1.1em;
  margin-top: 1.4em;
  font-size: var(--micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}
.theme-toggle:hover { text-decoration: underline; text-underline-offset: 2px; }

.colophon {
  margin-top: 1.6em;
  font-size: var(--micro);
  color: var(--faint);
}

/* --- right column: the stream -------------------------------------------- */

.stream {
  margin-left: var(--col);
  padding: var(--gutter) var(--gutter) 22vh;
  width: calc(100% - var(--col));
}

.project {
  padding-top: 3.4em;
  scroll-margin-top: var(--gutter);
}
.project:first-child { padding-top: 0; }

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5em 1em;
  padding-bottom: 0.7em;
  border-bottom: 1px solid var(--rule);
}

.project-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.project-title .alt {
  margin-left: 0.6em;
  font-weight: 400;
  color: var(--muted);
}

.project-meta {
  margin-left: auto;
  font-size: var(--micro);
  line-height: 1.6;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
}
.project-meta .credit { color: var(--faint); }

.project-text {
  margin: 1.1em 0 0;
  max-width: 58ch;
  color: var(--fg);
}
.project-text p { margin: 0 0 0.8em; }

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em 1.2em;
  margin: 0.4em 0 0;
  padding: 0;
  list-style: none;
  max-width: 58ch;
  font-size: var(--micro);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* media */

.plate {
  margin: 2.2em 0 0;
}

.plate-frame {
  position: relative;
  display: block;
  /* full column width, except for tall pieces: --ar (width/height) keeps a
     portrait clip from running metres down the page */
  width: min(100%, calc(84vh * var(--ar, 1.7778)));
  margin: 0;
  padding: 0;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--field);
  color: inherit;
  font: inherit;
  cursor: zoom-in;
  overflow: hidden;
  line-height: 0;
}

.plate-frame img,
.plate-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.plate-frame img.is-ready,
.plate-frame video.is-ready { opacity: 1; }

/* a clip stored in one orientation and shown in another — main.js sets the
   swapped width/height and the rotation itself */
.is-turned {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
}

/* the poster sits under the video until the video has frames to show */
.plate-frame .poster {
  position: absolute;
  inset: 0;
  opacity: 1;
  transition: opacity 0.6s ease;
}
.plate-frame .poster.is-hidden { opacity: 0; }

.plate-caption {
  display: flex;
  align-items: baseline;
  gap: 1em;
  margin-top: 0.65em;
  font-size: var(--micro);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.plate-caption .idx {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

.plate-tools {
  margin-left: auto;
  display: flex;
  gap: 0.9em;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.plate:hover .plate-tools,
.plate-tools:focus-within { opacity: 1; }

.plate-tools button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  letter-spacing: inherit;
  text-transform: uppercase;
  cursor: pointer;
}
.plate-tools button:hover { color: var(--fg); }
.plate-tools button[aria-pressed="true"] { color: var(--fg); }

.stream-end {
  margin-top: 6em;
  padding-top: 1.2em;
  border-top: 1px solid var(--rule);
  font-size: var(--micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.noscript {
  max-width: 46ch;
  font-size: var(--small);
  color: var(--muted);
}

/* --- hover preview -------------------------------------------------------- */

.peek {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: 190px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 0, 0);
  transition: opacity 0.18s ease;   /* never transition transform: it follows the cursor */
  will-change: transform;
}
.peek.is-visible { opacity: 1; }
.peek img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--field);
}

/* --- lightbox ------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vh, 64px);
  background: var(--bg);
}
.lightbox[hidden] { display: none; }

.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.lb-stage img,
.lb-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* holds a turned clip: height-led, so the box keeps the shown aspect ratio */
.lb-turn {
  position: relative;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
}
.lb-turn video { max-width: none; max-height: none; object-fit: cover; }

/* boards are published larger than the screen so they can be read */
.lb-stage img.can-zoom { cursor: zoom-in; }
.lb-stage.is-zoomed {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
}
.lb-stage.is-zoomed img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.lb-close,
.lb-nav {
  position: absolute;
  z-index: 2;
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: var(--micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.lb-close { top: var(--gutter); right: var(--gutter); }
.lb-prev { left: var(--gutter); top: 50%; transform: translateY(-50%); font-size: 15px; }
.lb-next { right: var(--gutter); top: 50%; transform: translateY(-50%); font-size: 15px; }
.lb-close:hover, .lb-nav:hover { text-decoration: underline; text-underline-offset: 3px; }

.lb-caption {
  position: absolute;
  left: var(--gutter);
  bottom: var(--gutter);
  margin: 0;
  font-size: var(--micro);
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* --- narrow screens ------------------------------------------------------- */

@media (max-width: 900px) {
  :root { --col: 0%; }

  .index {
    position: static;
    width: 100%;
    height: auto;
    overflow: visible;
    padding-bottom: 0;
    border-bottom: 1px solid var(--rule);
  }
  .index-inner { min-height: 0; }

  .wordmark { font-size: clamp(38px, 13vw, 84px); }
  .role { margin-bottom: 2em; }

  .toc-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 2em;
  }

  .info { margin-top: 2em; padding-bottom: var(--gutter); }
  .info p { max-width: 46ch; }

  .stream { margin-left: 0; width: 100%; padding-top: 2em; }
  .project-meta { margin-left: 0; width: 100%; text-align: left; }
  .peek { display: none; }
}

/* --- motion / print ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .peek { display: none; }
}

@media print {
  .index { position: static; width: 100%; height: auto; }
  .stream { margin-left: 0; width: 100%; }
  .plate-tools, .peek, .lightbox, .skip { display: none !important; }
}
