/* ==========================================================================
   nyteshift: light to dark — pass 4, as kept in pass 5
   The cards, their categories and the case sheet. Pass 4's crossing, threads
   and hand-off were removed in pass 5 (pass5.css has the wire, the night
   edge, the Projects sign and the sticky category bar).
   Static by default: with no script, and with reduced motion, every project
   is listed in order with its beats. .work--cards turns them into cards that
   open the case sheet.
   ========================================================================== */

:root {
  --hz-hot: linear-gradient(90deg, rgba(255, 226, 190, .5), var(--hot) 10%, #FFF4E6 50%, var(--hot) 90%, rgba(255, 226, 190, .5));
  --media-r: 10px;
}

/* the scrollbar's place is kept even when the page is locked under the case sheet, so locking it never
   changes the page's width (and so its layout). Where the scrollbar takes space (Windows) it is already
   there, so nothing moves; overlay scrollbars (macOS, phones) take none, so this does nothing there */
html { scrollbar-gutter: stable; }

/* ==========================================================================
   THE HORIZON EVERY CARD STANDS ON
   ========================================================================== */
.case__horizon { position: relative; height: 1px; pointer-events: none; }
.case__horizon::before {
  content: ""; position: absolute; left: -3%; right: -3%; top: 0; height: 1px;
  background: linear-gradient(90deg, rgba(var(--glow), 0), var(--sodium) 9%, var(--sodium) 91%, rgba(var(--glow), 0));
  opacity: .55;
}
.case__horizon::after {
  content: ""; position: absolute; left: 0; right: 0; top: 1px; height: 3.25rem;
  background: radial-gradient(ellipse 60% 100% at 50% 0, rgba(var(--glow), .1), rgba(var(--glow), .03) 52%, rgba(var(--glow), 0));
}
/* ==========================================================================
   RECENT WORK
   Default (no script): every project in order, with its beats.
   ========================================================================== */
.work {
  padding-block: 0 clamp(5rem, 12vh, 8rem);
  --cg: clamp(1rem, 1.9vw, 1.75rem);
}
.work__shell { max-width: 1480px; }
.work__filters { position: relative; display: flex; gap: clamp(1.15rem, 2.2vw, 2.1rem); }
.work__filters::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--c-rule-2); }
.work__filter {
  position: relative; display: inline-flex; align-items: flex-start; gap: .28em; min-height: 2.75rem; padding: .65rem 0 .85rem;
  white-space: nowrap; cursor: pointer;
  font-size: clamp(.9375rem, 1.05vw, 1.0625rem); letter-spacing: -.005em; color: var(--c-ink-3);
  transition: color .25s var(--e-io);
}
.work__n {
  font-size: .6875rem; line-height: 1; padding-top: .1em; letter-spacing: .01em; color: var(--c-ink-4);
  font-variant-numeric: tabular-nums; transition: color .25s var(--e-io);
}
.work__filter:hover { color: var(--c-ink-1); }
.work__filter[aria-pressed="true"] { color: var(--paper); }
.work__filter[aria-pressed="true"] .work__n { color: var(--sodium); }
.work__filter:focus-visible { outline-offset: 2px; }
.work__mark {
  position: absolute; left: 0; bottom: -.5px; z-index: 1; width: 100px; height: 2px; border-radius: 2px;
  background: var(--sodium); box-shadow: 0 0 8px rgba(var(--glow), .7);
  transform-origin: 0 50%; transform: scaleX(0);
  transition: transform .42s var(--e-smooth);
}
.work__mark.is-instant { transition: none; }

.cases { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(4.5rem, 12vh, 7.5rem); }
.case { position: relative; min-width: 0; scroll-margin-top: calc(var(--nav-h) + 1.5rem); }
.case__card { position: relative; }
.case__say { max-width: 40rem; }
.case__meta { font-size: var(--t-small); letter-spacing: .01em; color: var(--sodium); }
.case__title { margin-top: .55rem; font-size: clamp(1.75rem, 3vw, 2.75rem); line-height: 1.04; letter-spacing: -.038em; color: var(--c-ink-1); text-wrap: balance; }
.case__deck { margin-top: .7rem; font-size: var(--t-lead); line-height: 1.5; color: var(--c-ink-2); max-width: 38ch; }
.case__link {
  display: inline-flex; align-items: center; min-height: 2.5rem; margin-top: .55rem;
  font-size: .875rem; color: var(--sodium);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .3em;
  text-decoration-color: rgba(var(--glow), .35);
  transition: text-decoration-color .25s var(--e-io);
}
.case__link:hover { text-decoration-color: var(--sodium); }

