/* ==========================================================================
   Anthony Madrigal — portfolio
   Scaling: on screens wider than 900px the whole layout is sized in rem,
   and the root font-size is tied to the window width. A laptop therefore
   shows the same layout as a 27" monitor, just proportionally smaller.
   Phones get a stacked single-column layout instead.
   ========================================================================== */

:root {
  --paper: #f4f1ea;
  --paper-2: #ebe6db;
  --ink: #16140f;
  --ink-2: #4a463d;
  --ink-3: #7c776b;
  --line: #d6cfc0;
  --accent: #8c1c2b;      /* Dr Pepper maroon */
  --accent-2: #c2410c;    /* workshop orange */
  --dark: #121110;
  --dark-2: #1d1b18;
  --on-dark: #f4f1ea;
  --on-dark-2: #a9a397;

  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --wrap: 92rem;
  --gutter: 4rem;
}

/* --- Proportional scaling ------------------------------------------------ */
/* 1920px wide -> 17.5px base; 1440px -> 14px; 2560px -> 23px. */
html { font-size: clamp(13px, calc(100vw / 110), 26px); }
@media (max-width: 900px) {
  html { font-size: 16px; }
  :root { --gutter: 1.25rem; }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.02; margin: 0; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- Header ------------------------------------------------------------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  transition: background .3s, border-color .3s, color .3s;
  border-bottom: 1px solid transparent;
  color: var(--ink);
}
.site-header.on-dark { color: var(--on-dark); }
.site-header.scrolled {
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-color: var(--line); color: var(--ink);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 4.25rem; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; gap: 2.25rem; }
.nav a { text-decoration: none; font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: .8; }
.nav a:hover, .nav a[aria-current="page"] { opacity: 1; text-decoration: underline; text-underline-offset: .35em; }
@media (max-width: 900px) { .brand { font-size: .95rem; white-space: nowrap; } .nav { gap: .9rem; } .nav a { font-size: .66rem; letter-spacing: .05em; } }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .9rem 1.4rem; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  text-decoration: none; font-weight: 600; font-size: .95rem;
  transition: transform .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); background: var(--accent); }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }
.btn .arrow { transition: transform .2s; }
.btn:hover .arrow { transform: translateX(3px); }

