/* ==========================================================================
   Juan Núñez Prieto — Portfolio
   Grid: 12 columns / 16px gutter / 48px margin (desktop), 8 (tablet), 4 (mobile)
   ========================================================================== */

/* Typefaces: Lastik (display) and ABC Areal (text) */
@font-face {
  font-family: "Lastik";
  src: url("assets/fonts/Lastik-Free.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "ABC Areal";
  src: url("assets/fonts/ABCArealVariable.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* Cross-page fade on larger screens only */
@media (min-width: 768px) { @view-transition { navigation: auto; } }
/* Prevent horizontal page overflow; clip (unlike hidden) keeps position: sticky working */
html, body { overflow-x: clip; }
html { overscroll-behavior-x: none; }

/* Registered so the page and top-bar colours can transition together */
@property --page-bg {
  syntax: "<color>";
  inherits: true;
  initial-value: #000000;
}

:root {
  /* Color */
  --black: #000000;
  --white: #ffffff;
  --forest-900: #122c21;           /* About page background */
  --white-80: rgba(255, 255, 255, 0.8);
  --white-50: rgba(255, 255, 255, 0.5);
  --white-10: rgba(255, 255, 255, 0.1);
  --white-5: rgba(255, 255, 255, 0.05);
  --accent: #dfe700;                /* clock seconds hand */

  --page-bg: var(--black);          /* set per section by script.js */

  /* Type */
  --font-display: "Lastik", Georgia, serif;
  --font-body: "ABC Areal", system-ui, -apple-system, sans-serif;

  /* Type scale */
  --t-display: clamp(36px, 2.4rem + 2.2vw, 64px);   /* display */
  --t-lead: clamp(20px, 1rem + 0.56vw, 24px);       /* intro */
  --t-title: 20px;                                   /* titles */
  --t-ui: 16px;                                      /* UI labels */
  --t-body-l: 16px;                                  /* long-form body */
  --t-body: 14px;                                    /* body */
  --track: 0;                                        /* body text */
  --track-ui: -0.04em;                               /* UI labels */
  --track-display: -0.02em;                          /* display text */

  /* Grid */
  --cols: 12;
  --gutter: 16px;
  --margin: 48px;

  /* Spacing */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-6: 24px; --s-8: 32px;
  --s-16: 64px; --s-24: 96px;

  /* Carousel */
  --slide-h: clamp(220px, 26vw, 520px);  /* 374px at 1440px */
  --radius-media: 8px;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 200ms;
  --dur-bg: 900ms;
}

@media (max-width: 1199px) {
  :root { --cols: 8; --margin: 32px; }
}
@media (max-width: 767px) {
  :root { --cols: 4; --margin: 20px; --gutter: 12px; --slide-h: calc((100vw - 2 * var(--margin)) * 374 / 665); }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--page-bg);
  transition: --page-bg var(--dur-bg) var(--ease-soft);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--page-bg); /* iOS Safari tints the status bar from the body background */
  color: var(--white);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.36;
  letter-spacing: var(--track);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html.page-about { --page-bg: var(--forest-900); }

img, video, svg { display: block; max-width: 100%; }
a { color: inherit; }
p, h1, h2, h3, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; }

:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; border-radius: 4px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--margin); top: -60px; z-index: 100;
  background: var(--white); color: var(--black); padding: 8px 12px; border-radius: 10px;
  text-decoration: none; transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus { top: 12px; }

/* ---------- Grid ---------- */
.wrap { padding-inline: var(--margin); }
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gutter);
}

/* ---------- Type styles ---------- */
.t-title { font-family: var(--font-display); font-weight: 400; font-size: var(--t-title); line-height: normal; letter-spacing: var(--track-display); }
.t-lead { font-size: var(--t-lead); line-height: 1.24; letter-spacing: var(--track); font-weight: 400; }
.t-display { font-family: var(--font-display); font-weight: 400; font-size: var(--t-display); line-height: 1.12; letter-spacing: var(--track-display); }
.t-body { font-size: var(--t-body); line-height: 1.36; letter-spacing: var(--track); }
.t-body-l { font-size: var(--t-body-l); line-height: 1.45; letter-spacing: var(--track); }
.t-muted { color: var(--white-80); }
.t-faint { color: var(--white-50); }

/* ==========================================================================
   Header / nav
   ========================================================================== */
