/* =========================================================
   Yvonne Mak: portfolio
   One stylesheet for every page. Normally you do not need to
   touch this file. The few things you may want to change are
   at the top, in :root.
   ========================================================= */

:root {
  --ink: #000;
  --paper: #fff;
  --mute: #6b6b6b;

  --pad: clamp(16px, 2vw, 28px);           /* distance to the screen edge */
  --text-col: clamp(300px, 30vw, 440px);   /* width of the white text column */
  --panel: clamp(270px, 22vw, 360px);      /* width of the sliding menu (the page is pushed by this much) */
  --burger: 56px;                          /* size of the menu button */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { display: block; width: 100%; height: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- Home: one image, no scrolling ---------- */

body.home { height: 100vh; height: 100dvh; overflow: hidden; }
.hero { position: fixed; inset: 0; }
.hero img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Work pages: fixed text left, images scroll right ---------- */

.work-layout {
  display: grid;
  grid-template-columns: var(--text-col) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.text {
  position: sticky;
  top: 0;              /* site.js lowers this for long texts so the whole text can be read */
  align-self: start;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  background: var(--paper);
}

.text h1 { font-size: 15px; font-weight: 500; line-height: 1.3; }
.text .sub { font-style: italic; font-size: 13px; line-height: 1.4; }
.text .year { color: var(--mute); font-size: 12px; margin-top: 2px; }

.text .body { margin-top: 2.25rem; max-width: 42ch; }
.text .body p + p { margin-top: 0.9em; }
.text .body a { text-underline-offset: 3px; }
.text .body .material + p { margin-top: 1.6em; }

.text .meta { margin-top: auto; padding-top: 2.5rem; }
.meta .insta { display: inline-block; line-height: 0; }
.meta small { display: block; margin-top: 0.9rem; font-size: 11px; color: var(--ink); }

.images img { width: 100%; height: auto; }   /* full width, never cropped */

/* Text-only pages (Press, Biography) */
.work-layout.text-only { display: block; }
.text-only .text {
  position: static;
  height: auto;
  min-height: 0;
  max-width: 36rem;
  padding-top: calc(var(--pad) + 4px);
  padding-bottom: 4rem;
}

/* ---------- Story page (Sandbag Castle): text and images scroll together ---------- */

.story { --gutter: clamp(16px, 10vw, 180px); }   /* white space left and right of smaller images */

.story-head { padding: calc(var(--burger) + 8px) var(--pad) 0; }
.story-head h1 { font-size: 15px; font-weight: 500; line-height: 1.3; }
.story-head .sub { font-style: italic; font-size: 13px; line-height: 1.4; }
.story-head .year { color: var(--mute); font-size: 12px; margin-top: 2px; }

.story img { display: block; width: 100%; height: auto; }

/* Text */
.story-text {
  max-width: calc(46ch + 2 * var(--pad));
  padding: 3rem var(--pad);
}
.story-text h2 { font-size: 14px; font-weight: 500; margin-bottom: 0.6rem; }
.story-text p + p { margin-top: 0.9em; }
.story-text a { text-underline-offset: 3px; }

/* One image, full width (use once, at the start) */
.story-full { margin: 0; }

/* Two images side by side, with white space around */
.story-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: clamp(16px, 4vw, 64px);
  padding: 3rem var(--gutter);
}

/* Text left, image right (add class "reverse" to flip) */
.story-split {
  display: grid;
  grid-template-columns: 5fr 6fr;
  align-items: start;
  gap: clamp(24px, 5vw, 80px);
  padding: 3rem var(--pad);
}
.story-split .story-text { padding: 0; max-width: 46ch; }
.story-split.reverse { grid-template-columns: 6fr 5fr; }
.story-split.reverse > :first-child { order: 2; }

/* One smaller image, to the left or right, with white space */
.story-inset { margin: 0; padding: 3rem var(--gutter); }
.story-inset img { width: 55%; }
.story-inset.right img { margin-left: auto; }

.story-text.wide { max-width: none; }

.colophon {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.55rem 1.5rem;
  max-width: 46rem;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}
.colophon dd { margin: 0; }
.colophon dt { margin: 0; }

.story figcaption { padding-top: 0.5rem; font-size: 12px; color: var(--mute); }

.story-foot { padding: 2.5rem var(--pad) 3rem; }
.story-foot .insta { display: inline-block; line-height: 0; }
.story-foot small { display: block; margin-top: 0.9rem; font-size: 11px; }

.text .body h2 { font-size: 14px; font-weight: 500; margin: 2.2rem 0 0.8rem; break-after: avoid-column; }
.text .body h2:first-child { margin-top: 0; }
.text .cv-head + .body { margin-top: 0; }
.text .cv-head { font-size: 15px; font-weight: 500; line-height: 1.3; margin-top: 4rem; margin-bottom: 1.6rem; }

/* Text-only pages: two columns on a wide screen, like a printed page */
@media (min-width: 1000px) {
  .text-only .text { max-width: none; }
  .text-only .body { max-width: 100ch; column-count: 2; column-gap: clamp(32px, 5vw, 80px); }
  .text-only .body p { break-inside: avoid-column; }
}

/* ---------- Menu button ---------- */

.menu-btn {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  width: var(--burger);
  height: var(--burger);
  background: var(--paper);
  border: 0;
  cursor: pointer;
}
.menu-btn span {
  position: absolute;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--ink);
  transition: transform 0.35s ease, opacity 0.2s ease;
}
.menu-btn span:nth-child(1) { top: 20px; }
.menu-btn span:nth-child(2) { top: 27px; }
.menu-btn span:nth-child(3) { top: 34px; }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Sliding menu panel ---------- */

.menu-scrim {            /* invisible: click outside the panel closes it */
  position: fixed;
  inset: 0;
  z-index: 15;
  display: none;
}
.menu-scrim.open { display: block; }

.menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: var(--panel);
  overflow-y: auto;
  padding: var(--pad);
  padding-top: calc(var(--burger) + 12px);
  background: var(--paper);
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.menu.open { transform: none; }

.menu a { text-decoration: none; }
.menu a:hover { text-decoration: underline; text-underline-offset: 3px; }
.menu a[aria-current="page"] { text-decoration: underline; text-underline-offset: 3px; }

.menu .home-link {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  font-size: 14px;
  font-weight: 500;
}

.menu ul { list-style: none; }
.menu .top li,
.menu .work-head { font-size: 18px; line-height: 1.25; margin-bottom: 10px; }
.menu .work-head { margin-top: 2.1rem; margin-bottom: 14px; }

.menu .group { margin-bottom: 1.05rem; }
.menu .group-title { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
.menu .group li { font-size: 13px; font-style: italic; line-height: 1.35; margin: 0 0 5px 1.3rem; }

.menu .menu-foot { margin-top: 2.5rem; padding-bottom: 1rem; }
.menu .menu-foot .insta { display: inline-block; line-height: 0; }
.menu .menu-foot small { display: block; margin-top: 0.9rem; font-size: 11px; }

/* ---------- Hover preview ---------- */

/* fills the whole space left of the menu, edge to edge (images are cropped to fit) */
.preview {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: calc(100vw - var(--panel));
  z-index: 10;
  background: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.preview.on { opacity: 1; }
.preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@media (hover: none) { .preview { display: none; } }

/* ---------- The page is pushed to the left when the menu opens ---------- */

.hero, .work-layout, .story {
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
html.menu-open .hero,
html.menu-open .work-layout,
html.menu-open .story {
  transform: translateX(calc(var(--panel) * -1));
}

/* ---------- Mobile ---------- */

@media (max-width: 800px) {
  :root { --burger: 52px; --panel: min(80vw, 360px); }

  .work-layout { display: block; }

  .text {
    position: static;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-top: calc(var(--burger) + 8px);
    padding-bottom: 2rem;
  }
  .text .body { max-width: 60ch; }
  .text .meta { padding-top: 2rem; }
  .story { --gutter: var(--pad); }
  .story-text { padding: 2rem var(--pad); }
  .story-pair { grid-template-columns: 1fr; padding: 1.5rem var(--pad); }
  .story-split, .story-split.reverse { grid-template-columns: 1fr; padding: 1.5rem var(--pad); }
  .story-split.reverse > :first-child { order: 0; }
  .story-inset { padding: 1.5rem var(--pad); }
  .story-inset img { width: 100%; }

  .text-only .text { padding-top: calc(var(--burger) + 8px); }
}

@media (prefers-reduced-motion: reduce) {
  .menu, .menu-btn span, .hero, .work-layout, .story, .preview { transition: none; }
}
