/* ==========================================================================
   Selected work: horizontal project showcase
   - Default: a native horizontal scroller with scroll-snap, arrow buttons
     and keyboard support.
   - Large mouse-driven screens: JS adds .is-pinned; the section sticks to the
     viewport and vertical scrolling moves the track sideways
     (scripts/features/work-scroller.js).
   ========================================================================== */

.work {
  position: relative;
}

.work__viewport {
  position: relative;
  padding: var(--section-y) 0;
}

.work__track {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  padding: 10px var(--gutter);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
}

.work__track::-webkit-scrollbar {
  display: none;
}

.work__track:focus-visible {
  outline-offset: -5px;
}

/* ---- Intro column (first item in the track) ---- */
.work__intro {
  flex: 0 0 min(82vw, 520px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-snap-align: start;
}

.work__intro .section-title {
  font-size: var(--heading-md);
}

.work__lede {
  max-width: 400px;
  margin: 0;
  font-size: var(--text-lead);
  color: var(--color-muted);
}

.work__hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 500 9px / 1 var(--font-body);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-muted);
}

.work__index-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-underline-offset: 6px;
}

/* ---- Outro column (last item in the track) ---- */
.work__outro {
  flex: 0 0 min(70vw, 360px);
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-snap-align: end;
}

.work__outro-link {
  font-family: var(--font-display);
  font-stretch: var(--stretch-display);
  font-weight: var(--weight-display);
  font-size: var(--text-xl);
  line-height: 1.25;
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
  text-underline-offset: 8px;
  text-decoration-thickness: 1px;
}

/* ---- Arrow controls + position label ---- */
.work__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin: 28px var(--gutter) 0;
}

.work__arrow {
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-ink);
  border-radius: 50%;
  background: var(--color-paper);
  color: var(--color-ink);
  font-size: 20px;
  cursor: pointer;
  transition: transform 140ms var(--ease), background-color 160ms;
}

.work__arrow:disabled {
  opacity: .35;
  cursor: default;
}

.work__arrow:active:not(:disabled) {
  transform: scale(.95);
}

@media (hover: hover) and (pointer: fine) {
  .work__arrow:hover:not(:disabled) { background: var(--color-stone); }
}

.work__position {
  min-width: 132px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- Progress bar under the track ---- */
.work__progress {
  height: 1px;
  margin: 20px var(--gutter) 0;
  background: var(--color-line);
}

.work__progress i {
  display: block;
  height: 100%;
  background: var(--color-ink);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---- Pinned mode (large screens) ---- */
.work.is-pinned .work__viewport {
  position: sticky;
  top: 0;
  box-sizing: border-box;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 90px 0 112px;
  overflow: hidden;
}

/* ScrollSmoother: the row is held in place by work-scroller.js instead */
.has-smooth .work.is-pinned .work__viewport {
  position: relative;
  will-change: transform;
}

.work.is-pinned .work__track {
  overflow: visible;
  scroll-snap-type: none;
  will-change: transform;
}

.work.is-pinned .work__intro {
  flex-basis: min(34vw, 440px);
  align-self: center;
}

.work.is-pinned .card {
  flex-basis: min(44vw, 620px, 60vh);
}

.work.is-pinned .work__controls {
  position: absolute;
  right: 0;
  bottom: 48px;
}

.work.is-pinned .work__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  margin-top: 0;
}

/* ==========================================================================
   Project card
   ========================================================================== */

.card {
  flex: 0 0 min(82vw, 560px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-snap-align: center;
}

/* Preview tile: a small browser window showing a screenshot of the site.
   It is a real link to the project; on mouse devices it tilts toward the
   pointer (scripts/features/cards.js).
   Browser-bar color variants: tile--dark | tile--stone | tile--taupe | tile--outline */
.tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: 0;   /* keep the 16:10 shape; don't grow to fit the tall screenshot */
  flex: none;
  display: flex;
  flex-direction: column;
  border: 1px solid rgb(var(--ink-rgb) / .18);
  border-radius: var(--radius-box);
  text-decoration: none;
  cursor: pointer;
  transition: transform 200ms var(--ease), box-shadow 200ms;
}

.tile--dark    { background: var(--color-ink);    color: var(--color-paper); }
.tile--stone   { background: var(--color-stone);  color: var(--color-ink); }
.tile--taupe   { background: var(--color-taupe);  color: var(--color-ink); }
.tile--outline { background: var(--color-paper);  color: var(--color-ink); }

/* Browser bar: three dots, project number, category */
.tile__bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.tile__dots {
  flex: none;
  width: 36px;
  height: 8px;
  background: radial-gradient(circle, currentColor 3px, transparent 3.5px) 0 50% / 12px 8px repeat-x;
  opacity: .55;
}

.tile__note {
  margin-left: auto;
  text-align: right;
}

.tile--dark .tile__num {
  color: var(--color-stone);
}

/* Screenshot: a tall capture of the whole page, cropped to the tile and
   anchored to the top. On hover it scrolls down the page (below); when the
   pointer leaves it glides back up. */
.tile__shot {
  flex: 1 1 0px;   /* take the space under the bar, never the image's own height */
  height: 0;
  min-height: 0;
  width: 100%;
  object-fit: cover;
  object-position: center top;
  background: var(--color-mist);
  transform-origin: top center;
  transition: transform 900ms var(--ease), object-position 1200ms var(--ease);
}

.tile__visit {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-ink);
  border-radius: 50%;
  background: var(--color-paper);
  color: var(--color-ink);
  font-size: 18px;
}