/* --- Home hero ---------------------------------------------------------- */
.home-hero { min-height: 100vh; display: grid; align-items: center; padding: 7rem 0 4rem; position: relative; }
.home-hero .wrap { display: grid; grid-template-columns: 1.15fr 1fr; gap: 5rem; align-items: center; }
.home-hero .kicker { color: var(--accent); margin-bottom: 1.5rem; }
.home-hero h1 { font-size: 6.4rem; font-weight: 800; }
.home-hero h1 span { display: block; color: var(--ink-3); }
.home-hero .lede { font-size: 1.3rem; color: var(--ink-2); max-width: 32rem; margin: 2rem 0 2.5rem; }
.home-hero .actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero-stack { position: relative; aspect-ratio: 4 / 4.4; }
.hero-stack > a { position: absolute; display: block; border-radius: 1rem; overflow: hidden; box-shadow: 0 1.5rem 3rem -1.5rem rgba(22,20,15,.45); transition: transform .35s cubic-bezier(.2,.7,.2,1); }
.hero-stack > a:hover { transform: translateY(-.35rem); }
.hero-stack figure { position: relative; margin: 0; width: 100%; height: 100%; }
.hero-stack img { width: 100%; height: 100%; object-fit: cover; }
.hero-stack .a { inset: 0 24% 8% 0; }
.hero-stack .a img { object-position: 50% 35%; }
/* The shredder render is a landscape CAD image on white, so show all of it */
.hero-stack .b { width: 54%; aspect-ratio: 4/3; right: 0; bottom: 0; border: .4rem solid var(--paper); background: #fff; }
.hero-stack .b img { object-fit: contain; padding: .5rem; }
.hero-stack .tag {
  position: absolute; left: 1rem; bottom: 1rem; background: var(--paper); color: var(--ink);
  padding: .4rem .7rem; border-radius: .4rem;
}
.scroll-cue { position: absolute; left: 50%; bottom: 1.75rem; transform: translateX(-50%); color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.scroll-cue::after { content: ""; width: 1px; height: 2.5rem; background: currentColor; animation: cue 2s infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* --- Section headings --------------------------------------------------- */
.section { padding: 8rem 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 3.5rem; border-bottom: 1px solid var(--line); padding-bottom: 1.5rem; }
.section-head h2 { font-size: 3.6rem; font-weight: 800; }
.section-head .mono { color: var(--ink-3); }

/* --- Featured project (home) -------------------------------------------- */
.featured {
  display: grid; grid-template-columns: 1fr 1.1fr; min-height: 44rem;
  background: var(--dark); color: var(--on-dark); border-radius: 1.5rem; overflow: hidden; text-decoration: none;
}
.featured .media { position: relative; overflow: hidden; }
.featured .media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s cubic-bezier(.2,.7,.2,1); }
.featured:hover .media img { transform: scale(1.04); }
.featured .body { padding: 4rem; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; }
.featured .label { color: var(--accent-2); }
.featured h3 { font-size: 4.2rem; font-weight: 800; margin: 1rem 0 1.5rem; }
.featured p { color: var(--on-dark-2); font-size: 1.12rem; max-width: 34rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; border-top: 1px solid #34312c; padding-top: 1.75rem; }
.stats b { display: block; font-family: var(--font-display); font-size: 2.4rem; font-weight: 800; line-height: 1; color: var(--on-dark); }
.stats span { color: var(--on-dark-2); }
.featured .go { display: inline-flex; gap: .6rem; align-items: center; font-weight: 600; }

/* --- Project list (home) ------------------------------------------------ */
.project-row {
  display: grid; grid-template-columns: 6rem 1fr 26rem; gap: 3rem; align-items: center;
  padding: 2.5rem 0; border-bottom: 1px solid var(--line); text-decoration: none;
}
.project-row .num { color: var(--ink-3); }
.project-row h3 { font-size: 2.8rem; font-weight: 800; transition: color .2s; }
.project-row p { color: var(--ink-2); margin: .75rem 0 0; max-width: 40rem; }
.project-row .thumb { aspect-ratio: 16/10; border-radius: .9rem; overflow: hidden; background: var(--paper-2); }
.project-row .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.project-row:hover h3 { color: var(--accent); }
.project-row:hover .thumb img { transform: scale(1.05); }
.chip-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.chip { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); }

/* --- Workbench band ----------------------------------------------------- */
.band { position: relative; height: 34rem; overflow: hidden; }
.band img { position: absolute; inset: -10% 0; width: 100%; height: 120%; object-fit: cover; will-change: transform; }
.band::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(18,17,16,.75), rgba(18,17,16,.1) 70%); }
.band .wrap { position: relative; z-index: 1; height: 100%; display: flex; align-items: center; color: var(--on-dark); }
.band blockquote { margin: 0; font-family: var(--font-display); font-size: 3rem; font-weight: 700; line-height: 1.1; max-width: 40rem; letter-spacing: -.02em; }

/* --- Logos -------------------------------------------------------------- */
.logos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; }
.logos figure { margin: 0; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 2.5rem 1rem; }
.logos img { height: 5rem; width: auto; object-fit: contain; filter: grayscale(1); opacity: .8; transition: filter .3s, opacity .3s; }
.logos figure:hover img { filter: none; opacity: 1; }
.logos figcaption { color: var(--ink-3); text-align: center; }
.logos .wordmark { height: 5rem; display: flex; align-items: center; font-family: var(--font-display); font-weight: 800; font-size: 2.2rem; letter-spacing: -0.03em; color: var(--ink-2); transition: color .3s; }
.logos figure:hover .wordmark { color: var(--ink); }