/* the media slot */
.case__media {
  position: relative; margin: clamp(1.5rem, 3.5vh, 2.25rem) 0 0; aspect-ratio: 16 / 10;
  overflow: hidden; border-radius: var(--media-r) var(--media-r) 0 0; background: #1E2120;
}
.case__rise { position: absolute; inset: 0; }
.case__rise > img, .case__rise > video, .case__pages { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.case__rise > video { object-fit: contain; background: #E8E8DF; }
.case__rise > [data-beat]:not([data-beat="1"]) { opacity: 0; }
.case__pages {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px; padding: 5px; background: #D9D4C8;
}
.case__pages img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; border-radius: 6px 6px 2px 2px; display: block; }
.case__beats { margin: clamp(1.5rem, 3.5vh, 2.25rem) 0 0; display: grid; gap: 1.5rem clamp(1.5rem, 3.4vw, 3.5rem); }
.beat { min-width: 0; }
.beat dt { font-size: var(--t-small); letter-spacing: .01em; font-weight: 500; color: var(--sodium); }
.beat dd { margin: .5rem 0 0; font-size: clamp(.9688rem, 1.08vw, 1.0625rem); line-height: 1.55; color: var(--c-ink-2); max-width: 40ch; }
@media (min-width: 781px) { .case__beats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.video-toggle {
  position: absolute; right: 14px; bottom: 14px; z-index: 2; cursor: pointer;
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 2.25rem; padding: 0 .9rem 0 .75rem; border-radius: 999px;
  font-size: .75rem; font-weight: 500; letter-spacing: .005em; color: var(--paper);
  background: rgba(23, 25, 24, .84); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background-color .25s var(--e-io), transform .18s var(--e-out);
}
.video-toggle::before { content: ""; width: .55rem; height: .65rem; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.video-toggle.is-playing::before { clip-path: polygon(0 0, 34% 0, 34% 100%, 0 100%, 0 0, 66% 0, 100% 0, 100% 100%, 66% 100%, 66% 0); }
.video-toggle:hover { background: var(--carbon); }
.video-toggle:active { transform: scale(.96); }

/* ── the cards ───────────────────────────────────────────────────────────
   Big cards that show everything at a glance. On wide screens they pair up big
   and small and swap sides each row, the small one standing lower, so the work
   reads as a sequence rather than a grid of tiles. */
.work--cards .case__beats, .work--cards .case__link, .work--cards .video-toggle,
.work--cards .case__rise > [data-beat]:not([data-beat="1"]) { display: none; }
.work--cards .case__card { display: flex; flex-direction: column; }
.work--cards .case__media { order: -1; margin: 0; }
.work--cards .case__horizon { order: 0; }
.work--cards .case__say { order: 1; padding-top: clamp(1.15rem, 2.6vh, 1.6rem); }
.work--cards .case__title { margin-top: .4rem; font-size: clamp(1.45rem, 2.05vw, 2.15rem); }
.work--cards .case__deck { margin-top: .5rem; font-size: clamp(.9688rem, 1.08vw, 1.0938rem); max-width: 40ch; }
.work--cards .case--big .case__title { font-size: clamp(1.7rem, 2.65vw, 2.7rem); }
.work--cards .case--big .case__deck { font-size: var(--t-lead); }
.work--cards .case__rise > img, .work--cards .case__rise > video { transition: transform 1.1s var(--e-out); }
.work--cards .case__rise > video { object-fit: cover; background: #1E2120; }
.work--cards .case__media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
/* the whole card opens its case; the title is the link */
.case__open { color: inherit; }
.case__open::after { content: ""; position: absolute; inset: -.5rem; z-index: 2; border-radius: calc(var(--media-r) + 6px); }
.case__open:focus-visible { outline: none; box-shadow: none; }
.case__open:focus-visible::after { outline: 2px solid var(--sodium); outline-offset: 2px; box-shadow: 0 0 0 7px rgba(var(--glow), .2); }
/* a light runs along the horizon when you reach for a card */
.case__run {
  position: absolute; left: 0; top: -5px; width: 11px; height: 11px; margin-left: -5.5px; border-radius: 50%;
  background: radial-gradient(circle, #FFFCF6 0 18%, #FFD9A8 34%, rgba(var(--glow), 0) 70%);
  box-shadow: 0 0 16px 4px rgba(var(--glow), .35);
  opacity: 0; transform: translate3d(0, 0, 0);
}
.case__horizon::before, .case__horizon::after { transition: opacity .5s var(--e-io); }
@media (hover: hover) {
  .work--cards .case__card:hover .case__rise > img, .work--cards .case__card:hover .case__rise > video { transform: scale(1.025); }
  .work--cards .case__card:hover .case__horizon::before { opacity: 1; }
  .work--cards .case__card:hover .case__run { animation: case-run 1s var(--e-io) both; }
}
.work--cards .case__card:focus-within .case__horizon::before { opacity: 1; }
.work--cards .case__card:focus-within .case__run { animation: case-run 1s var(--e-io) both; }
@keyframes case-run {
  0% { opacity: 0; transform: translate3d(0, 0, 0); }
  12% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--run-w, 400px), 0, 0); }
}

/* dimming: the projects outside the chosen category go quiet but stay where they are. A layer of
   carbon over the card, on the carbon page, looks exactly like the card faded (80% carbon over it is
   the card at 20%), but the card itself is never changed: it stays drawn as it is, and the veil is a
   plain colour the browser fades for nothing */
.work--cards .case__card::before {
  content: ""; position: absolute; inset: -1.25rem -4%; z-index: 1; pointer-events: none;
  background: var(--carbon); opacity: 0; will-change: opacity;
  transition: opacity .45s var(--e-io);
}
.work.is-open .cases[data-filter] .case:not(.is-match) .case__card::before { opacity: .8; }
@media (hover: hover) { .work.is-open .cases[data-filter] .case:not(.is-match) .case__card:hover::before { opacity: .38; } }
.work.is-open .cases[data-filter] .case:not(.is-match) .case__card:focus-within::before { opacity: .25; }

@media (min-width: 1000px) {
  .work--cards .cases {
    grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--cg);
    row-gap: clamp(4rem, 10vh, 6.75rem); align-items: end;
  }
  .work--cards .case:nth-child(4n+1) { grid-column: 1 / span 7; }
  .work--cards .case:nth-child(4n+2) { grid-column: 9 / span 4; }
  .work--cards .case:nth-child(4n+3) { grid-column: 1 / span 4; }
  .work--cards .case:nth-child(4n+4) { grid-column: 6 / span 7; }
  /* a small card left on its own at the end takes the big place */
  .work--cards .case:nth-child(4n+3):last-child { grid-column: 1 / span 7; }
}
@media (min-width: 600px) and (max-width: 999px) {
  .work--cards .cases { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--cg); row-gap: clamp(3rem, 7vh, 4.5rem); align-items: start; }
  .work--cards .case:first-child { grid-column: 1 / -1; }
  .work--cards .case:nth-child(2n+3) { padding-top: clamp(2.5rem, 8vw, 4.5rem); }
  .work--cards .case:nth-child(2n):last-child { grid-column: 1 / -1; padding-top: 0; }
}
@media (max-width: 599px) {
  .work--cards .cases { gap: clamp(3rem, 8vh, 4rem); }
}

