/* ============================================================
   Gabriel Genesis — Portfolio
   Shared stylesheet for all pages (index + /work/*.html)
   ============================================================ */

:root {
  --bg: oklch(0.98 0.003 60);
  --text: oklch(0.18 0.005 60);
  --text-secondary: oklch(0.5 0.008 60);
  --text-muted: oklch(0.45 0.008 60);
  --text-dim: oklch(0.55 0.008 60);
  --text-emphasis: oklch(0.15 0.005 60);
  --text-about: oklch(0.28 0.008 60);
  --text-nda: oklch(0.6 0.008 60);
  --footer-text: oklch(0.3 0.008 60);
  --accent: rgb(52, 168, 141);
  --hairline: oklch(0.18 0.005 60 / 0.12);
  --tile-1: oklch(0.9 0.002 60);
  --tile-2: oklch(0.86 0.002 60);
  --tile-3: oklch(0.74 0.002 60);
  --tile-dark: oklch(0.18 0.005 60);

  --max-width: 1280px;
  --pad-x: clamp(20px, 5vw, 48px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; max-width: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Public Sans', sans-serif;
  min-height: 100vh;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent); color: var(--bg); }

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: clamp(20px, 4vw, 28px);
}
.nav__logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--text);
}
.nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(16px, 4vw, 36px);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.nav__links a {
  text-decoration: none;
  color: var(--text);
  transition: color 0.15s ease;
}
.nav__links a:hover { color: var(--accent); }

/* Hero / title section (shared between homepage + case studies) */
.hero {
  padding-top: clamp(40px, 8vw, 64px);
}
.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: clamp(56px, 12vw, 120px);
  flex-wrap: wrap;
}
.meta-row__label {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.meta-row__contact {
  text-align: right;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  line-height: 1.7;
}
.back-link {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--accent); }

