/* Factora project page. Builds on main.css (fonts, tokens, cursor,
   rolling-letter links). The screens turn on a drum - the same "roll"
   idea as the rolling letters on every link of the site: the current
   screen faces you, the previous one rolls away over the top, the next
   one comes up from below. The drum is driven by the normal page scroll
   (never hijacked). Without JS, on small screens and for reduced motion
   the screens are a plain vertical list. */

.case-page {
  /* Same side margins as the home page (5rem, 2rem from 1200px down). */
  --case-gutter: 5rem;
  /* Same dark as the home page hero, with white text. */
  --case-line: 1px solid #ffffff;
  background-color: #1f1f1f;
  color: #ffffff;
}

/* ---------- Intro ---------- */

.drum-intro {
  padding: 7rem var(--case-gutter) 3rem;
  text-align: center;
}

.case-title {
  margin: 0;
  color: inherit;
  font-family: "tan-pearl";
  font-weight: 400;
  font-size: 7.5rem;
  line-height: 1.1;
}

/* Names whose letters hang far below the line (y, g in Tan Pearl) need
   room before the description. */
.case-title--tails {
  margin-bottom: 0.45em;
}

.drum-lead {
  /* case.js sets --lead-w to the first screen's width. Pages that open
     with a phone use the width a desktop screen gets on Factora (the
     carousel width, capped by a 4:3 screen at the available height). */
  max-width: var(--lead-w, min(70vw, 1240px, calc((100svh - 15rem) * 4 / 3)));
  margin: 1.5rem auto 0;
  font-family: "MabryPro-Light", sans-serif;
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.5;
}

.case-team {
  margin: 1rem 0 0;
  opacity: 0.7;
}

.case-team + .case-behance {
  margin-top: 1.25rem;
}

/* Same size as the home page menu items. */
.case-behance {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 1.5rem;
  color: #ffffff;
  font-family: "tan-pearl";
  font-size: 1rem;
  -webkit-text-stroke: 1px currentColor;
  text-decoration: none;
}

.case-behance span {
  font: inherit;
}

.case-behance .case-arrow {
  font-family: "MabryPro-Regular", sans-serif;
}

@media (hover: hover) and (pointer: fine) {
  .case-behance:hover .case-arrow {
    transform: translate(3px, -3px);
  }
}

/* ---------- Screens: flat list (default) ---------- */

.drum {
  padding: 2rem var(--case-gutter) 4rem;
}

.drum-counter {
  display: none;
}

.drum-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin: 0 auto 4rem;
  max-width: 1100px;
}

.drum-media {
  width: 100%;
}

.drum-zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
}

/* The zoom button keeps the custom cursor instead of the generic button
   pointer (only while the custom cursor is running - see main.css). */
.has-custom-cursor .drum-zoom {
  cursor: none;
}

.drum-screen {
  display: block;
  width: 100%;
  height: auto;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 28px 56px -24px rgba(0, 0, 0, 0.6);
}

.drum-caption {
  /* As wide as the screens (case.js sets --lead-w from the first one). */
  max-width: var(--lead-w, 62ch);
  text-align: center;
  line-height: 1.5;
}

.drum-caption-title {
  display: block;
  margin-bottom: 0.25rem;
  font-family: "tan-pearl";
  -webkit-text-stroke: 1px currentColor;
}

.drum-caption-text {
  display: block;
}

.drum-caption-text + .drum-caption-text {
  margin-top: 0.5rem;
}

/* ---------- Screens: the drum (added by case.js) ---------- */

.drum.is-3d {
  position: relative;
  padding: 0;
  /* height is set by case.js: one viewport + one scroll step per screen */
}

.drum.is-3d .drum-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.drum.is-3d .drum-wheel {
  position: absolute;
  inset: 0;
  perspective: 1200px;
}

.drum.is-3d .drum-item {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(70vw, 1240px);
  margin: 0;
  will-change: transform, opacity, filter;
  backface-visibility: hidden;
  /* transform, opacity, filter, z-index: written per frame by case.js */
}

.drum.is-3d .drum-item:not(.is-current) {
  pointer-events: none;
}