.topbar {
  --topbar-h: 66px;
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  padding: 13px var(--margin);
  /* safe-area inset for viewport-fit=cover */
  padding-top: max(13px, env(safe-area-inset-top));
  padding-left: max(var(--margin), env(safe-area-inset-left));
  padding-right: max(var(--margin), env(safe-area-inset-right));
  /* iOS 26 Safari no longer reads theme-color: it tints the status-bar area from a fixed bar's own
     background at the top edge. Giving the bar the section color (invisible against the same page
     color) lets the area under the clock follow each section. */
  background-color: var(--page-bg);
  transition: transform 500ms var(--ease-out);
  will-change: transform;
}
.topbar::before {
  content: ""; position: absolute; inset: 0 0 -28px 0; z-index: -1;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
  pointer-events: none;
  background: color-mix(in srgb, var(--page-bg) 86%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  backdrop-filter: blur(20px) saturate(1.3);
  opacity: 0; transition: opacity 400ms var(--ease-out);
}
.topbar.is-scrolled::before { opacity: 1; }
.topbar.is-hidden { transform: translateY(-100%); }
.topbar:focus-within { transform: none; }
@media (prefers-reduced-motion: reduce) { .topbar, .nav__name, .nav__surname, .nav__hi, .nav .toggle { transition: none; } }

.site-header { padding: calc(26px + 40px + var(--s-24)) var(--margin) var(--s-16); }
.site-header--bare { padding-bottom: 0; padding-top: calc(26px + 40px + var(--s-16)); }
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-4);
}
.nav__name {
  font-family: var(--font-display); font-weight: 400;
  font-size: var(--t-title); letter-spacing: var(--track-display); text-decoration: none;
  justify-self: start;
}
/* Away from the top of the page the name shortens to "Juan" */
.nav__surname {
  display: inline-block; vertical-align: bottom; overflow: hidden; white-space: pre;
  max-width: 5.5em;
  transition: max-width 500ms var(--ease-out), opacity 300ms var(--ease-out);
}
.topbar.is-scrolled .nav__surname { max-width: 0; opacity: 0; }
/* Contact link (uses .text-link) */
.nav__hi { justify-self: end; font-size: var(--t-ui); line-height: 1.2; letter-spacing: var(--track-ui); }

/* Work / About toggle */
.toggle {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 12px;
  background: var(--white-10);
  -webkit-backdrop-filter: blur(82px);
  backdrop-filter: blur(82px);
}
.toggle__thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / 2);
  border-radius: 10px;
  background: var(--white-10);
  transition: transform 450ms var(--ease-out);
}
.toggle[data-active="about"] .toggle__thumb { transform: translateX(100%); }
.toggle__opt {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  min-width: 54px; padding: 6px 10px;
  font-size: var(--t-ui); line-height: 1.2; letter-spacing: var(--track-ui);
  text-decoration: none; border-radius: 10px;
  color: var(--white-80);
  transition: color var(--dur-fast) var(--ease-out);
}
.toggle__opt[aria-current="page"], .toggle__opt:hover { color: var(--white); }
/* The thumb follows the hovered option and returns to the current page on leave */
@media (hover: hover) {
  .toggle__thumb { transition: transform 380ms cubic-bezier(0.3, 0.9, 0.3, 1); }
  .toggle:has(.toggle__opt:nth-of-type(1):hover) .toggle__thumb { transform: translateX(0); }
  .toggle:has(.toggle__opt:nth-of-type(2):hover) .toggle__thumb { transform: translateX(100%); }
  /* dim the current label while another option is hovered */
  .toggle:has(.toggle__opt:hover) .toggle__opt[aria-current="page"]:not(:hover) { color: var(--white-80); }
}

.intro { max-width: 660px; text-wrap: balance; }
.nowrap { white-space: nowrap; }

/* ==========================================================================
   Project sections
   ========================================================================== */
.project { padding-block: var(--s-24); position: relative; }
.project__header { position: relative; padding-top: var(--s-4); }

/* Section divider (animated in on reveal) */
.rule {
  position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: var(--white-10);
  transform-origin: left center;
}
.project__name { grid-column: span 3; }
.project__summary { grid-column: span 5; }
/* Secondary text opacity; raised per section (--meta) where needed for WCAG AA contrast */
.project { --meta: 0.5; }
.project__people { grid-column: span 3; }
.project__role { color: var(--white); }
.project__credits { color: rgba(255, 255, 255, var(--meta)); }
.project__year { grid-column: span 1; color: rgba(255, 255, 255, var(--meta)); }
.project__more { display: none; }
.project__tags { grid-column: 4 / span 5; grid-row: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-4); }
/* Two-row header: the summary sets row one, so tags sit a fixed distance below it
   regardless of the length of the other columns */
.project__header { grid-template-rows: auto 1fr; }
.project__header > .project__name, .project__header > .project__title,
.project__people, .project__year { grid-row: 1 / span 2; }
.project__summary { grid-row: 1; }
.tag {
  font-size: var(--t-body); line-height: 1.2; letter-spacing: -0.02em;
  padding: 7px 14px; border-radius: 9999px;
  background: var(--white-10); color: #fff;
}
/* Optical vertical centring: trim the line box to cap height and baseline */
@supports (text-box: trim-both cap alphabetic) {
  .tag { text-box: trim-both cap alphabetic; padding-block: 10px; }
}