/* ==========================================================================
   THE CASE SHEET
   ========================================================================== */
.csheet {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--c-ink-1); overflow: hidden;
  font-family: var(--f);
}
.csheet:not([open]) { display: none; }
.csheet::backdrop { background: rgba(12, 13, 13, .74); opacity: 0; transition: opacity .38s var(--e-io); }
.csheet.is-in::backdrop { opacity: 1; }
.csheet.is-out::backdrop { transition-duration: .26s; }
.csheet__panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(calc(100% - 4rem), 1440px);
  background: #1A1C1B; box-shadow: -1px 0 0 rgba(242, 238, 228, .06), -40px 0 80px -30px rgba(0, 0, 0, .6);
  opacity: .001; transform: translate3d(36px, 0, 0); will-change: transform, opacity;
  transition: opacity .09s var(--e-out), transform .5s var(--e-smooth);
}
.csheet.is-in .csheet__panel { opacity: 1; transform: none; }
.csheet.is-out .csheet__panel { transition-duration: .2s, .3s; transform: translate3d(24px, 0, 0); opacity: 0; }
.csheet__scroll { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3A3C3A transparent; }
.csheet__grid {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start;
  gap: clamp(2rem, 4vw, 4.5rem); padding: clamp(1.25rem, 2.6vw, 2.5rem) clamp(1.25rem, 3vw, 3rem) clamp(2rem, 5vh, 3.5rem);
}
.csheet__media { display: grid; gap: clamp(.75rem, 1.4vw, 1.1rem); min-width: 0; }
.csheet__fig { position: relative; margin: 0; aspect-ratio: 16 / 10; overflow: hidden; border-radius: var(--media-r); background: #1E2120; }
.csheet__fig > img, .csheet__fig > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.csheet__fig > video { object-fit: contain; background: #E8E8DF; }
.csheet__fig::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.csheet__fig .case__pages { position: absolute; inset: 0; width: 100%; height: 100%; }
.csheet__fig--pages { aspect-ratio: 16 / 10; }
.csheet__text {
  position: sticky; top: var(--stick, 0px); min-width: 0;
  padding-top: clamp(3.75rem, 9vh, 5.5rem);
}
.csheet__meta { font-size: var(--t-small); letter-spacing: .01em; color: var(--sodium); }
.csheet__title { margin-top: .6rem; font-size: clamp(2rem, 3.2vw, 3.1rem); line-height: 1.02; letter-spacing: -.04em; text-wrap: balance; }
/* it takes focus when the sheet opens, so it is announced; it is not a control, so it shows no ring */
.csheet__title:focus, .csheet__title:focus-visible { outline: none; box-shadow: none; }
.csheet__deck { margin-top: .9rem; font-size: var(--t-lead); line-height: 1.5; color: var(--c-ink-2); max-width: 36ch; }
.csheet__link:empty { display: none; }
.csheet__link { margin-top: .5rem; }

/* the beats, with the light that runs down them (How I work's current, in miniature) */
.csheet__beats { position: relative; margin-top: clamp(2rem, 5vh, 3rem); padding-left: clamp(1.4rem, 2vw, 1.9rem); }
.csheet__beats dl { margin: 0; }
.csheet__beats .beat { position: relative; padding: 1.15rem 0 1.5rem; }
.csheet__beats .beat dd { margin-top: .45rem; font-size: clamp(.9688rem, 1.1vw, 1.0938rem); max-width: 42ch; }
.cs-spine, .cs-spine-lit { position: absolute; left: 0; top: 0; width: 1px; height: var(--spine, 100%); }
.cs-spine { background: var(--c-rule-2); }
.cs-spine-lit { background: linear-gradient(to bottom, rgba(var(--glow), .3), var(--sodium)); transform-origin: 50% 0; transform: scaleY(1); }
.cs-head {
  position: absolute; left: -7px; top: -7px; width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle, #FFFCF6 0 16%, #FFDDB0 30%, rgba(var(--glow), .45) 50%, rgba(var(--glow), 0) 71%);
  box-shadow: 0 0 24px 6px rgba(var(--glow), .28); opacity: 0;
}
.cs-head::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 64px; height: 1px; margin: -.5px 0 0 -32px;
  background: linear-gradient(90deg, rgba(var(--glow), 0), rgba(255, 231, 200, .85), rgba(var(--glow), 0));
}
.beat__rule {
  position: absolute; left: calc(clamp(1.4rem, 2vw, 1.9rem) * -1); right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, var(--c-rule-2), rgba(62, 63, 61, .55) 55%, rgba(62, 63, 61, 0));
}
.beat__lit {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--sodium), rgba(var(--glow), .72) 40%, rgba(var(--glow), .16) 85%, rgba(var(--glow), 0));
  transform-origin: 0 50%;
}
.beat__spark {
  position: absolute; left: -5px; top: -5px; width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle, #FFFCF6 0 18%, #FFD9A8 34%, rgba(var(--glow), 0) 70%);
  box-shadow: 0 0 16px 4px rgba(var(--glow), .35); opacity: 0;
}
.csheet__beats .beat dt, .csheet__beats .beat dd { transition: opacity .6s var(--e-io); }
.csheet__beats.is-waiting .beat:not(.is-lit) dt { opacity: .55; }
.csheet__beats.is-waiting .beat:not(.is-lit) dd { opacity: .62; }