/* --- Contact / footer --------------------------------------------------- */
.contact { background: var(--dark); color: var(--on-dark); padding: 8rem 0 3rem; }
.contact h2 { font-size: 6rem; font-weight: 800; }
.contact h2 em { font-style: normal; color: var(--accent-2); }
.contact .lede { color: var(--on-dark-2); font-size: 1.2rem; max-width: 36rem; margin: 1.5rem 0 3rem; }
.contact .links { display: flex; flex-wrap: wrap; gap: 1rem; }
.contact .btn { background: var(--on-dark); color: var(--dark); }
.contact .btn:hover { background: var(--accent-2); color: var(--on-dark); }
.contact .btn.ghost { background: transparent; color: var(--on-dark); }
.contact .btn.ghost:hover { background: var(--on-dark); color: var(--dark); }
.foot { display: flex; justify-content: space-between; margin-top: 7rem; padding-top: 1.5rem; border-top: 1px solid #34312c; color: var(--on-dark-2); }

/* ==========================================================================
   Project "story" pages
   ========================================================================== */
.p-hero { min-height: 100vh; background: var(--dark); color: var(--on-dark); display: grid; position: relative; overflow: hidden; }
.p-hero .wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: center; padding-top: 6rem; padding-bottom: 5rem; }
.p-hero .crumbs { color: var(--on-dark-2); margin-bottom: 2rem; }
.p-hero .crumbs a { text-decoration: none; }
.p-hero .crumbs a:hover { color: var(--on-dark); }
.p-hero h1 { font-size: 6rem; font-weight: 800; }
.p-hero .lede { color: var(--on-dark-2); font-size: 1.25rem; margin: 2rem 0 2.75rem; max-width: 32rem; }
.p-hero .stats { max-width: 34rem; }
.p-hero .media { position: relative; height: 82vh; max-height: 56rem; border-radius: 1.25rem; overflow: hidden; }
.p-hero .media img { width: 100%; height: 100%; object-fit: cover; }
.p-hero .scroll-cue { color: var(--on-dark-2); }

/* Story layout: sticky chapter rail + content */
.story { display: grid; grid-template-columns: 14rem 1fr; gap: 4rem; padding-top: 7rem; padding-bottom: 4rem; }
.rail { position: sticky; top: 7rem; align-self: start; }
.rail ol { list-style: none; margin: 0; padding: 0; position: relative; }
.rail ol::before { content: ""; position: absolute; left: .3rem; top: .5rem; bottom: .5rem; width: 1px; background: var(--line); }
.rail .progress { position: absolute; left: .3rem; top: .5rem; width: 1px; background: var(--accent); height: 0; transition: height .15s linear; }
.rail li { position: relative; padding: 0 0 1.35rem 1.75rem; }
.rail li::before { content: ""; position: absolute; left: 0; top: .45rem; width: .65rem; height: .65rem; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--line); transition: all .25s; }
.rail li.done::before { background: var(--accent); border-color: var(--accent); }
.rail li.active::before { background: var(--paper); border-color: var(--accent); box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--accent) 18%, transparent); }
.rail a { text-decoration: none; color: var(--ink-3); font-size: .9rem; display: block; line-height: 1.35; transition: color .2s; }
.rail a small { display: block; font-family: var(--font-mono); font-size: .66rem; letter-spacing: .08em; }
.rail li.active a, .rail a:hover { color: var(--ink); }

.chapter { padding-bottom: 7rem; scroll-margin-top: 6rem; }
.chapter + .chapter { border-top: 1px solid var(--line); padding-top: 5rem; }
.chapter .eyebrow { color: var(--accent); margin-bottom: 1rem; }
.chapter h2 { font-size: 3.8rem; font-weight: 800; margin-bottom: 2rem; }
.chapter .text { max-width: 46rem; font-size: 1.14rem; color: var(--ink-2); }
.chapter .text strong { color: var(--ink); }
.chapter .text.big { font-size: 1.6rem; line-height: 1.45; color: var(--ink); font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; max-width: 52rem; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: start; }
.split .sticky { position: sticky; top: 7rem; }

