/* =====================================================================
   HOME.CSS  -  homepage only: the card gallery, name wordmark, focus brackets, cursor, loader.
   (Shared colours, chips and screen overlays are in site.css.)
   ===================================================================== */

:root {
  --ratio: 1.41;
  --card-h: calc(var(--card-w) / var(--ratio));
  --cy: 44%;            /* vertical position of the gallery */
}
html, body { height: 100%; overflow: hidden; }

/* leaving the page: the name, labels and cursor clear out so the card flies through empty space */
body.is-flying #wordmark, body.is-flying .ui, body.is-flying #cursor { opacity: 0; transition: opacity .3s ease; }

/* ---------- WORDMARK: your name artwork, big along the bottom ----------
   Sits UNDER the gallery, so cards slide across it. width = how far across the screen it reaches. */
#wordmark {
  position: fixed; z-index: 1; left: 16px; bottom: 0; margin: 0;
  width: min(calc(66.7vw - 16px), 1180px); line-height: 0;
  transform: translateY(8%);          /* sits low: the "y" tail just kisses the bottom edge */
  pointer-events: none; user-select: none;
}
#wordmark img { display: block; width: 100%; height: auto; }

/* ---------- LOGO behind the cards ----------
   Centred on the gallery. --mark = its size. The ::after layer is a paper-coloured fade over the
   lower half: on the plain paper it's invisible, so it only lightens the logo itself, blending it
   into the page. Raise the .55 / .8 to fade it more, lower them to fade it less. */
#mark {
  --mark: min(84vmin, 880px);
  position: fixed; z-index: 1; left: 50%; top: var(--cy);
  width: var(--mark); height: var(--mark); margin: calc(var(--mark) / -2) 0 0 calc(var(--mark) / -2);
  pointer-events: none; user-select: none;
}
#mark img { display: block; width: 100%; height: 100%; will-change: transform; }
#mark::after {
  content: ""; position: absolute; inset: -2px;
  background: linear-gradient(to bottom,
    rgba(239, 237, 232, 0) 0%, rgba(239, 237, 232, 0) 40%,
    rgba(239, 237, 232, .55) 72%, rgba(239, 237, 232, .8) 100%);
}
body.is-flying #mark { opacity: 0; transition: opacity .3s ease; }
body.is-list #mark { visibility: hidden; }

/* ---------- BRIEF: a small technical readout, bottom-right, in the space the cards don't reach ----------
   A few point-form lines pulled from the about page: focus, goals, current role, toolkit. */
#brief {
  position: fixed; z-index: 10; right: 16px; bottom: 60px;
  width: clamp(220px, 25vw, 300px);
  background: var(--paper); border: 1px solid var(--ink);
  font-size: 10px; letter-spacing: .04em;
  pointer-events: none;
}
body.is-flying #brief { opacity: 0; transition: opacity .3s ease; }
.brief__bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-bottom: 1px solid var(--ink);
  font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
}
.brief__bar .chip--live { margin-left: auto; }
.brief__list { list-style: none; padding: 3px 0; }
.brief__list li {
  display: flex; gap: 8px; align-items: baseline; padding: 4px 9px;
  line-height: 1.35; text-transform: uppercase;
}
.brief__list b { color: var(--hot); font-weight: 500; flex: none; }
@media (max-width: 900px) { #brief { display: none; } }   /* the phone layout has no room for it */

/* ---------- STAGE: the camera ---------- */
#stage {
  position: fixed; inset: 0; z-index: 2;
  perspective: 1000px; perspective-origin: 50% 42%;
  cursor: grab; touch-action: pan-y;
  user-select: none; -webkit-user-select: none; overflow: hidden;
}
body.is-dragging #stage { cursor: grabbing; }
#world { position: absolute; inset: 0; transform-style: preserve-3d; }

.stack {
  position: absolute; left: 50%; top: var(--cy);
  width: var(--card-w); height: var(--card-h);
  margin-left: calc(var(--card-w) / -2);
  margin-top: calc(var(--card-h) / -2);
  will-change: transform, opacity;
}
.tilt { position: absolute; inset: 0; will-change: transform; }