/* Carousel — full-bleed, aligned to the grid margin */
.carousel { position: relative; margin-top: var(--s-8); }
.carousel__viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
}
.carousel__viewport::-webkit-scrollbar { display: none; }
.carousel__viewport.is-dragging { cursor: grabbing; }
.carousel__viewport.is-dragging .slide { pointer-events: none; }
.carousel__track {
  display: flex;
  gap: var(--gutter);
  padding-inline: var(--margin);
  width: max-content;
}
.slide {
  position: relative;
  flex: none;
  height: var(--slide-h);
  aspect-ratio: 665 / 374;
  border-radius: var(--radius-media);
  overflow: hidden;
  background: var(--white-5);
  isolation: isolate;
}
.slide--narrow { aspect-ratio: 332 / 374; }
.slide--photo { aspect-ratio: 960 / 662; }
.slide img, .slide video {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 900ms var(--ease-out), opacity 600ms var(--ease-out);
  user-select: none; -webkit-user-drag: none;
}
.slide:hover img, .slide:hover video { transform: scale(1.015); }
.slide video { position: absolute; inset: 0; }
.slide--placeholder { background: rgba(255, 255, 255, 0.07); }
.slide--placeholder::after {
  content: "Coming soon"; position: absolute; left: 16px; bottom: 14px;
  font-size: var(--t-body); color: var(--white-50);
}

/* Video play/pause control */
.video-control {
  position: absolute; right: 24px; bottom: 24px; z-index: 2;
  opacity: 0; transform: translateY(4px);
  width: 30px; height: 30px;
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 10px; cursor: pointer;
  background: rgba(0, 0, 0, 0.1);
  -webkit-backdrop-filter: blur(82px) saturate(1.2);
  backdrop-filter: blur(82px) saturate(1.2);
  transition: background-color var(--dur-fast) var(--ease-out), transform 300ms var(--ease-out), opacity 300ms var(--ease-out);
}
.slide:hover .video-control,
.video-control:focus-visible { opacity: 1; transform: none; }
.slide__credit {
  position: absolute; left: 24px; bottom: 24px; z-index: 2;
  height: 30px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 10px;
  font-size: 12px; letter-spacing: var(--track); color: #fff;
  background: rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(82px) saturate(1.2); backdrop-filter: blur(82px) saturate(1.2);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}
.slide:hover .slide__credit { opacity: 1; transform: none; }
@media (hover: none) { .video-control, .slide__credit { opacity: 1; transform: none; } }
.video-control[data-mode="light"] { background: var(--white-10); }
.slide:hover .video-control:hover { background: rgba(0, 0, 0, 0.24); transform: scale(1.06); }
.video-control[data-mode="light"]:hover { background: rgba(255, 255, 255, 0.18); }
.video-control:active { transform: scale(0.94); }
.video-control svg { width: 10px; height: 10px; }
.video-control .i-play { display: none; }
.video-control[data-playing="false"] .i-play { display: block; }
.video-control[data-playing="false"] .i-pause { display: none; }
.video-control[hidden] { display: none; }

/* Password-protected projects (script §4b): cover stays sharp, other slides are blurred */
.carousel--locked:not(.is-unlocked) .carousel__viewport { overflow: hidden; cursor: default; touch-action: pan-y; }
.carousel--locked .slide :is(img, video) {
  transition: filter 1400ms cubic-bezier(0.22, 1, 0.36, 1), transform 1600ms cubic-bezier(0.22, 1, 0.36, 1), opacity 600ms var(--ease-out);
  transition-delay: var(--veil-delay, 0ms);
}
.slide.is-veiled :is(img, video), .slide.is-veiled:hover :is(img, video) { filter: blur(16px) saturate(1.25); transform: scale(1.2); }
/* Hide the leading loop clone until the reveal */
.js .carousel.carousel--locked[data-reveal] .slide.lead { opacity: 0; transition: opacity 1400ms var(--ease-out), transform 1100ms var(--ease-out); transition-delay: 0ms; }
.js .carousel.carousel--locked[data-reveal].is-opening .slide.lead,
.js .carousel.carousel--locked[data-reveal].is-unlocked .slide.lead { opacity: 1; }

