/* Work index. Palette comes from the desk scene: the paper backdrop, the
   cubicle-wall green for the active filter, the autumn tree for hover.
   Font, margins and page transitions live in base.css. */

:root {
  --paper: #e8e5de;
  --ink: #1d1c1a;
  --muted: #6f6a61;
  --rule: #cfc9be;
  --wall: #2f4c3d;
  --leaf: #c8632a;
  --pixel: 'Geist Pixel', ui-monospace, monospace;
  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
}

a {
  color: inherit;
}

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

/* Clears the fixed site header up top (and the phone nav at the bottom). */
.work {
  padding: calc(var(--top) + 88px) var(--edge) clamp(96px, 10vw, 160px);
}

@media (max-width: 800px) {
  .work {
    padding-bottom: calc(var(--top) + 120px);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The one loud thing on the page: Work [lever] Off the clock. */
.heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: clamp(32px, 7vw, 88px) 0 32px;
}

.count {
  margin: 0 0 0.4em;
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ink);
}

.filters button {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font: 500 14px/1.2 var(--sans);
  cursor: var(--hand);
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.filters .n {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

.filters button[aria-pressed='true'] .n {
  color: rgb(232 229 222 / 0.7);
}

@media (hover: hover) and (pointer: fine) {
  .filters button[aria-pressed='false']:hover {
    border-color: var(--ink);
  }
}

.filters button:active {
  scale: 0.97;
}

/* --- Index rows --- */

.index {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row a {
  display: grid;
  grid-template-columns: 7ch minmax(0, 1fr) minmax(0, 16ch) minmax(0, 14ch);
  align-items: baseline;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

.year,
.discipline,
.client {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Each year prints once, at the top of its group. */
.repeat-year .year {
  visibility: hidden;
}

.year-start {
  margin-top: 32px;
}

.title {
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  transition: color 150ms ease-out;
}

.client {
  text-align: right;
}

.thumb {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .row a:hover .title {
    color: var(--leaf);
  }
}

.row a:focus-visible {
  outline-offset: -2px;
}

/* --- Cursor preview --- */

.preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 320px;
  aspect-ratio: 4 / 3;
  background-color: var(--thumb);
  background-size: cover;
  background-position: center;
  pointer-events: none;
  clip-path: inset(50% 50% 50% 50%);
  transition: clip-path 160ms steps(4, end);
}

/* --- Off the clock: masonry board --- */

.board {
  display: flex;
  gap: 16px;
  padding-top: 24px;
}

.board-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.tile {
  margin: 0;
}

.art {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background-color: var(--thumb);
  background-size: cover;
  background-position: center;
}

.tile figcaption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.tile-title {
  font-weight: 500;
}

.tile-kind {
  color: var(--muted);
  text-align: right;
}

/* A faint pixel grid over placeholder colours, echoing the voxels. Real
   covers switch it off (thumbStyle sets --grid: none). */
.preview::after,
.art::after,
.thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grid, linear-gradient(rgb(255 255 255 / 0.12) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 0.12) 1px, transparent 1px));
  background-size: 16px 16px;
}

.preview.show {
  clip-path: inset(0);
  transition-duration: 240ms;
}

/* --- Small screens: thumbnail inline, details stacked --- */

@media (max-width: 720px) {
  .heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .lever {
    zoom: 0.75;
  }

  /* At heading size "Work / Off the clock" is wider than a phone, so the
     second word drops to its own line under the lever. */
  .heading .mode {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .board {
    gap: 10px;
  }

  .board-col {
    gap: 16px;
  }

  .tile figcaption {
    flex-direction: column;
    gap: 0;
  }

  .tile-kind {
    text-align: left;
  }

  .row a {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'thumb thumb'
      'title year'
      'discipline client';
    gap: 4px 16px;
    padding: 20px 0;
  }

  .thumb {
    position: relative;
    display: block;
    grid-area: thumb;
    aspect-ratio: 4 / 3;
    margin-bottom: 12px;
    background-color: var(--thumb);
    background-size: cover;
    background-position: center;
  }

  .title {
    grid-area: title;
  }

  .year {
    grid-area: year;
  }

  .discipline {
    grid-area: discipline;
  }

  .client {
    grid-area: client;
  }

  .repeat-year .year {
    visibility: visible;
  }

  .preview {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview,
  .preview.show,
  .lever-stick,
  .mode-word {
    transition: none;
  }
}

/* Back from a case study: the card its cover shrinks into, then fades
   (src/case-zoom-land.js). Centred, the size of the hover preview. */
.zoom-land {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10;
  width: min(320px, calc(100vw - 40px));
  aspect-ratio: 4 / 3;
  translate: -50% -50%;
  background: center / cover no-repeat;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.zoom-land.is-on { opacity: 1; visibility: visible; }
.zoom-land.is-leaving { opacity: 0; scale: 0.96; transition: opacity 320ms ease-out, scale 320ms ease-out; }
