/*
  The numbers live in tokens.css (pixels at a 1920px-wide window). Here they become real sizes:
  --px is one of those pixels scaled to the current window, so `200 * var(--px)` is 200px at 1920
  and grows or shrinks with the window. Text uses max(…) so it never drops below a readable size.
*/
:root {
  --px: calc(100vw / 1920);
  --gutter-len: max(12px, calc(var(--gutter) * var(--px)));
  --card-width-len: calc(var(--card-width) * var(--px));
  --card-gap-len: max(4px, calc(var(--card-gap) * var(--px)));
  --card-radius-len: max(4px, calc(var(--card-radius) * var(--px)));
  --hero-gap-len: calc(var(--hero-gap) * var(--px));
  --section-gap-len: calc(var(--section-gap) * var(--px));
  --row-gap-len: calc(var(--row-gap) * var(--px));
  --intro-bottom-len: calc(var(--intro-bottom) * var(--px));
  --site-name-len: max(15px, calc(var(--site-name-size) * var(--px)));
  --media-gap-len: max(4px, calc(var(--media-gap) * var(--px)));
  --greeting-len: max(calc(var(--greeting-min) * 1px), calc(var(--greeting-size) * var(--px)));
  --header-top-len: calc(var(--header-top) * var(--px));
  /* Puts the hero line's top at --page-top: what's left after the header */
  --hero-top-len: calc((var(--page-top) - var(--header-top)) * var(--px) - var(--greeting-len));
}

* {
  box-sizing: border-box;
}

/*
  Giving <html> its own background stops the browser moving body's background onto the page
  canvas, which blend modes can't see. Body then paints a real white layer the cursor
  can "difference" against.
*/
html {
  background: var(--color-bg);
}

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg);
}