.project__title { grid-column: span 3; }
.lock {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin-top: var(--s-3);
  transition: opacity 500ms var(--ease-out), height 900ms cubic-bezier(0.22, 1, 0.36, 1), margin 900ms cubic-bezier(0.22, 1, 0.36, 1);
}
.lock.is-fading { opacity: 0; pointer-events: none; }
.lock.is-done { opacity: 0; overflow: hidden; margin-top: 0; pointer-events: none; }
/* Desktop: form is positioned under the title, out of flow */
@media (min-width: 1200px) {
  .project__title { position: relative; }
  .project__title .lock { position: absolute; left: 0; flex-wrap: nowrap; white-space: nowrap; }
}
.lock__field {
  position: relative; display: flex; align-items: center;
  width: 220px; height: 30px; border-radius: 9999px;
  background: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  backdrop-filter: blur(20px) saturate(1.2);
  transition: background-color 300ms var(--ease-out), box-shadow 300ms var(--ease-out);
}
.lock__field:focus-within { background: rgba(255, 255, 255, 0.2); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }
.lock__input {
  flex: 1; min-width: 0; height: 100%;
  padding: 0 72px 0 14px; border: 0; background: none; color: #fff; outline: none;
  font: inherit; font-size: var(--t-body); letter-spacing: 0.08em;
}
.lock__input::placeholder { color: rgba(255, 255, 255, 0.7); letter-spacing: var(--track); }
/* Inset action pill: "Request" when empty, "Unlock" once typed (width via --thumb-w, script §4b) */
.lock__thumb {
  position: absolute; right: 3px; top: 3px; bottom: 3px;
  width: var(--thumb-w, 64px); border-radius: 9999px;
  background: var(--white-10); pointer-events: none;
  transition: width 380ms cubic-bezier(0.3, 0.9, 0.3, 1), background-color var(--dur-fast) var(--ease-out);
}
.lock__field:has(.lock__request:hover, .lock__submit:hover) .lock__thumb { background: rgba(255, 255, 255, 0.18); }
.lock__submit, .lock__request {
  position: absolute; right: 3px; top: 3px; bottom: 3px; z-index: 1;
  display: flex; align-items: center; padding: 0 10px;
  border: 0; border-radius: 9999px; background: none; cursor: pointer; white-space: nowrap; text-decoration: none;
  font: inherit; font-size: 12px; letter-spacing: var(--track); line-height: 1;
  color: var(--white-80);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out), color var(--dur-fast) var(--ease-out), visibility 0s;
}
.lock__submit:hover, .lock__request:hover { color: var(--white); }
.lock__submit:focus-visible, .lock__request:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Label crossfade */
.lock__submit,
.lock__input:not(:placeholder-shown) ~ .lock__request {
  opacity: 0; transform: translateX(4px); visibility: hidden; pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
.lock__input:not(:placeholder-shown) ~ .lock__submit {
  opacity: 1; transform: none; visibility: visible; pointer-events: auto;
  transition: opacity 260ms var(--ease-out) 80ms, transform 260ms var(--ease-out) 80ms, color var(--dur-fast) var(--ease-out), visibility 0s;
}
.lock__input:not(:placeholder-shown) ~ .lock__submit:disabled { cursor: progress; opacity: 0.6; }
.lock.is-wrong .lock__field { animation: lock-shake 420ms var(--ease-out); }
@keyframes lock-shake { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .lock.is-wrong .lock__field { animation: none; }
  .lock, .lock__submit, .lock__request, .lock__thumb, .carousel--locked .slide img { transition: none; }
}

/* "Email copied" note (script §8) */
.copied {
  position: fixed; z-index: 60; left: 0; top: 0;
  padding: 5px 10px; border-radius: 9999px;
  background: rgba(255, 255, 255, 0.16); color: #fff;
  -webkit-backdrop-filter: blur(20px) saturate(1.2); backdrop-filter: blur(20px) saturate(1.2);
  font-size: 12px; letter-spacing: var(--track); white-space: nowrap; pointer-events: none;
  opacity: 0; transform: translate(-50%, calc(-100% + 4px));
  transition: opacity 250ms var(--ease-out), transform 350ms var(--ease-out);
}
.copied.is-below { transform: translate(-50%, -4px); }
.copied.is-on { opacity: 1; transform: translate(-50%, -100%); }
.copied.is-below.is-on { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .copied { transition: opacity 150ms linear; } }

/* Slide viewer (script §9) */
html.has-viewer { overflow: hidden; }
.viewer {
  position: fixed; inset: 0; z-index: 80;
  display: grid; grid-template-rows: 64px 1fr; padding: 0 var(--margin) var(--s-8);
  touch-action: none;
}
.viewer[hidden] { display: none; }
.viewer::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--page-bg) 90%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.1); backdrop-filter: blur(24px) saturate(1.1);
  opacity: 0; transition: opacity 420ms var(--ease-out);
}
.viewer.is-open::before { opacity: 1; }
.viewer__bar, .viewer__nav { opacity: 0; transition: opacity 300ms var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.viewer.is-open .viewer__bar, .viewer.is-open .viewer__nav { opacity: 1; transition-delay: 120ms; }
.viewer__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); font-size: var(--t-body); letter-spacing: var(--track); }
.viewer__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__count { margin-left: 10px; color: rgba(255, 255, 255, 0.6); font-variant-numeric: tabular-nums; }
.viewer__close {
  padding: 2px 0 1px; border: 0; cursor: pointer; color: #fff; font: inherit;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size 400ms var(--ease-out);
}
.viewer__close:hover { background-size: 0% 1px; background-position: 100% 100%; }
.viewer__stage { position: relative; min-height: 0; margin-inline: 56px; }
.viewer__media {
  position: absolute; margin: 0; border-radius: var(--radius-media); overflow: hidden;
  background: var(--white-5); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  will-change: transform;
}
.viewer__media img, .viewer__media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewer__media video { opacity: 0; transition: opacity 400ms var(--ease-out); }
.viewer__media .video-control { opacity: 1; transform: none; }
.viewer__credit {
  position: absolute; left: 16px; bottom: 16px; z-index: 2;
  padding: 5px 10px; border-radius: 9999px; font-size: 12px; letter-spacing: var(--track); color: #fff;
  background: rgba(0, 0, 0, 0.28); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.viewer__nav {
  position: absolute; top: 50%; z-index: 2; width: 40px; height: 40px; margin-top: 12px;
  display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; color: #fff;
  background: var(--white-10); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.viewer__nav:hover { background: rgba(255, 255, 255, 0.18); }
.viewer__nav[hidden] { display: none; }
.viewer__navs { display: contents; }
.viewer__nav svg { width: 16px; height: 16px; }
.viewer__nav--prev { left: calc(var(--margin) / 2); }
.viewer__nav--prev svg { transform: scaleX(-1); }
.viewer__nav--next { right: calc(var(--margin) / 2); }
.viewer__close:focus-visible, .viewer__nav:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-width: 767px) {
  /* Mobile: controls along the bottom edge */
  .viewer { grid-template-rows: 1fr auto 56px; padding-top: calc(var(--s-6) + env(safe-area-inset-top)); padding-bottom: env(safe-area-inset-bottom); }
  .viewer__stage { grid-row: 1; margin-inline: 0; }
  .viewer__navs { grid-row: 2; display: flex; justify-content: flex-start; gap: var(--s-3); padding-top: var(--s-4); }
  .viewer__nav { position: static; margin: 0; }
  .viewer__bar { grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) {
  .viewer::before, .viewer__bar, .viewer__nav { transition: none; }
}
.carousel:not(.carousel--locked) .slide, .carousel.is-unlocked .slide { cursor: pointer; }
.cursor-view {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  padding: 5px 10px; border-radius: 9999px; font-size: 12px; letter-spacing: var(--track); color: #fff;
  background: rgba(255, 255, 255, 0.16); -webkit-backdrop-filter: blur(20px) saturate(1.2); backdrop-filter: blur(20px) saturate(1.2);
  opacity: 0; scale: 0.85; transition: opacity 200ms var(--ease-out), scale 260ms var(--ease-out);
}
.cursor-view.is-on { opacity: 1; scale: 1; }

/* ==========================================================================
   Archive
   ========================================================================== */
.archive { padding-block: var(--s-16); }
.archive__title { margin-bottom: var(--s-4); }
.archive__list { display: flex; flex-direction: column; gap: var(--s-4); }
.archive__row {
  position: relative; padding-top: var(--s-4); align-items: center;
  color: inherit; text-decoration: none; transition: opacity 400ms var(--ease-out);
}
.archive__name { grid-column: span 6; }
.archive__type { grid-column: span 5; display: flex; flex-wrap: wrap; gap: 4px; }
.archive__year { grid-column: span 1; text-align: right; color: var(--white-50); }
.archive .tag { font-size: 12px; padding: 4px 9px; }
@supports (text-box: trim-both cap alphabetic) { .archive .tag { padding-block: 7px; } }
a.archive__row .archive__name::after { content: " ↗"; opacity: 0.64; }
/* Linked rows: dim siblings on hover */
.archive__list:has(a.archive__row:hover) .archive__row:not(:hover),
.archive__list:has(a.archive__row:focus-visible) .archive__row:not(:focus-visible) { opacity: 0.4; }

/* Cursor-following preview image */
.cursor-image {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  width: 88px; height: 88px; border-radius: 16px; overflow: hidden;
  opacity: 0; transform: translate3d(-200px, -200px, 0) scale(0.6) rotate(-4deg);
  transition: opacity 260ms var(--ease-out);
  will-change: transform;
}
.cursor-image img, .cursor-image video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Project preview variant */
.cursor-image.is-preview { width: 280px; height: 174px; border-radius: 8px; }
.cursor-image video[hidden], .cursor-image img[hidden] { display: none; }
.archive__row[data-cursor-image], .archive__row[data-cursor-video] { cursor: default; }
@media (hover: none) {
  .archive__row[data-cursor-image], .archive__row[data-cursor-video] { cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .archive__list:has(.archive__row.is-previewing) .archive__row:not(.is-previewing) { opacity: 0.45; }
}
/* Rows with previews: dim siblings on hover */
@media (hover: hover) {
  .archive__list:has(.archive__row[data-cursor-image]:hover, .archive__row[data-cursor-video]:hover) .archive__row:not(:hover) { opacity: 0.45; }
}
.cursor-image.is-on { opacity: 1; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-4);
  padding: var(--s-8) var(--margin);
  font-size: var(--t-body); color: var(--white-80);
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--white); }

/* ==========================================================================
   About page
   ========================================================================== */
.clock { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); width: 120px; }
.clock svg { width: 120px; height: 120px; overflow: visible; filter: drop-shadow(0 9px 9px rgba(0, 0, 0, 0.15)); }
.clock__label { font-size: var(--t-body); text-align: center; }
.clock__time { color: rgba(255, 255, 255, 0.64); font-variant-numeric: tabular-nums; }
.clock__date { color: rgba(255, 255, 255, 0.64); }
.clock__face-text { font-family: var(--font-body); fill: #fff; letter-spacing: 0.04em; }
.clock__numeral { font-family: var(--font-display); font-weight: 400; fill: #fff; }
/* Night lume (script §6) */
.clock__lume { opacity: 0; transition: opacity 2.4s var(--ease-out); pointer-events: none; }
.clocks.is-night .clock__lume { opacity: 0.85; }

.clocks { display: flex; gap: var(--s-8); align-items: flex-start; }
.clock { margin: 0; }

.about-intro { padding: calc(66px + var(--s-16)) var(--margin) var(--s-24); }

/* Left column: clock, sticky */
.about-intro__aside {
  grid-column: 1 / span 5;
  position: sticky; top: calc(66px + var(--s-8));
  align-self: start;
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-16);
}
.about-practice { display: flex; flex-wrap: wrap; gap: 6px; }

/* Right column: bio */
.about-intro__main {
  grid-column: 7 / -1;
  display: flex; flex-direction: column; gap: var(--s-16);
  padding-top: 6px;
}
.about-bio p { font-size: 18px; line-height: 1.5; letter-spacing: var(--track); }
.about-bio p + p { margin-top: 1em; }
.about-label {
  font-size: var(--t-body); font-weight: 400; line-height: 1.36; letter-spacing: var(--track);
  color: rgba(255, 255, 255, 0.64);
  margin-bottom: var(--s-4);
}
.about-list { display: flex; flex-direction: column; }
.about-list li { position: relative; padding-block: var(--s-3) var(--s-4); font-size: var(--t-body-l); line-height: 1.45; letter-spacing: var(--track); }
.about-list li .rule { top: 0; }
.about-links { display: inline-flex; gap: 16px; }
.about-cta { font-size: 18px; line-height: 1.5; letter-spacing: var(--track); }

.text-link {
  text-decoration: none; white-space: nowrap;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  padding-bottom: 1px;
  transition: background-size 400ms var(--ease-out);
}
.text-link:hover { background-size: 0% 1px; background-position: 100% 100%; }

/* Client logo tiles */
.logos { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.logo-tile {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--white-5);
  transition: background-color 300ms var(--ease-out);
}
.logo-tile:hover { background: var(--white-10); }
.logo-tile img { width: calc(var(--w, 30%) * 1.15); flex: none; height: auto; transition: transform 500ms var(--ease-out); }
.logo-tile--full img { width: 115%; max-width: none; }
.logo-tile:hover img { transform: scale(1.04); }
.js .logos[data-reveal] .logo-tile {
  opacity: 0; transform: translateY(10px); filter: blur(10px);
  transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out), filter 1000ms var(--ease-out), background-color 300ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms + 120ms);
}
.js .logos[data-reveal] .logo-tile img { opacity: 0; transform: scale(0.9); transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out); transition-delay: calc(var(--i, 0) * 55ms + 260ms); }
.js .logos[data-reveal].is-in .logo-tile { opacity: 1; transform: none; filter: none; }
.js .logos[data-reveal].is-in .logo-tile img { opacity: 1; transform: none; }
.js .logos[data-reveal].is-in .logo-tile:hover img { transform: scale(1.04); transition-delay: 0ms; }
/* Focus reveal: blur and slight scale resolving to sharp */
.js [data-reveal="focus"] > * {
  opacity: 0; filter: blur(16px); transform: scale(0.97);
  transition: opacity 900ms var(--ease-out), filter 1300ms var(--ease-out), transform 1300ms var(--ease-out);
}
.js [data-reveal="focus"] > *:nth-child(2) { transition-delay: 180ms; }
.js [data-reveal="focus"].is-in > * { opacity: 1; filter: none; transform: none; }
/* Faster word reveal for long paragraphs */
.js .about-bio [data-reveal="words"] .w > span,
.js .about-cta[data-reveal="words"] .w > span { transition-duration: 800ms; transition-delay: calc(var(--i, 0) * 9ms + var(--d, 0ms)); }

