/* Shared styles for project case-study pages (site/work/*).
   Uses brand.css and system.css tokens exclusively. */

/* ── Safety net: nothing ever runs off-screen ───────────────────────────── */
html, body { overflow-x: clip; }

@media (max-width: 639px) {
  :root {
    --gut: 16px;
  }
}

body {
  line-height: 1.625;
}

/* ── Container ────────────────────────────────────────────────────────────── */
.work-wrap {
  width: min(100% - 2 * var(--gut, 32px), 1200px);
  margin-inline: auto;
}

/* Override system.css full-viewport section sizing (desktop and mobile) */
:root main > section.work-section {
  height: auto;
  min-height: 0;
}

:root main > section.work-section > .work-wrap {
  height: auto;
}

/* ── Title block ──────────────────────────────────────────────────────────── */
/* Top padding clears the fixed nav + breathing room */
:root main > section.work-head {
  padding: calc(var(--nav, 72px) + 48px) 0 var(--s-7, 56px);
}

@media (max-width: 639px) {
  :root main > section.work-head {
    padding: calc(var(--nav, 60px) + 24px) 0 var(--s-5, 32px);
  }
}

/* H1 big style: clamp(44px, 8vw, 128px), weight 800, tight tracking, 2-line max */
.work-head h1 {
  font-size: clamp(44px, 8vw, 128px);
  line-height: 1.0;
  font-weight: 800;
  letter-spacing: -0.03em;
  /* overflow hidden is set on .sw-line by motion.js for split lines */
}

/* Keep line wrappers clipping the rising inner span */
.work-head h1 .sw-line {
  display: block;
  overflow: hidden;
}
.work-head h1 .sw-line-inner {
  display: block;
}

.work-desc {
  margin-top: var(--s-4, 20px);
  font-size: var(--t-lead, 1.125rem);
  line-height: 1.5;
  max-width: 60ch;
  color: var(--ink);
  word-break: break-word;
}

.work-meta {
  margin-top: var(--s-3, 12px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2, 8px);
  font-size: var(--t-small, 0.875rem);
  line-height: 1.5;
  color: var(--muted);
  word-break: break-word;
}

.work-meta a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--dur) var(--ease);
  /* Keep link reachable on mobile */
  display: inline-flex;
  align-items: center;
}

.work-meta a:hover,
.work-meta a:focus-visible {
  text-decoration-color: currentColor;
}

@media (max-width: 639px) {
  .work-meta a {
    padding-block: 11px;
  }
}

/* ── Gallery ──────────────────────────────────────────────────────────────── */
:root main > section.work-gallery {
  padding: 0 0 var(--s-9, 80px);
}

@media (max-width: 639px) {
  :root main > section.work-gallery {
    padding: 0 0 var(--s-7, 56px);
  }
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2, 8px);
  align-items: start;
}

@media (min-width: 720px) {
  .work-grid--ads {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .work-item--wide {
    grid-column: 1 / -1;
  }
}

.work-item {
  margin: 0;
  border-radius: var(--r-sm, 8px);
  overflow: clip;
  /* Surface-coloured background while image loads */
  background: #ede6dc;
}

.work-item img,
.work-item video {
  display: block;
  width: 100%;
  height: auto;
  /* Ensure images are always visible even without JS */
  opacity: 1;
}

/* Gallery images: visible by default; GSAP overrides during animation */
.work-item[data-reveal="clip"] {
  clip-path: inset(0% 0% 0% 0%);
}

/* ── Horizontal strip (ad pages only) ───────────────────────────────────── */
.work-hstrip-wrap {
  overflow: hidden;
  position: relative;
}

.work-hstrip {
  display: flex;
  gap: 24px;
  /* width set by JS */
  will-change: transform;
}

.work-hstrip__card {
  flex: 0 0 auto;
  height: 42vh;
  border-radius: var(--r-sm, 8px);
  overflow: clip;
  background: #ede6dc;
  /* width set by JS from natural aspect ratio */
  display: flex;
  align-items: stretch;
}

.work-hstrip__card img {
  display: block;
  height: 100%;
  width: auto;
  object-fit: cover;
}

@media (max-width: 639px) {
  /* Strip renders as normal grid on phones */
  .work-hstrip-wrap {
    overflow: visible;
  }
  .work-hstrip {
    flex-wrap: wrap;
    gap: var(--s-2, 8px);
  }
  .work-hstrip__card {
    height: auto;
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .work-hstrip__card img {
    width: 100%;
    height: auto;
  }
}

/* ── Next-project takeover ───────────────────────────────────────────────── */
.work-takeover {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #17130f;
  overflow: clip;
  padding: var(--s-9, 80px) var(--gut, 32px);
  cursor: pointer;
  text-align: center;
  gap: var(--s-5, 32px);
}

.work-takeover__cover {
  width: 40vw;
  max-width: 560px;
  min-width: 200px;
  border-radius: var(--r-md, 12px);
  overflow: clip;
  background: #2a2420;
  /* will-change applied by JS */
}

@media (max-width: 639px) {
  .work-takeover__cover {
    width: 80vw;
  }
}

.work-takeover__cover img {
  display: block;
  width: 100%;
  height: auto;
}

.work-takeover__name {
  font-size: clamp(44px, 8vw, 128px);
  line-height: 1.0;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f6f2ec;
  /* overflow hidden wraps are set by motion.js split */
}

.work-takeover__name .sw-line {
  display: block;
  overflow: hidden;
}
.work-takeover__name .sw-line-inner {
  display: block;
}

.work-takeover__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2, 8px);
  font-size: var(--t-small, 0.875rem);
  font-weight: 500;
  color: #f6f2ec;
  opacity: 0.6;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: opacity 0.2s ease;
  margin-top: var(--s-2, 8px);
}