.csheet__nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: clamp(1.5rem, 4vh, 2.5rem);
  padding-top: 1.25rem; border-top: 1px solid var(--c-rule);
}
.csheet__step {
  display: grid; gap: .2rem; justify-items: start; text-align: left; min-height: 2.75rem; padding: .35rem 0; cursor: pointer;
  color: var(--c-ink-2); transition: color .2s var(--e-io);
}
.csheet__step--next { justify-items: end; text-align: right; }
.csheet__dir { font-size: var(--t-small); color: var(--c-ink-4); transition: color .2s var(--e-io); }
.csheet__to { font-size: .9375rem; line-height: 1.3; letter-spacing: -.01em; }
.csheet__step:hover { color: var(--c-ink-1); }
.csheet__step:hover .csheet__dir { color: var(--sodium); }
.csheet__step[hidden] { display: none; }

.csheet__close {
  position: absolute; top: clamp(1rem, 2vw, 1.5rem); right: clamp(1rem, 2vw, 1.5rem); z-index: 3;
  display: grid; place-items: center; width: 2.9rem; height: 2.9rem; border-radius: 50%; cursor: pointer;
  color: var(--paper); background: rgba(23, 25, 24, .86); box-shadow: inset 0 0 0 1px rgba(242, 238, 228, .16);
  transition: background-color .2s var(--e-io), box-shadow .2s var(--e-io), transform .18s var(--e-out);
}
.csheet__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.csheet__close:hover { background: var(--carbon); box-shadow: inset 0 0 0 1px rgba(var(--glow), .7); }
.csheet__close:active { transform: scale(.96); }
.csheet .video-toggle { display: inline-flex; }