.drum.is-3d .drum-caption {
  opacity: var(--caption, 1);
}

.drum.is-3d .drum-media {
  display: flex;
  justify-content: center;
}

/* Every screen fits the stage whatever its proportions; tall ones get
   narrower rather than taller. */
.drum.is-3d .drum-zoom,
.drum.is-3d .drum-media > video {
  width: auto;
  max-width: 100%;
}

.drum.is-3d .drum-screen {
  width: auto;
  max-width: 100%;
  max-height: calc(100svh - 15rem);
}

/* Counter in the bottom-left corner of the stage: the digits roll like a
   drum too. */
.drum.is-3d .drum-counter {
  position: absolute;
  bottom: 1.5rem;
  left: var(--case-gutter);
  z-index: 200;
  display: flex;
  align-items: baseline;
  gap: 0.15em;
  font-family: "tan-pearl";
  font-size: 2rem;
  line-height: 1.4;
}

.drum-counter span {
  font: inherit;
}

.drum-counter-window {
  display: inline-block;
  height: 1.4em;
  overflow: hidden;
}

.drum-counter-strip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  transform: translateY(calc(-1.4em * var(--active, 0)));
  transition: transform 600ms var(--ease-out);
}

.drum-counter-strip span {
  height: 1.4em;
  line-height: 1.4;
}

/* ---------- Phone slides (mobile projects) ----------
   A recorded phone next to its text: the phone on the left, the title
   and key points on the right, so a tall phone still uses the width. */
.drum-phone {
  /* The recording is cropped to the phone's outline; round the corners
     to match the device. */
  border-radius: 15.3% / 7.6%;
  box-shadow: none;
}

.drum-item--split {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
}

.drum-item--split .drum-media {
  width: auto;
  flex: none;
}

.drum-item--split .drum-phone {
  width: auto;
  height: min(calc(100svh - 10rem), 900px);
  max-width: none;
}

.drum.is-3d .drum-item--split .drum-phone {
  max-height: none;
}

.drum-item--split .drum-caption {
  max-width: 28rem;
  text-align: left;
}

.drum-item--split .drum-caption-title {
  margin-bottom: 1rem;
  font-size: 1.75rem;
  line-height: 1.38;
  letter-spacing: 0.012em;
  -webkit-text-stroke: 0;
}

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

.drum-caption-list li {
  position: relative;
  padding-left: 1.25rem;
}

.drum-caption-list li + li {
  margin-top: 0.5rem;
}

.drum-caption-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background-color: currentColor;
}

@media (max-width: 767px) {
  .drum-item--split {
    flex-direction: column;
  }

  /* The phone's width must not depend on the video itself: Safari sizes
     an auto-width box from the video's natural size, which it forgets
     while it re-loads a paused video - the box shrank to Safari's default
     300px and grew back as you scrolled. A fixed width keeps it steady. */
  .drum-item--split .drum-media {
    width: min(100%, 22rem);
  }

  .drum-item--split .drum-phone {
    height: auto;
    width: 100%;
  }

  .drum-item--split .drum-caption-title {
    font-size: 1.5rem;
  }
}