/* ---------- CARD: flat colour, hard edge, big type ---------- */
.card {
  position: absolute; inset: 0;
  container-type: inline-size;          /* lets everything inside size itself in cqw */
  background: var(--hot); color: var(--ink);
  border: var(--edge) solid var(--ink);
  box-shadow: var(--shadow);                   /* solid faint drop shadow, sits in the card's plane */
  transition: background .3s ease, color .3s ease, box-shadow .3s ease;
}
.card__in {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 5cqw;
}
.card__meta {
  display: flex; justify-content: space-between; gap: 1em;
  font-size: max(9px, 3.1cqw); line-height: 1; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
}
.card__title {
  font-family: var(--display); font-weight: 400; text-transform: uppercase;
  /* every card title is the SAME height. The script then warps each word's width (scaleX)
     so it runs edge to edge: short words stretch wide, long words squeeze. */
  font-size: 28cqw; line-height: .84; letter-spacing: -.005em;
}
.card__title .ln { display: block; width: max-content; white-space: nowrap; transform-origin: 0 50%; }

/* the centred card inverts - the only "state" in the whole page */
.stack.is-active .card {
  background: var(--ink); color: var(--paper);
  box-shadow: 0 0 0 var(--edge) var(--paper), var(--shadow);   /* paper ring keeps the black card cut out from the black wordmark */
}

/* ---------- WRAPPER + VIGNETTE ----------
   #ca holds the whole page. When the script turns the effect on it gets filter:url(#ca-filter). */
#ca { position: fixed; inset: 0; z-index: 1; background: var(--paper); }
#ca.on { filter: url(#ca-filter); }

/* ---------- FOCUS BRACKETS ----------
   Four corner brackets and four edge ticks in the ink (off-black) colour lock onto the centred card. They live
   on the stack (not the tilted layer), so they follow the card's angle but stay put when it lifts. */
.vf { position: absolute; inset: calc(var(--edge) * -1 - 16px); pointer-events: none; opacity: 0; transition: opacity .25s ease; }
.stack.is-active .vf { opacity: 1; }
.vf i { position: absolute; width: 18px; height: 18px; border: 0 solid var(--ink); }
.vf i:nth-child(1) { top: 0;    left: 0;  border-width: 3px 0 0 3px; }
.vf i:nth-child(2) { top: 0;    right: 0; border-width: 3px 3px 0 0; }
.vf i:nth-child(3) { bottom: 0; left: 0;  border-width: 0 0 3px 3px; }
.vf i:nth-child(4) { bottom: 0; right: 0; border-width: 0 3px 3px 0; }
.vf b { position: absolute; background: var(--ink); }
.vf b:nth-child(5) { top: 0;    left: 50%; width: 2px; height: 9px; margin-left: -1px; }
.vf b:nth-child(6) { bottom: 0; left: 50%; width: 2px; height: 9px; margin-left: -1px; }
.vf b:nth-child(7) { left: 0;   top: 50%;  height: 2px; width: 9px; margin-top: -1px; }
.vf b:nth-child(8) { right: 0;  top: 50%;  height: 2px; width: 9px; margin-top: -1px; }

.ui--br  { bottom: 16px; right: 16px; }

/* ---------- CURSOR (mouse only): a square dot + a verb ---------- */
#cursor {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  display: none; align-items: center; gap: 10px;
  mix-blend-mode: difference; color: #fff; opacity: 0;
  transition: opacity .2s ease;
}
#cursor i { width: 10px; height: 10px; background: #fff; margin-left: -5px; }
#cursor b {
  font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
}
@media (hover: hover) and (pointer: fine) {
  #cursor { display: flex; }
  #stage, body.is-dragging #stage { cursor: none; }
}