p,
h2 {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.muted {
  color: var(--color-muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--header-top-len) var(--gutter-len) 0;
}

/* The greeting is typed in by js/greeting.js; the right border is the typing caret */
.logo {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  font-size: var(--greeting-len);
  font-weight: var(--greeting-weight);
  line-height: 1;
  white-space: nowrap;
}

.greeting {
  padding-right: 0.1em;
  border-right: max(1px, 2 * var(--px)) solid transparent;
}

.greeting.is-typing {
  border-right-color: currentColor;
}

/*
  The nav stays put while the page scrolls. Each link is black, and turns white while it's over
  a card or other dark content (js/nav-contrast.js) — only ever black or white, never grey.
*/
.nav {
  --nav-len: max(calc(var(--small-min) * 1px), calc(var(--nav-size) * var(--px)));

  position: fixed;
  /* Lines the nav's baseline up with the greeting's (0.8635 = Inter's baseline at line-height 1) */
  top: calc(var(--header-top-len) + 0.8635 * (var(--greeting-len) - var(--nav-len)));
  right: var(--gutter-len);
  z-index: 100;
  display: flex;
  gap: max(12px, calc(var(--nav-gap) * var(--px)));
  font-size: var(--nav-len);
  font-weight: var(--nav-weight);
  line-height: 1;
}

.nav a {
  color: #000;
  transition:
    color 0.2s ease,
    opacity 0.2s ease;
}

.nav a.is-on-dark,
.logo.is-on-dark {
  color: #fff;
}

.logo.is-on-dark .muted {
  color: rgba(255, 255, 255, 0.6);
}

.logo .muted {
  transition: color 0.2s ease;
}

/* Fading works on both black and white, where a grey hover colour wouldn't */
.nav a:hover {
  opacity: 0.5;
}

/*
  Hero — one line: location and live LA time on the left; the tagline starts at 60% of the page,
  split into "Designer." · "Dreamer." · "Giving form to possibilities." by long gaps
*/

.hero {
  display: grid;
  grid-template-columns: calc(var(--location-column) / 1888 * 100%) 1fr;
  align-items: baseline;
  padding: var(--hero-top-len) var(--gutter-len) 0;
  font-size: max(calc(var(--small-min) * 1px), calc(var(--location-size) * var(--px)));
  line-height: 1.2;
  white-space: nowrap;
}

.location {
  display: flex;
  gap: max(10px, calc(var(--clock-gap) * var(--px)));
  font-weight: var(--location-weight);
}

.clock {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.tagline {
  display: flex;
  align-items: baseline;
  font-size: max(calc(var(--small-min) * 1px), calc(var(--tagline-size) * var(--px)));
  font-weight: var(--tagline-weight);
}

.tagline > :nth-child(1) {
  margin-right: calc(var(--tagline-word-gap) * var(--px));
}

.tagline > :nth-child(2) {
  margin-right: calc(var(--tagline-gap) * var(--px));
}

/* Project rows — they roll inside the page margins */

.work {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap-len);
  padding: var(--hero-gap-len) var(--gutter-len) var(--section-gap-len);
}

.project-row {
  overflow: hidden;
}

.project-row h2 {
  margin-bottom: max(10px, calc(var(--title-gap) * var(--px)));
  font-size: max(calc(var(--small-min) * 1px), calc(var(--title-size) * var(--px)));
  font-weight: var(--title-weight);
  line-height: 1.2;
}

.project-year {
  color: var(--color-muted);
}

/* Without JS (or with reduced motion) rows are swipeable; js/marquee.js upgrades them to rolling rows */
.card-track {
  display: flex;
  gap: var(--card-gap-len);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.card-track::-webkit-scrollbar {
  display: none;
}

.card-track.is-marquee {
  overflow: visible;
  scroll-snap-type: none;
  will-change: transform;
}

.card {
  flex: 0 0 var(--card-width-len);
  aspect-ratio: var(--card-width) / var(--card-height);
  border-radius: var(--card-radius-len);
  background: var(--color-card);
  scroll-snap-align: start;
  transition: background 0.2s ease;
}

.card:hover {
  background: var(--color-card-hover);
}

/* Images and videos fill the card and are cropped to its shape */
.card {
  overflow: hidden;
}

.card img,
.card video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Footer — one centred grey line, with "love" and "care" picked out in black */

.site-footer {
  color: var(--color-muted);
  padding: 0 var(--gutter-len) max(12px, calc(var(--footer-bottom) * var(--px)));
  text-align: center;
  font-size: max(11px, calc(var(--footer-size) * var(--px)));
  font-weight: var(--footer-weight);
  line-height: 1.2;
}

.site-footer strong {
  color: var(--color-text);
  font-weight: inherit;
}

/* Homepage rows link to their project page */

.project-link {
  display: block;
}

/*
  Project page — a full-screen video that stays put while the rest of the page (white, on top)
  slides up over it, then the intro text, then full-width images and videos.
*/

.project-page .site-header,
.about-page .site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
}

/* Other pages: "June Zhao" instead of the typed greeting, fixed in line with the nav */
.site-name {
  position: fixed;
  top: var(--header-top-len);
  left: var(--gutter-len);
  z-index: 100;
  font-size: var(--site-name-len);
  font-weight: 700;
  line-height: 1;
  color: #000;
  transition: color 0.2s ease;
}

.site-name.is-on-dark {
  color: #fff;
}

.project-page .nav {
  top: calc(var(--header-top-len) + 0.8635 * (var(--site-name-len) - var(--nav-len)));
}

/* Phones only (see the end of this file): the nav folds into this button */
.menu-toggle {
  display: none;
}

.project-hero {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100vh;
  height: 100svh;
  background: #000;
}

.project-hero video,
.project-hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Bottom-left of the opening video; black or white depending on what's behind it */
.sound-toggle {
  position: absolute;
  left: var(--gutter-len);
  bottom: var(--gutter-len);
  z-index: 1;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: max(calc(var(--small-min) * 1px), calc(var(--nav-size) * var(--px)));
  font-weight: var(--nav-weight);
  line-height: 1;
  color: #000;
  transition:
    color 0.2s ease,
    opacity 0.2s ease;
}

.sound-toggle.is-on-dark {
  color: #fff;
}

.sound-toggle:hover {
  opacity: 0.5;
}

.project-body {
  position: relative;
  z-index: 1;
  background: var(--color-bg);
}

/* The facts sit right at the top edge, as close as the side margins */
.project-intro {
  padding: var(--gutter-len) var(--gutter-len) var(--intro-bottom-len);
}

/*
  Facts across the top — grey label over black value. The first three sit in sixths of the
  page; the project type lines up with the homepage tagline at 60%.
*/
.project-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 0.6fr 2.4fr;
  margin: 0;
  font-size: max(12px, calc(var(--meta-size) * var(--px)));
  font-weight: var(--location-weight);
  line-height: 1.25;
}

