/* ==========================================================================
   Project case study — shared template for every project page.
   Six blocks: header, chapter divider, prose, notes, figure, next project.
   Each block is one viewport tall so a reader takes in one section per fold.
   min-height, never height: on mobile a prose block legitimately runs longer
   than the fold and must be allowed to.
   ========================================================================== */
:root { --pj-accent: #f8853d; }

.pj-section {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(96px, 12vh, 150px) clamp(24px, 5vw, 72px);
  position: relative;
  overflow: hidden;
}

/* Text-light blocks. A prose section holding 230px of copy, centred in a
   900px box, is 74% empty — and two of them back to back put a whole screen
   of nothing between the two things you are meant to read. These are allowed
   to be shorter than a fold; a section still owns the screen it lands on,
   because every one of them follows a full-height block. */
.pj-section--tight {
  min-height: 64svh;
  /* The full-fold padding is 216px of vertical air, which on a short block is
     most of the emptiness on its own. */
  padding-top: clamp(64px, 8vh, 100px);
  padding-bottom: clamp(64px, 8vh, 100px);
}
.pj-inner { max-width: 1400px; margin: 0 auto; width: 100%; }

/* Acts alternate tone; the divider is what announces each flip. */
.pj-section--light { background: #fff3eb; color: #0d0d0d; }
.pj-section--cream { background: #f2e6d6; color: #0d0d0d; }
.pj-section--dark  { background: #131211; color: #fdfaf6; }

.pj-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  opacity: 0.55; margin: 0;
}
.pj-section--dark .pj-eyebrow { opacity: 0.6; }

.pj-h {
  font-family: 'Barlow Condensed', 'Onest', sans-serif;
  font-weight: 800; text-transform: uppercase;
  line-height: 0.9; letter-spacing: -0.015em; margin: 0;
  font-size: clamp(2.2rem, 6vw, 5.5rem);
}
.pj-body {
  font-family: 'Onest', sans-serif;
  font-size: clamp(15px, 1.15vw, 19px); line-height: 1.6;
  max-width: 68ch; margin: 0;
}
.pj-body + .pj-body { margin-top: 1.1em; }
.pj-section--dark .pj-body { color: rgba(253, 250, 246, 0.82); }
.pj-section--light .pj-body,
.pj-section--cream .pj-body { color: rgba(13, 28, 28, 0.78); }

/* Marker-pen highlight. background-size on a gradient rather than a scaled
   pseudo-element: cheaper, interruptible, and it wipes like a real pen. */
.pj-mark {
  background-image: linear-gradient(var(--pj-accent), var(--pj-accent));
  background-repeat: no-repeat;
  background-position: 0 0.08em;
  background-size: 0% 92%;
  color: inherit;
  padding: 0 0.12em;
  transition: background-size var(--dur-base) var(--ease-out) 0.15s;
}
.pj-section.is-in .pj-mark { background-size: 100% 92%; }
.pj-section--dark .pj-mark { color: #131211; }

/* ── 1. Header ──────────────────────────────────────────────────────── */
.pj-back {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'Onest', sans-serif; font-size: 15px;
  color: #0d0d0d; text-decoration: none; opacity: 0.7;
  transition: opacity 0.2s var(--ease-state);
  margin-bottom: clamp(32px, 5vh, 64px);
}
.pj-back svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .pj-back:hover { opacity: 1; } }

.pj-title { font-size: clamp(3rem, 11vw, 11rem); }

.pj-chips { display: flex; flex-wrap: wrap; gap: 12px; margin: clamp(32px, 5vh, 64px) 0 0; padding: 0; list-style: none; }
.pj-chip {
  font-family: 'Onest', sans-serif; font-size: clamp(11px, 0.9vw, 14px);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  border: 1px solid rgba(13, 13, 13, 0.55); border-radius: 3px;
  padding: 12px 20px; white-space: nowrap;
}

.pj-meta { display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 64px); margin-top: clamp(28px, 4vh, 48px); }
.pj-meta__item { font-family: 'Onest', sans-serif; font-size: clamp(14px, 1vw, 17px); }
.pj-meta__label { font-weight: 700; color: #0d0d0d; }
.pj-meta__value { color: rgba(13, 13, 13, 0.55); }
.pj-meta__value a { color: inherit; }

/* ── 2. Chapter ─────────────────────────────────────────────────────────
   Header and body are one block, not two sections. The ✦ is punctuation
   introducing the paragraph beneath it — separated by a scroll they stop
   reading as heading and body, which is what left a dead screen between
   every chapter and its own copy. */
.pj-chapter__head {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(14px, 2.2vh, 26px);
}
/* Rules flank the numeral, not the label below it. */
.pj-rule-row { display: flex; align-items: center; gap: clamp(20px, 3.5vw, 56px); justify-content: center; }
.pj-rule { height: 1px; width: clamp(48px, 10vw, 150px); background: currentColor; opacity: 0.28; }
.pj-numeral {
  font-family: 'Barlow Condensed', 'Onest', sans-serif;
  font-weight: 800; font-size: clamp(4rem, 9vw, 8rem); line-height: 0.8;
  color: var(--pj-accent);
}
.pj-star { color: var(--pj-accent); font-size: 20px; line-height: 1; }

/* Second line of the chapter headline carries the accent. */
.pj-h .pj-accent { color: var(--pj-accent); }

/* Body: left-aligned text in a column centred under the header. */
.pj-chapter__body {
  margin: clamp(30px, 5vh, 60px) auto 0;
  max-width: 66ch;
  width: 100%;
}
.pj-chapter__body .pj-body { max-width: none; }

/* ── 3 & 4. Prose and notes ─────────────────────────────────────────── */
.pj-label { font-size: clamp(1.6rem, 3.4vw, 3rem); margin-bottom: clamp(24px, 4vh, 44px); }
.pj-section--dark .pj-label { color: var(--pj-accent); }

.pj-note {
  display: grid;
  grid-template-columns: clamp(64px, 8vw, 130px) 1fr auto;
  gap: clamp(16px, 3vw, 48px);
  align-items: start;
  padding: clamp(22px, 3.5vh, 40px) clamp(16px, 2vw, 28px);
  border-top: 1px solid rgba(13, 13, 13, 0.14);
}
.pj-section--dark .pj-note { border-top-color: rgba(253, 250, 246, 0.16); }
.pj-note:last-child { border-bottom: 1px solid rgba(13, 13, 13, 0.14); }
.pj-section--dark .pj-note:last-child { border-bottom-color: rgba(253, 250, 246, 0.16); }
.pj-note:nth-child(even) { background: rgba(13, 13, 13, 0.035); }
.pj-section--dark .pj-note:nth-child(even) { background: rgba(253, 250, 246, 0.04); }
.pj-note__num {
  font-family: 'Barlow Condensed', 'Onest', sans-serif;
  font-weight: 800; font-size: clamp(2.2rem, 4.5vw, 4rem); line-height: 0.85;
}
.pj-note__title { font-size: clamp(1.05rem, 1.7vw, 1.7rem); margin: 0 0 0.5em; }
.pj-note__tag { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.16em; opacity: 0.4; white-space: nowrap; }

/* ── 7. Overview with meta rail ─────────────────────────────────────────
   Kept the rail, dropped the reference's terminal chrome. The rail (tier /
   scope / audience) is useful on any project; the terminal frame reads as
   "developer tool" and would fight a brand or architecture case study. */
.pj-overview { display: grid; grid-template-columns: minmax(170px, 20%) 1fr; gap: clamp(28px, 5vw, 90px); }

.pj-facts { margin: 0; padding-left: clamp(16px, 1.6vw, 26px); border-left: 1px solid rgba(253, 250, 246, 0.2); }
.pj-fact { display: grid; grid-template-columns: 1fr; gap: 2px; }
.pj-fact + .pj-fact { margin-top: clamp(14px, 1.8vh, 22px); }
.pj-fact dt {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.45;
}
.pj-fact dd {
  margin: 0; font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 0.85vw, 13px); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--pj-accent);
}
.pj-overview__slug { margin-top: clamp(22px, 3vh, 34px); padding-left: clamp(16px, 1.6vw, 26px); opacity: 0.3; }
.pj-overview__main .pj-h { margin-bottom: clamp(22px, 3.5vh, 42px); font-size: clamp(1.9rem, 4.4vw, 4.2rem); }

/* ── 8. Numbered insights ───────────────────────────────────────────────
   The problem blocks. A badge plus a spine says "these are a sequence" —
   which is the one thing a reader needs to know before the first one ends. */
.pj-section--grid {
  background-image: radial-gradient(circle, rgba(13, 13, 13, 0.10) 1px, transparent 1px);
  background-size: 26px 26px;
}
.pj-insights { list-style: none; margin: 0; padding: 0; }
.pj-insight {
  display: grid;
  grid-template-columns: clamp(56px, 6vw, 90px) 1fr;
  gap: clamp(20px, 3.5vw, 56px);
}
.pj-insight + .pj-insight { margin-top: clamp(40px, 6vh, 76px); }

.pj-insight__col { position: relative; display: flex; flex-direction: column; align-items: center; }
.pj-insight__badge {
  width: clamp(50px, 5vw, 76px); aspect-ratio: 1; border-radius: 50%;
  background: var(--pj-accent); color: #131211;
  display: grid; place-items: center; flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace; font-weight: 600;
  font-size: clamp(12px, 1vw, 15px); letter-spacing: 0.04em;
}
/* Drawn on reveal rather than scrubbed to scroll: the whole block sits in one
   fold, so a scrubbed line would already be complete before it read as motion. */
.pj-insight__spine {
  flex: 1; width: 1px; margin-top: 12px;
  background: rgba(13, 13, 13, 0.22);
  transform: scaleY(0); transform-origin: top;
  transition: transform var(--dur-slow) var(--ease-out) 0.15s;
}
.pj-section.is-in .pj-insight__spine { transform: scaleY(1); }
.pj-insight:last-child .pj-insight__spine { display: none; }

.pj-insight__eyebrow { display: flex; align-items: center; gap: clamp(12px, 1.6vw, 24px); margin-bottom: clamp(14px, 2vh, 22px); }
.pj-insight__eyebrow .pj-rule { width: clamp(40px, 8vw, 120px); }
.pj-insight__title { font-size: clamp(1.6rem, 3.6vw, 3.4rem); margin: 0 0 clamp(16px, 2.4vh, 26px); }

/* ── 5. Figure ──────────────────────────────────────────────────────── */
.pj-figure { margin: 0; }
/* The frame is a fixed-ratio box so an image of unknown dimensions cannot
   reflow the page as it decodes — critical on a scroll this long. */
.pj-figure__frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; background: #131211;
  clip-path: inset(0 0 100% 0 round 12px);
  transition: clip-path var(--dur-slow) var(--ease-in-out);
}
.pj-section.is-in .pj-figure__frame { clip-path: inset(0 0 0 0 round 12px); }
/* Oversized so the parallax shift never exposes an edge. */
.pj-figure__media { position: absolute; inset: -12% 0; width: 100%; height: 124%; display: block; object-fit: cover; will-change: transform; }
.pj-figure__cap { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.5; margin-top: 16px; }

