/* Animatable colour tokens — the whole page fades between palettes */
@property --dark  { syntax: '<color>'; inherits: true; initial-value: #1e1e1e; }
@property --mid   { syntax: '<color>'; inherits: true; initial-value: #777777; }
@property --light { syntax: '<color>'; inherits: true; initial-value: #e6e6e6; }
@property --ink   { syntax: '<color>'; inherits: true; initial-value: #ffffff; }

:root {
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .1, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: #1e1e1e; color: #fff; font-family: var(--mono); overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* Film grain over everything */
body::after {
  content: ""; position: fixed; inset: -50%; z-index: 999; pointer-events: none;
  opacity: .16; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(5) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 3%); }
  40% { transform: translate(3%, -2%); }
  60% { transform: translate(-3%, -3%); }
  80% { transform: translate(2%, 2%); }
}

/* ───────── STAGE ───────── */
/* Blob positions are animatable, so the gradient can slowly drift.
   1 = dark patch (starts at the top-right corner of Hearst's H, drifts up toward Condé Nast),
   2 = light patch (top right), 3 = soft mid-tone */
@property --x1 { syntax: '<percentage>'; inherits: false; initial-value: 30%; }
@property --y1 { syntax: '<percentage>'; inherits: false; initial-value: 53%; }
@property --x2 { syntax: '<percentage>'; inherits: false; initial-value: 82%; }
@property --y2 { syntax: '<percentage>'; inherits: false; initial-value: 24%; }
@property --x3 { syntax: '<percentage>'; inherits: false; initial-value: 62%; }
@property --y3 { syntax: '<percentage>'; inherits: false; initial-value: 82%; }

.stage {
  position: relative; height: 100svh; min-height: 520px; overflow: hidden;
  background:
    radial-gradient(66% 82% at var(--x1) var(--y1), var(--dark) 0%, transparent 70%),
    radial-gradient(55% 60% at var(--x2) var(--y2), var(--light) 0%, transparent 70%),
    radial-gradient(45% 50% at var(--x3) var(--y3), color-mix(in srgb, var(--mid) 70%, var(--light)) 0%, transparent 70%),
    linear-gradient(45deg, var(--mid) 0%, var(--light) 100%);
  /* --fade is set by script.js: quick for hovers, very slow for the background cycle */
  transition: --dark var(--fade, 1.1s) ease-in-out, --mid var(--fade, 1.1s) ease-in-out, --light var(--fade, 1.1s) ease-in-out, --ink var(--fade, 1.1s) ease-in-out;
  animation: drift 26s ease-in-out infinite alternate;
}
/* The dark patch travels a short, gentle path from Hearst's top-right corner
   up toward Condé Nast, then eases back (alternate) */
@keyframes drift {
  0%   { --x1: 30%; --y1: 53%; --x2: 82%; --y2: 24%; --x3: 62%; --y3: 82%; }
  33%  { --x1: 32%; --y1: 49%; --x2: 76%; --y2: 30%; --x3: 55%; --y3: 76%; }
  66%  { --x1: 35%; --y1: 45%; --x2: 86%; --y2: 18%; --x3: 68%; --y3: 88%; }
  100% { --x1: 37%; --y1: 41%; --x2: 79%; --y2: 27%; --x3: 59%; --y3: 80%; }
}

.top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 3vw, 36px); color: var(--ink);
}
/* Name and Contact share one style, each sitting in a liquid-glass pill */
.top__name, .top__link {
  position: relative; display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 11px; line-height: 1; letter-spacing: .22em; text-transform: uppercase; text-decoration: none;
  color: var(--ink); text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
  /* letter-spacing adds a trailing gap, so the right padding is a touch smaller */
  padding: 11px calc(17px - .22em) 11px 17px; border-radius: 999px;
  /* the glass: blurs and brightens whatever drifts behind it */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .2) 0%, rgba(255, 255, 255, .04) 55%, rgba(255, 255, 255, .1) 100%),
    rgba(0, 0, 0, .1); /* a whisper of shade so white text reads on pale colours */
  -webkit-backdrop-filter: blur(14px) saturate(1.7) brightness(.96);
          backdrop-filter: blur(14px) saturate(1.7) brightness(.96);
  border: 1px solid rgba(255, 255, 255, .28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),   /* bright top lip */
    inset 0 -1px 1px rgba(255, 255, 255, .12), /* soft bottom rim */
    inset 0 -8px 14px -10px rgba(0, 0, 0, .25),
    0 8px 24px -8px rgba(0, 0, 0, .35);       /* lift off the page */
  transition: transform .5s var(--ease), background .4s, box-shadow .4s;
}
/* specular highlight sweeping across the top half, like light on curved glass */
.top__name::before, .top__link::before {
  content: ""; position: absolute; inset: 1px 1px 50% 1px; border-radius: 999px 999px 40% 40% / 999px 999px 100% 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .32), rgba(255, 255, 255, 0));
  pointer-events: none; opacity: .7; transition: opacity .4s;
}
.top__name:hover, .top__link:hover, .top__link[aria-expanded="true"] {
  transform: scale(1.04);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .28) 0%, rgba(255, 255, 255, .08) 55%, rgba(255, 255, 255, .16) 100%),
    rgba(0, 0, 0, .1);
}
.top__name:hover::before, .top__link:hover::before { opacity: 1; }
.top__name:focus-visible, .top__link:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.top__sep { opacity: .5; margin: 0 .4em; }