.project-meta > :last-child {
  grid-column: 5;
}

.project-meta dt {
  color: var(--color-muted);
}

.project-meta dd {
  margin: 0;
}

.project-description {
  max-width: 66%;
  margin-top: calc(var(--description-gap) * var(--px));
  font-size: max(22px, calc(var(--description-size) * var(--px)));
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

/* Images and videos: full width, all cropped to the same shorter frame; black between them */
.project-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--media-gap-len);
  background: #000;
}

.project-gallery > img,
.project-gallery > video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--media-ratio);
  object-fit: cover;
}

/* Two or three pieces side by side, sharing one frame */
.media-row {
  display: flex;
  gap: var(--media-gap-len);
  aspect-ratio: var(--media-ratio);
  /* Without this a tall (portrait) piece stretches the frame */
  overflow: hidden;
}

.media-row > * {
  display: block;
  flex: 1;
  min-width: 0;
  height: 100%;
  object-fit: cover;
}

.project-gallery + .site-footer {
  padding-top: var(--section-gap-len);
}

/*
  About — a 4:5 photo in the left half, its top level with the greeting; the typed greeting,
  the statement and education / experience on the right, starting where the homepage's content
  does. The cat (js/about.js) walks along the top of education / experience, as if on the floor.
*/

.about {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  min-height: 100svh;
}

.about-photo {
  padding: calc(var(--page-top) * var(--px)) var(--gutter-len) var(--gutter-len);
}

.about-photo img {
  display: block;
  width: calc(var(--about-photo) * var(--px));
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 35%;
}

.about-text {
  position: relative;
  padding: calc(var(--page-top) * var(--px)) var(--gutter-len) calc(var(--gutter-len) * 3);
}

.about-text .logo {
  margin: 0;
}

.about-statement {
  max-width: 34em;
  margin-top: calc(var(--about-gap) * var(--px));
  font-size: max(17px, calc(var(--about-size) * var(--px)));
  font-weight: 500;
  line-height: 1.35;
}

/* Education | Experience — set like the project pages' facts: grey labels, black titles */
.about-cv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gutter-len);
  margin-top: calc(var(--cv-gap) * var(--px));
  font-size: max(calc(var(--small-min) * 1px), calc(var(--nav-size) * var(--px)));
  font-weight: var(--location-weight);
  line-height: 1.3;
}

.cv-heading {
  margin: 0 0 1.2em;
  font: inherit;
  color: var(--color-muted);
}

.cv-column ul {
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv-line {
  display: flex;
  gap: 1.5em;
  color: var(--color-muted);
}

.about-cat {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/*
  Playground — an endless grid you drag around (js/playground.js), on a light dot grid that
  moves with it. Each piece is kept whole, centred in a square cell that spans whole dots.
*/

.playground-page {
  overflow: hidden;
}

.pg-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: var(--pg-bg);
  background-image: radial-gradient(circle, var(--pg-dot) 1.2px, transparent 1.6px);
  background-size: var(--pg-dot-len) var(--pg-dot-len);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.pg-cell {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--pg-cell-len);
  height: var(--pg-cell-len);
  will-change: transform;
}

.pg-cell img,
.pg-cell video {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* June's cat (js/cat.js) — lives on the canvas, above the pieces */
/* A point at the cat's feet; the drawing hangs off it. It ignores the mouse entirely. */
.pg-cat {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 0;
  height: 0;
  pointer-events: none;
  will-change: transform;
}

.pg-cat svg {
  position: absolute;
  display: block;
  overflow: visible;
}

/* The magnifier: a round lens that replaces the cursor while it's over a piece */
.pg-magnifier {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 220px;
  height: 220px;
  border: 1px solid var(--color-text);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pg-magnifier.is-visible {
  opacity: 1;
}

.pg-magnifying .cursor {
  opacity: 0 !important;
}

/* Custom cursor (only on devices with a mouse — see js/cursor.js) */

.has-custom-cursor,
.has-custom-cursor * {
  cursor: none;
}

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  overflow: hidden;
  border: 1px solid #fff;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  /* Same Difference trick as the nav: the dot and ring turn black on light content, white on dark */
  mix-blend-mode: difference;
  transition:
    width 0.35s ease,
    height 0.35s ease,
    background-color 0.35s ease,
    border-color 0.35s ease,
    opacity 0.3s ease;
}

.has-custom-cursor .cursor {
  display: flex;
}

.cursor.is-hidden {
  opacity: 0;
}

.cursor.is-link {
  width: 28px;
  height: 28px;
  background: transparent;
}

/*
  Over cards the cursor stays a solid black circle: inverted, the "view" label would vanish
  into mid-tone images (and into the grey placeholders completely).
*/
.cursor.is-card {
  width: 72px;
  height: 72px;
  border-color: var(--color-text);
  background: var(--color-text);
  mix-blend-mode: normal;
}

.cursor-label {
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cursor.is-card .cursor-label {
  opacity: 1;
  transition-delay: 0.1s;
}

/* Scroll reveal (see js/reveal.js) */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity calc(var(--reveal-duration) * 1s) ease,
    transform calc(var(--reveal-duration) * 1s) cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--delay, 0ms);
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] {
    transform: none;
  }
}

