/* ============================================================
   Jeremy Huang — personal site
   Design tokens
   ------------------------------------------------------------
   paper   cool near-white background
   ink     near-black text
   muted   gray for descriptors / metadata
   line    hairline dividers
   accent  deep pine green — links, arrows, focus
   ============================================================ */

:root {
  --paper:  #FCFCFA;
  --ink:    #16181D;
  --muted:  #6B7079;
  --line:   #E5E5DF;
  --accent: #1F5C4D;
  --accent-wash: rgba(31, 92, 77, 0.06);

  --measure: 42rem;          /* comfortable reading width */
  --step:    clamp(1rem, 0.9rem + 0.5vw, 1.125rem);  /* base body size */

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
}

/* ---------- reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step);
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------- layout shell ---------- */
.wrap {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

/* ============================================================
   Homepage — the index list (the front door)
   ============================================================ */
.home {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: 4rem;
}

.masthead {
  text-align: center;
  margin-bottom: 3.5rem;
}
.masthead h1 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(2.5rem, 1.8rem + 3vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 0.6rem;
}
.masthead .role {
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.01em;
  margin: 0;
}

/* the section index */
.index { border-top: 1px solid var(--line); }

.index__row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding: 1.6rem 1rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background-color 0.25s ease, padding-left 0.25s ease;
}
.index__label {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.index__desc {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.95rem;
}
.index__arrow {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--accent);
  font-size: 1.4rem;
  transition: transform 0.25s ease;
}

.index__row:hover,
.index__row:focus-visible {
  background: var(--accent-wash);
  padding-left: 1.5rem;
  outline: none;
}
.index__row:hover .index__arrow,
.index__row:focus-visible .index__arrow {
  transform: translateX(6px);
}
.index__row:hover .index__label,
.index__row:focus-visible .index__label {
  color: var(--accent);
}

.home__foot {
  margin-top: 3rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.home__foot a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.home__foot a:hover { color: var(--accent); border-color: var(--accent); }
.home__foot .dot { margin-inline: 0.5rem; opacity: 0.5; }

/* ============================================================
   Inner pages — slim persistent nav + content
   ============================================================ */
.topnav {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(120%) blur(8px);
  z-index: 5;
}
.topnav__inner {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.topnav__name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--ink);
}
.topnav__links { display: flex; gap: 1.25rem; }
.topnav__links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
}
.topnav__links a:hover,
.topnav__links a[aria-current="page"] { color: var(--accent); }

main.page { padding-block: 3.5rem 5rem; }

.page h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
  letter-spacing: -0.015em;
  margin: 0 0 1.5rem;
}
.page h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  margin: 2.5rem 0 0.75rem;
}
.page p { margin: 0 0 1.1rem; max-width: 38rem; }
.page a.inline { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }

.lede { font-size: 1.15rem; color: var(--ink); }

