/* ==========================================================================
   LinedUp v3 — tokens, page, info drawer
   ========================================================================== */

/* Tiempos (variable, roman only). Headline for the page heading, Text for the drawer. */
@font-face {
  font-family: "Tiempos Headline";
  src: url("fonts/tiempos-headline-vf-roman.woff2") format("woff2-variations"),
       url("fonts/tiempos-headline-vf-roman.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Tiempos Text";
  src: url("fonts/tiempos-text-vf-roman.woff2") format("woff2-variations"),
       url("fonts/tiempos-text-vf-roman.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --ink: #323232;
  --drawer-bg: #323232;
  --drawer-ink: #ffffff;
  --drawer-muted: rgba(255, 255, 255, 0.82);

  --gutter: clamp(20px, 4.4vw, 64px);

  /* Logo widths. Large = intro state, small = resting state top left. */
  --logo-lg: clamp(260px, 48vw, 1200px);
  --logo-sm: 104px;
  /* Height of the small logo's caps (L / U), used to line up INFO */
  --logo-cap: calc(var(--logo-sm) * 0.183);

  --serif-headline: "Tiempos Headline", Georgia, serif;
  --serif-text: "Tiempos Text", Georgia, serif;
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;

  /* Header bar: gutter above the logo caps, gutter below */
  --bar-h: calc(2 * var(--gutter) + var(--logo-cap));
  /* Where the headline starts. Laptops: just under the header bar, leaving more
     height for the carousel. Tablets and phones: lower, with more air (see below). */
  --page-top: var(--bar-h);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.87, 0, 0.13, 1);
}

@media (max-width: 1024px) {
  :root { --page-top: max(calc(var(--gutter) + var(--logo-cap) + 12svh), calc(var(--bar-h) + 16px)); }
}
@media (max-width: 600px) {
  :root { --logo-lg: calc(100vw - 2 * var(--gutter)); --logo-sm: 84px; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: inherit; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

/* ---------- Header (INFO) ---------- */

.info-toggle {
  position: fixed;
  top: var(--gutter);
  right: var(--gutter);
  z-index: 20;
  height: var(--logo-cap);
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-weight: 700;
  font-size: calc(var(--logo-cap) / 0.727);   /* Inter cap height = 0.727em → caps match L U */
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.info-toggle::after {          /* bigger hit area */
  content: "";
  position: absolute;
  inset: -14px -14px;
}

/* When the page scrolls vertically, give the fixed logo + INFO a white bar to sit on
   instead of floating over the content. Same space (one gutter) above and below the
   logo caps; the page starts below it so it never covers the headline at rest. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 15;   /* above the page, below INFO (20), logo (30) and drawer (40) */
  height: var(--bar-h);
  background: var(--bg);
  pointer-events: none;
}

/* ---------- Page ---------- */

.page {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: var(--page-top) var(--gutter)
           calc(clamp(20px, 2.6vw, 40px) + 17px + clamp(16px, 2vw, 32px));   /* bottom: gutter + copyright line + space above it */
}

.headline {
  margin: 0;
  font-family: var(--serif-headline);
  font-weight: 300;
  font-size: clamp(38px, 5vw, 96px);
  line-height: 1.12;
  letter-spacing: -0.025em;
}
.headline span { display: block; }

@media (max-width: 600px) {
  /* Keep the headline on two lines on narrow phones: the longer line ("Powered by
     Shopify.") is ~8.98em wide in Tiempos Headline, so fit it to the content width
     with a little to spare (÷ 9.4). Never larger than the desktop minimum of 38px. */
  .headline { font-size: min(38px, calc((100vw - 2 * var(--gutter)) / 9.4)); }
}

/* ---------- Carousel (see carousel.js) ---------- */

:root {
  --card-gap: clamp(12px, 1.7vw, 24px);
  /* One width for every card; height follows each card's own ratio.
     Also capped by screen height so the page fits without scrolling on laptops. */
  --card-w: clamp(200px, min(24vw, calc((100svh - 420px) / 1.5)), 520px);
  --row-ratio: 1.5;   /* row height = card width × this (2:3 fits; taller media is cropped) */
  --landscape-w: 1.6; /* landscape cards share a wider width (× card width); height follows their ratio.
                         Portrait/square cards use --card-w. */

  /* "uniform" layout only */
  --name-h: 2.75rem;                        /* room for the name under each card */
  /* Everything on the page that isn't the cards: space above the headline, two-line headline,
     space above the carousel, card names, copyright and the space around it */
  --chrome-h: calc(
    var(--page-top)
    + 2.24 * clamp(38px, 5vw, 96px)
    + clamp(24px, 3vw, 44px)
    + var(--name-h)
    + clamp(20px, 2.6vw, 40px) + 17px + clamp(16px, 2vw, 32px)
  );
  /* Every card this tall (width follows its ratio). Capped by the height left on
     screen so the page fits without scrolling; never shorter than 250px. */
  --uniform-h: max(250px, min(calc(var(--card-w) * 1.25), calc(100svh - var(--chrome-h))));
}
@media (min-width: 601px) and (max-width: 1024px) {
  /* Tablets: taller cards than the laptop formula gives, still capped by the height left */
  :root { --uniform-h: max(250px, min(48vw, calc(100svh - var(--chrome-h)))); }
}
@media (min-width: 601px) and (orientation: portrait) {
  /* Portrait tablets and up: plenty of height, so fill what's left on screen
     (capped at 80vw so cards keep some breathing room) */
  :root { --uniform-h: max(250px, min(60vw, calc(100svh - var(--chrome-h)))); }
}
@media (max-width: 600px) {
  /* Phones scroll anyway and the headline wraps differently, so size by width only */
  :root { --uniform-h: calc(var(--card-w) * 1.25); }
}
@media (max-width: 600px) {
  :root { --card-w: 66vw; }
}

.work {
  align-self: center;
  margin: clamp(24px, 3vw, 44px) calc(-1 * var(--gutter)) 0;   /* full bleed */
}

.carousel {
  position: relative;
  height: calc(var(--card-w) * var(--row-ratio));
  outline: none;
  overflow: hidden;
  touch-action: pan-y;        /* vertical page scroll stays native on touch */
  overscroll-behavior-x: contain;
  user-select: none;
  -webkit-user-select: none;
}
.carousel:focus-visible { outline: 1px solid currentColor; outline-offset: -1px; }

.carousel__track {
  position: relative;
  height: 100%;
  margin: 0;
  padding: 0 0 0 var(--gutter);   /* padding-left = where the captioned card sits, read by JS */
  column-gap: var(--card-gap);    /* read by JS */
  list-style: none;
}

.card {
  position: absolute;
  top: 0;
  left: 0;
  /* Never wider than the screen minus the gutters and a peek of the next card */
  /* step = 0 for portrait/square, 1 for landscape */
  --step: clamp(0, (var(--ar) - 1) * 1000, 1);
  width: min(calc(var(--card-w) * (1 + (var(--landscape-w) - 1) * var(--step))), calc(100vw - 2 * var(--gutter) - 32px));
  height: 100%;
  will-change: transform;
}

.card__link {
  display: flex;
  align-items: center;      /* cards centred on the row */
  height: 100%;
}

.card__frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ar);
  max-height: 100%;
  overflow: hidden;
  background: #d9d9d9;
  will-change: transform;
}

/* Name under each card: "uniform" layout only */
.card__name { display: none; }

/* ---------- "uniform" layout: equal heights, name under each card ---------- */

.carousel[data-layout="uniform"] { height: calc(var(--uniform-h) + var(--name-h)); }
.carousel[data-layout="uniform"] .card {
  /* Width always follows the card's ratio, so media is never cropped left/right.
     Wide cards may be wider than a phone screen; that's fine. */
  width: calc(var(--uniform-h) * var(--ar));
}
.carousel[data-layout="uniform"] .card__link { display: block; }
.carousel[data-layout="uniform"] .card__frame {
  height: var(--uniform-h);
  aspect-ratio: auto;
  max-height: none;
  transform-origin: 50% 100%;
}
.carousel[data-layout="uniform"] .card__name {
  display: block;
  margin: 0;
  padding-top: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(14px, 1.1vw, 16px);
  font-weight: 600;
  letter-spacing: -0.005em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 900ms var(--ease-out), transform 1000ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms + 550ms);
}
.carousel[data-layout="uniform"].is-in .card__name { opacity: 1; transform: none; }
.carousel[data-layout="uniform"].is-settled .card__name { transition-delay: 0s; }
.work:has([data-layout="uniform"]) .work__caption { display: none; }