/* ==========================================================================
   Reveal animations (only when JS is running)
   ========================================================================== */
.js [data-reveal="words"] .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.js [data-reveal="words"] .w > span {
  display: inline-block;
  transform: translate3d(0, 105%, 0);
  backface-visibility: hidden;
  will-change: transform;
  transition: transform 900ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 28ms + var(--d, 0ms));
}
.js [data-reveal="words"].is-in .w > span { transform: none; }

.js [data-reveal="fade"] {
  opacity: 0; transform: translateY(10px);
  transition: opacity 800ms var(--ease-out), transform 800ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.js [data-reveal="fade"].is-in { opacity: 1; transform: none; }

.js .rule { transform: scaleX(0); transition: transform 1200ms var(--ease-out); }
.js .is-in > .rule, .js .rule.is-in, .js .is-in .rule { transform: scaleX(1); }

.js .carousel[data-reveal="slide"] .slide {
  opacity: 0; transform: translateX(24px);
  transition: opacity 900ms var(--ease-out), transform 1100ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms + 150ms);
}
.js .carousel[data-reveal="slide"].is-in .slide { opacity: 1; transform: none; }
/* Carousel focus reveal */
.js .carousel[data-reveal="slide"] .carousel__viewport {
  filter: blur(22px) saturate(1.25);
  transform: scale(1.02);
  transition: filter 1300ms var(--ease-out) 120ms, transform 1300ms var(--ease-out) 120ms;
}
.js .carousel[data-reveal="slide"].is-in .carousel__viewport { filter: none; transform: none; }