/* ---------- LOADER: a counter that lies a little, then a curtain up ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100; background: var(--ink); color: var(--paper);
  /* overflow hidden: the big counter is nudged down past the bottom edge (see #ld-num), so without
     this it hung below the black as the curtain lifted and looked like it lagged behind. Now
     everything is clipped to the curtain and moves exactly with it. */
  overflow: hidden; will-change: transform;
  transition: transform 1s cubic-bezier(.7, 0, .2, 1);
}
#loader .scan { z-index: 0; --scan-rgb: 255, 255, 255; --scan-a: .06; }   /* light lines on the black loader */
#loader.is-out { transform: translateY(-100%); }
#loader.is-done { display: none; }
#loader .ld-top {
  position: absolute; top: 16px; left: 16px; right: 16px;
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
}
#ld-num {
  position: absolute; left: 12px; bottom: 0;
  font-family: var(--display); font-size: 38vw; line-height: .8;
  color: var(--hot); transform: translateY(8%);
  font-variant-numeric: tabular-nums;
}

/* ---------- CARD PICTURES ----------
   A card with an img (SITE.pages) shows it as a framed photo between the label row and the word.
   The word gets a little shorter to make room; it still stretches edge to edge. */
.card--img .card__title { font-size: 22cqw; }
.card__img {
  flex: 1; min-height: 0; margin: 2.6cqw 0 3cqw;
  border: max(2px, .55cqw) solid currentColor; background: var(--ink); overflow: hidden;
}
.card__img img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }

/* ---------- HERO: one plain sentence + two buttons, top left ---------- */
#hero {
  position: fixed; z-index: 10; left: 16px; top: 72px;
  width: min(460px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 14px;
}
.hero__line {
  font-size: clamp(14px, 1.15vw, 17px); line-height: 1.45; font-weight: 500;
  background: var(--paper); padding: 2px 0;            /* stays readable if a card swings behind it */
}
.hero__cta { display: flex; flex-wrap: wrap; gap: 8px; }
body.is-flying #hero, body.is-list #hero { opacity: 0; pointer-events: none; transition: opacity .3s ease; }

/* ---------- LIST VIEW ---------- */
#list {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--paper);
  padding: 72px 16px 76px;
}
#list[hidden] { display: none; }
.list__rows { list-style: none; max-width: 1400px; margin: 0 auto; border-top: var(--edge) solid var(--ink); }
.row {
  display: grid; grid-template-columns: 70px 120px 1fr auto; align-items: center; gap: 24px;
  padding: 14px 10px; border-bottom: 1px solid var(--ink); color: inherit; text-decoration: none;
  transition: background .2s, color .2s, padding .2s;
}
.row__n, .row__s { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; }
.row__img { width: 120px; aspect-ratio: 1.41; border: 2px solid currentColor; overflow: hidden; background: var(--hot); }
.row__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row__t { font-family: var(--display); text-transform: uppercase; font-size: clamp(44px, 7.5vw, 112px); line-height: .9; }
.row:hover, .row:focus-visible { background: var(--ink); color: var(--paper); padding-left: 22px; outline: none; }
.row:hover .row__n { color: var(--hot); }
body.is-list #wordmark, body.is-list #brief, body.is-list #cursor { opacity: 0; }
body.is-list #stage { visibility: hidden; }

/* ---------- PHONES ---------- */
@media (max-width: 640px) {
  :root { --cy: 56%; }
  #hero { top: 64px; gap: 12px; }
  #wordmark { width: calc(100vw - 32px); bottom: 50px; transform: none; }   /* sits above the list / counter chips */
  #mark { --mark: 96vw; }
  .hero__line { font-size: 14px; }
  .btn { padding: 10px 13px; font-size: 11px; }
  .row { grid-template-columns: 34px 84px 1fr; gap: 12px; padding: 12px 4px; }
  .row__img { width: 84px; }
  .row__s { display: none; }
  .row__t { font-size: clamp(34px, 11vw, 60px); }
}
body.is-list .ui--br .chip:not(#viewToggle) { display: none; }   /* the card counter means nothing in the list */

/* loader: your logo turns next to "Loading" */
.ld-brand { display: inline-flex; align-items: center; gap: 10px; }
.ld-logo { width: 22px; height: 22px; animation: ldSpin 2.4s linear infinite; }
@keyframes ldSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ld-logo { animation: none; } }
