/* ==========================================================================
   alexanderfrieden.com
   Paper and ink: one serif (Newsreader) for reading, one mono (IBM Plex Mono)
   for small labels. Photographs supply the color; the page stays quiet.
   ========================================================================== */

:root {
  --paper: #f2efe8;
  --ink: #161513;
  --muted: #6d695f;
  --rule: #d8d2c4;
  --placeholder: #e3ded2;
  --accent: #8f2c1c; /* used sparingly: focus rings, errors, link hover */
  --vellum: rgb(242 239 232 / 0.8); /* tracing paper: --paper, see-through */
  /* Party colors for the election charts on the Projects page, muted for paper */
  --dem: #33537d;
  --rep: #a3402d;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --measure: 40rem; /* reading column */
  --wide: 68rem;    /* images may extend past the text column */
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--rule);
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

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

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.4rem 0.7rem;
  z-index: 10;
}

.skip-link:focus { top: 1rem; }

/* Icons (Iconoir, MIT) inherit text color and size */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}

/* --------------------------------------------------------------------------
   Layout
   ----------------------------------------------------------------------- */

/* Every section shares one left edge. Text is held to a readable measure,
   while figures and the hero headline may use the full width. */
.column {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.column:not(.hero) > :not(figure):not(.photo):not(.clippings):not(.advance-scrolly):not(.story-scrolly):not(.logo-strip):not(.case-facts):not(.work-grid) {
  max-width: var(--measure);
}

.section {
  /* The rule sits close above the label. The room is under the section,
     so Skills, How I work, and Contact don't float in a wide gap. */
  padding-top: clamp(1.35rem, 2.8vw, 2rem);
  padding-bottom: clamp(2.75rem, 6vw, 4.25rem);
  border-top: 1px solid var(--rule);
}

.label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.75rem;
}

/* --------------------------------------------------------------------------
   Header and footer
   ----------------------------------------------------------------------- */

/* Sticky, so the navigation is always one scroll up away. main.js adds
   .is-hidden while scrolling down (the header slides out of view) and
   .is-stuck once the page has scrolled (a rule under it). Without JS it
   simply stays in view. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5; /* above the pinned map stages (up to 3), below the skip link (10) */
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem 1rem;
  padding-block: 1.75rem;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.8rem;
  transition: transform 0.25s ease, box-shadow 0.2s ease;
}

.site-header.is-stuck {
  box-shadow: 0 1px 0 var(--rule);
}

/* The extra pixel takes the rule along with it */
.site-header.is-hidden {
  transform: translateY(calc(-100% - 1px));
}

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .site-header .name,
  .site-header .name::before { transition: none; }
}

/* Name and mark are one home link. The mark is at least 12px tall, with
   clear space of half its height before the name, per the brand kit.
   The SVG is a mask so the mark stays ink, same as the type.

   Settled by default, so moving between pages doesn't snap the name.
   boot.js adds .mark-pending before paint on a shift-refresh (and the
   first look), and main.js eases the mark in once the file arrives. */
.site-header .name {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-left: 2.55rem; /* mark width plus clear space of half its height */
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.site-header .name::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 2.05rem;
  height: 1rem;
  margin-top: -0.5rem;
  background: currentColor;
  -webkit-mask: url("/images/avf-mark.svg") left center / contain no-repeat;
  mask: url("/images/avf-mark.svg") left center / contain no-repeat;
  transform-origin: left center;
}

html.mark-pending .site-header .name {
  padding-left: 0;
  transition: padding-left 0.7s cubic-bezier(0.65, 0, 0.35, 1);
}

html.mark-pending .site-header .name.has-mark {
  padding-left: 2.55rem;
}

html.mark-pending .site-header .name::before {
  opacity: 0;
  transform: scale(0.45);
  /* The mark waits until the name has moved, then pops into the opening. */
  transition:
    opacity 0.36s cubic-bezier(0.22, 1, 0.36, 1) 0.4s,
    transform 0.5s cubic-bezier(0.22, 1.35, 0.36, 1) 0.38s;
}

html.mark-pending .site-header .name.has-mark::before {
  opacity: 1;
  transform: scale(1);
}

html.mark-pending .site-header .name.is-instant,
html.mark-pending .site-header .name.is-instant::before,
html.mark-missing .site-header .name,
html.mark-missing .site-header .name::before {
  transition: none;
}

/* The file never arrived: no empty gap beside the name. */
html.mark-missing .site-header .name {
  padding-left: 0;
}

html.mark-missing .site-header .name::before {
  opacity: 0;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}

@media (max-width: 30rem) {
  .site-nav { gap: 1.1rem; }
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
}

/* .is-active marks the section you're in: the Work group on its subpages,
   and Blog on individual posts */
.site-nav a:hover,
.site-nav a[aria-current="page"],
.site-nav .is-active > a,
.site-nav > a.is-active {
  color: var(--ink);
}

/* Work submenu: opens on hover (mouse) or keyboard focus. On touch screens,
   tapping "Work" goes to the /work overview, which links to every page. */
.nav-group {
  position: relative;
}

.submenu {
  position: absolute;
  top: 100%;
  left: -0.9rem;
  z-index: 5;
  display: none;
  min-width: 9.5rem;
  margin: 0;
  padding: 0.85rem 0.9rem 0.6rem;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--rule);
}

.submenu a {
  display: block;
  padding-block: 0.3rem;
}

.nav-group:focus-within .submenu {
  display: block;
}

@media (hover: hover) {
  .nav-group:hover .submenu {
    display: block;
  }
}

/* Three columns: copyright, the bookshelf icon centered, social links */
.site-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
}

.site-footer > :last-child {
  justify-self: end;
}

/* Social links share the right-hand column so the grid stays three wide */
.footer-social {
  display: flex;
  gap: 1rem;
}

/* Bookshelf icon: the only way to the /books page (an easter egg, so it's
   not in the menu). On hover or keyboard focus the tallest book slides up
   out of its slot and tips forward; on leave it straightens, then slides
   back in. Books are filled with paper so the pulled one covers its
   neighbor, as if it's coming toward you. */
.shelf-link {
  display: block;
}

.shelf-link[aria-current="page"] {
  color: var(--ink);
}

.shelf-icon {
  display: block;
  width: 1.6rem;
  height: 1.6rem;
}

.shelf-icon rect {
  fill: var(--paper);
}

.shelf-icon-book {
  transform-box: fill-box;
  transform-origin: left bottom;
}

.shelf-link:hover .shelf-icon-book,
.shelf-link:focus-visible .shelf-icon-book {
  translate: 0 -4px;
  rotate: 12deg;
}

/* Two steps each way: slide out then tip on hover; straighten then slide
   in on leave. Without motion the book simply appears pulled. */
@media (prefers-reduced-motion: no-preference) {
  .shelf-icon-book {
    transition: rotate 0.2s ease, translate 0.25s ease 0.15s;
  }

  .shelf-link:hover .shelf-icon-book,
  .shelf-link:focus-visible .shelf-icon-book {
    transition: translate 0.25s ease, rotate 0.3s cubic-bezier(0.3, 1.5, 0.6, 1) 0.18s;
  }
}

/* --------------------------------------------------------------------------
   Home: hero and about
   ----------------------------------------------------------------------- */

/* The portrait sits beside the headline. About and everything down to
   Skills is its own block at the reading measure, on the shared left
   edge, so the lines run under the photo instead of beside it. */
.hero {
  container-type: inline-size;
  padding-block: clamp(2.25rem, 5vw, 3.75rem) clamp(2.5rem, 6vw, 4.5rem);
}

.hero-layout {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.35rem, 4.8vw, 3.6rem);
  font-weight: 350;
  line-height: 1.05;
  letter-spacing: -0.022em;
  max-width: 16em;
}

.hero h1 em {
  font-weight: 300;
}