/* Two-up detail pair. No parallax here: the page already has two drifting
   full-bleed images, and once everything moves the effect stops meaning
   anything. These sit still so the big ones keep their weight. */
.pj-figures { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(16px, 2.2vw, 34px); }
.pj-figures .pj-figure__frame { aspect-ratio: 4 / 3; }
.pj-figures .pj-figure__media { position: static; inset: auto; width: 100%; height: 100%; }
/* Second frame trails the first so the pair resolves left-to-right. */
.pj-figures .pj-figure:nth-child(2) .pj-figure__frame { transition-delay: 0.1s; }

/* ── 6. Next project ────────────────────────────────────────────────── */
.pj-next__row { display: flex; align-items: center; justify-content: space-between; gap: 24px; text-decoration: none; color: inherit; }
.pj-next__name { font-size: clamp(2.6rem, 9vw, 8rem); }
.pj-next__arrow { width: clamp(44px, 4vw, 64px); height: clamp(44px, 4vw, 64px); flex-shrink: 0; opacity: 0.6; transition: transform 0.26s var(--ease-state), opacity 0.26s var(--ease-state); }
@media (hover: hover) and (pointer: fine) {
  .pj-next__row:hover .pj-next__arrow { transform: translateX(10px); opacity: 1; }
  .pj-next__row:hover .pj-next__name { color: var(--pj-accent); }
}
.pj-next__name { transition: color 0.26s var(--ease-state); }
.pj-pill {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'Onest', sans-serif; font-size: 15px;
  border: 1px solid rgba(253, 250, 246, 0.3); border-radius: 999px;
  padding: 14px 26px; margin-top: clamp(32px, 6vh, 64px);
  color: inherit; text-decoration: none;
  transition: background-color 0.24s var(--ease-state), border-color 0.24s var(--ease-state), color 0.24s var(--ease-state);
}
@media (hover: hover) and (pointer: fine) {
  .pj-pill:hover { background: #fdfaf6; border-color: #fdfaf6; color: #131211; }
}
.pj-pill:active { transform: scale(0.98); transition-duration: 0.12s; }

/* ── Section reveal ─────────────────────────────────────────────────────
   One shot per section as it enters. At one section per fold the reader
   sees this ~8 times over the page, not 40 — which is what makes it
   affordable at all. Children stagger 60ms. */
.pj-reveal > * {
  opacity: 0;
  transform: translateY(var(--rise-md));
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
}
.pj-section.is-in .pj-reveal > * { opacity: 1; transform: none; }
.pj-section.is-in .pj-reveal > *:nth-child(2) { transition-delay: var(--stagger); }
.pj-section.is-in .pj-reveal > *:nth-child(3) { transition-delay: 140ms; }
.pj-section.is-in .pj-reveal > *:nth-child(4) { transition-delay: 210ms; }
.pj-section.is-in .pj-reveal > *:nth-child(5) { transition-delay: 280ms; }
.pj-section.is-in .pj-reveal > *:nth-child(6) { transition-delay: 350ms; }

/* ── Chapter rail ───────────────────────────────────────────────────── */
.pj-rail { position: fixed; right: clamp(14px, 2vw, 34px); top: 50%; transform: translateY(-50%); z-index: 60; display: flex; flex-direction: column; gap: 12px; }
.pj-rail__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.22; transition: opacity 0.24s var(--ease-state), transform 0.24s var(--ease-state); }
.pj-rail__dot.is-active { opacity: 1; background: var(--pj-accent); transform: scale(1.5); }
@media (max-width: 767.98px) { .pj-rail { display: none; } }