@media (max-width: 767px) {
  .js .project__header [data-reveal="fade"].project__summary,
  .js .project__header [data-reveal="fade"].project__credits,
  .js .project__header .project__summary[data-reveal="fade"],
  .js .project__header .project__credits[data-reveal="fade"] { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
  .js [data-reveal] .w > span,
  .js [data-reveal="fade"],
  .js .rule,
  .js .carousel[data-reveal="slide"] .carousel__viewport { filter: none !important; transform: none !important; transition: none !important; }
  .js .carousel[data-reveal="slide"] .slide,
  .js [data-reveal="focus"] > *,
  .js .logos[data-reveal] .logo-tile,
  .js .logos[data-reveal] .logo-tile img { transform: none !important; opacity: 1 !important; transition: none !important; }
  .toggle__thumb, .slide img, .slide video { transition: none; }
}

/* ==========================================================================
   Tablet — 8 col
   ========================================================================== */
@media (max-width: 1199px) {
  .project { padding-block: var(--s-16); }
  /* Name and year on one line; summary and credits below */
  .project__header { align-items: baseline; }
  .project__name { grid-column: 1 / 7; grid-row: 1; margin-bottom: var(--s-4); }
  .project__year { grid-column: 7 / -1; grid-row: 1; margin-top: 0; text-align: right; white-space: nowrap; }
  .project__summary { grid-column: 1 / span 5; grid-row: 2; }
  .project__header { grid-template-rows: auto auto 1fr; }
  .project__header > .project__name { grid-row: 1; }
  .project__people { grid-column: 6 / -1; grid-row: 2 / span 2; }
  .project__tags { grid-column: 1 / span 5; grid-row: 3; }
  .project__title { display: contents; }
  /* Protected projects: form sits under the carousel (script §4b) */
  .project > .lock { margin: var(--s-4) var(--margin) 0; }
  .project > .lock.is-done { margin-top: 0; }
  /* Archive: name and year on one line, tags below */
  .archive__row { align-items: baseline; }
  .archive__name { grid-column: 1 / 7; grid-row: 1; }
  .archive__year { grid-column: 7 / -1; grid-row: 1; }
  .archive__type { grid-column: 1 / -1; grid-row: 2; margin-top: var(--s-4); }
  .archive__row { padding-block: 9px; }
  .archive__year { font-size: 12px; }
  .archive__type { margin-top: 3px; gap: 0; }
  .archive .tag { background: none; padding: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5); border-radius: 0; text-box: normal; }
  .archive .tag + .tag::before { content: "·"; margin: 0 6px; }
  /* About: clock in the first two columns */
  .about-intro__aside { grid-column: 1 / span 2; top: calc(66px + var(--s-8)); }
  .clocks { flex-direction: column; gap: var(--s-8); }
  .about-intro__main { grid-column: 3 / -1; }
}