/* ───────── LOGOS ───────── */
/* --tx/--ty/--s move a logo when its work is open; --hs is the small hover lift */
.co {
  position: absolute; z-index: 3; cursor: pointer; outline: none;
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(calc(var(--s, 1) * var(--hs, 1)));
  transition: opacity .6s var(--ease), transform 1.1s cubic-bezier(.65, 0, .25, 1);
}
.co__logo {
  display: block; width: 100%; background: var(--ink);
  -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat;
}
.co:hover, .co.is-active { --hs: 1.04; }
.stage.has-active .co:not(.is-active) { opacity: .28; }

/* A client is open: the others vanish, the chosen one glides to the left */
.stage.is-open .co:not(.is-open) { opacity: 0; pointer-events: none; }
.stage.is-open .co.is-open { --hs: 1; }
.co:focus-visible { outline: 1px solid var(--ink); outline-offset: 10px; }
.co__tag {
  position: absolute; left: 0; top: calc(100% + 14px); white-space: nowrap; color: var(--ink);
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  opacity: 0; transform: translateY(-6px); transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.co.is-active .co__tag { opacity: .9; transform: none; }

.co[data-co="conde"]  { left: 41%; top: 21%; width: clamp(150px, 19vw, 300px); }
.co[data-co="conde"]  .co__logo { aspect-ratio: 3840 / 572; --src: url("assets/logos/conde-nast.webp"); }
/* Hearst (original lockup: big H + HEARST, "magazines UK" removed) sits on the dark patch,
   centred 26% across, 60% down */
.co[data-co="hearst"] { left: calc(26% - clamp(31px, 3.6vw, 56px)); top: calc(60% - clamp(40px, 4.66vw, 72px)); width: clamp(62px, 7.2vw, 112px); }
.co[data-co="hearst"] .co__logo { aspect-ratio: 1598 / 2069; --src: url("assets/logos/hearst-lockup.png"); }
.co[data-co="wgsn"]   { left: 67%; top: 46%; width: clamp(110px, 12.5vw, 200px); }
.co[data-co="wgsn"]   .co__logo { aspect-ratio: 1020.47 / 255.12; --src: url("assets/logos/wgsn.svg"); }

@media (max-width: 700px) {
  .co[data-co="conde"]  { left: 36%; top: 22%; }
  .co[data-co="wgsn"]   { left: 50%; top: 62%; }
}

/* ───────── WORK PANEL (right side) ───────── */
.work {
  position: absolute; z-index: 4; top: 78px; bottom: 24px; right: clamp(16px, 3vw, 36px);
  width: min(56vw, 820px); display: flex; flex-direction: column; color: #f4f1ec;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  /* frosted glass, tinted by the current palette, so text reads on any colour */
  padding: 18px 22px 0; border-radius: 12px;
  background: color-mix(in srgb, var(--dark) 52%, transparent);
  -webkit-backdrop-filter: blur(26px) saturate(1.3); backdrop-filter: blur(26px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateX(28px);
  transition: opacity .7s var(--ease) .25s, transform .9s var(--ease) .25s;
}
.work[hidden] { display: none; }
.work.is-open { opacity: 1; transform: none; }

.work__head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, .14);
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
}
.work__label { opacity: .7; }
.work__btn { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; opacity: .85; transition: opacity .3s; padding: 4px 0; }
.work__btn:hover { opacity: 1; }

