/* Trionn-style "Selected work" — HORIZONTAL edition.
   Section pins to the viewport; cards travel horizontally on scroll (GSAP
   ScrollTrigger pin + scrub, self-hosted). Behaviour in assets/js/selected-work.js. */

/* the Works wrapper sits between two light sections, so it carries the same
   light tone and no vertical padding — the sections meet flush and their
   divider lines line up. */
#works {
  /* white at the top so it meets Key Facts flush, easing to the light grey
     the brands strip starts from */
  background: linear-gradient(to bottom, #FFFFFF 0%, #FFFFFF 70%, #EFEEEC 100%);
  padding-top: 0;
  padding-bottom: 0;
}

#tw-selected-work {
  background: transparent;
  --tw-bg: #efeeec;
  --tw-ink: #1a1a1a;
  --tw-ink-soft: #6b6b6b;
  --tw-green: #35E07F;   /* the site's accent green */
  --tw-line: rgba(0, 0, 0, 0.28);   /* separator lines between projects */
  --tw-mono: Figtree, "Figtree Fallback", system-ui, sans-serif;
  position: relative;
  z-index: 10;   /* above the next section's sticky heading while pinned */
  background: var(--tw-bg);
  color: var(--tw-ink);
  font-family: inherit;
  width: 100%;
  overflow: hidden;
}

/* :where() keeps specificity at 0 so the class rules below always win */
:where(#tw-selected-work *) { box-sizing: border-box; margin: 0; padding: 0; }

.tw-grid {
  height: 100vh;
  position: relative;
}
/* thin vertical divider BETWEEN items -- rides along with the track */
.tw-sep {
  flex: 0 0 1px;
  align-self: stretch;
  background: var(--tw-line);
}

/* ---- intro block: first item of the horizontal track; it slides off to
        the left together with the cards as you scroll ---- */
.tw-intro {
  flex: 0 0 auto;
  width: min(38vw, 640px);
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 2vw 0 6vw;
}
.tw-title {
  font-size: clamp(38px, 4.2vw, 68px);
  line-height: 1.06;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #121212;
}
.tw-title .tw-line { display: block; overflow: hidden; padding-bottom: 0.16em; margin-bottom: -0.16em; }
/* No transform in the base rule: GSAP owns the char position entirely (a CSS
   baseline gets absorbed into GSAP's transform cache as a permanent offset).
   The hidden start state lives only in the no-GSAP fallback path below. */

.tw-viewall {
  margin-top: 3em;
  align-self: flex-start;
  font-family: var(--tw-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tw-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 2.2em;
  padding-bottom: 0.9em;
  position: relative;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s ease 0.45s, transform 0.8s cubic-bezier(0.19,1,0.22,1) 0.45s;
}
#tw-selected-work.tw-inview .tw-viewall { opacity: 1; transform: none; }
.tw-viewall::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--tw-green);
  transform-origin: right;
  transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}
.tw-viewall:hover::after { transform: scaleX(0.35); }
.tw-viewall .tw-arrow { color: var(--tw-green); transition: transform 0.45s cubic-bezier(0.65,0,0.35,1); }
.tw-viewall:hover .tw-arrow { transform: translateX(8px); }

/* progress hint: 01 / 03 counter bottom-left (stays put while track slides) */
.tw-count {
  position: absolute;
  left: 6vw;
  bottom: 6vh;
  z-index: 2;
  font-family: var(--tw-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--tw-ink-soft);
}
.tw-count .tw-current { color: var(--tw-ink); }

/* ---- full-width horizontal track (intro + cards) ---- */
.tw-right {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  height: 100vh;
  z-index: 1;
}
.tw-track {
  display: flex;
  align-items: center;
  gap: 2.3vw;   /* separators sit mid-gap, so total card spacing stays ~4.6vw */
  padding: 0 8vw 0 0;
  height: 100vh;   /* separators stretch the full section height */
  will-change: transform;
}
/* no-GSAP fallback: native horizontal scroll */
#tw-selected-work:not([data-gsap]) .tw-right { overflow-x: auto; scrollbar-width: thin; }

.tw-card {
  flex: 0 0 auto;
  width: min(56vw, 880px);
  display: block;
  text-decoration: none;
  color: inherit;
}
.tw-media {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  aspect-ratio: 16 / 10.6;
  background: #dcdad6;
  clip-path: inset(0 100% 0 0);           /* wipe reveal, left→right */
  transition: clip-path 1.1s cubic-bezier(0.65, 0, 0.35, 1);
}
.tw-card.tw-inview .tw-media { clip-path: inset(0 0% 0 0); }
.tw-par { position: absolute; inset: 0 -8%; }  /* oversized so parallax never shows edges */
.tw-par > img, .tw-par > video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  transition: transform 1.2s cubic-bezier(0.19, 1, 0.22, 1);
}
.tw-card:hover .tw-par > img, .tw-card:hover .tw-par > video { transform: scale(1.01); }

