/* Main page: three full-viewport screens (splash → categories → cases), routed by hash in js/main.js.
   States follow the Figma components: default / hover (#ff0025, marker square, brand imagery on cards). */
@font-face { font-family: "Apfel Grotezk"; src: url(../fonts/ApfelGrotezk-Regular.otf); font-weight: 400; font-display: swap; }
@font-face { font-family: "Apfel Grotezk"; src: url(../fonts/ApfelGrotezk-Mittel.otf); font-weight: 500; font-display: swap; }
@font-face { font-family: "Berkeley Mono"; src: url(../fonts/BerkeleyMono-Regular.otf); font-weight: 400; font-display: swap; }

@view-transition { navigation: auto; }

:root { --gutter: clamp(24px, 4.2vw, 96px); --ink: #000; --muted: #878787; --line: #171717; --bg: #fff; --hot: #ff0025; --ease: cubic-bezier(.2,.7,.2,1); --out: cubic-bezier(.6,0,.8,.3); }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "Apfel Grotezk", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--hot); outline-offset: 4px; }
::selection { background: var(--hot); color: #fff; }
.mono { font-family: "Berkeley Mono", ui-monospace, monospace; font-size: clamp(13px, .85vw, 17px); letter-spacing: 0; text-transform: uppercase; line-height: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Screens ──────────────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; display: flex; justify-content: center; padding: clamp(24px, 2.6vw, 56px) var(--gutter); overflow-y: auto; overflow-x: hidden;
  visibility: hidden; opacity: 0; transition: opacity .5s var(--ease), visibility 0s .5s; }
.screen:focus { outline: none; }
.screen.active { visibility: visible; opacity: 1; transition: opacity .5s var(--ease); }
.frame { width: 100%; max-width: 2200px; min-height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.bar a { transition: color .2s; }
.bar a:hover { color: var(--hot); }

/* Staggered entrance: children with --i fade/rise when their screen becomes active */
.enter { opacity: 0; transform: translateY(24px); transition: opacity .6s var(--ease), transform .8s var(--ease); transition-delay: calc(var(--i, 0) * 60ms + 120ms); }
.active .enter { opacity: 1; transform: none; }
.leaving .enter { opacity: 0; transform: translateY(-16px); transition: opacity .3s var(--out), transform .3s var(--out); transition-delay: 0s; }

/* ── Splash ───────────────────────────────────────────────────────── */
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: clamp(48px, 5.6vw, 120px); transition: color .25s; }
.hero h1 { font-weight: 500; font-size: clamp(40px, 6.4vw, 150px); letter-spacing: -0.04em; text-transform: uppercase; line-height: 1.05; }
.hero h1 .ch { display: inline-block; transform: translateY(110%); transition: transform .9s var(--ease); transition-delay: calc(var(--c) * 28ms + 200ms); }
.hero h1 .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .06em; }
.active .hero h1 .ch { transform: none; }
.hero .sub { margin-top: 16px; font-size: clamp(16px, 1.1vw, 22px); opacity: 0; transform: translateY(-4px); transition: opacity .25s, transform .25s var(--ease); }
.hero .arrow { flex: none; width: clamp(48px, 5vw, 120px); height: clamp(48px, 5vw, 120px); opacity: 0; transform: translateX(-16px); transition: opacity .25s, transform .35s var(--ease); }
.hero:hover, .hero:focus-visible { color: var(--hot); }
.hero:hover .sub, .hero:focus-visible .sub { opacity: 1; transform: none; }
.hero:hover .arrow, .hero:focus-visible .arrow { opacity: 1; transform: none; }
.cursor-blink::after { content: "_"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hint { color: var(--muted); }

/* ── Category filter: <div class="chips"><button aria-pressed>Title<sup>05</sup></button>…</div> */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: clamp(20px, 2vw, 36px); }
.chips button { text-transform: inherit; display: inline-flex; align-items: flex-start; gap: 4px; padding: .75em 1em; border: .5px solid var(--line); line-height: 1; transition: background .2s, color .2s, border-color .2s, transform .15s; }
.chips sup { font-size: .75em; opacity: .5; }
.chips button:hover { color: var(--hot); border-color: var(--hot); }
.chips button:active { transform: scale(.97); }
.chips button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ── Cases ────────────────────────────────────────────────────────── */
.cases .frame { gap: 0; justify-content: flex-start; }
.cases-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 24px; }
.cases-head h2 { font-weight: 500; font-size: clamp(28px, 3vw, 64px); letter-spacing: 0.02em; text-transform: uppercase; line-height: 1.2; }
.cases-head p { margin-top: 8px; font-size: clamp(15px, 1vw, 20px); letter-spacing: -0.03em; }
.nav { display: flex; align-items: center; gap: 8px; }
.nav .count { margin-right: 8px; font-variant-numeric: tabular-nums; }
.nav button { width: clamp(40px, 2.8vw, 56px); height: clamp(40px, 2.8vw, 56px); border: .5px solid var(--line); display: grid; place-items: center; transition: background .2s, color .2s, border-color .2s, opacity .2s; }
.nav button:hover:not(:disabled) { background: var(--hot); border-color: var(--hot); color: #fff; }
.nav button:disabled { opacity: .25; cursor: default; }
.crumb a { transition: color .2s; }
.crumb a:hover { color: var(--hot); }

.gallery { display: flex; gap: 24px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 35px 0; margin-right: calc(-1 * max(var(--gutter), (100vw - 2200px) / 2)); padding-right: var(--gutter);
  scrollbar-width: none; overscroll-behavior-x: contain; flex: 1; align-items: center; }
.gallery::-webkit-scrollbar { display: none; }
.gallery.dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.gallery.dragging .card { pointer-events: none; }
.empty { padding: 120px 0; color: var(--muted); }

.card { --dot: #fff; position: relative; flex: none; width: clamp(300px, min(24vw, 44vh), 520px); aspect-ratio: 346 / 520; padding: clamp(24px, 2vw, 44px); display: flex; flex-direction: column; justify-content: space-between;
  background: #fff; border: .5px solid var(--line); overflow: hidden; scroll-snap-align: start; isolation: isolate;
  transition: border-color .3s, border-radius .3s, box-shadow .3s, transform .5s var(--ease); }
.card .bg { position: absolute; inset: 0; z-index: -1; opacity: 0; transform: scale(1.08); transition: opacity .45s var(--ease), transform 1.2s var(--ease); }
.card .bg img { width: 100%; height: 100%; object-fit: cover; object-position: bottom; display: block; }
.card .bg::after { content: ""; position: absolute; inset: 0; background: var(--tint, transparent); mix-blend-mode: var(--blend, normal); }
.card .logo { flex: 1; display: grid; place-items: center; }
.card .logo > span { grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: opacity .3s; }
.card .logo .on { opacity: 0; transform: scale(.94); transition: opacity .3s, transform .6s var(--ease); }
.card:is(:hover, :focus-visible) .logo .on { transform: none; }
.card .logo .row { display: flex; align-items: center; gap: 7.4px; }
.card .logo em { font-style: normal; font-weight: 500; font-size: 14px; letter-spacing: -0.01em; }
.card .logo .on em { color: #fff; }
.card .logo img[src$="billy-cube.png"] { filter: drop-shadow(0 0 28px rgba(255, 186, 90, .75)); }
.card h3 { display: flex; align-items: center; gap: 0; font-weight: 400; font-size: clamp(20px, 1.4vw, 30px); text-transform: uppercase; line-height: 1; margin-bottom: 10px; transition: gap .3s var(--ease), color .3s; }
.card h3::before { content: ""; width: 0; height: 7px; background: var(--dot); transition: width .3s var(--ease); flex: none; }
.card p { transition: color .3s; }
.card .badges { position: absolute; top: clamp(20px, 1.6vw, 36px); right: clamp(20px, 1.6vw, 36px); display: flex; gap: 6px; }
.card .badge { padding: 6px 8px; border: .5px solid currentColor; font-size: 11px; line-height: 1.2; white-space: nowrap; color: var(--muted); transition: color .3s, background .3s; }
.card .badge.ds { background: var(--ink); border-color: var(--ink); color: #fff; }
.card:is(:hover, :focus-visible) .badge.ds { background: #fff; border-color: #fff; color: var(--ink) !important; }
.card:is(:hover, :focus-visible) { border-color: var(--hover-border, var(--line)); }
.card:is(:hover, :focus-visible) .bg { opacity: 1; transform: none; }
.card:is(:hover, :focus-visible) .off { opacity: 0; }
.card:is(:hover, :focus-visible) .on { opacity: 1; }
.card:is(:hover, :focus-visible) h3 { gap: 6px; font-weight: 500; }
.card:is(:hover, :focus-visible) h3::before { width: 7px; }
.card:not(.light):is(:hover, :focus-visible) :is(h3, p, .badge) { color: #fff; }
.card.round:is(:hover, :focus-visible) { border-radius: 10px; border-color: transparent; box-shadow: 0 4px 24px rgba(0,0,0,.25); }
.card.nopage { cursor: default; }
/* Entrance: cards slide in from the right with a stagger */
.card.enter { transform: translateX(80px); transition: opacity .6s var(--ease), transform .9s var(--ease), border-color .3s, border-radius .3s, box-shadow .3s; transition-delay: calc(var(--i, 0) * 70ms + 150ms); }
.active .card.enter { transform: none; }

/* Filter switch: cards and heading replay a short entrance (class toggled in renderCases) */
@keyframes card-in { from { opacity: 0; transform: translateX(48px); } }
@keyframes head-in { from { opacity: 0; transform: translateY(12px); } }

/* Pointer label that follows the mouse over cards */
.pointer { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; padding: 8px 10px; background: var(--hot); color: #fff; opacity: 0;
  transform: translate(var(--x, -100px), var(--y, -100px)) translate(14px, 14px) scale(.6); transition: opacity .2s, transform .12s linear; white-space: nowrap; }
.pointer.on { opacity: 1; transform: translate(var(--x), var(--y)) translate(14px, 14px); }
.pointer.muted { background: #000; }

/* Desktop: the gallery takes whatever height is left under the header and filters; cards are sized from that height,
   so the screen never needs a vertical scroll. */
@media (min-width: 901px) {
  .cases .frame { height: 100%; }
  .gallery { flex: 1 1 0; min-height: 340px; padding-top: clamp(16px, 3vh, 35px); padding-bottom: clamp(16px, 3vh, 35px); }
  .card { height: 100%; width: auto; max-height: 760px; }
}

/* Card logos grow with the cards on large screens */
@media (min-width: 1600px) { .card .logo > span { zoom: 1.2; } }
@media (min-width: 2000px) { .card .logo > span { zoom: 1.45; } }

@media (max-width: 900px) {
  .screen { padding: 24px 16px; }
  .hero { margin-bottom: 48px; }
  .hero .arrow { width: 40px; height: 40px; opacity: 1; transform: none; }
  
  .cases-head { flex-direction: column; align-items: flex-start; }
  .cases-head .nav, .cases .bar .hint { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
  .chips button { flex: none; }
  .gallery { margin-right: -16px; padding-right: 16px; }
  .card { width: min(320px, 78vw, 42vh); }
}
@media (hover: none) { .pointer { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; animation: none !important; }
  @view-transition { navigation: none; }
}

.card p.mono { line-height: 1.35; }
.hero .sub { line-height: 1.3; }


/* Touch: there is no hover, so cards rest in their colour state */
@media (hover: none) {
  .card .bg { opacity: 1; transform: none; }
  .card .badge.ds { background: #fff; border-color: #fff; color: var(--ink) !important; }
  .card .off { opacity: 0; } .card .on { opacity: 1; transform: none; }
  .card { border-color: var(--hover-border, var(--line)); }
  .card:not(.light) :is(h3, p, .badge) { color: #fff; }
  .card.round { border-radius: 10px; border-color: transparent; }
}
@media (max-width: 900px) { .card { width: min(340px, 80vw, 56vh); } }

/* ── Splash shapes: canvas behind the name (js/shapes.js) ── */
.splash .frame { justify-content: flex-end; position: relative; z-index: 1; }
.shapes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; --x-a: #ff0025; --x-b: #ff8a00;
  opacity: 0; transition: opacity 1.2s var(--ease) .5s; }
.active .shapes { opacity: 1; }
.shape-cap { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: pre; pointer-events: none; opacity: 0; transition: opacity 1s .9s; }
.active .shape-cap { opacity: 1; }

@media (max-width: 900px) { .bar a { padding: 12px 0; margin: -12px 0; } }

.card[hidden] { display: none; }