@media (hover: hover) and (pointer: fine) {
  .tile:hover {
    box-shadow: 0 30px 60px -30px rgba(30, 30, 30, .4);
  }

  /* Scroll through the site: slow and steady down, after a short pause.
     Taller screenshots set a longer --scroll-time on the <img>. */
  .tile:hover .tile__shot {
    object-position: center bottom;
    transition: transform 900ms var(--ease), object-position var(--scroll-time, 7s) cubic-bezier(.35, 0, .3, 1) 250ms;
  }

  .tile__visit {
    transition: transform 300ms var(--ease), background-color 200ms;
  }

  .tile:hover .tile__visit {
    background: var(--color-stone);
    transform: rotate(45deg);
  }
}

/* No tilt, zoom or auto-scroll when motion is paused or reduced */
html.motion-off .tile,
html.is-keyboard .tile,
html.motion-off .tile__shot,
html.motion-off .tile__visit {
  transform: none !important;
}

html.motion-off .tile__shot {
  object-position: center top !important;
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .tile__shot,
  .tile__visit {
    transform: none !important;
  }

  .tile__shot {
    object-position: center top !important;
  }
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Status label sits above the title */
.card__header {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.card__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 500;
  line-height: 1.3;
}

.card__text {
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-muted);
}

.card__link {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: var(--text-sm);
  letter-spacing: .04em;
  text-underline-offset: 5px;
  overflow-wrap: anywhere;
}

.card__link svg {
  flex-shrink: 0;
  transition: transform .3s var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .card__link:hover svg { transform: translate(3px, -3px); }
}

@media (max-width: 700px) {
  .work__intro { flex-basis: min(76vw, 380px); }
  .tile__note { display: none; }
}

/* ---- Swipe cue (sideways-scrolling layout only) ----
   A pill in the intro column with a dot that slides like a finger, and a
   soft fade on the right edge of the row. Once the visitor swipes, the pill
   dims and the fade goes. */
.work__swipe {
  display: none;
  align-items: center;
  gap: 12px;
  align-self: flex-start;
  width: max-content;
  margin: 0;
  padding: 10px 18px;
  border: 1px solid var(--color-ink);
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  transition: opacity 400ms ease;
}

.work__swipe-dot {
  position: relative;
  width: 34px;
  height: 10px;
}

/* the "finger": a dot that slides left and fades, like a swipe */
.work__swipe-dot::before {
  content: '';
  position: absolute;
  top: 1px;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: swipe-hint 1.6s var(--ease) infinite;
}

/* the track it moves along */
.work__swipe-dot::after {
  content: '';
  position: absolute;
  top: 4.5px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgb(var(--ink-rgb) / .25);
}

@keyframes swipe-hint {
  0%   { transform: translateX(0); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateX(-26px); opacity: 0; }
}

/* touch screens and narrower windows; mouse users on wide screens have the arrows */
@media (hover: none), (max-width: 1000px) {
  .work:not(.is-pinned) .work__swipe {
    display: flex;
  }

  /* the pill takes over from the plain text hint */
  .work:not(.is-pinned) .work__hint {
    display: none;
  }
}

/* more cards are off to the right */
.work:not(.is-pinned):not(.is-end) .work__track {
  -webkit-mask-image: linear-gradient(to right, #000 82%, transparent);
  mask-image: linear-gradient(to right, #000 82%, transparent);
}

.work.is-swiped .work__swipe {
  opacity: .35;
}

.work.is-swiped .work__swipe-dot::before {
  animation: none;
  opacity: 1;
}

html.motion-off .work__swipe-dot::before { animation: none; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .work__swipe-dot::before { animation: none; opacity: 1; }
}