.tw-meta { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-top: 1.5rem; }
.tw-name {
  font-size: clamp(22px, 1.9vw, 30px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #121212;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease 0.25s, transform 0.7s cubic-bezier(0.19,1,0.22,1) 0.25s;
}
.tw-desc {
  margin-top: 0.5rem;
  max-width: 34ch;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--tw-ink-soft);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease 0.35s, transform 0.7s cubic-bezier(0.19,1,0.22,1) 0.35s;
}
.tw-card.tw-inview .tw-name, .tw-card.tw-inview .tw-desc { opacity: 1; transform: none; }

.tw-explore {
  flex-shrink: 0;
  font-family: var(--tw-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 1.6em;
  padding-bottom: 0.8em;
  position: relative;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.7s ease 0.45s;
}
.tw-card.tw-inview .tw-explore { opacity: 1; }
.tw-explore::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--tw-green);
  transform-origin: right;
  transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}
.tw-card:hover .tw-explore::after { transform: scaleX(0.35); }
.tw-explore .tw-arrow { color: var(--tw-green); transition: transform 0.45s cubic-bezier(0.65,0,0.35,1); }
.tw-card:hover .tw-explore .tw-arrow { transform: translateX(8px); }

/* ---- the terminal "view all" slide: a calm text panel that closes the track ---- */
.tw-end {
  flex: 0 0 auto;
  width: min(42vw, 640px);
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.7rem;
  padding: 0 5vw 0 3vw;
  text-decoration: none;
  color: inherit;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.tw-end.tw-inview { opacity: 1; }
/* only the no-GSAP/mobile path uses a CSS transform; on desktop GSAP owns Y */
#tw-selected-work:not([data-gsap]) .tw-end {
  transform: translateY(26px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.19, 1, 0.22, 1);
}
#tw-selected-work:not([data-gsap]) .tw-end.tw-inview { transform: none; }

.tw-end-eyebrow {
  font-family: var(--tw-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tw-ink-soft);
}
.tw-end-title {
  font-size: clamp(27px, 2.5vw, 42px);
  line-height: 1.16;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: #121212;
  max-width: 15ch;
}
.tw-end-cta {
  margin-top: 0.6rem;
  align-self: flex-start;
  font-family: var(--tw-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tw-ink);
  display: inline-flex;
  align-items: center;
  gap: 2.2em;
  padding-bottom: 0.9em;
  position: relative;
}
.tw-end-cta::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--tw-green);
  transform-origin: right;
  transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}
.tw-end:hover .tw-end-cta::after { transform: scaleX(0.35); }
.tw-end-cta .tw-arrow { color: var(--tw-green); transition: transform 0.45s cubic-bezier(0.65,0,0.35,1); }
.tw-end:hover .tw-end-cta .tw-arrow { transform: translateX(8px); }

/* ---- mobile: refined vertical stack, no pin ---- */
@media (max-width: 900px) {
  .tw-grid { height: auto; }
  .tw-grid::before { display: none; }
  .tw-count { display: none; }
  .tw-right { overflow: visible; height: auto; }
  .tw-track { flex-direction: column; align-items: stretch; gap: 0; padding: 0 6vw 11vh; height: auto; }
  .tw-sep { display: none; }
  .tw-intro { width: 100%; height: auto; padding: 11vh 0 2vh; }
  .tw-title { font-size: clamp(34px, 9vw, 46px); }
  .tw-viewall { margin-top: 2.2em; }

  /* each project is a clean block separated by a thin rule */
  .tw-card {
    width: 100%; margin: 0;
    padding: 36px 0 40px;
    border-top: 1px solid var(--tw-line);
  }
  .tw-card:first-of-type { border-top: none; padding-top: 12px; }
  .tw-media { border-radius: 8px; }

  /* title on the left with the Explore arrow beside it, description below */
  .tw-meta {
    flex-direction: row; align-items: flex-start; justify-content: space-between;
    gap: 1.1rem; margin-top: 1.25rem;
  }
  .tw-name { font-size: 21px; }
  .tw-desc { max-width: 30ch; margin-top: 0.5rem; font-size: 14.5px; line-height: 1.55; }
  .tw-explore { opacity: 1; flex-shrink: 0; padding-top: 4px; font-size: 11px; }

  .tw-end {
    width: 100%; height: auto;
    padding: 40px 0 8px;
    border-top: 1px solid var(--tw-line);
    gap: 1.2rem;
  }
  .tw-end-title { font-size: clamp(25px, 7.5vw, 34px); max-width: 20ch; }
  .tw-end-cta { opacity: 1; }
}