.headline {
  position: relative;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: clamp(30px, 7vw, 54px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  max-width: 1080px;
  margin: 0 0 clamp(48px, 10vw, 96px);
  color: var(--text);
}
.headline .accent { color: var(--accent); }

.eyebrow {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Selected work list (homepage) */
.work-list { padding-bottom: 40px; }
.work-row {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(20px, 4vw, 48px);
  padding: 32px 0;
  border-top: 1px solid var(--hairline);
  background-color: transparent;
  transition: background-color 250ms ease;
}
.work-list .work-row:last-child { border-bottom: 1px solid var(--hairline); }
.work-row:hover,
.work-row:focus-visible {
  background-color: oklch(0.18 0.005 60 / 0.03);
}

.work-row__num {
  flex: 0 0 auto;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  color: var(--text-dim);
}
.work-row__image {
  flex: 1.68 1 200px;
  min-width: 180px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  background: var(--tile-1);
  container-type: size;
}
.work-row__image img,
.work-row__image video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.work-row__image video {
  position: absolute;
  inset: 0;
  border: 0;
  pointer-events: none;
}
/* Video embeds (Vimeo/YouTube) can't use object-fit, so oversize the
   iframe and center-crop it to fully cover the tile like a background video. */
.work-row__image iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, calc(100cqh * 16 / 9));
  height: max(100cqh, calc(100cqw * 9 / 16));
  transform: translate(-50%, -50%);
  border: 0;
  pointer-events: none;
}
.is-media-loading iframe,
.is-media-loading video {
  clip-path: inset(0 100% 0 0);
}
.is-media-ready iframe,
.is-media-ready video {
  z-index: 1;
  animation: media-reveal-swipe 250ms linear forwards;
}
@keyframes media-reveal-swipe {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.work-row__title-block { flex: 1.5 1 160px; min-width: 160px; }
.work-row__title {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  font-size: 26px;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.work-row__role { font-size: 14px; line-height: 1.5; color: var(--text-muted); }

.work-row__desc { flex: 2.2 1 240px; min-width: 220px; }
.work-row__desc p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 10px;
}
p.work-row__stat {
  font-size: 16px;
  line-height: 1.6;
  color: #000;
  font-weight: 700;
  margin: 0 0 14px;
}
.work-row__stat span { font-weight: 400; }
.work-row__more { font-size: 15px; color: var(--accent); font-weight: 700; }

/* About */
.about-body {
  font-size: clamp(17px, 2.4vw, 20px);
  line-height: 1.7;
  color: var(--text-about);
  max-width: 760px;
}
.about-body p { margin: 0 0 1em; }
.about-body p:last-child { margin-bottom: 0; }

.hairline { border-top: 1px solid var(--hairline); }

/* Footer */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: clamp(32px, 8vw, 48px);
  padding-bottom: 56px;
  border-top: 1px solid var(--hairline);
}
.footer__contact {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  font-size: 15px;
  color: var(--footer-text);
}
.footer__contact a {
  text-decoration: none;
  color: inherit;
  transition: color 0.15s ease;
}
.footer__contact a:hover { color: var(--accent); }
.footer__status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* Copyright bar */
.copyright {
  padding-top: 20px;
  padding-bottom: 32px;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.copyright__mark {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Case-study description block */
.description-block {
  max-width: 820px;
  padding: 40px 0;
  border-top: 1px solid var(--hairline);
}
.description-block__role {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.description-block p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 24px;
}
.description-block p:last-child { margin-bottom: 0; }
.description-block .stat { color: var(--text-emphasis); font-weight: 700; }
.description-block .nda { color: var(--text-nda); }

/* Gallery grid — max 2 items per row, each tile sizes itself via aspect-ratio
   so future stills/videos of different dimensions can drop in without
   reworking the layout. Add a size modifier (see below) per tile as needed. */
.gallery { max-width: 820px; padding-top: 16px; padding-bottom: 56px; }
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(4px, 1.4vw, 16px);
}
@media (max-width: 680px) {
  .gallery__grid { grid-template-columns: 1fr; }
}
.gallery__tile {
  position: relative;
  background: var(--tile-1);
  overflow: hidden;
  container-type: size;
  aspect-ratio: 16 / 9;
}
.gallery__tile--alt { background: var(--tile-2); }
.gallery__tile--dark { background: var(--tile-dark); }
/* Size/shape modifiers — mix and match per tile as new assets come in. */
.gallery__tile--full { grid-column: 1 / -1; }
.gallery__tile--wide { aspect-ratio: 21 / 9; }
.gallery__tile--square { aspect-ratio: 1 / 1; }
.gallery__tile--tall { aspect-ratio: 4 / 5; }
.gallery__tile-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, monospace;
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}
.gallery__tile img,
.gallery__tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  pointer-events: none;
}
/* Video embeds (Vimeo/YouTube) can't use object-fit, so oversize the
   iframe and center-crop it to fully cover the tile like a background video. */
.gallery__tile iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, calc(100cqh * 16 / 9));
  height: max(100cqh, calc(100cqw * 9 / 16));
  transform: translate(-50%, -50%);
  border: 0;
  pointer-events: none;
}

/* Video / embed skeleton — injected by motion.js while media loads */
.media-skeleton {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--tile-1);
  pointer-events: none;
  overflow: hidden;
}
.media-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    oklch(0.95 0.003 60 / 0.55) 45%,
    oklch(0.97 0.003 60 / 0.75) 50%,
    oklch(0.95 0.003 60 / 0.55) 55%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: media-skeleton-shimmer 1.6s ease-in-out infinite;
}
.is-media-ready .media-skeleton {
  animation: media-skeleton-wipe-out 250ms linear forwards;
}
@keyframes media-skeleton-wipe-out {
  from { clip-path: inset(0 0 0 0); }
  to { clip-path: inset(0 0 0 100%); }
}
@keyframes media-skeleton-shimmer {
  to { transform: translateX(100%); }
}