/* How-it-works steps */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 3.5rem 1fr; gap: 1.25rem; padding: 1.5rem 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(s, decimal-leading-zero); font-family: var(--font-mono); font-size: .85rem; color: var(--accent); padding-top: .2rem; }
.steps b { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1.25rem; margin-bottom: .3rem; }

/* Bill of materials */
.bom { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: .9rem; overflow: hidden; margin: 2.5rem 0 0; }
.bom div { background: var(--paper); padding: 1.1rem 1.25rem; }
.bom b { display: block; font-family: var(--font-display); font-size: 1.05rem; }
.bom span { color: var(--ink-3); font-size: .85rem; }

/* Justified galleries: each figure grows by its aspect ratio (--r) */
.gallery { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 3rem; }
/* Invisible filler so a lone photo on the last row doesn't stretch full width */
.gallery::after { content: ""; flex: 140 1 0; min-width: 0; }
.gallery.single::after { display: none; }
.gallery figure { margin: 0; flex: calc(var(--r) * 100) 1 calc(var(--r) * 15rem); max-width: 100%; position: relative; border-radius: .8rem; overflow: hidden; background: var(--paper-2); cursor: zoom-in; }
.gallery figure img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: var(--r); transition: transform .5s; }
.gallery figure:hover img { transform: scale(1.03); }
.gallery figcaption { position: absolute; left: .6rem; bottom: .6rem; background: rgba(18,17,16,.78); color: var(--on-dark); padding: .3rem .55rem; border-radius: .35rem; font-size: .75rem; opacity: 0; transform: translateY(.3rem); transition: all .25s; }
.gallery figure:hover figcaption, .gallery figure:focus-visible figcaption { opacity: 1; transform: none; }
.gallery.cad figure { background: #fff; }
.gallery.cad figure img { object-fit: contain; }
.gallery-label { margin-top: 3.5rem; color: var(--ink-3); display: flex; align-items: center; gap: 1rem; }
.gallery-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gallery-label + .gallery { margin-top: 1.25rem; }

/* Video */
.video { position: relative; aspect-ratio: 16/9; border-radius: 1rem; overflow: hidden; background: #000; margin-top: 2.5rem; }
.video iframe, .video button, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video button { cursor: pointer; padding: 0; background: #000; }
.video button img { width: 100%; height: 100%; object-fit: cover; opacity: .8; transition: opacity .3s; }
.video button:hover img { opacity: 1; }
.video .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 6rem; height: 6rem; border-radius: 50%; background: var(--paper); display: grid; place-items: center; transition: transform .25s; }
.video button:hover .play { transform: translate(-50%,-50%) scale(1.08); }
.video .play::before { content: ""; border-style: solid; border-width: 1.1rem 0 1.1rem 1.8rem; border-color: transparent transparent transparent var(--ink); margin-left: .4rem; }

/* Finale */
.finale { position: relative; border-radius: 1.5rem; overflow: hidden; background: var(--dark); color: var(--on-dark); display: grid; grid-template-columns: 1fr 1fr; min-height: 44rem; }
.finale img { width: 100%; height: 100%; object-fit: cover; }
.finale .body { padding: 4rem; display: flex; flex-direction: column; justify-content: center; }
.finale h2 { font-size: 3.6rem; font-weight: 800; margin: 1rem 0 1.5rem; }
.finale p { color: var(--on-dark-2); font-size: 1.12rem; }

/* Placeholder note for unwritten sections */
.todo { border: 1.5px dashed var(--accent-2); color: var(--ink-2); border-radius: .8rem; padding: 1.25rem 1.5rem; max-width: 46rem; background: color-mix(in srgb, var(--accent-2) 6%, transparent); }
.todo b { color: var(--accent-2); }

/* Next project */
.next { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2rem; padding: 4rem 0; border-top: 1px solid var(--line); text-decoration: none; }
.next h3 { font-size: 4rem; font-weight: 800; transition: color .2s; }
.next .mono { color: var(--ink-3); margin-bottom: .75rem; }
.next .circle { width: 6rem; height: 6rem; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font-size: 2rem; transition: all .25s; }
.next:hover h3 { color: var(--accent); }
.next:hover .circle { background: var(--ink); color: var(--paper); transform: translateX(.5rem); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(12,11,10,.94); display: none; align-items: center; justify-content: center; padding: 3rem; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: .5rem; }
.lightbox button { position: absolute; background: none; border: 0; color: var(--on-dark); font-size: 2rem; cursor: pointer; padding: 1rem; line-height: 1; }
.lightbox .close { top: 1rem; right: 1.25rem; }
.lightbox .prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox .nextb { right: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox .cap { position: absolute; bottom: 1.25rem; left: 0; right: 0; text-align: center; color: var(--on-dark-2); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(1.5rem); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-cue::after { animation: none; }
}

/* ==========================================================================
   Phone / small tablet layout
   ========================================================================== */
@media (max-width: 900px) {
  .home-hero { min-height: auto; padding: 6rem 0 3rem; }
  .home-hero .wrap, .p-hero .wrap { grid-template-columns: 1fr; gap: 2.5rem; }
  .home-hero h1 { font-size: 3.4rem; }
  .home-hero .lede { font-size: 1.1rem; margin: 1.25rem 0 1.75rem; }
  .scroll-cue { display: none; }
  .section { padding: 4.5rem 0; }
  .section-head { flex-direction: column; align-items: start; gap: .5rem; margin-bottom: 2rem; }
  .section-head h2 { font-size: 2.3rem; }
  .featured { grid-template-columns: 1fr; min-height: 0; }
  .featured .media { aspect-ratio: 4/3; }
  .featured .body { padding: 1.75rem; }
  .featured h3 { font-size: 2.3rem; }
  .stats b { font-size: 1.6rem; }
  .stats { gap: 1rem; }
  .project-row { grid-template-columns: 1fr; gap: 1rem; padding: 2rem 0; }
  .project-row .thumb { order: -1; }
  .project-row h3 { font-size: 1.9rem; }
  .band { height: 22rem; }
  .band blockquote { font-size: 1.8rem; }
  .logos { grid-template-columns: repeat(3, 1fr); }
  .logos figure { padding: 1.5rem .5rem; gap: .6rem; }
  .logos img, .logos .wordmark { height: 3rem; }
  .logos .wordmark { font-size: 1.3rem; }
  .logos figcaption { font-size: .6rem; }
  .contact { padding: 5rem 0 2rem; }
  .contact h2 { font-size: 3.2rem; }
  .foot { flex-direction: column; gap: .5rem; margin-top: 4rem; }

  .p-hero { min-height: auto; }
  .p-hero .wrap { padding-top: 5.5rem; padding-bottom: 3rem; }
  .p-hero h1 { font-size: 3rem; }
  .p-hero .lede { font-size: 1.1rem; margin: 1.25rem 0 1.75rem; }
  .p-hero .media { height: auto; aspect-ratio: 3/4; }
  .story { grid-template-columns: 1fr; padding-top: 3.5rem; gap: 0; }
  .rail { display: none; }
  .chapter { padding-bottom: 4rem; }
  .chapter + .chapter { padding-top: 3.5rem; }
  .chapter h2 { font-size: 2.3rem; margin-bottom: 1.25rem; }
  .chapter .text { font-size: 1.02rem; }
  .chapter .text.big { font-size: 1.25rem; }
  .split { grid-template-columns: 1fr; gap: 2rem; }
  .split .sticky { position: static; }
  .bom { grid-template-columns: 1fr 1fr; }
  .gallery { gap: .6rem; margin-top: 2rem; }
  .gallery figure { flex-basis: calc(var(--r) * 7rem); }
  .finale { grid-template-columns: 1fr; min-height: 0; }
  .finale .body { padding: 1.75rem; }
  .finale h2 { font-size: 2.2rem; }
  .next h3 { font-size: 2.2rem; }
  .next .circle { width: 3.5rem; height: 3.5rem; font-size: 1.3rem; }
  .lightbox { padding: 3.5rem .5rem; }
}

/* When JavaScript lays the gallery out, it sets each photo's exact width */
.gallery.js::after { display: none; }
.gallery.js figure { flex: none; max-width: none; }

/* --- Clickable logos ----------------------------------------------------- */
.logos .logo-link { display: block; background: var(--paper); text-decoration: none; color: inherit; }
.logos .logo-link figure { height: 100%; transition: background .25s; }
.logos .logo-link:hover figure, .logos .logo-link:focus-visible figure { background: var(--paper-2); }
.logos .logo-link:hover img { filter: none; opacity: 1; }
.logos .logo-link:hover .wordmark { color: var(--ink); }
.logos .logo-link:hover figcaption { color: var(--ink); }
.logos .ext { display: inline-block; opacity: 0; transform: translate(-.2rem, .2rem); transition: opacity .25s, transform .25s; }
.logos .logo-link:hover .ext, .logos .logo-link:focus-visible .ext { opacity: 1; transform: none; }
@media (hover: none) { .logos .ext { opacity: .7; transform: none; } }

/* --- "Scroll to read the story" cue on project pages --------------------- */
.p-hero { min-height: 94vh; }
.story-cue {
  position: absolute; left: 50%; bottom: 2rem; transform: translateX(-50%); z-index: 2;
  display: inline-flex; align-items: center; gap: .9rem;
  padding: .85rem .85rem .85rem 1.5rem; border-radius: 999px;
  background: var(--on-dark); color: var(--dark); text-decoration: none;
  font-weight: 600; font-size: 1rem; box-shadow: 0 1rem 2.5rem -1rem rgba(0,0,0,.6);
  transition: background .2s, color .2s;
}
.story-cue .chev {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-dark); font-size: 1.1rem;
  animation: bob 1.6s ease-in-out infinite;
}
.story-cue:hover { background: var(--accent-2); color: var(--on-dark); }
.story-cue:hover .chev { background: var(--dark); }
@keyframes bob { 0%, 100% { transform: translateY(-.15rem); } 50% { transform: translateY(.3rem); } }

/* Thin reading-progress bar along the top of project pages */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 60; background: var(--accent-2); transform-origin: 0 50%; transform: scaleX(0); }

@media (prefers-reduced-motion: reduce) { .story-cue .chev { animation: none; } }
@media (max-width: 900px) {
  .p-hero { min-height: auto; }
  .p-hero .wrap { padding-bottom: 6.5rem; }
  /* On phones the hero is taller than the screen, so pin the cue to the bottom of the screen */
  .story-cue { position: fixed; bottom: 1.25rem; font-size: .95rem; white-space: nowrap; transition: opacity .3s, transform .3s, background .2s; }
  .story-cue.gone { opacity: 0; transform: translate(-50%, 1rem); pointer-events: none; }
}

/* Home hero labels sit at the top so the overlapping card never hides them */
.hero-stack .a .tag { top: 1rem; bottom: auto; }
.hero-stack .b img { padding: 2.6rem .6rem .6rem; }
.hero-stack .b .tag { top: .6rem; left: .6rem; bottom: auto; }
@media (max-width: 900px) {
  .hero-stack .tag { font-size: .62rem; padding: .3rem .5rem; }
  .hero-stack .b img { padding-top: 2rem; }
}