.work__scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 22px 6px 64px 0;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent;
  -webkit-mask: linear-gradient(transparent, #000 22px, #000 calc(100% - 56px), transparent);
          mask: linear-gradient(transparent, #000 22px, #000 calc(100% - 56px), transparent);
}

/* Project cards */
/* Gallery: thumbnails flow in rows at their true shape (wide and vertical side by side).
   Each tile grows in proportion to its aspect ratio, so every tile in a row is the same height. */
.work__list { --row: clamp(150px, 14vw, 210px); list-style: none; display: flex; flex-wrap: wrap; gap: 30px 16px; }
.work__list::after { content: ""; flex: 999 1 0; } /* keeps the last row from stretching */
.work__list > li { flex: var(--ar) 1 calc(var(--ar) * var(--row)); max-width: calc(var(--ar) * var(--row) * 1.5); min-width: 0; }
.work__list[hidden] { display: none; }
.card {
  width: 100%; display: block;
  text-align: left; color: inherit;
  opacity: 0; transform: translateY(22px);
  transition: opacity .7s var(--ease), transform .8s var(--ease);
  transition-delay: calc(.35s + var(--i, 0) * 70ms);
}
.work.is-open .card { opacity: 1; transform: none; }
.card__thumb {
  position: relative; display: block; width: 100%; aspect-ratio: var(--ar, 16 / 9); overflow: hidden; border-radius: 4px;
  background: color-mix(in srgb, var(--dark) 55%, transparent);
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 1s var(--ease), opacity .6s; }
.card__thumb img[data-loading] { opacity: 0; }
.card__thumb-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; opacity: .55; }
.card:hover .card__thumb img, .card:focus-visible .card__thumb img { transform: scale(1.05); }
.card__title {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 10px; font-size: 12px; line-height: 1.5;
}
.card__title span { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .4s var(--ease); }
.card:hover .card__title span, .card:focus-visible .card__title span { background-size: 100% 1px; }
.card__year { display: block; margin-top: 3px; font-size: 10px; letter-spacing: .22em; opacity: .6; }
.card:focus-visible, .detail__back:focus-visible, .work__btn:focus-visible { outline: 1px solid rgba(255, 255, 255, .7); outline-offset: 6px; }
.detail__back:focus:not(:focus-visible), .card:focus:not(:focus-visible) { outline: none; }

/* Project detail */
.detail { animation: detailIn .6s var(--ease); }
.detail[hidden] { display: none; }
@keyframes detailIn { from { opacity: 0; transform: translateY(14px); } }
.detail__back { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; opacity: .85; margin-bottom: 20px; padding: 4px 0; }
.detail__back:hover { opacity: 1; }
.detail__body { display: grid; gap: 22px; }
.detail__body.is-portrait { grid-template-columns: minmax(0, 300px) 1fr; align-items: start; }
.detail__player { width: 100%; aspect-ratio: var(--ar, 16 / 9); display: block; border: 0; border-radius: 4px; background: #000; }
.detail__pub { display: inline-block; margin-top: 10px; font-size: 11px; letter-spacing: .06em; opacity: .7; text-decoration: none; }
.detail__pub:hover { opacity: 1; text-decoration: underline; }
.detail__text p + p { margin-top: 2px; }
.detail__client { opacity: .6; }
.detail__desc { margin-top: 16px !important; white-space: pre-line; opacity: .85; }
.detail__fail { display: grid; place-items: center; aspect-ratio: var(--ar, 16 / 9); border-radius: 4px; background: rgba(0,0,0,.35); font-size: 11px; letter-spacing: .1em; }

@media (max-width: 700px) {
  .work { top: 196px; bottom: 16px; left: 16px; right: 16px; width: auto; padding: 14px 14px 0; transform: translateY(28px); }
  .work__list { --row: 128px; gap: 22px 10px; }
  .card__title { font-size: 11px; }
  .detail__body.is-portrait { grid-template-columns: 46% 1fr; gap: 14px; }
  .work__scroll { padding-right: 0; }
}

/* ───────── FINDER WINDOW ───────── */
.finder {
  position: fixed; z-index: 50; left: 50%; top: 50%;
  width: min(440px, calc(100vw - 32px));
  color: #f4f1ec; border-radius: 12px; overflow: hidden;
  background: rgba(28, 27, 25, .62);
  -webkit-backdrop-filter: blur(28px) saturate(1.4); backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45), 0 0 0 .5px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
  transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(.92);
  opacity: 0; transition: opacity .35s var(--ease), transform .45s var(--ease);
}
.finder[hidden] { display: none; }
.finder.is-open { opacity: 1; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1); }
.finder.is-dragging { transition: none; }

.finder__bar {
  position: relative; display: flex; align-items: center; gap: 18px;
  height: 44px; padding: 0 14px; cursor: grab; user-select: none; touch-action: none;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.finder.is-dragging .finder__bar { cursor: grabbing; }
.finder__lights { display: flex; gap: 8px; }
.light { width: 12px; height: 12px; border-radius: 50%; display: block; position: relative; }
.light--close { background: #ff5f57; }
.light--min   { background: #febc2e; }
.light--max   { background: #28c840; }
.light--close::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; line-height: 1; color: rgba(0,0,0,.6); opacity: 0; transition: opacity .2s; }
.finder__lights:hover .light--close::after, .light--close:focus-visible::after { opacity: 1; }
/* One font, one size for everything in the window */
.finder, .finder__title, .finder__main { font-family: var(--mono); font-size: 13px; line-height: 1.8; letter-spacing: 0; }
.finder__title { position: absolute; left: 50%; transform: translateX(-50%); color: rgba(255, 255, 255, .8); }

.finder__main { padding: 22px 24px 24px; }
.finder__main a { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .4s var(--ease); }
.finder__main a:hover, .finder__main a:focus-visible { background-size: 100% 1px; outline: none; }

@media (prefers-reduced-motion: reduce) {
  body::after, .stage, .detail { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
