/* ======================================================================
   /work/ project scroller. Names on the left + full-bleed image on the right.
   All classes namespaced under .work-scroller__* (+ .work-search for the search
   UI) to isolate from the rest.
   ====================================================================== */

/* ============ Search trigger (top-right floating button) ============ */
/* Clears the shared right side bar (88px, z-index 2000), which would otherwise
   paint over this button and swallow its clicks. */
.work-search-btn {
  position: fixed;
  top: clamp(16px, 2.4vh, 28px);
  right: calc(var(--sidebar-w, 88px) + clamp(16px, 2vw, 28px));
  z-index: 20;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  color: #0a0a0a;
  cursor: pointer;
  padding: 0;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.work-search-btn:hover,
.work-search-btn:focus-visible {
  background: #0a0a0a;
  color: #ffffff;
  border-color: #0a0a0a;
  outline: none;
}

/* ============ Search overlay ============ */
/* Above the shared side bars and their menu overlay (max z-index 2100). */
.work-search {
  position: fixed;
  inset: 0;
  z-index: 2200;
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(80px, 10vh, 140px) clamp(16px, 4vw, 48px) clamp(32px, 4vh, 64px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.work-search[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.work-search__panel {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.work-search__field {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.work-search__icon {
  color: #666;
}

.work-search__input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 400;
  color: #0a0a0a;
}

.work-search__input::placeholder {
  color: #999;
}

.work-search__close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: #0a0a0a;
  cursor: pointer;
  padding: 0;
  border-radius: 999px;
  transition: background-color 180ms ease;
}

.work-search__close:hover,
.work-search__close:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}

.work-search__results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
}

.work-search__result {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 160ms ease;
}

.work-search__result:hover,
.work-search__result:focus-visible,
.work-search__result.is-highlighted {
  background: rgba(0, 0, 0, 0.05);
  outline: none;
}

.work-search__thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  object-fit: cover;
  background: #e9e9e6;
}

.work-search__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.work-search__title {
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  line-height: 1.15;
  color: #0a0a0a;
  letter-spacing: -0.01em;
}

.work-search__tags {
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.work-search__empty {
  margin: 0;
  padding: 24px 18px;
  text-align: center;
  color: #777;
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: 0.9rem;
}

/* Discipline chips (mutex, combined AND with the text input) */
.work-search__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px;
}

.work-search__chip {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: #0a0a0a;
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.work-search__chip:hover,
.work-search__chip:focus-visible {
  background: rgba(0, 0, 0, 0.05);
  outline: none;
}

.work-search__chip.is-active {
  background: #0a0a0a;
  color: #ffffff;
  border-color: #0a0a0a;
}

.work-search__chip.is-active:hover,
.work-search__chip.is-active:focus-visible {
  background: #0a0a0a;
  color: #ffffff;
}

@media (max-width: 820px) {
  .work-search__chips {
    padding: 0 12px;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }
  .work-search__chip {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 7px 13px;
    letter-spacing: 0.1em;
  }
}

/* Lock page scroll while the overlay is open */
body.work-search-open {
  overflow: hidden;
}

@media (max-width: 820px) {
  .work-search {
    padding: 72px 16px 24px;
  }
  .work-search__panel { gap: 16px; }
  .work-search__field { padding: 10px 12px; }
  .work-search__result { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .work-search,
  .work-search-btn,
  .work-search__close,
  .work-search__result {
    transition: none;
  }
}

.work-scroller {
  position: relative;
}

.work-scroller__pin {
  position: relative;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  padding-left: clamp(24px, 4vw, 64px);
  padding-right: 0;                 /* image column goes flush to the viewport edge */
  box-sizing: border-box;
  overflow: hidden;
}

/* ============ LEFT: names list (Hayler fade stays here) ============ */

.work-scroller__col--list {
  position: relative;
  height: 100%;
  padding-right: clamp(24px, 4vw, 64px);
  display: flex;
  align-items: center;
}

.work-scroller__viewport {
  position: relative;
  width: 100%;
  height: 100%;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%);
  overflow: hidden;
}

.work-scroller__list {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  will-change: transform;
  /* JS sets an initial transform so the first item lands at the viewport
     vertical center; without this it would start a half-item below the line. */
}

.work-scroller__item {
  padding: clamp(8px, 1.2vh, 16px) 0;
  font-family: 'Galatea', 'Times New Roman', serif;
  font-size: clamp(1.8rem, 4.6vw, 4.8rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: #0a0a0a;
  opacity: 0.15;
  transition: opacity 0.3s ease;
}

.work-scroller__item.is-active {
  opacity: 1;
}

.work-scroller__item a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  padding: 2px 0;
}

.work-scroller__item a:hover,
.work-scroller__item a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 6px;
  outline: none;
}

/* ============ RIGHT: image stack, image keeps full presence (no fade on edges) === */

.work-scroller__col--media {
  position: relative;
  height: 100%;
  background: #e9e9e6;              /* soft fallback while images swap */
  overflow: hidden;
}

.work-scroller__media {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity 450ms ease;
  will-change: opacity;
}

.work-scroller__media.is-active {
  opacity: 1;
  pointer-events: auto;
}

.work-scroller__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* ============ MOBILE (≤820px): single column, static stacked cards ============ */

@media (max-width: 820px) {
  /* Pin + scrub también en mobile. Layout vertical: imagen 50vh arriba,
     lista 50vh abajo, scrubing centra cada nombre en la mitad del bloque inferior. */
  .work-scroller__pin {
    height: 100vh;
    height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: 50% 50%;
    gap: 0;
    padding: 0;
    overflow: hidden;
  }

  .work-scroller__col--media { order: 0; }
  .work-scroller__col--list { order: 1; }

  /* Image column: fills the top half, same crossfade logic as desktop */
  .work-scroller__col--media {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;              /* cancel the earlier aspect-ratio rule */
    background: #e9e9e6;
    overflow: hidden;
    padding: 0;
  }

  .work-scroller__media {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 450ms ease;
  }

  .work-scroller__media.is-active {
    opacity: 1;
    pointer-events: auto;
  }

  /* List column: bottom half with mask fade, names scroll through its center */
  .work-scroller__col--list {
    position: relative;
    height: 100%;
    padding: 0;
    display: block;
  }

  .work-scroller__viewport {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 15%, #000 85%, transparent 100%);
            mask-image: linear-gradient(to bottom, transparent 0, #000 15%, #000 85%, transparent 100%);
    overflow: hidden;
  }

  .work-scroller__list {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* no transform override, JS/GSAP controls it */
  }

  .work-scroller__item {
    opacity: 0.15;
    font-size: clamp(1.3rem, 5.5vw, 2.1rem);
    padding: 8px clamp(16px, 5vw, 24px);
    transition: opacity 0.25s ease;
  }

  .work-scroller__item.is-active {
    opacity: 1;
  }

  /* The hero menu button is anchored at right:16px and runs ~74px wide, so it
     occupies the first 90px. Sit clear of it, not under it. */
  .work-search-btn {
    top: clamp(14px, 2vh, 24px);
    right: 102px;
  }
}

/* ============ Reduced motion: static accessible layout ============ */
@media (prefers-reduced-motion: reduce) {
  .work-scroller__pin {
    height: auto;
    overflow: visible;
  }
  .work-scroller__col--list {
    height: auto;
    padding: 0 clamp(16px, 5vw, 24px);
  }
  .work-scroller__viewport {
    position: static;
    height: auto;
    -webkit-mask-image: none;
            mask-image: none;
    overflow: visible;
  }
  .work-scroller__list {
    position: static;
    top: auto;
    transform: none !important;
  }
  .work-scroller__item {
    opacity: 1;
    transition: none;
  }
  .work-scroller__col--media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    height: auto;
    background: #e9e9e6;
    overflow: hidden;
    padding: 0;
  }
  .work-scroller__media {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: none;
  }
  .work-scroller__media.is-active {
    opacity: 1;
    pointer-events: auto;
  }
}