/* ── Responsive — same motion, shorter travel ───────────────────────── */
@media (max-width: 991.98px) {
  .pj-note { grid-template-columns: clamp(52px, 12vw, 80px) 1fr; }
  .pj-note__tag { display: none; }
  .pj-figure__frame { aspect-ratio: 4 / 3; }
  /* Rail above the prose rather than beside it — at this width a 20% column
     wraps its values onto three lines each. */
  .pj-overview { grid-template-columns: 1fr; gap: clamp(24px, 4vh, 40px); }
  .pj-facts { display: flex; flex-wrap: wrap; gap: 0 clamp(20px, 5vw, 48px); border-left: 0; padding-left: 0; }
  .pj-fact + .pj-fact { margin-top: 0; }
  .pj-overview__slug { display: none; }
  .pj-figures { grid-template-columns: 1fr; }
  .pj-figures .pj-figure__frame { aspect-ratio: 16 / 10; }
}
@media (max-width: 575.98px) {
  .pj-section { padding-left: 24px; padding-right: 24px; }
  .pj-chip { padding: 9px 14px; }
  .pj-figure__frame { aspect-ratio: 3 / 2; }
}

@media (prefers-reduced-motion: reduce) {
  .pj-reveal > * { transition: opacity 0.3s ease; transform: none; }
  .pj-section.is-in .pj-reveal > * { transform: none; }
  .pj-figure__frame { clip-path: none; opacity: 0; transition: opacity 0.3s ease; }
  .pj-section.is-in .pj-figure__frame { clip-path: none; opacity: 1; }
  /* Parallax is decorative — drop the movement, keep the image. */
  .pj-figure__media { transform: none !important; inset: 0; height: 100%; }
  .pj-mark { transition: none; background-size: 100% 92%; }
  /* The spine still draws — it carries meaning (these are a sequence) — but
     without the travel. Reduced motion means gentler, not absent. */
  .pj-insight__spine { transition: opacity 0.3s ease; transform: scaleY(1); opacity: 0; }
  .pj-section.is-in .pj-insight__spine { opacity: 1; }
}