/* the card's image, growing into the sheet */
.csheet__ghost {
  position: fixed; left: 0; top: 0; z-index: 4; margin: 0; overflow: hidden; pointer-events: none;
  border-radius: var(--media-r); transform-origin: 0 0; background: #1E2120; will-change: transform;
}
.csheet__ghost > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.csheet__fig.is-held { visibility: hidden; }

/* full screen on phones and tablets, read top to bottom: the project, its media, its story, the next one */
@media (max-width: 999px) {
  .csheet__panel { width: 100%; }
  .csheet__grid { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 4.75rem var(--gut) 2.5rem; }
  .csheet__text { display: contents; }
  .csheet__media { order: 1; margin-top: 1.6rem; }
  .csheet__beats { order: 2; }
  .csheet__nav { order: 3; }
  .csheet__title { font-size: clamp(1.9rem, 7vw, 2.6rem); }
}

/* ==========================================================================
   NARROW
   ========================================================================== */
@media (max-width: 780px) {
  .work__filters {
    max-width: calc(100% + var(--gut) * 2); margin: 0 calc(var(--gut) * -1); padding-inline: var(--gut);
    overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gut), #000 calc(100% - var(--gut)), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 var(--gut), #000 calc(100% - var(--gut)), transparent);
    background: linear-gradient(var(--c-rule-2), var(--c-rule-2)) left bottom / 100% 1px no-repeat local;
  }
  .work__filters::-webkit-scrollbar { display: none; }
  .work__filters::after { display: none; }
  .case__title { font-size: clamp(1.75rem, 8vw, 2.4rem); }
  .work--cards .case__title, .work--cards .case--big .case__title { font-size: clamp(1.5rem, 6.6vw, 2.1rem); }
  .case__deck { font-size: 1.0625rem; }
  .beat dd { font-size: 1rem; }
}

/* ==========================================================================
   REDUCED MOTION: static and complete; the sheet still opens and closes
   ========================================================================== */
html.reduce .csheet::backdrop, html.reduce .csheet__panel { transition: none; }
html.reduce .case__card::before, html.reduce .case__rise > img, html.reduce .case__rise > video { transition: none; }
html.reduce .case__run { display: none; }