/* Hero video (optional autoplay reel — see /assets/js/ or embed docs) */
.hero-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tile-dark);
  margin-bottom: clamp(32px, 6vw, 56px);
}
.hero-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ============================================================
   Motion system
   Shared by all pages via assets/js/motion.js. Everything here is
   additive/progressive: with JS disabled or reduced-motion set,
   content is fully visible and static — nothing depends on it.
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hero headline: one continuous left-to-right mask reveal that
   travels from the very first word to the very last, in reading
   order. .headline__line is a block wrapper per authored line
   (forces the same two-row layout as before, and lets long lines
   wrap naturally on narrow screens). Each word inside it gets its
   OWN positioned .headline__word box — this matters because a mask
   spanning a whole (possibly wrapped) line clips by raw horizontal
   position, not reading order: if a line wraps into two visual rows,
   words starting at the same x-position on different rows (e.g. the
   first word of each row) would reveal simultaneously. Masking
   per-word avoids that entirely, since each word's clip-path is
   scoped to its own box regardless of which row it wraps onto.
   Inside each word: a .headline__ghost sits in normal flow at 5%
   opacity (defines the word's box + always-visible "watermark" text),
   and a .headline__reveal is an absolutely-positioned, fully-opaque
   duplicate clipped with clip-path. Every word shares one
   GPU-accelerated clip-path animation; each word's own
   animation-duration/-delay (set inline, roughly proportional to its
   length) chain back-to-back with zero gap and zero overlap, so each
   word's sweep picks up the instant the previous one finishes —
   reading as a single unbroken sweep through the whole sentence. */
.headline__line {
  display: block;
}
.headline__word {
  position: relative;
  display: inline-block;
}
.headline__ghost {
  opacity: 0.05;
}
.headline__reveal {
  position: absolute;
  inset: 0;
  opacity: 1;
  clip-path: inset(0 100% 0 0);
  animation-name: headline-mask-reveal;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  animation-duration: 0.14s;
  animation-delay: 0.1s;
}
@keyframes headline-mask-reveal {
  to { clip-path: inset(0 0 0 0); }
}

/* Skip the mask-reveal on repeat visits within the same browser session
   (e.g. navigating back from a project page) — .no-hero-replay is added
   synchronously by an inline script in index.html before first paint,
   so the headline just renders in its finished state with no flash. */
.no-hero-replay .headline__reveal {
  animation: none;
  clip-path: inset(0 0 0 0);
}
.no-hero-replay .headline__ghost {
  opacity: 0;
}

/* Scroll reveal: fade in + slide up into place.
   Defaults (25px / 500ms / no delay) match the CSS var fallbacks
   below; motion.js only overrides them when data-reveal-* attrs
   are present on an element. */
[data-reveal] {
  opacity: 0;
  transform: translateY(var(--reveal-distance, 25px));
  transition:
    opacity var(--reveal-duration, 500ms) cubic-bezier(0.16, 1, 0.3, 1),
    transform var(--reveal-duration, 500ms) cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Animated underline: a left-to-right "stroke" on hover/focus.
   Applied to nav links, back-link, and footer links. */
.link-underline {
  position: relative;
}
.link-underline::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 250ms ease;
}
.link-underline:hover::after,
.link-underline:focus-visible::after {
  transform: scaleX(1);
}

/* Same underline treatment for "Learn more →", triggered by hovering
   the whole work-row (since the row itself is the clickable link). */
.work-row__more {
  position: relative;
  display: inline-block;
}
.work-row__more::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 250ms ease;
}
.work-row:hover .work-row__more::after,
.work-row:focus-visible .work-row__more::after {
  transform: scaleX(1);
}

@media (prefers-reduced-motion: reduce) {
  .media-skeleton::after {
    animation: none;
    transform: none;
    opacity: 0.35;
  }
  .is-media-loading iframe,
  .is-media-loading video {
    clip-path: inset(0 0 0 0);
  }
  .is-media-ready iframe,
  .is-media-ready video {
    animation: none;
    clip-path: inset(0 0 0 0);
  }
  .is-media-ready .media-skeleton {
    animation: none;
    clip-path: inset(0 0 0 100%);
    opacity: 0;
  }
  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .headline__reveal {
    animation: none;
    clip-path: inset(0 0 0 0);
  }
  .headline__ghost {
    opacity: 0;
  }
  .link-underline::after,
  .work-row__more::after {
    transition: none;
  }
  .work-row {
    transition: none;
  }
}