.work-takeover__link:hover,
.work-takeover__link:focus-visible {
  opacity: 1;
}

/* ── Original next-project section (kept for no-JS / fallback) ──────────── */
:root main > section.work-next {
  padding: var(--s-8, 64px) 0;
}

@media (max-width: 639px) {
  :root main > section.work-next {
    padding: var(--s-7, 56px) 0;
  }
}

.work-next h2 {
  font-size: var(--t-h2);
  line-height: 1.08;
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  margin-bottom: var(--s-6, 40px);
}

@media (max-width: 639px) {
  .work-next h2 {
    margin-bottom: var(--s-5, 32px);
  }
}

.work-next__card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5, 32px);
  align-items: center;
  padding: var(--s-4, 20px);
  border-radius: var(--r-lg, 16px);
  background: var(--p-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: border-color var(--m-out, 120ms) var(--m-ease, var(--ease));
}

@media (min-width: 720px) {
  .work-next__card {
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    gap: var(--s-6, 40px);
    padding: var(--s-5, 32px);
  }
}

.work-next__media {
  border-radius: var(--r-md, 12px);
  overflow: clip;
  background: var(--surface);
}

.work-next__media img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform var(--m-image-out, 400ms) var(--m-ease, var(--ease));
}

@media (hover: hover) and (pointer: fine) {
  .work-next__card:hover {
    border-color: var(--line-strong);
  }
  .work-next__card:hover .work-next__media img {
    transform: scale(1.03);
    transition-duration: var(--m-image, 600ms);
  }
}

.work-next__body {
  display: grid;
  gap: var(--s-3, 12px);
  align-content: center;
  justify-items: start;
}

.work-next__title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: var(--t-h3);
  line-height: 1.18;
  letter-spacing: var(--display-tracking);
}

.work-next__desc {
  color: var(--muted);
  font-size: var(--t-body);
  line-height: 1.5;
  max-width: 48ch;
}

.work-next__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2, 8px);
  margin-top: var(--s-2, 8px);
  font-size: var(--t-small, 0.875rem);
  font-weight: 500;
  color: var(--ink);
}

/* ── Ground-shift section (before takeover) ────────────────────────────── */
/* data-bg="#17130f" is handled by motion.js; this is a CSS assist */

/* ── Parallax utility ──────────────────────────────────────────────────── */
/* Columns with data-parallax need overflow on their parent */
.work-grid--ads {
  overflow: clip;
}

/* ── Reduced motion defaults ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .work-head h1 .sw-line-inner {
    transform: none !important;
  }
  .work-item,
  .work-next__media img,
  .work-takeover__cover,
  .work-hstrip__card {
    transition: none;
    transform: none !important;
    opacity: 1 !important;
    clip-path: none !important;
  }
}

/* Strip fills the screen while pinned: full-height frame, cards centred below the nav, large enough to read. */
@media (min-width: 640px) {
  .work-hstrip-wrap { height: 100vh; height: 100svh; display: flex; align-items: center; padding-top: var(--nav, 72px); box-sizing: border-box; }
  .work-hstrip { align-items: center; }
  .work-hstrip__card, .work-hstrip__card img { height: min(68vh, 640px); width: auto; }
}
@media (min-width: 640px) {
  /* Cards take the ad's own shape (no side crop), and the strip's images sit at their real size: the vertical clip reveal can't settle inside a sideways strip. */
  .work-hstrip__card { width: auto !important; flex: 0 0 auto; overflow: hidden; }
  .work-hstrip__card img { width: auto !important; object-fit: contain; transform: none !important; clip-path: none !important; }
}

/* Glass nav floats 14px down and is 56px tall (bottom at 70px): keep the title clear of it on phones. */
@media (max-width: 639px) {
  :root main > section.work-head { padding-top: 104px; }
}

/* the logo never wraps in the five-link glass nav (same as the home page) */
.nav__logo { white-space: nowrap; }