/* ==========================================================================
   Mobile — 4 col
   ========================================================================== */
@media (max-width: 767px) {
  .topbar { padding-block: max(12px, env(safe-area-inset-top)) 12px; }
  .site-header { padding-top: calc(12px + 36px + var(--s-16)); padding-bottom: var(--s-8); }
  .site-header--bare { padding-top: calc(12px + 36px + var(--s-8)); padding-bottom: 0; }
  .nav { grid-template-columns: auto 1fr auto; column-gap: 8px; }
  .nav__name { font-size: 18px; }
  .nav__hi { font-size: 13px; }
  .toggle { justify-self: center; padding: 3px; border-radius: 11px; }
  .toggle__thumb { top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 2); }
  .toggle__opt { min-width: 0; padding: 4px 8px; font-size: 13px; }
  /* Name and contact link show only at the top; once scrolled, just the centred toggle stays */
  .topbar.is-hidden { transform: none; }
  .topbar { transition: background-color 400ms var(--ease-out); }
  .topbar.is-scrolled { background-color: transparent; pointer-events: none; }
  .topbar.is-scrolled::before { opacity: 0; }
  .topbar.is-scrolled .nav__surname { max-width: 5.5em; opacity: 1; }
  .nav__name, .nav__hi { transition: opacity 300ms var(--ease-out); }
  .topbar.is-scrolled :is(.nav__name, .nav__hi) { opacity: 0; }
  .nav .toggle { transition: transform 500ms var(--ease-out), background-color 400ms var(--ease-out), box-shadow 400ms var(--ease-out); }
  .topbar.is-scrolled .toggle {
    pointer-events: auto;
    transform: translateX(var(--toggle-shift, 0px)) scale(1.15);
    background-color: color-mix(in srgb, var(--page-bg) 55%, rgba(255, 255, 255, 0.1));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }

  .project { padding-block: var(--s-8) var(--s-16); }
  .project__header { align-items: baseline; }
  .project__header { grid-template-rows: none; }
  .project__name { grid-column: 1 / 4; grid-row: 1; margin-bottom: var(--s-3); }
  .project__year { grid-column: 4 / 5; grid-row: 1; margin-top: 0; text-align: right; white-space: nowrap; }
  .project__summary { grid-column: 1 / -1; grid-row: 2; }
  /* Role stays visible; team collapses with the summary */
  .project__people { display: contents; }
  .project__role { grid-column: 1 / -1; grid-row: 2; margin-top: calc(var(--s-3) * -0.5); font-size: 13px; color: rgba(255, 255, 255, var(--meta)); }
  /* Summary and team collapse behind "Info" */
  .project__more {
    grid-column: 4 / 5; grid-row: 3; justify-self: end; align-self: center; display: inline-block; margin-top: var(--s-3); white-space: nowrap; position: relative; z-index: 1;
    padding: 0 0 1px; border: 0; cursor: pointer; color: rgba(255, 255, 255, 0.86); font-size: 13px; letter-spacing: var(--track);
    background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  }
  .project__summary, .project__credits {
    grid-column: 1 / -1; overflow: hidden; max-height: 0; opacity: 0; margin-top: 0;
    transition: max-height 500ms var(--ease-out), opacity 400ms var(--ease-out), margin-top 500ms var(--ease-out);
  }
  .project__summary { grid-row: 4; }
  .project__credits { grid-row: 5; }
  .project__header.is-open .project__summary { max-height: 240px; opacity: 1; margin-top: var(--s-3); }
  .project__header.is-open .project__credits { max-height: 120px; opacity: 1; margin-top: var(--s-2); }
  /* Single-line, horizontally scrolling tag row */
  .project__tags {
    grid-column: 1 / -1; grid-row: 3; align-self: center; margin-top: var(--s-3); gap: 4px; padding-right: 48px;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0;
  }
  .project__tags.is-overflowing {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 76px), transparent calc(100% - 48px));
    mask-image: linear-gradient(to right, #000 calc(100% - 76px), transparent calc(100% - 48px));
  }
  .project__tags::-webkit-scrollbar { display: none; }
  .project__tags .tag { flex: none; }
  /* Reveal "Info" with the tag row */
  .js .project__header .project__more { opacity: 0; transform: translateY(10px); transition: opacity 800ms var(--ease-out), transform 800ms var(--ease-out); }
  .js .project__header:has(.project__tags.is-in) .project__more { opacity: 1; transform: none; transition-delay: var(--d, 0ms); }
  /* Smaller tags on mobile */
  .tag { font-size: 12px; padding: 5px 10px; }
  @supports (text-box: trim-both cap alphabetic) { .tag { padding-block: 8px; } }
  .archive__type, .about-practice { gap: 4px; }
  .carousel { margin-top: var(--s-6); }
  .video-control { right: 14px; bottom: 14px; }

  .archive__row { align-items: baseline; }
  .archive__name { grid-column: 1 / 4; grid-row: 1; }
  .archive__year { grid-column: 4 / 5; grid-row: 1; }
  .archive__type { grid-column: 1 / -1; grid-row: 2; margin-top: var(--s-4); }
  .archive__row { padding-block: 9px; }
  .archive__year { font-size: 12px; }
  .archive__type { margin-top: 3px; gap: 0; }
  .archive .tag { background: none; padding: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5); border-radius: 0; text-box: normal; }
  .archive .tag + .tag::before { content: "·"; margin: 0 6px; }

  .about-intro { padding-top: calc(60px + var(--s-8)); padding-bottom: var(--s-16); }
  .about-intro__aside { grid-column: 1 / -1; grid-row: 2; position: static; margin: var(--s-16) 0 0; }
  .about-intro__main { grid-row: 1; }
  .clocks { flex-direction: row; gap: var(--s-6); }
  .about-intro__main { grid-column: 1 / -1; gap: var(--s-12, 48px); }
  .about-bio p, .about-cta { font-size: 16px; }
  .clock, .clock svg { width: 110px; }
  .clock svg { height: 110px; }
  .clock__label p { white-space: nowrap; }
  .clock__label { font-size: 12px; }
  .logos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logo-tile { aspect-ratio: 352 / 248.5; overflow: hidden; }
  .logo-tile img { width: var(--w, 30%); }
  .logo-tile--full img { width: 100%; }

  .site-footer { flex-direction: row; justify-content: space-between; align-items: center; padding-block: var(--s-6); }
}