.card__media {
  position: absolute;
  inset: 0 -7%;             /* overscan so horizontal parallax never shows an edge */
  width: 114%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

/* Reveal: frames wipe up, media settles from a zoom (after the welcome animation) */
.card__frame {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1.4s var(--ease-out), opacity 0.6s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms + 150ms), 0s;
}
.card__media {
  scale: 1.35;
  transition: scale 1.8s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms + 150ms);
}
.carousel.is-in .card__frame { clip-path: inset(0 0 0 0); }
.carousel.is-in .card__media { scale: 1; }

/* After the reveal, drop the stagger so hover responds instantly */
.carousel.is-settled .card__frame { transition-delay: 0s; }
.carousel.is-settled .card__media { transition: scale 1.1s var(--ease-out); }

@media (hover: hover) {
  .carousel.is-settled:not(.is-dragging):has(.card__link:hover) .card:not(:hover) .card__frame { opacity: 0.4; }
}
.is-dragging .card__link { pointer-events: none; }

/* Caption (client of the card at the gutter) + copyright */
.work__caption {
  min-height: 1.3em;
  margin-top: clamp(12px, 1.7vw, 24px);
  padding-inline: var(--gutter);
  font-size: clamp(16px, 1.4vw, 21px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.colophon {
  position: absolute;
  right: var(--gutter);
  bottom: clamp(20px, 2.6vw, 40px);
  font-size: 12px;
  opacity: 0.8;
}

/* Native grab cursor on desktop */
@media (hover: hover) and (pointer: fine) {
  .carousel { cursor: grab; }
  .carousel.is-dragging { cursor: grabbing; }
  .carousel a.card__link { cursor: pointer; }
}

@media (prefers-reduced-motion: reduce) {
  .card__frame, .card__media { transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}

/* ---------- Info drawer ---------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 800ms;
}
.drawer.is-open {
  visibility: visible;
  pointer-events: auto;
  transition: none;
}

/* Clickable area left of the panel closes it. Kept clear, as in the design. */
.drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 600ms var(--ease-out);
}
.drawer.is-open .drawer__scrim { background: rgba(0, 0, 0, 0); }

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(50vw, 820px);
  min-width: min(100vw, 480px);
  display: flex;
  flex-direction: column;
  padding: clamp(28px, 3.4vw, 48px) clamp(24px, 4vw, 56px) clamp(28px, 3.4vw, 48px) clamp(24px, 4vw, 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--drawer-bg);
  color: var(--drawer-ink);
  transform: translateX(100%);
  transition: transform 800ms var(--ease-in-out);
}
.drawer.is-open .drawer__panel { transform: none; }

/* Contents follow the panel in, slightly later */
.drawer__body > * {
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 300ms ease, transform 300ms ease;
}
.drawer.is-open .drawer__body > * {
  opacity: 1;
  transform: none;
  transition:
    opacity 700ms var(--ease-out) calc(380ms + var(--i, 0) * 70ms),
    transform 900ms var(--ease-out) calc(380ms + var(--i, 0) * 70ms);
}

.drawer__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.drawer__close {
  position: absolute;
  top: clamp(26px, 3.2vw, 44px);
  right: clamp(24px, 3vw, 36px);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.drawer__close::before,
.drawer__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transition: transform 500ms var(--ease-out);
}
.drawer__close::before { transform: rotate(45deg); }
.drawer__close::after { transform: rotate(-45deg); }
.drawer__close:hover::before { transform: rotate(135deg); }
.drawer__close:hover::after { transform: rotate(45deg); }

.drawer__intro {
  max-width: 30em;
  padding-right: 48px;           /* clear of the close button */
  font-family: var(--serif-text);
  font-weight: 400;
  font-size: clamp(18px, 1.9vw, 30px);
  line-height: 1.4;
  letter-spacing: -0.005em;
}

.drawer__contact {
  margin-top: auto;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  column-gap: clamp(48px, 6vw, 96px);
  font-size: clamp(14px, 1.1vw, 17px);
  line-height: 1.3;
  color: var(--drawer-muted);
}
.drawer__contact address { font-style: normal; display: grid; gap: 14px; align-content: start; }
.drawer__contact ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; align-content: start; }
.drawer__contact a { text-underline-offset: 3px; }
.drawer__contact a:hover { color: var(--drawer-ink); }
.drawer__contact ul a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.drawer__contact ul a:hover { text-decoration: underline; }
.drawer__contact ul svg { width: 0.8em; height: 0.8em; transition: transform 300ms var(--ease-out); }
.drawer__contact ul a:hover svg { transform: translate(2px, -2px); }

.drawer__logo {
  display: block;
  align-self: flex-end;
  width: 104px;
  height: auto;
  margin-top: clamp(24px, 4vw, 56px);
}

@media (max-width: 600px) {
  .drawer__panel { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer__panel, .drawer__body > *, .drawer__scrim { transition-duration: 1ms !important; transition-delay: 0ms !important; }
}