/* CV-style entries */
.entry {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.25rem 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.entry__when { color: var(--muted); font-size: 0.9rem; padding-top: 0.15rem; }
.entry__what strong { font-weight: 600; }
.entry__what .where { color: var(--muted); }
@media (max-width: 34rem) {
  .entry { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* ============================================================
   Videos & Media — card grid (rendered from content/videos.json)
   ============================================================ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.75rem 1.5rem;
  margin-top: 2rem;
  padding: 0;
  list-style: none;
}
.card { margin: 0; }
.card a { text-decoration: none; color: inherit; display: block; }
.card__thumb {
  aspect-ratio: 16 / 9;
  background: var(--accent-wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.card a:hover .card__thumb img { transform: scale(1.04); }
.card__thumb--empty {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.5rem;
}
.card__source {
  margin: 0.7rem 0 0.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.card__title { margin: 0; font-size: 1.05rem; line-height: 1.35; font-weight: 500; }
.card a:hover .card__title { color: var(--accent); }
.card__meta { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.85rem; }

.empty-note { color: var(--muted); font-style: italic; }

/* ============================================================
   Homepage "stage" — cropped hand-drawn objects as portals
   ============================================================ */
.stage {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
}
.stage__name {
  position: absolute;
  inset: 0;
  margin: auto;
  height: max-content;
  text-align: center;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(3rem, 1.8rem + 6vw, 6.5rem);
  letter-spacing: -0.02em;
  line-height: 1;
  z-index: 10;                     /* name always sits above the objects */
  pointer-events: none;
}
.stage__tag {
  display: block;
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 0.7rem + 0.5vw, 1rem);
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-top: 0.9rem;
}

/* a clickable object cluster */
.obj {
  position: absolute;
  inset: 0;
  text-decoration: none;
  color: var(--ink);
  z-index: 1;
  pointer-events: none;            /* the art + label are the real click targets */
}
.obj > * { pointer-events: auto; }
.obj img { position: absolute; }
.doodle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.doodle .fillaccent { fill: var(--accent); stroke: none; }
.doodle .strokeaccent { stroke: var(--accent); }
.doodle .ink { fill: var(--ink); stroke: none; }

/* hand-drawn PNGs now ship with real transparent backgrounds */
img.doodle {
  display: block;
  height: auto;
  transition: transform 0.4s cubic-bezier(.2,.8,.3,1);
}

/* section labels are words written on a torn piece of tape */
.obj__label {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 344px;
  height: 124px;
  padding: 0 44px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 3.4rem;
  line-height: 1;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  background: url(images/transparent_backgrounds_png/blank_tape_short_transparent.png) center / 100% 100% no-repeat;
  transition: transform 0.25s ease;
}
/* hover: the tape lifts and tilts a touch */
.obj:hover .obj__label,
.obj:focus-visible .obj__label { transform: rotate(-2.5deg) scale(1.06); }
.obj--media:hover .obj__label,
.obj--media:focus-visible .obj__label { transform: translateX(-50%) rotate(-2.5deg) scale(1.06); }
.obj:focus-visible { outline: none; }
.obj:focus-visible .obj__label {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 3px;
}

/* hover: paired objects counter-rotate and pop a touch (label still greens).
   each transform repeats its base translate so only the rotation changes. */
.obj--cv:hover .d-note,      .obj--cv:focus-visible .d-note      { transform: rotate(106deg) scale(1.03); }
.obj--about:hover .d-tire,   .obj--about:focus-visible .d-tire   { transform: rotate(3deg) scale(1.03); }
.obj--about:hover .d-spike,  .obj--about:focus-visible .d-spike  { transform: rotate(-45deg) scale(1.03); }
.obj--media:hover .d-vhs,    .obj--media:focus-visible .d-vhs    { transform: translateX(-50%) rotate(85deg) scale(1.03); }
.obj--media:hover .d-pencil, .obj--media:focus-visible .d-pencil { transform: translateX(-64%) rotate(157deg) scale(1.03); }

/* placement — big objects, oversized + rotated, cropped by the stage edges.
   coords are relative to the full stage (each .obj is inset:0). */

/* CV — "Economics" notebook, top-left, huge, swung ~100° clockwise */
.d-note { top: -120px; left: -150px; width: clamp(270px, 36vw, 505px); transform: rotate(100deg); }
.obj--cv .obj__label { top: 470px; left: 60px; }

/* stacking so every label clears other clusters' art (name still tops all) */
.obj--about { z-index: 4; }
.obj--cv    { z-index: 3; }
.obj--media { z-index: 2; }

/* About — Pirelli wheel cropped into the corner; transparent PNG, so it's
   naturally opaque inside its outline and the shoe hides behind it (z-index). */
.d-tire  { top: -290px; right: -255px; width: clamp(400px, 50vw, 680px); transform: rotate(8deg); z-index: 2; }
.d-spike { top: -215px; right: -25px;  width: clamp(360px, 48vw, 680px); transform: rotate(-52deg); z-index: 3; }
.obj--about .obj__label { top: 470px; right: 78px; }

/* Videos & Media — VHS stood on end (90°) & bigger; pencil flipped 180°
   overlapping it; whole cluster centered */
.d-vhs    { left: 54.5%; bottom: -360px; width: clamp(460px, 58vw, 780px);
            transform: translateX(-50%) rotate(90deg); z-index: 1; }
/* pencil: transparent PNG, opaque inside its own outline. Lowered below the
   label and nudged left; sits above the VHS via z-index. */
.d-pencil { left: 50%; bottom: -250px;  width: clamp(440px, 56vw, 760px);
            transform: translateX(-64%) rotate(150deg); z-index: 2; }
/* level with About/CV (top:470), but never ride up into the name on tall screens */
.obj--media .obj__label { left: 50%; top: max(470px, calc(50% + 58px)); transform: translateX(-50%); }

/* mobile: drop the crop trick, stack the objects in a calm column */
/* Narrow screens (phones, tablets, squished windows): the wide "stage" with its
   cropped-edge doodles is a wide-screen composition. Keep it simple here — just
   the name and the three tape buttons, stacked and centered. */
@media (max-width: 75rem) {
  .stage {
    overflow: visible;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
  }
  .stage__name {
    position: static; inset: auto; height: auto; display: block; width: 100%;
    margin: 0 0 2.75rem;
    font-size: clamp(1.7rem, 7vw, 3rem); line-height: 1.1; text-align: center;
  }

  /* hide the doodles; the tape labels are the buttons */
  .obj img { display: none !important; }

  .obj {
    position: static !important; inset: auto !important; width: auto !important;
    margin: 0; display: block;
    transform: none !important; pointer-events: auto !important;
  }
  .obj + .obj { margin-top: 1.4rem; }

  .obj__label {
    position: static !important;
    margin: 0 auto;
    width: min(320px, 82vw);
    height: clamp(74px, 23vw, 104px);
    padding: 0 1.4rem;
    font-size: clamp(1.55rem, 6vw, 2rem);
  }
  /* subtle hand-placed tilt so the stacked tape feels casual, not rigid */
  .obj--about .obj__label { transform: rotate(-1.5deg); }
  .obj--cv .obj__label    { transform: rotate(1.5deg); }
  .obj--media .obj__label { transform: rotate(-1deg); }
}

/* ---------- accessibility floor ---------- */
:where(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
html { scroll-behavior: smooth; }

/* ============================================================
   About page — scrolling life timeline
   ------------------------------------------------------------
   Each life stage is one <section class="stage">. Text sits in
   a centered column; the graphic drifts into the left or right
   margin, auto-alternating by order. Override with data-side.
   ============================================================ */
.about-intro {
  position: relative;
  max-width: 40rem;
  margin: 0 auto;
  /* fill the first screen so the timeline (and its reveal) starts below the fold */
  min-height: 86vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}

/* scroll cue at the bottom of the intro */
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 2.2rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  transition: opacity 0.4s ease;
}
.scroll-cue__label {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
}
.scroll-cue__arrow { animation: cue-bounce 1.8s ease-in-out infinite; }
@keyframes cue-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}
.about-intro h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 1.8rem + 2.5vw, 3.6rem);
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
}
.about-intro p {
  color: var(--muted);
  font-size: 1.15rem;
  margin: 0;
}

/* intro portrait: circular headshot with the curly arrow pointing at it */
.about-portrait {
  position: relative;
  width: max-content;
  margin: 2.4rem auto 0;
}
.about-headshot {
  display: block;
  width: clamp(168px, 22vw, 230px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 8px 26px rgba(22, 24, 29, 0.10);
}
.about-arrow {
  position: absolute;
  width: clamp(86px, 11vw, 124px);
  left: clamp(-120px, -9vw, -90px);
  bottom: -14px;
  transform: rotate(16deg);           /* resting angle (JS adds scroll tilt) */
  transform-origin: 75% 60%;
  pointer-events: none;
}
@media (max-width: 40rem) {
  .about-arrow { left: -52px; bottom: -6px; width: 74px; }
}

/* a real photo as stage art reads as a framed photo, not a doodle */
.life__art--photo {
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(22, 24, 29, 0.12);
}

/* the text column drives each section; the gap between sections is fixed and
   uniform (= 2× the old UChicago→Walmart gap of 34px → 68px) no matter how long
   the prose is */
.timeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8.5rem;                 /* spacing after each section (2× the prior 4.25rem) */
  padding-block: 8.5rem 0;
}

/* .life (not .stage — .stage is the homepage's full-viewport container) */
.life {
  position: relative;                 /* anchor for the absolutely-placed art */
  width: min(34rem, 100% - 3rem);     /* the reading column */
}
.life__head {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}
.life__head .year { color: var(--accent); }
.life__text p { margin: 0 0 1.1rem; }
.life__text p:last-child { margin-bottom: 0; }
.life__text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.life__text a:hover { text-decoration-thickness: 2px; }

/* graphic — anchored to the TOP of the text, floated into the margin, so it
   never affects the section's height. Left margin by default, right on evens. */
.life__art {
  position: absolute;
  top: -0.3rem;
  width: clamp(118px, 13vw, 158px);
  height: auto;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.life:nth-of-type(odd)  .life__art { right: 100%; margin-right: clamp(1.25rem, 3vw, 3rem); }
.life:nth-of-type(even) .life__art { left: 100%;  margin-left:  clamp(1.25rem, 3vw, 3rem); }
/* explicit override wins (placed after, equal specificity) */
.life[data-side="left"]  .life__art { right: 100%; left: auto; margin-right: clamp(1.25rem, 3vw, 3rem); margin-left: 0; }
.life[data-side="right"] .life__art { left: 100%; right: auto; margin-left: clamp(1.25rem, 3vw, 3rem); margin-right: 0; }

/* in focus: fade up to full (rotation is handled live by about.js) */
.life.is-visible .life__art { opacity: 1; }

/* closing photo — centered below the final stage */
.closing {
  /* top gap matches the uniform stage spacing; generous bottom gives the photo
     room to scroll through center so it rotates as much as the other graphics */
  margin: 8.5rem auto clamp(8rem, 24vh, 16rem);
  padding-inline: 1.5rem;
  text-align: center;
}
.closing__img {
  display: inline-block;
  width: clamp(240px, 42vw, 380px);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(22, 24, 29, 0.14);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.closing.is-visible .closing__img { opacity: 1; }

/* mobile: stack art above text, centered (no side margin to float into) */
@media (max-width: 48rem) {
  .timeline { gap: 6rem; padding-block: 6rem 0; }
  .life { width: min(34rem, 100% - 2.5rem); }
  .life__art,
  .life:nth-of-type(odd)  .life__art,
  .life:nth-of-type(even) .life__art,
  .life[data-side="left"]  .life__art,
  .life[data-side="right"] .life__art {
    position: static;
    display: block;
    inset: auto;
    margin: 0 auto 1.25rem;
    width: clamp(130px, 38vw, 190px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .life__art, .closing__img { opacity: 1 !important; transform: none !important; }
  .scroll-cue__arrow { animation: none; }
}

/* ============================================================
   CV page — hand-drawn "Vita" header + clean, scannable record
   ============================================================ */
.cv-header {
  text-align: center;
  margin: 0;
  padding: 3.5rem 1.5rem 0.5rem;
}
.cv-vita {
  display: inline-block;
  width: clamp(150px, 24vw, 260px);
  height: auto;
}

.cv {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem 1.5rem 6rem;
}

/* full-CV button */
.cv-pdf {
  display: flex;
  width: max-content;
  max-width: 100%;
  margin: 0.5rem auto 3rem;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.3rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.cv-pdf:hover { background: var(--accent); color: var(--paper); }

.cv-section { margin-top: 2.8rem; }
.cv-h {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  letter-spacing: -0.01em;
  margin: 0 0 0.25rem;
}

.cv-entry {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.2rem 1.5rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
}
.cv-when {
  color: var(--muted);
  font-size: 0.9rem;
  padding-top: 0.2rem;
}
.cv-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.cv-line {
  margin: 0 0 0.3rem;
  font-size: 0.97rem;
  line-height: 1.55;
}
.cv-line:last-child { margin-bottom: 0; }
.cv-what a, .cv-title a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.cv-title a:hover, .cv-what a:hover { text-decoration-thickness: 2px; }

@media (max-width: 34rem) {
  .cv-entry { grid-template-columns: 1fr; gap: 0.1rem; }
  .cv-when { padding-top: 0; }
}

/* Media page — hand-drawn title image (e.g. "Coming Soon") */
.media-title {
  text-align: center;
  margin: 1rem 0 2.75rem;
}
.media-title-img {
  display: inline-block;
  width: clamp(200px, 36vw, 380px);
  height: auto;
}