.drum-sound {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
  padding: 0.5rem 1rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.drum-sound:active {
  transform: scale(var(--press-scale));
}

.drum-sound[aria-pressed="true"] {
  background-color: #ffffff;
  color: #1f1f1f;
}

/* Three bars: still when off, gently bouncing while the sound plays. */
.drum-sound-icon {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 14px;
  height: 12px;
  background:
    linear-gradient(currentColor, currentColor) 0 100% / 3px 40% no-repeat,
    linear-gradient(currentColor, currentColor) 50% 100% / 3px 70% no-repeat,
    linear-gradient(currentColor, currentColor) 100% 100% / 3px 50% no-repeat;
}

.drum-sound[aria-pressed="true"] .drum-sound-icon {
  animation: sound-bars 900ms var(--ease-in-out) infinite alternate;
}

@keyframes sound-bars {
  to {
    background-size: 3px 90%, 3px 35%, 3px 80%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drum-sound[aria-pressed="true"] .drum-sound-icon {
    animation: none;
  }
}

/* ---------- Background illustration ----------
   A large outline shape fixed behind the page (Amygdala's flower). It
   turns with the scroll - quickly at first, slowing down towards the end
   (case.js sets --spin). Content sits above it. */
.case-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.case-bg {
  --bg-size: min(120vmin, 1100px);
}

.case-bg-spin {
  /* Centred on the screen even when it is larger than the screen (on a
     phone it is wider than the window). "inset: 0; margin: auto" can't do
     that - an over-wide box keeps its left edge and spills to the right -
     so the centre is placed at 50% / 50% and pulled back by half its size. */
  position: absolute;
  top: 50%;
  left: 50%;
  margin: calc(var(--bg-size) / -2) 0 0 calc(var(--bg-size) / -2);
  width: var(--bg-size);
  height: var(--bg-size);
  opacity: 0.14;
  transform: rotate(var(--spin, 0deg));
  will-change: transform;
}

.case-bg ~ .case-main,
.case-bg ~ .case-foot {
  position: relative;
  z-index: 1;
}

/* ---------- Footer: back + next ---------- */

.case-foot {
  display: flex;
  justify-content: space-between;
  /* "All projects" on the same line as "Next project". */
  align-items: flex-start;
  gap: 1.5rem;
  margin: 0 var(--case-gutter);
  padding: 1.5rem 0 3rem;
  border-top: var(--case-line);
}

.case-foot a {
  color: #ffffff;
  text-decoration: none;
}

.case-foot span {
  font: inherit;
}

/* Tan Pearl has no arrow glyphs - arrows are drawn in Mabry. */
.case-arrow {
  font-family: "MabryPro-Regular", sans-serif;
  line-height: 1;
  -webkit-text-stroke: 0;
  transition: transform var(--dur-base) var(--ease-out);
}

/* Same size and height as the home page menu items. */
.case-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: "tan-pearl";
  font-size: 1rem;
  -webkit-text-stroke: 1px currentColor;
}

.case-back .case-arrow {
  font-family: "MabryPro-Regular", sans-serif;
  font-size: 1.1em;
}

@media (hover: hover) and (pointer: fine) {
  .case-back:hover .case-arrow {
    transform: translateX(-3px);
  }
}

.case-next {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.case-foot .case-next-label {
  font-family: "tan-pearl";
  -webkit-text-stroke: 1px currentColor;
}

.case-foot .case-next-title {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  font-family: "tan-pearl";
  font-size: 5rem;
  line-height: 1.1;
}

.case-foot .case-next-title .case-arrow {
  font-family: "MabryPro-Light", sans-serif;
  font-size: 0.7em;
}

@media (hover: hover) and (pointer: fine) {
  .case-next:hover .case-arrow {
    transform: translateX(6px);
  }
}

/* `font: inherit` above also resets line-height; give each rolling
   letter back its window. */
.case-page .roll-char {
  line-height: 1.5;
}

/* Tan Pearl's y and g hang far below the line at this size, so the big
   name gets a taller rolling window (and a matching offset for the copy)
   - otherwise their tails are clipped after the roll and peek out above. */
.case-next-title .roll-char {
  --roll-h: 2em;
  height: var(--roll-h);
  line-height: var(--roll-h);
}

.case-next-title .roll-char > span::after {
  top: var(--roll-h);
}

.case-next:focus-visible .case-next-title .roll-char > span {
  transform: translateY(calc(-1 * var(--roll-h)));
}

@media (hover: hover) and (pointer: fine) {
  .case-next:hover .case-next-title .roll-char > span {
    transform: translateY(calc(-1 * var(--roll-h)));
  }
}

/* ---------- Lightbox ---------- */

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 4rem var(--case-gutter);
  border: 0;
  overflow: auto;
  background: rgba(20, 20, 26, 0.94);
  cursor: zoom-out;
}

.lightbox::backdrop {
  background: transparent;
}

.lightbox[open] {
  animation: lightbox-in var(--dur-slow) var(--ease-out);
}

.lightbox-img {
  display: block;
  width: 100%;
  max-width: 2200px;
  height: auto;
  margin: 0 auto;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
}

/* ---------- Arrival from the home page ----------
   While the cover morphs into the first screen, the rest of the page
   draws itself in, one piece after another. Only `translate` and
   opacity animate (the carousel owns `transform`). */
.vt-enter .case-title,
.vt-enter .drum-lead,
.vt-enter .drum-counter,
.vt-enter .drum-item:first-child .drum-caption,
.vt-enter .drum-item:not(:first-child),
.vt-enter .case-foot {
  animation: vt-draw-in 700ms var(--ease-out) both;
}

/* The name and the line under it come out of a soft blur, slowly. */
.vt-enter .case-title,
.vt-enter .drum-lead,
.vt-enter .case-behance {
  animation: vt-title-in 1100ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.vt-enter .case-title {
  animation-delay: 300ms;
}

.vt-enter .drum-lead {
  animation-delay: 500ms;
}

.vt-enter .case-behance {
  animation-delay: 650ms;
}

@keyframes vt-title-in {
  from {
    opacity: 0;
    filter: blur(10px);
    translate: 0 0.75rem;
  }
}

.vt-enter .drum-item:first-child .drum-caption,
.vt-enter .drum-counter {
  animation-delay: 750ms;
}

.vt-enter .drum-item:not(:first-child),
.vt-enter .case-foot {
  animation-delay: 850ms;
}

@keyframes vt-draw-in {
  from {
    opacity: 0;
    translate: 0 1.5rem;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .case-page {
    --case-gutter: 2rem;
  }
}

@media (max-width: 1023px) {
  .case-title {
    font-size: 5rem;
  }

  .drum-lead {
    font-size: 1.25rem;
  }

  .case-foot .case-next-title {
    font-size: 3.5rem;
  }
}

@media (max-width: 500px) {
  .drum-intro {
    padding-top: 4rem;
  }

  .case-title {
    font-size: 3.5rem;
  }

  .drum-lead {
    font-size: 1.1rem;
  }

  .drum-item {
    margin-bottom: 3rem;
  }

  .case-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .case-next {
    align-items: flex-start;
  }

  .case-foot .case-next-title {
    /* Long names (Cultural Planet) must still fit the phone width. */
    font-size: min(2.75rem, 8vw);
  }

  .lightbox {
    padding: 4rem 0 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drum-counter-strip,
  .lightbox[open] {
    transition: none;
    animation: none;
  }
}

/* A recording that already shows the whole phone with its dark-matched
   surroundings: no extra rounding, which would clip the device frame. */
/* Cultural Planet's solar system, seen from above, in the manner of a
   printed chart: a solid sun, small planets, dotted orbit arcs and
   labels set along the orbits (each planet's figures). The whole drawing doesn't spin; each orbit turns at its
   own speed with the scroll (case.js), inner ones faster, so the planets
   travel round the sun. */
.case-bg-system {
  opacity: 0.34;
  transform: none;
}

/* Labels along the orbits, as on a printed solar-system chart. */
.case-bg-system .sys-text {
  font-family: "MabryPro-Medium", "MabryPro-Regular", sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
}

/* The description after each name is quieter than the name, so it never
   competes with the captions. */
.case-bg-system .sys-rest {
  opacity: 0.6;
}


/* Amygdala's double flower: its outer petals are a deep violet, so the
   drawing needs a little more presence than a white line to read. */
.case-bg-spin--flower {
  opacity: 0.55;
}

/* Good Food: a plate seen from above, drawn in one loose line, with a
   fork and knife that take the positions of table etiquette - the silent
   language between guest and waiter - one for each flow as the visitor
   scrolls (case.js). The current position is named under the plate. */
.case-bg-cutlery {
  /* Centred the same way as .case-bg-spin. */
  position: absolute;
  top: 50%;
  left: 50%;
  margin: calc(var(--bg-size) / -2) 0 0 calc(var(--bg-size) / -2);
  width: var(--bg-size);
  height: var(--bg-size);
  /* The thread running through the drawing leaves the screen on both
     sides; the fixed layer behind it clips it at the window edge. */
  overflow: visible;
}

.case-bg-cutlery .cut-line {
  opacity: 0.34;
}

.case-bg-cutlery .cut-label {
  font-family: "MabryPro-Medium", "MabryPro-Regular", sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  opacity: 0;
}

.case-bg-cutlery .cut-label[data-i="0"] {
  opacity: 0.55;
}

/* Behance links hidden for now - delete this rule to show them again */
.case-behance {
  display: none;
}

/* ---------- Spacing scale (case pages) ----------
   Same proximity scale as the home page: screen → its caption 32px,
   caption title → its points 16px, points 8px apart, project name →
   lead 32px (as on the home page), lead → team line 16px, intro → first
   screen 128px (64px on phones), screen groups 64px apart. Distances are between what you see, so margins subtract
   the font's own line spacing: 0.5 * (1lh - k * 1em) (tan-pearl k 1.27,
   Mabry k 1). Amygdala's title keeps its extra room for the y/g tails. */
.drum-caption .drum-caption-title {
  margin-top: calc(-0.5 * (1lh - 1.27em));
  margin-bottom: calc(11px - 0.5 * (1lh - 1.27em));
}

/* With a "Play with sound" button between them: title → button 16px,
   button → points 16px. */
.drum-caption .drum-caption-title:has(+ .drum-sound) {
  margin-bottom: calc(15px - 0.5 * (1lh - 1.27em));
}

.drum-caption .drum-sound {
  margin-bottom: 12px;
}

@media (min-width: 501px) {
  .drum-caption .drum-caption-title {
    margin-bottom: calc(12px - 0.5 * (1lh - 1.27em));
  }
}

.drum-caption .drum-caption-list li + li {
  margin-top: 0;
}

/* Screen → its caption 32px wherever the caption sits under the screen
   (split slides put it beside the screen instead). */
.drum-item:not(.drum-item--split) {
  gap: 32px;
}

/* Caption paragraphs (Factora) 16px apart, like the home page. */
.drum-caption .drum-caption-text + .drum-caption-text {
  margin-top: 8px;
}

/* The title is fluid, so the step is worked out from both fonts' own
   line spacing rather than fixed per breakpoint. */
.case-title {
  /* Measured: the glyphs end 0.085em above the line box's bottom edge.
     Padding, not margin, so it adds to the lead's margin (block margins
     would collapse). */
  padding-bottom: 0.085em;
}

.case-title + .drum-lead {
  margin-top: calc(32px - 0.5 * (1lh - 1em));
}

/* Amygdala's y/g tails: tails.js adds the room they need (like every
   heading with descenders), so its title follows the same rule. */
.case-title--tails {
  margin-bottom: 0;
}

.case-team {
  margin-top: 6px;
}

@media (max-width: 500px) {
  .case-team {
    margin-top: 8px;
  }
}

/* Flat list (phones): intro → first screen 64px, one screen + caption
   group to the next 64px, last caption → footer line 64px. */
.drum:not(.is-3d) {
  padding-top: 12px;
  padding-bottom: 0;
}

.drum:not(.is-3d) .drum-item {
  margin-bottom: 64px;
}

/* Footer: line → "Next project" / "All projects" 24px, label → project
   name 8px (a pair), and on phones name → "All projects" 32px. */
.case-foot {
  padding-top: 24px;
}

.case-foot .case-next-label {
  margin-top: calc(-1px - 0.5 * (1lh - 1.27em));
}

.case-back {
  margin-top: calc(1px - 0.5 * (1lh - 1.27em));
}

.case-next {
  gap: 6px;
}

@media (max-width: 500px) {
  .case-foot {
    /* + the big name's own line spacing ≈ 32px to "All projects". */
    gap: 36px;
  }
  .case-back {
    margin-top: 0;
  }
}

/* Same fluid size as the home page name (main.css). Every project title
   gets the same size at every width, set by the widest one (Amygdala,
   6.4em), so the names don't jump as you go from project to project. */
.case-title,
.case-title.case-title {
  --fit: 6.4;
  /* --fit = the longest word's width in em (set on the title): on narrow
     phones a long word shrinks just enough to fit the column instead of
     running off the screen. */
  font-size: min(
    clamp(4rem, 8.43vw + 2.1rem, 7.5rem),
    calc((100vw - 4rem) / var(--fit, 0.01))
  );
}