/* Phones: switch to fixed sizes so cards and spacing stay usable */

@media (max-width: 767px) {
  :root {
    --gutter-len: 16px;
    --card-width-len: 75vw;
    --card-gap-len: 8px;
    --header-top-len: 20px;
    --hero-top-len: 72px;
    --hero-gap-len: 100px;
    --section-gap-len: 72px;
    --row-gap-len: 45px;
  }

  /*
    The nav folds into a two-line button at the top right (js/menu.js); tapping it opens the
    nav full screen, in big type, and the lines turn into a cross
  */
  .menu-toggle {
    position: fixed;
    top: var(--header-top-len);
    right: var(--gutter-len);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 28px;
    height: 22px;
    padding: 0;
    border: 0;
    background: none;
    color: #000;
    transition: color 0.2s ease;
  }

  .menu-toggle.is-on-dark {
    color: #fff;
  }

  .menu-toggle span {
    display: block;
    height: 2px;
    background: currentColor;
    transition: transform 0.3s ease;
  }

  .menu-open .menu-toggle span:first-child {
    transform: translateY(4px) rotate(45deg);
  }

  .menu-open .menu-toggle span:last-child {
    transform: translateY(-4px) rotate(-45deg);
  }

  .nav {
    inset: 0;
    z-index: 150;
    flex-direction: column;
    gap: 12px;
    padding: 120px var(--gutter-len) var(--gutter-len);
    background: var(--color-bg);
    font-size: 32px;
    font-weight: var(--greeting-weight);
    transition: opacity 0.25s ease, visibility 0.25s;
  }

  .project-page .nav {
    top: 0;
  }

  html:not(.menu-open) .nav {
    visibility: hidden;
    opacity: 0 !important;
  }

  /* Opening the menu should be quick, not the slow fade the nav gets when the page loads */
  .js .nav {
    transition: opacity 0.25s ease, visibility 0.25s;
    transform: none;
  }

  .menu-open body {
    overflow: hidden;
  }

  /* Small enough that the longest greeting + "My name is June." fits on one line */
  .logo {
    font-size: min(22px, 5.8vw);
  }

  /* No room for one line: location and time on top, the tagline underneath (wrapping if needed) */
  .hero {
    grid-template-columns: 1fr;
    gap: 40px;
    white-space: normal;
  }

  .tagline {
    flex-wrap: wrap;
  }

  .tagline > :nth-child(1),
  .tagline > :nth-child(2) {
    margin-right: 24px;
  }

  .project-intro {
    padding: var(--gutter-len) var(--gutter-len) 72px;
  }

  /* About: photo on top, statement underneath */
  .about {
    grid-template-columns: 1fr;
  }

  .about-photo {
    padding: 128px var(--gutter-len) 0;
  }

  .about-photo img {
    width: 100%;
  }

  .about-text {
    padding: 48px var(--gutter-len) 72px;
  }

  .about-cv {
    grid-template-columns: 1fr;
    gap: 40px;
    margin-top: 56px;
  }

  .about-statement {
    margin-top: 20px;
  }

  .project-meta {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .project-meta > :last-child {
    grid-column: auto;
  }

  .project-description {
    max-width: none;
    margin-top: 24px;
  }
}