.hero .open-to {
  margin: 1.15rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

/* Same width and left edge as Skills and the sections below it.
   The hero itself is exempt from the reading-measure cap. */
.bio {
  max-width: var(--measure);
  margin-top: clamp(2rem, 4vw, 3rem);
}

.bio-prose p {
  margin: 0 0 1.05em;
  text-wrap: pretty;
}

.bio-prose > p:last-of-type {
  margin-bottom: 0;
}

/* Circular portrait. On a narrow column it sits above the headline, on
   the same left edge. Once there is room it stays beside the headline
   only; About begins underneath, at full width. */
.portrait {
  width: 8.5rem;
  aspect-ratio: 1;
  margin: 0 0 1.25rem;
  border-radius: 50%;
  background: var(--placeholder);
  overflow: hidden;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Cold load and shift-refresh: the circle is there, the photo eases in.
   A decoded file never gets .portrait-pending, so it doesn't blink. */
html.portrait-pending .portrait img {
  opacity: 0;
  transform: scale(0.97);
}

html.portrait-pending .portrait img.is-ready {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* First visit: sections rest slightly low and clear, then ease into place
   as they come into view. boot.js records what has already faded
   (data-faded) so a later visit paints those still, with no replay.
   Clearing site data for this site is what starts it over. */
html.reveal [data-reveal] {
  opacity: 0;
  transform: translateY(0.65rem);
}

html.reveal [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-faded~="hero"] [data-reveal="hero"],
html[data-faded~="skills"] [data-reveal="skills"],
html[data-faded~="work"] [data-reveal="work"],
html[data-faded~="method"] [data-reveal="method"],
html[data-faded~="contact"] [data-reveal="contact"] {
  opacity: 1;
  transform: none;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  html.reveal [data-reveal],
  html.reveal [data-reveal].is-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

@container (min-width: 42rem) {
  .hero-layout {
    grid-template-columns: 12.25rem minmax(0, 1fr);
    column-gap: 2.25rem;
    /* Headline and role line sit in the vertical middle of the circle. */
    align-items: center;
    max-width: calc(12.25rem + 2.25rem + 42rem);
  }

  .portrait {
    width: 12.25rem;
    margin: 0;
  }

  .hero-copy {
    max-width: 42rem;
  }
}

.facts {
  margin: 1.5rem 0 0;
  display: grid;
  grid-template-columns: 9rem 1fr;
  row-gap: 0.9rem;
  column-gap: 1.5rem;
}

.facts dt {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.35rem;
}

.facts dd {
  margin: 0;
}

.streak-day {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 32rem) {
  .facts { grid-template-columns: 1fr; row-gap: 0.2rem; }
  .facts dd { margin-bottom: 0.9rem; }
}

/* --------------------------------------------------------------------------
   Index list: the ruled rows on Work, Tech, Projects, Blog, and Politics
   ----------------------------------------------------------------------- */

.index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.index-list a {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.index-list .title {
  font-size: 1.3rem;
}

.index-list .meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.index-list a:hover .title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.more-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  text-decoration: none;
}

.more-link .icon {
  transition: transform 0.15s ease;
}

.more-link:hover .icon {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   Page intro (Work, Photographs)
   ----------------------------------------------------------------------- */

.page-intro {
  padding-block: clamp(3.5rem, 11vw, 8rem) clamp(2.5rem, 6vw, 4rem);
}

.page-intro h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 350;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.page-intro p {
  margin: 0;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Logo strip (Politics): every campaign and organization, scrolling slowly
   like a client list. main.js repeats the list, adds .is-looping, and moves
   the track (speed follows the pointer; see setupLogoStrips). Until then
   (no JS, reduced motion) the logos sit still and wrap into rows.
   ----------------------------------------------------------------------- */

.logos {
  padding-bottom: clamp(2.5rem, 6vw, 4rem);
}

.logo-strip {
  overflow: hidden;
}

.logo-strip-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.75rem 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.logo-strip a {
  display: block;
}

/* Grayscale like the logos on the story cards, so the strip reads as ink;
   a logo eases into its own colors when pointed at or focused. */
.logo-strip img {
  display: block;
  width: auto;
  height: 2.25rem;
  max-width: 10rem;
  object-fit: contain;
  filter: grayscale(1) contrast(1.6);
  transition: filter 0.4s ease;
}

.logo-strip a:hover img,
.logo-strip a:focus-visible img {
  filter: none;
}

/* Seals and square marks read smaller than wordmarks at the same height */
.logo-strip img.is-mark {
  height: 3rem;
}

.logo-strip.is-looping {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}

.logo-strip.is-looping .logo-strip-track {
  display: flex;
  width: max-content;
  will-change: transform;
}

/* Each copy of the list ends with one gap, so the seam of the loop matches */
.logo-strip.is-looping .logo-strip-list {
  flex-wrap: nowrap;
  padding-right: 3rem;
}

/* --------------------------------------------------------------------------
   Image placeholders (replace with <img> as photos arrive)
   ----------------------------------------------------------------------- */

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--placeholder);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

.placeholder--portrait { aspect-ratio: 4 / 5; }
.placeholder--wide { aspect-ratio: 16 / 9; }

/* --------------------------------------------------------------------------
   Themed pages (Tech, Politics, Projects)
   Written like a short essay: chapters of prose with photos, press
   clippings, and quotes placed wherever they fit the story.
   ----------------------------------------------------------------------- */

.chapter {
  padding-block: clamp(3rem, 8vw, 5.5rem);
  border-top: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}

.chapter h2 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.012em;
}

.chapter p {
  margin: 0 0 1.1em;
}

/* A short index under a chapter, used where the politics page points
   at the political-technology work on other pages. */
.chapter .index-list {
  margin: 2rem 0 2.25rem;
}

.chapter figure {
  margin: 2.75rem 0;
}

.chapter figcaption {
  margin-top: 0.75rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Press clippings: a source line, the headline, and a date */
.clippings {
  list-style: none;
  margin: 2.5rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0 2rem;
}

.clipping {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  height: 100%;
  padding-block: 1.1rem 1.25rem;
  border-top: 1px solid var(--ink);
  text-decoration: none;
}

.clipping .source,
.clipping .date {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.clipping .headline {
  grid-column: 1 / -1;
  font-size: 1.2rem;
  line-height: 1.3;
}

.clipping .date {
  grid-column: 1;
}

.clipping .icon {
  grid-row: 1;
  grid-column: 2;
  transition: transform 0.15s ease;
}

a.clipping:hover .headline {
  color: var(--accent);
}

a.clipping:hover .icon {
  transform: translate(2px, -2px);
}

/* A quote from a colleague, set larger than body text */
.pullquote {
  margin: 2.75rem 0;
  padding: 0;
}

.pullquote p {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 2.6vw, 1.65rem);
  font-style: italic;
  font-weight: 350;
  line-height: 1.35;
}

.pullquote footer {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Advance map (Politics page): summary numbers, map, era timeline
   ----------------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 1.5rem 1rem;
  margin: 2.75rem 0 0;
}

/* Number above label: the dd is shown first via column-reverse */
.stats div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  border-top: 1px solid var(--ink);
  padding-top: 0.7rem;
}

.stats dd {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 350;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums tabular-nums;
}

.stats dt {
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.advance-map {
  margin: 3rem 0 0;
}

.advance-map canvas {
  display: block;
  width: 100%;
}

.advance-map.is-unavailable canvas {
  display: none;
}

/* Era timeline: thin bars on a year axis. Eras that overlap in time, or
   whose labels would collide, stack in lanes. The lane is only as tall as
   the bar plus its label, so every name stays visible without a tall stack. */
.era-timeline {
  --lane-height: 1.4rem;
  --axis: 0.85rem; /* year numerals under the axis line */
  position: relative;
  /* Press or drag to jump to the nearest card. Vertical swipes still
     scroll the page on touch screens; horizontal drags scrub. */
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  /* One lane per row of labels, then a gap so the last label clears the
     trip hashes, then the year numerals. */
  height: calc(var(--lanes, 1) * var(--lane-height) + 0.55rem + var(--axis));
}

.era-timeline.is-scrubbing {
  cursor: grabbing;
}

.era-timeline::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--axis);
  border-top: 1px solid var(--rule);
}

.era {
  position: absolute;
  top: calc(var(--lane) * var(--lane-height));
  left: var(--left);
  width: var(--width);
}

.era-bar {
  display: block;
  height: 3px;
  background: var(--ink);
}

/* Headquarters jobs (no trips) are drawn hollow */
.era--hq .era-bar {
  background: transparent;
  border: 1px solid var(--ink);
  height: 5px;
}

.era-label {
  position: absolute;
  top: 0.38rem; /* just under the bar, including the taller hollow HQ bar */
  left: 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.15;
  color: var(--muted);
  white-space: nowrap;
}

.era--flip .era-label {
  left: auto;
  right: 0;
}

.era-tick {
  position: absolute;
  bottom: 0;
  left: var(--left);
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 1;
  color: var(--muted);
}

/* One hash per trip, standing on the axis line */
.trip-hash {
  position: absolute;
  bottom: var(--axis);
  left: var(--left);
  width: 1px;
  height: 5px;
  background: var(--ink);
  opacity: 0.25;
  pointer-events: none;
}

/* Trips that get their own story card */
.trip-hash--featured {
  height: 7px;
  background: var(--accent);
  opacity: 0.75;
}

/* Active era and the "you are here" marker */
.era.is-active .era-label {
  color: var(--ink);
}

.era-marker {
  position: absolute;
  top: 0;
  bottom: var(--axis);
  left: var(--left, 0);
  width: 0;
  border-left: 1px dashed var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.era-marker.is-visible {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Advance scroll story: the map stays pinned while cards scroll past.
   The Projects page's stories (.story-scrolly) share this layout.
   ----------------------------------------------------------------------- */

.advance-scrolly,
.story-scrolly {
  position: relative;
  margin-top: 3rem;
}

.advance-stage,
.story-stage {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--paper);
}

.advance-stage .advance-map {
  margin: 0;
}

.advance-steps,
.story-steps {
  position: relative;
  z-index: 2;
  list-style: none;
  margin: 0;
  padding: 0;
}

.story-step {
  display: flex;
  align-items: center;
  min-height: 80vh;
}

/* The map story spaces its cards a screen apart, so the camera (and the
   plane) have room to fly between them; see cameraRange in advance-map.js. */
.advance-steps {
  --step-height: 100vh;
}

.advance-steps .story-step {
  min-height: var(--step-height);
}

/* Era paths between cards, drawn by advance-map.js. Lines and dots are
   positioned from the column's center line via --x / --top / --height. */
.era-paths {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.era-path {
  position: absolute;
  top: var(--top);
  left: calc(50% + var(--x));
  height: var(--height);
  border-left: 1px solid var(--ink);
  opacity: 0.18;
}

/* After an era's last card its path fades out */
.era-path--tail {
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
}

.era-path-trip {
  position: absolute;
  top: var(--top);
  left: calc(50% + var(--x));
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2px; /* centered on the 1px line */
  border-radius: 50%;
  background: var(--color);
  opacity: 0.7;
}

.story-card {
  width: 100%;
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  font-size: 1.05rem;
  line-height: 1.5;
  transition: opacity 0.3s ease, border-color 0.3s ease;
}

.story-step.is-active .story-card {
  border-color: var(--ink);
}

.story-card p {
  margin: 0 0 0.75em;
}

.story-card p:last-child {
  margin-bottom: 0;
}

.story-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.story-card img,
.story-card .story-photo {
  width: 100%;
  margin: 0 0 0.85rem;
}

.story-card .story-photo {
  aspect-ratio: 16 / 10;
}

/* Photo carousels (built by advance-map.js for cards with 2+ photos).
   The card gets extra scroll height per extra photo and stays pinned
   while the photos slide by; --pos is the photo showing (fractional). */
.story-step.has-carousel {
  align-items: flex-start;
  min-height: calc(var(--step-height, 80vh) + (var(--photos) - 1) * 45vh);
}

/* Flight cards (see advance-map.js) pin the same way while the plane
   hops through every trip of the era. */
.story-step.has-flight {
  align-items: flex-start;
  min-height: calc(var(--step-height, 80vh) + 200vh);
}

.story-step.has-carousel .story-card,
.story-step.has-flight .story-card {
  position: sticky;
  top: 20vh;
  z-index: 1; /* slides over the era path below it */
}

.advance-steps.is-measuring .story-step.has-carousel .story-card,
.advance-steps.is-measuring .story-step.has-flight .story-card {
  position: static;
}

.story-carousel {
  overflow: hidden;
  aspect-ratio: 3 / 2;
  margin: 0 0 0.85rem;
}

.story-carousel-track {
  display: flex;
  height: 100%;
  transform: translateX(calc(var(--pos, 0) * -100%));
}

.story-card .story-carousel-track > img,
.story-card .story-carousel-track > .story-photo {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
}

/* Photos of me at work: an <img> wrapped in figure.story-photo.story-photo--me
   with a short caption on a paper label in the corner. As a direct child
   of the card it joins the carousel like any other photo. */
.story-card .story-photo--me {
  position: relative;
  aspect-ratio: auto; /* size to the photo, not the placeholder ratio */
}

.story-card .story-photo--me img {
  margin: 0;
}

.story-card .story-carousel-track > .story-photo--me img {
  height: 100%;
  object-fit: cover;
}

.story-card .story-photo--me figcaption {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  max-width: calc(100% - 1rem);
  margin: 0;
  padding: 0.2rem 0.45rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.68rem;
  line-height: 1.4;
}

.story-press {
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* Credit line for Creative Commons photos; their licenses require it */
.story-credit {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* A colleague's quote, set as a card of its own */
.story-quote {
  margin: 0;
}

.story-quote p {
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 350;
  line-height: 1.4;
}

.story-quote footer {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

/* Live "stop N of M" line on a flight card */
.flight-counter {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* Country flag(s) at the end of the date line, for trips abroad.
   Flags: flag-icons (MIT), self-hosted in /images/flags. The place and
   its flags wrap as one unit, so a flag never sits on a line alone. */
.story-place {
  white-space: nowrap;
}

.story-card .story-flag {
  display: inline-block;
  width: auto;
  height: 0.9em;
  margin: 0 0 0 0.4em;
  vertical-align: -0.1em;
  box-shadow: 0 0 0 1px var(--rule); /* keeps white edges visible on paper */
}

/* Logos of organizations tied to a trip, at the bottom of the card.
   Grayscale and multiplied into the paper, so they read as ink and any
   white logo background disappears. Must stay out of the card's direct
   children, or advance-map.js would treat them as carousel photos. */
.story-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
  margin-top: 0.9rem;
}

.story-card .story-logos img {
  width: auto;
  max-width: 6.5rem;
  height: 2.2rem;
  margin: 0;
  object-fit: contain;
  filter: grayscale(1) contrast(1.6);
  mix-blend-mode: multiply;
}

/* Wide screens: cards in a left column, map pinned on the right */
@media (min-width: 56.01rem) {
  .advance-scrolly,
  .story-scrolly {
    display: grid;
    grid-template-columns: minmax(15rem, 19rem) 1fr;
    gap: 2.5rem;
  }

  .advance-stage,
  .story-stage {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    height: 100vh;
  }

  .advance-steps,
  .story-steps {
    grid-column: 1;
    grid-row: 1;
    padding-block: 45vh 50vh;
  }

  .story-step:not(.is-active) .story-card {
    opacity: 0.35;
  }
}

/* Narrow screens: map pinned to the top, cards scroll up beneath it.
   --stage-height is set on the scrolly so the sticky cards can match it.
   Phones override it below so the card keeps more of the screen. */
@media (max-width: 56rem) {
  .advance-scrolly {
    --stage-height: 58vh;
  }

  .advance-stage {
    height: var(--stage-height);
  }

  .story-stage {
    height: 58vh;
  }

  .advance-stage,
  .story-stage {
    z-index: 3; /* cards pass underneath the pinned map */
  }

  .advance-steps,
  .story-steps {
    z-index: 1;
    padding-block: 20vh 30vh;
  }

  .story-step {
    min-height: 70vh;
    align-items: flex-end;
  }

  .advance-steps {
    --step-height: 90vh;
  }

  .story-step.has-carousel {
    align-items: flex-start;
    min-height: calc(var(--step-height, 70vh) + (var(--photos) - 1) * 45vh);
  }

  .story-step.has-flight {
    min-height: calc(var(--step-height, 70vh) + 200vh);
  }

  /* Pin just below the map rather than underneath it. Projects stories
     have no --stage-height, so they keep the 58vh stage. */
  .story-step.has-carousel .story-card,
  .story-step.has-flight .story-card {
    top: calc(var(--stage-height, 58vh) + 0.5rem);
  }
}

/* --------------------------------------------------------------------------
   The Politics map runs edge to edge: its stage breaks out of the column
   to fill the screen, the map fades into the paper at the top and bottom
   rather than ending at a hard line, and on wide screens the cards lie
   over it like sheets of tracing paper. (The Projects page's stories keep
   the boxed layout above.)
   ----------------------------------------------------------------------- */

/* A 100vw stage overhangs by the scrollbar's width where scrollbars take
   up room (e.g. Windows). "clip" rather than "hidden", so sticky still works. */
main:has(.advance-scrolly) {
  overflow-x: clip;
}

/* Full screen width, with padding that puts its contents back on the column */
.advance-stage {
  margin-inline: calc(50% - 50vw);
  padding-inline: calc(50vw - 50%);
}

/* The map fills the whole stage; advance-map.js matches its pixels to this
   box and frames each card's subject in the clear part (FRAME_INSET there
   follows these fades). --timeline-space, also set there, is the room the
   timeline takes at the bottom: the map has faded out by the time it
   reaches it. */
.advance-stage .advance-map canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

@media (min-width: 56.01rem) {
  /* Under the whole width, with the timeline beside the cards at the bottom */
  .advance-stage {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(15rem, 19rem) 1fr; /* same columns as .advance-scrolly */
    column-gap: 2.5rem;
    align-content: end;
    padding-bottom: 2rem;
  }

  .advance-stage .advance-map {
    grid-column: 2;
  }

  /* Clear at the very top, where the site header slides in, then fading in */
  .advance-stage .advance-map canvas {
    -webkit-mask-image: linear-gradient(to bottom, transparent 4rem, #000 9rem, #000 calc(100% - var(--timeline-space, 0px) - 4rem), transparent calc(100% - var(--timeline-space, 0px)));
    mask-image: linear-gradient(to bottom, transparent 4rem, #000 9rem, #000 calc(100% - var(--timeline-space, 0px) - 4rem), transparent calc(100% - var(--timeline-space, 0px)));
  }

  /* Tracing paper: the map shows through, softened */
  .advance-steps .story-card {
    background: var(--vellum);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

@media (max-width: 56rem) {
  /* Map across the top, timeline along its bottom edge */
  .advance-stage {
    justify-content: flex-end;
    padding-bottom: 0.75rem;
  }

  .advance-stage .advance-map canvas {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 3rem, #000 calc(100% - var(--timeline-space, 0px) - 3rem), transparent calc(100% - var(--timeline-space, 0px)));
    mask-image: linear-gradient(to bottom, transparent, #000 3rem, #000 calc(100% - var(--timeline-space, 0px) - 3rem), transparent calc(100% - var(--timeline-space, 0px)));
  }

  /* Cards fade as they slide under the map instead of meeting a hard line */
  .advance-stage::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 2.5rem;
    background: linear-gradient(var(--paper), transparent);
    pointer-events: none;
  }
}

/* Phones: a shorter map and timeline, so a story card isn't clipped under
   the pinned stage. svh follows the visible screen (vh includes the iPhone
   browser chrome). Labels stay on; the denser lanes above keep them from
   overlapping or eating the map. */
@media (max-width: 30rem) {
  .advance-scrolly {
    --stage-height: 42vh;
    --stage-height: 38svh;
  }

  .advance-stage {
    padding-bottom: 0.3rem;
  }

  .advance-stage .era-timeline {
    margin-top: 0.15rem;
  }

  .advance-stage .advance-map canvas {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 1rem, #000 calc(100% - var(--timeline-space, 0px) - 1rem), transparent calc(100% - var(--timeline-space, 0px)));
    mask-image: linear-gradient(to bottom, transparent, #000 1rem, #000 calc(100% - var(--timeline-space, 0px) - 1rem), transparent calc(100% - var(--timeline-space, 0px)));
  }

  .advance-stage::after {
    height: 1.15rem;
  }
}

/* --------------------------------------------------------------------------
   Projects page stages, drawn by projects.js. Each sits in a .story-stage
   (layout above) and changes as the cards beside it scroll past.
   ----------------------------------------------------------------------- */

.story-stage figure {
  margin: 0;
}

/* Calypso: the CRM's systems map, drawn as SVG */
.calypso-map svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 8rem);
  overflow: visible;
}

.cal-edge {
  fill: none;
  stroke: #bdb5a4;
  stroke-width: 1;
  transition: stroke 0.3s ease;
}

.cal-edge.is-lit {
  stroke: var(--ink);
}

/* Tools start faint, darken once a card has wired them in, and turn ink
   while their card is active */
.cal-node rect {
  fill: var(--paper);
  stroke: var(--rule);
  transition: stroke 0.3s ease;
}

.cal-node text {
  font-family: var(--mono);
  fill: var(--muted);
  opacity: 0.5;
  transition: opacity 0.3s ease, fill 0.3s ease;
}

.cal-node.is-on rect { stroke: #bdb5a4; }
.cal-node.is-on text { fill: var(--ink); opacity: 0.75; }
.cal-node.is-lit rect { stroke: var(--ink); }
.cal-node.is-lit text { fill: var(--ink); opacity: 1; }

.cal-hub rect {
  fill: var(--ink);
}

.cal-hub text {
  font-family: var(--mono);
  font-weight: 500;
  fill: var(--paper);
}

.cal-group {
  font-family: var(--mono);
  letter-spacing: 0.06em;
  fill: var(--muted);
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.cal-group.is-on,
.cal-group.is-lit {
  opacity: 1;
}

/* Red mirage: the panels stack in the stage; the active card's is shown */
.mirage {
  position: relative;
  height: calc(100vh - 6rem);
}

.mirage p {
  margin: 0;
}

.mirage-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.75rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.mirage-panel.is-shown {
  opacity: 1;
  visibility: visible;
}

.mirage-label,
.mirage-source {
  font-family: var(--mono);
  color: var(--muted);
}

.mirage-label {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mirage-source {
  font-size: 0.7rem;
}

/* Electoral votes: Biden fills from the left, Trump from the right.
   projects.js sets --dem-share (Biden's share of the bar, 0 to 1). */
.mirage .ev-numbers {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.ev-numbers [data-ev] {
  font-family: var(--serif);
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 350;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums;
}

.ev-dem [data-ev] { margin-right: 0.35rem; }
.ev-rep [data-ev] { margin-left: 0.35rem; }

.ev-side {
  transition: color 0.3s ease;
}

.ev-side.is-leading {
  color: var(--ink);
}

.ev-track {
  position: relative;
  height: 1.5rem;
}

.ev-fill {
  position: absolute;
  top: 0;
  bottom: 0;
}

.ev-fill--dem {
  left: 0;
  width: calc(var(--dem-share, 0.5) * 100%);
  background: var(--dem);
}

.ev-fill--rep {
  right: 0;
  width: calc((1 - var(--dem-share, 0.5)) * 100%);
  background: var(--rep);
}

/* 270 of 538 electoral votes */
.ev-270 {
  position: absolute;
  top: -0.45rem;
  bottom: -0.45rem;
  left: 50.186%;
  border-left: 1px dashed var(--ink);
}

.mirage .ev-270-label {
  margin-top: 0.6rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* The mail-ballot slider; projects.js sets --counted (0 to 100) */
.vbm-value {
  font-size: 1.05rem;
}

.vbm-value [data-vbm] {
  font-variant-numeric: lining-nums tabular-nums;
}

.vbm-track {
  position: relative;
  height: 1px;
  margin: 1rem 0 0.65rem;
  background: var(--rule);
}

.vbm-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 1px;
  width: calc(var(--counted, 0) * 1%);
  background: var(--ink);
}

.vbm-handle {
  position: absolute;
  top: 0;
  left: calc(var(--counted, 0) * 1%);
  width: 13px;
  height: 13px;
  margin: -6px 0 0 -6.5px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.vbm-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* Florida early vote: two bars; projects.js sets each segment's --w (%) */
.mirage .fl-title {
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

.fl-bar {
  display: flex;
  height: 1.25rem;
  background: var(--placeholder);
}

.fl-seg {
  width: calc(var(--w, 0) * 1%);
}

.fl-seg--dem, .fl-key--dem { --key: var(--dem); }
.fl-seg--rep, .fl-key--rep { --key: var(--rep); }
.fl-seg--npa, .fl-key--npa { --key: #b8b09f; }
.fl-seg--other, .fl-key--other { --key: var(--muted); }
.fl-seg--voted, .fl-key--voted { --key: var(--ink); }
.fl-seg--yet, .fl-key--yet { --key: var(--placeholder); }

.fl-seg {
  background: var(--key);
}

.fl-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  margin: 0.6rem 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.fl-legend li::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.4rem;
  vertical-align: -0.05rem;
  background: var(--key);
  box-shadow: 0 0 0 1px var(--rule);
}

/* The dashboard design, zoomed by projects.js as its card scrolls */
.mirage-mock {
  align-items: center;
  gap: 0.75rem;
}

.mock-frame {
  height: calc(100% - 2.5rem);
  aspect-ratio: 1400 / 2042;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: #fff;
}

.mock-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transform-origin: 50% 56%;
}

/* Images shown whole in the stage: the MSNBC graphic and the Election
   Watch Dashboard design. They fit the stage's width or height, whichever
   runs out first, leaving room for the source line. */
.mirage-shot {
  align-items: center;
  gap: 0.75rem;
}

.mirage-shot img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100% - 2.5rem);
  border: 1px solid var(--rule);
}

/* Refugee guide globe */
.guide-globe canvas {
  display: block;
  width: 100%;
}

.guide-globe.is-unavailable canvas {
  display: none;
}

@media (max-width: 56rem) {
  .calypso-map svg {
    max-height: calc(58vh - 3rem);
  }

  .mirage {
    height: calc(58vh - 1.5rem);
  }

  .mirage-panel {
    gap: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mirage-panel,
  .cal-edge,
  .cal-node rect,
  .cal-node text {
    transition: none;
  }
}

/* Visible reminder of content still to be added; remove once filled in */
.todo,
.clipping.todo .headline {
  color: var(--muted);
  font-style: italic;
}

.clipping.todo {
  border-top-style: dashed;
  border-top-color: var(--muted);
}

/* /work overview: one line of description under each title */
.overview {
  padding-bottom: clamp(4rem, 10vw, 7rem);
}

.index-list .desc {
  grid-column: 1 / -1;
  font-size: 1rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Photographs page
   The page is one screen tall. One square photograph sits in the open
   band; the previous and next squares use the width a square leaves on
   a wide screen (js/photographs.js). The header, transport, and footer
   float over the darkroom. Until photos load, placeholder squares sit
   in a row you can still scroll.
   ----------------------------------------------------------------------- */

.photo-page {
  /* Darker than the old darkroom grey, still warm, from the same brown as the ink. */
  --darkroom: #1c1a17;
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background: var(--darkroom);
  color: var(--paper);
}

/* Floated over the photograph. --photo-footer is the footer's height,
   set by photographs.js, so the transport sits just above it. */
.photo-page .site-header,
.photo-page .site-footer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  background: transparent;
  color: var(--paper);
  text-shadow: 0 1px 10px rgb(22 21 19 / 0.6);
}

.photo-page .site-header {
  top: 0;
  box-shadow: none;
}

/* A short fade, so the name stays readable when a print sits behind it. */
.photo-page .site-header::before,
.photo-page .site-footer::before,
.photo-deck::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  z-index: -1;
  pointer-events: none;
}

.photo-page .site-header::before {
  top: 0;
  height: 160%;
  background: linear-gradient(to bottom, rgb(28 26 23 / 0.92) 20%, rgb(28 26 23 / 0));
}

.photo-page .site-footer::before {
  bottom: 0;
  height: 160%;
  background: linear-gradient(to top, rgb(28 26 23 / 0.92), rgb(28 26 23 / 0));
}

.photo-deck::before {
  bottom: 0;
  height: 150%;
  background: linear-gradient(to top, rgb(28 26 23 / 0.72), rgb(28 26 23 / 0));
}

.photo-page .site-footer {
  bottom: 0;
  border-top: 0;
  padding-block: 0.65rem 0.9rem;
}

.photo-page .site-nav a {
  color: rgb(242 239 232 / 0.78);
}

.photo-page .site-nav a:hover,
.photo-page .site-nav a[aria-current="page"],
.photo-page .site-nav .is-active > a {
  color: var(--paper);
}

/* The Work menu is a paper panel, so it keeps the usual ink type. */
.photo-page .submenu {
  background: var(--paper);
  color: var(--ink);
  text-shadow: none;
}

.photo-page .submenu a,
.photo-page .submenu a:hover {
  color: var(--muted);
  text-shadow: none;
}

.photo-page .submenu a:hover {
  color: var(--ink);
}

.photo-page .site-footer a:hover {
  color: var(--paper);
}

.photo-stage {
  position: absolute;
  inset: 0;
}

/* Without the script, the squares are a sideways row you can scroll.
   --photo-size is the square; photographs.js sets it from the open band. */
.photo-reel {
  position: absolute;
  inset: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  padding-top: var(--photo-header, 4.75rem);
  padding-bottom: calc(var(--photo-footer, 3.25rem) + var(--photo-deck, 4.5rem));
}

@media (prefers-reduced-motion: reduce) {
  .photo-reel { scroll-behavior: auto; }
}

.photo-track {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding-inline: max(var(--gutter), calc(50% - min(68vh, 86vw) / 2));
}

/* Once the script is driving it, the track slides and the reel clips it. */
.photo-reel.is-ready {
  overflow: hidden;
  scroll-snap-type: none;
}

.photo-reel.is-ready .photo-track {
  gap: var(--photo-gap, 1rem);
  padding-inline: 0;
  flex: none;
  touch-action: none;
  cursor: grab;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.photo-reel.is-ready .photo-track.is-instant {
  transition: none;
}

.photo-reel.is-ready .photo-track.is-dragging {
  transition: none;
  cursor: grabbing;
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  .photo-reel.is-ready .photo-track { transition: none; }
}

/* Hidden while js/photographs.js loads the list, so the placeholders don't
   flash before the real photos replace them. */
[data-photos].is-loading {
  visibility: hidden;
}

/* The photograph is square. Anything that isn't is cropped to the square
   rather than letterboxed, so the row stays even. */
.photo-slide {
  flex: 0 0 min(68vh, 86vw);
  width: min(68vh, 86vw);
  margin: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.photo-reel.is-ready .photo-slide {
  flex-basis: var(--photo-size, min(68vh, 86vw));
  width: var(--photo-size, min(68vh, 86vw));
}

.photo-slide-media {
  background: #2a2723;
  overflow: hidden;
}

.photo-slide img,
.photo-slide .placeholder {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  max-width: none;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.photo-slide .placeholder {
  display: flex;
}

/* Neighbors stay in the row at full size and step back, so the square
   you're on is the only one that reads as the photograph. */
.photo-reel.is-ready .photo-slide-media {
  opacity: 0.38;
  transition: opacity 0.45s ease;
}

.photo-reel.is-ready .photo-slide.is-current .photo-slide-media {
  opacity: 1;
}

.photo-slide figcaption {
  min-height: 2.75rem;
  margin: 0.75rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  color: rgb(242 239 232 / 0.86);
}

.photo-slide figcaption span + span::before {
  content: ", ";
}

.photo-slide figcaption a {
  display: block;
  color: rgb(242 239 232 / 0.62);
}

.photo-reel.is-ready .photo-slide figcaption {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.photo-reel.is-ready .photo-slide.is-current figcaption {
  opacity: 1;
  pointer-events: auto;
}

/* Transport: title and sentence on the left, keys in the middle, count
   on the right. On a narrow screen the keys drop to their own row. */
.photo-deck {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--photo-footer, 3.25rem);
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: clamp(0.75rem, 2vw, 1.5rem);
  row-gap: 0.55rem;
  padding: 0.55rem var(--gutter) 0.4rem;
  border-top: 0;
  background: transparent;
  color: var(--paper);
  text-shadow: 0 1px 10px rgb(22 21 19 / 0.6);
}

.photo-deck-copy h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.photo-deck-copy p {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  line-height: 1.3;
  color: rgb(242 239 232 / 0.82);
  text-wrap: pretty;
}

.photo-transport {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.photo-transport button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 2.25rem;
  min-width: 2.25rem;
  padding: 0 0.6rem;
  border: 1px solid rgb(242 239 232 / 0.55);
  border-radius: 0;
  background: transparent;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: none;
  cursor: pointer;
}

.photo-transport .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.photo-transport button:hover {
  border-color: var(--paper);
}

/* Play shows the triangle until it's running; pause shows the bars.
   Shuffle and pause share the filled key so "on" is obvious. */
.photo-transport [data-play][aria-pressed="false"] .icon-pause,
.photo-transport [data-play][aria-pressed="true"] .icon-play {
  display: none;
}

.photo-transport button[aria-pressed="true"] {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--ink);
}

.photo-transport button:disabled {
  opacity: 0.4;
  cursor: default;
}

.photo-count {
  margin: 0;
  justify-self: end;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: rgb(242 239 232 / 0.82);
}

/* Only stack the keys once the sentence and the transport no longer fit
   on one line. Above this, the photograph keeps the height. */
@media (max-width: 40rem) {
  .photo-deck {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .photo-transport {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

/* --------------------------------------------------------------------------
   Admin (/admin): manages the photographs page (js/admin.js). Reuses the
   contact form's .form, .field, .button, and .form-status.
   ----------------------------------------------------------------------- */

.admin {
  padding-bottom: clamp(4rem, 10vw, 7rem);
}

.admin .label {
  margin: 4rem 0 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.admin-auth-status {
  margin-top: 1.25rem;
}

.admin-account {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-note {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: var(--muted);
}

/* Text-style buttons for secondary actions (sign out, move, delete) */
.admin-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--rule);
  cursor: pointer;
}

.admin-link:hover:not(:disabled) {
  text-decoration-color: currentColor;
}

.admin-link:disabled {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}

.admin-link--danger {
  color: var(--accent);
}

.button--small {
  padding: 0.55rem 1rem;
}

.field input[type="file"] {
  border-bottom: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.field input[type="file"]::file-selector-button {
  margin-right: 1rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.admin-preview {
  width: auto;
  max-height: 14rem;
  margin-top: 1rem;
}

/* The photos on the page, in order: thumbnail beside its caption fields */
.admin-photos {
  display: grid;
  gap: 2.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-photo {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1.5rem;
  align-items: start;
}

.admin-photo img {
  width: 100%;
  height: auto;
  background: var(--placeholder);
}

.admin-photo .form {
  gap: 1.25rem;
}

.admin-photo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

@media (max-width: 32rem) {
  .admin-photo { grid-template-columns: 1fr; }
  .admin-photo img { max-width: 12rem; }
}

/* Links between the admin pages (Photos, Instagram) */
.admin-nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.admin-nav a {
  color: var(--muted);
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a[aria-current="page"] {
  color: var(--ink);
}

.ig-connection {
  margin-top: 0.75rem;
}

/* Instagram grid (/admin/instagram): square thumbnails, newest first.
   A checked box is on the photographs page. An outline means the copy
   is already stored. */
.ig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.ig-item {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: var(--placeholder);
  cursor: pointer;
}

.ig-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.15s ease;
}

.ig-item:hover img {
  opacity: 0.85;
}

.ig-item.is-on-site {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

/* The checkbox is the control now: checked means the photo is on the page. */
.ig-cell {
  position: relative;
}

.ig-check {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  z-index: 1;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.ig-cell.is-repressed .ig-item img {
  opacity: 0.4;
}

/* Previous / Page N of M / Next, under the grid */
.ig-pages {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 1.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.ig-pages[hidden] {
  display: none;
}

/* The panel for one picked photo */
.ig-dialog {
  width: min(36rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 2.75rem 1.5rem 1.5rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.ig-dialog::backdrop {
  background: rgba(22, 21, 19, 0.45);
}

/* .form and .form-actions set display, which would beat the hidden attribute */
.ig-dialog [hidden] {
  display: none;
}

.ig-dialog-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
}

.ig-dialog-image {
  width: 100%;
  max-height: 45vh;
  object-fit: contain;
  background: var(--placeholder);
}

.admin .ig-dialog .label {
  margin: 1.5rem 0 0.5rem;
  padding-top: 0;
  border-top: 0;
}

/* --------------------------------------------------------------------------
   Books page (/books): spines on a shelf. Picking one pulls it out and
   shows its details in the card below (js/books.js).
   ----------------------------------------------------------------------- */

.books {
  --row: 16.5rem;   /* one shelf: the tallest spine plus room to lift */
  --plank: 1px;
  --spine-light: #ebe7de; /* between --paper and --placeholder */
  padding-bottom: clamp(4rem, 10vw, 7rem);
}

/* Books wrap onto as many shelves as they need. Every item is exactly one
   row tall, so the repeating plank in the background lines up under
   each row of books. A 2px gap of paper separates the spines. */
.bookshelf {
  display: flex;
  flex-wrap: wrap;
  column-gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: linear-gradient(to top, var(--ink) var(--plank), transparent var(--plank)) 0 0 / 100% var(--row);
}

/* The top padding caps how tall a long-titled book can grow, keeping a gap
   below the shelf above. Direct children only, so the games inside the
   stack aren't given a full row each. */
.bookshelf > li {
  display: flex;
  align-items: flex-end;
  height: var(--row);
  padding: 1.25rem 0 var(--plank);
}

/* A spine reads top to bottom, like an American book: short title at the
   top, author's last name at the bottom. Heights below are minimums: a
   book with a long title grows taller (up to the shelf above), then wraps
   into a second column, which makes it thicker. */
.spine {
  writing-mode: vertical-rl;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-width: 2.15rem;
  min-height: 13rem;
  margin: 0;
  padding: 1rem 0.55rem 0.85rem;
  border: 0;
  border-radius: 0;
  background: var(--placeholder);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transform-origin: left bottom;
}

.spine-title {
  font-size: 0.875rem;
  line-height: 1.2;
  text-align: center;
  text-wrap: balance; /* two-line titles split evenly */
}

.spine-author,
.box-designer {
  flex: none;
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Variety without per-book classes: heights repeat every 5 books and
   tones every 7, so the pattern never visibly lines up. Adding a book
   needs no CSS. Tones stay within the paper palette. */
.bookshelf li:nth-child(5n+2) .spine { min-height: 12.25rem; }
.bookshelf li:nth-child(5n+3) .spine { min-height: 14rem; }
.bookshelf li:nth-child(5n+4) .spine { min-height: 12.75rem; }
.bookshelf li:nth-child(5n+5) .spine { min-height: 14.5rem; }

.bookshelf li:nth-child(7n+2) .spine,
.bookshelf li:nth-child(7n+5) .spine { background: var(--rule); }
.bookshelf li:nth-child(7n+4) .spine,
.bookshelf li:nth-child(7n) .spine { background: var(--spine-light); }

/* Optional real-world sizes, set with data-size on a book's <li>:
   "thick" for big books (wider and taller), "thin" for slim ones
   (narrower, shorter, smaller title). Everything must fit on two shelf
   rows on desktop, so balance thick against thin within a row and check
   the fit after changing them. */
.bookshelf > li[data-size="thick"] .spine {
  min-height: 14.75rem;
  padding-right: 0.8rem;
  padding-left: 0.8rem;
}

.bookshelf > li[data-size="thin"] .spine {
  min-width: 0;
  min-height: 11.25rem;
  padding-right: 0.35rem;
  padding-left: 0.35rem;
}

.bookshelf > li[data-size="thin"] .spine-title {
  font-size: 0.8rem;
}

/* Hover lifts a book slightly. The pulled book turns to ink, slides out,
   and tips forward a little, in front of its neighbor. */
@media (hover: hover) {
  .spine:hover {
    translate: 0 -0.35rem;
  }
}

.bookshelf li .spine[aria-pressed="true"] {
  position: relative;
  z-index: 1;
  translate: 0 -1rem;
  rotate: 3deg;
  background: var(--ink);
  color: var(--paper);
}

.spine[aria-pressed="true"] .spine-author,
.game-box[aria-pressed="true"] .box-designer {
  color: var(--rule);
}

/* Board games: boxes lying flat in one stack at the end of the shelf,
   each edge reading left to right (short title, then designers). The
   stack is as wide as its widest box. Side padding sets it apart from
   the books and leaves room on the right for a box to slide out. */
.bookshelf .game-stack {
  padding-inline: 0.5rem 1rem;
}

.game-stack ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  height: 1.3rem;
  margin: 0;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 0;
  background: var(--placeholder);
  color: var(--ink);
  font: inherit;
  white-space: nowrap; /* a long title widens the box instead of wrapping */
  cursor: pointer;
}

.box-title {
  font-size: 0.75rem;
  line-height: 1;
}

/* Same idea as the spines: heights repeat every 3 boxes, tones every 4,
   and small insets every 5 so the stack doesn't look machine-made. Ten
   boxes stay just under the tallest book; check the height if adding
   many more. */
.game-stack li:nth-child(3n+2) .game-box { height: 1.5rem; }
.game-stack li:nth-child(3n) .game-box { height: 1.2rem; }

.game-stack li:nth-child(4n+2) .game-box { background: var(--rule); }
.game-stack li:nth-child(4n) .game-box { background: var(--spine-light); }

.game-stack li:nth-child(5n+2) { margin-left: 0.4rem; }
.game-stack li:nth-child(5n+4) { margin-right: 0.5rem; }

/* Hover nudges a box out to the right; the pulled box slides out further
   and turns to ink, like a pulled book. */
@media (hover: hover) {
  .game-box:hover {
    translate: 0.3rem 0;
  }
}

.game-stack li .game-box[aria-pressed="true"] {
  position: relative;
  z-index: 1;
  translate: 1rem 0;
  background: var(--ink);
  color: var(--paper);
}

@media (prefers-reduced-motion: no-preference) {
  .spine {
    transition: rotate 0.2s ease, translate 0.25s ease 0.12s, background-color 0.2s ease, color 0.2s ease;
  }

  .bookshelf li .spine[aria-pressed="true"] {
    transition: translate 0.25s ease, rotate 0.3s cubic-bezier(0.3, 1.4, 0.6, 1) 0.15s, background-color 0.2s ease, color 0.2s ease;
  }

  .game-box {
    transition: translate 0.25s ease, background-color 0.2s ease, color 0.2s ease;
  }

  .game-stack li .game-box[aria-pressed="true"] {
    transition: translate 0.3s cubic-bezier(0.3, 1.4, 0.6, 1), background-color 0.2s ease, color 0.2s ease;
  }
}

/* Details of the pulled book. While a book is out (.is-open, set by
   books.js) the card is sticky, so on a phone it stays in view at the
   bottom of the screen while the shelf is on screen. */
.book-card {
  margin-top: 1.5rem;
  padding-block: 1.25rem 1.5rem;
  border-top: 1px solid transparent;
  background: var(--paper);
}

.book-card.is-open {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top-color: var(--rule);
}

.book-card h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.book-byline,
.book-card-hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.book-note {
  margin: 1rem 0 0;
}

/* Books without a note leave the note empty */
.book-note:empty {
  display: none;
}

.book-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  margin: 1rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.shelf-disclosure {
  margin: 1rem 0 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Blog: the index (/blog) and one page per post (/blog/<slug>).
   The index reuses .index-list; posts reuse .pullquote and .button.
   Case studies (/tech/<name>) reuse the post header too.
   Case studies (/tech/<slug>) reuse the post header too.
   ----------------------------------------------------------------------- */

.blog-list {
  padding-bottom: clamp(3.5rem, 9vw, 6rem);
}

.blog-list-intro {
  margin: 0 0 2rem;
}

/* Post header: kicker (links back to /blog), headline, subheader, date */
.post-header {
  padding-block: clamp(3.5rem, 11vw, 8rem) clamp(2.5rem, 6vw, 3.5rem);
}

.post-kicker,
.post-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-kicker {
  margin: 0 0 1.25rem;
}

.post-kicker a {
  text-decoration: none;
}

.post-kicker a:hover {
  color: var(--ink);
}

.post-header h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.1rem, 4.8vw, 3.25rem);
  font-weight: 350;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.post-dek {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.4rem);
  line-height: 1.4;
  color: var(--muted);
}

.post-date {
  margin: 1.75rem 0 0;
}

.post-body {
  padding-bottom: clamp(4rem, 10vw, 7rem);
  border-top: 1px solid var(--rule);
}

.post-body .pullquote {
  margin-top: clamp(2.5rem, 6vw, 3.5rem);
}

/* Placeholder paywall: gray bars stand in for the essay's opening lines
   and fade out under a gate. To publish a post, replace its whole
   .paywall block with the essay. */
.paywall-ghost {
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 90%);
  mask-image: linear-gradient(to bottom, #000, transparent 90%);
}

/* Bar spacing matches the body text's line height (about 1.9rem) */
.paywall-ghost span {
  display: block;
  height: 0.7rem;
  margin-bottom: 1.2rem;
  background: var(--placeholder);
}

/* Ragged line ends, plus one short line closing the first "paragraph" */
.paywall-ghost span:nth-child(odd) { width: 96%; }
.paywall-ghost span:nth-child(3n) { width: 91%; }
.paywall-ghost span:nth-child(5) { width: 58%; margin-bottom: 2.4rem; }

/* The gate overlaps the bottom of the fade */
.paywall-gate {
  position: relative;
  margin-top: -2.5rem;
  padding: 1.5rem 1.6rem;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.paywall-gate p {
  margin: 0;
}

.paywall-gate .paywall-label {
  margin-bottom: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Series navigation at the end of each post in a series */
.post-series {
  margin-top: clamp(3.5rem, 9vw, 5rem);
}

.post-series a[aria-current="page"] {
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Work index and case studies: the Tech index and home page list work
   with an outcome line and tags; each case study (/tech/<slug>) opens with
   facts at a glance, then numbered chapters.
   ----------------------------------------------------------------------- */

/* Small mono labels, e.g. SAAS · ANALYTICS */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.5rem 0 0;
}

.tags > span {
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.index-list .tags {
  grid-column: 1 / -1;
  margin-top: 0.15rem;
}

.work-index a {
  row-gap: 0.45rem;
  padding-block: 1.35rem;
}

/* Homepage selected work. Thumbnails sit above the title. Two columns
   while the page is wide enough for a pair of cards, then one. The grid
   is excluded from the reading measure above, so it can run as wide as
   the header; the label stays on the shared left edge. */
.work-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.75rem 2.25rem;
}

.work-grid a {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  height: 100%;
  text-decoration: none;
}

.work-grid .thumb {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  margin-bottom: 0.85rem;
  border: 1px solid var(--rule);
  background: var(--placeholder);
}

.work-grid .title {
  font-size: 1.35rem;
  line-height: 1.25;
}

.work-grid .meta {
  margin-top: 0.4rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Pin the tags to the bottom of the row, so uneven titles still line up. */
.work-grid .tags {
  margin: auto 0 0;
  padding-top: 0.7rem;
}

.work-grid a:hover .title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

@media (max-width: 42rem) {
  .work-grid {
    grid-template-columns: 1fr;
    gap: 2.25rem;
  }
}

/* Projects index: the work list with a thumbnail beside each entry */
.thumb-index a {
  grid-template-columns: 9rem 1fr auto;
  column-gap: 1.25rem;
}

.thumb-index .thumb {
  grid-column: 1;
  grid-row: 1 / span 3; /* title and meta, description, tags */
  align-self: start;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 1px solid var(--rule);
}

.thumb-index .placeholder.thumb {
  padding: 0.5rem;
  font-size: 0.66rem;
}

.thumb-index .desc,
.thumb-index .tags {
  grid-column: 2 / -1;
}

/* Phones: a smaller thumbnail, with the meta line under the title */
@media (max-width: 32rem) {
  .thumb-index a {
    grid-template-columns: 5.5rem 1fr;
    column-gap: 0.9rem;
  }

  .thumb-index .thumb {
    grid-row: 1 / span 4;
  }

  .thumb-index .meta {
    grid-column: 2;
  }
}

.work-also-label {
  margin-top: 3rem;
  margin-bottom: 0.9rem;
}

.work-also {
  margin: 0;
  color: var(--muted);
}

/* Role, team, timeline: a ruled strip under the case study's header */
.case-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.25rem 2rem;
  margin: 2.5rem 0 0;
}

.case-facts div {
  padding-top: 0.7rem;
  border-top: 1px solid var(--ink);
}

.case-facts dt {
  margin-bottom: 0.3rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.case-facts dd {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
}

/* Headline numbers reuse .stats from the Politics page */
.case-numbers {
  padding-bottom: clamp(2.5rem, 6vw, 4rem);
}

.case-numbers .stats {
  margin: 0;
}

/* Chapter number above each case-study heading */
.case-num {
  display: block;
  margin-bottom: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* What we learned → what we built */
.decisions {
  width: 100%;
  margin-top: 1.5rem;
  border-collapse: collapse;
  font-size: 1.02rem;
  line-height: 1.45;
}

.decisions th {
  padding: 0 1rem 0.6rem 0;
  border-bottom: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
}

.decisions td {
  padding: 0.9rem 1rem 0.9rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.decisions td:first-child {
  width: 45%;
  color: var(--muted);
}

/* Phones: each row stacks, learning above decision */
@media (max-width: 32rem) {
  .decisions thead {
    display: none;
  }

  .decisions,
  .decisions tbody,
  .decisions tr,
  .decisions td {
    display: block;
  }

  .decisions td:first-child {
    width: auto;
    padding-bottom: 0.2rem;
    border-bottom: 0;
  }
}

/* The refugee guide, one page at a time. The page is drawn to the column
   width, and the frame scrolls only that page. */
.guide-reader {
  margin: 2.75rem 0;
  border: 1px solid var(--rule);
  background: var(--paper);
}

.guide-reader-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  padding: 0.7rem 0.85rem;
}

.guide-reader-jump {
  flex: 1 1 14rem;
  min-width: 0;
}

.guide-reader select,
.guide-reader button {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 0.45rem 0.65rem;
}

.guide-reader select {
  width: 100%;
  cursor: pointer;
}

.guide-reader button {
  cursor: pointer;
}

.guide-reader button:hover:not(:disabled) {
  border-color: var(--ink);
}

.guide-reader button:disabled {
  opacity: 0.35;
  cursor: default;
}

.guide-reader-status,
.guide-reader-open,
.guide-reader-caption {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.guide-reader-status {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.guide-reader-open {
  margin-left: auto;
}

/* Tall enough to read, short enough to sit in the chapter. The canvas is
   exactly one page, so this scroll cannot reach the next page. */
.guide-reader-frame {
  max-height: min(34rem, 68vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--rule);
  background: #fff;
}

.guide-reader-frame:focus {
  outline: none;
}

.guide-reader-frame:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}

.guide-reader canvas {
  display: block;
  width: 100%;
  height: auto;
}

.guide-reader-caption {
  margin: 0;
  padding: 0.75rem 0.85rem 0.85rem;
}

/* The section menu drops out if its list fails to load. Page buttons stay. */
.guide-reader.is-unsectioned .guide-reader-jump {
  display: none;
}

/* The whole preview drops out if the page file cannot be drawn. */
.guide-reader.is-unavailable .guide-reader-jump,
.guide-reader.is-unavailable [data-prev],
.guide-reader.is-unavailable [data-next],
.guide-reader.is-unavailable .guide-reader-frame {
  display: none;
}

@media (max-width: 42rem) {
  .guide-reader [data-prev] { order: 1; }
  .guide-reader [data-next] { order: 2; }
  .guide-reader-status { order: 3; }
  .guide-reader-open { order: 4; margin-left: auto; }
  .guide-reader-jump { order: 5; flex: 1 1 100%; }
}

/* Product screenshots sit on white; a rule keeps their edge on paper */
.chapter img.screenshot {
  border: 1px solid var(--rule);
}

/* Images held to the reading column: marketing graphics with big type,
   and screenshots that would otherwise run taller than the screen */
.chapter figure.figure--measure {
  max-width: var(--measure);
}

.case-next {
  padding-block: 0 clamp(4rem, 10vw, 7rem);
}

/* Home page: skills from the resume, as four drawn marks and a tool row.
   The marks are illustrations. They are not charts of measured values. */
.skill-board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.25rem 2.75rem;
}

.skill-mark {
  display: block;
  width: 4.5rem;
  height: 2.5rem;
  color: var(--ink);
}

.skill-board h3 {
  margin: 0.85rem 0 0.3rem;
  font-size: 1.15rem;
  font-weight: 450;
  line-height: 1.3;
}

.skill-board p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--muted);
}

.tool-row {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 1.35rem 0 0;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem 1rem;
}

.tool-row li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-row .icon {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--ink);
}

@media (max-width: 32rem) {
  .skill-board { grid-template-columns: 1fr; gap: 1.75rem; }
  .tool-row { grid-template-columns: 1fr 1fr; }
}

/* Home page: how I work, as a grid of short principles */
.principles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.75rem 2.5rem;
}

.principles h3 {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 450;
  line-height: 1.3;
}

.principles h3 .icon {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2em;
}

.principles p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Contact form
   ----------------------------------------------------------------------- */

.contact-intro {
  margin: 0 0 2.5rem;
}

.form {
  display: grid;
  gap: 1.75rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
}

@media (max-width: 32rem) {
  .form-row { grid-template-columns: 1fr; }
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field .optional {
  text-transform: none;
  letter-spacing: 0;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  appearance: none;
}

.field select {
  cursor: pointer;
  /* Iconoir nav-arrow-down, drawn in the muted text color */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236d695f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 1.1rem;
  padding-right: 1.75rem;
}

.field textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

/* Honeypot: hidden from people, still present for bots */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.4rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.button:hover {
  background: transparent;
  color: var(--ink);
}

.button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.form-status {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.form-status.is-error {
  color: var(--accent);
}

/* reCAPTCHA attribution under the contact form. Google allows hiding its
   floating badge only when this text is shown instead. */
.form-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.grecaptcha-badge {
  visibility: hidden;
}

.contact-alt {
  margin: 2.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.contact-alt a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  text-decoration: none;
}

.contact-alt a:hover {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Error page (404.html)
   Firebase Hosting serves this one file for every missing path. The
   sentence is in the HTML; these rules keep the address and the
   "closest" row in the same paper-and-ink system.
   ----------------------------------------------------------------------- */

.error-page .label {
  margin-bottom: 1.25rem;
}

.error-lede {
  max-width: 40rem;
  color: var(--ink);
}

/* Same fact row as the bio, pulled a little closer to the sentence above.
   .facts is display:grid, which would otherwise beat the hidden attribute. */
.error-facts {
  margin-top: 2.25rem;
}

.error-facts[hidden] {
  display: none;
}

.error-facts dd {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.error-routes {
  padding-bottom: clamp(3.5rem, 9vw, 6.5rem);
}

/* The row error-page.js moves to the top, for the section they were nearest. */
.index-list .is-closest .meta {
  color: var(--accent);
}
