/* ==========================================================================
   case-study.css
   Styles used only on case study pages: progress nav, video hero,
   spec grid, image grids, the horizontal gallery and the end block.
   Every value comes from tokens.css.
   ========================================================================== */

/* ==========================================================================
   Progress navigation (left edge)
   ========================================================================== */
.progress-nav {
  --nav-panel: var(--surface-0-translucent);

  position: fixed;
  top: 50%;
  left: var(--space-5);
  z-index: var(--z-progress-nav);
  transform: translateY(-50%);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

/* When it sits over a light band, js/scroll-nav.js adds this class
   and the ink tokens flip so the lines stay visible */
.progress-nav.is-on-light {
  --ink-primary: var(--ink-inverse-primary);
  --ink-secondary: var(--ink-inverse-secondary);
  --ink-tertiary: var(--ink-inverse-secondary);
  --nav-panel: var(--surface-inverse-translucent);
}

/* On hover the nav gets a soft panel so the labels read over content */
.progress-nav:hover,
.progress-nav:focus-within {
  background-color: var(--nav-panel);
  -webkit-backdrop-filter: blur(var(--header-blur));
  backdrop-filter: blur(var(--header-blur));
}

.progress-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  /* Half the gap above and below each line gives --space-3 between lines
     and a bigger target for the mouse */
  padding-block: calc(var(--space-3) / 2);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

/* Fixed-width slot so labels do not shift when a line grows */
.progress-nav__mark {
  display: flex;
  width: var(--progress-line-width-active);
}

.progress-nav__line {
  display: block;
  width: var(--progress-line-width);
  height: var(--progress-line-height);
  border-radius: var(--radius-pill);
  background-color: var(--ink-tertiary);
}

.progress-nav__link.is-active .progress-nav__line {
  width: var(--progress-line-width-active);
  background-color: var(--ink-primary);
}

.progress-nav__label {
  color: var(--ink-secondary);
  font-size: var(--text-micro);
  line-height: var(--leading-micro);
  letter-spacing: var(--tracking-micro);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
}

.progress-nav__link.is-active .progress-nav__label,
.progress-nav__link:hover .progress-nav__label {
  color: var(--ink-primary);
}

.progress-nav:hover .progress-nav__label,
.progress-nav:focus-within .progress-nav__label {
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: no-preference) {
  .progress-nav,
  .progress-nav__line,
  .progress-nav__label {
    transition:
      width var(--transition-mid) var(--ease-out),
      background-color var(--transition-mid) var(--ease-out),
      color var(--transition-mid) var(--ease-out),
      opacity var(--transition-mid) var(--ease-out),
      visibility var(--transition-mid) var(--ease-out);
  }
}

/* The only width rule in v1: the nav needs room beside the content.
   Media queries cannot read custom properties, so 1023px is written here. */
@media (max-width: 1023px) {
  .progress-nav {
    display: none;
  }
}

/* ==========================================================================
   Hero (video placeholder)
   ========================================================================== */
.cs-hero {
  padding-top: calc(var(--header-height) + var(--space-5));
}

/* Full-bleed, inset from the window edge by the gutter */
.cs-hero__media {
  position: relative;
  margin-inline: var(--gutter);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: var(--placeholder-fill);
}

.cs-hero__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Dark gradient behind the title so it stays readable on any footage */
.cs-hero__scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  pointer-events: none;
}

.cs-hero__text {
  position: absolute;
  left: var(--space-7);
  bottom: var(--space-7);
  right: calc(var(--icon-button-size) + var(--space-7) * 2);
}

.cs-hero__descriptor {
  margin-top: var(--space-3);
  color: var(--ink-secondary);
}

.cs-hero__toggle {
  position: absolute;
  right: var(--space-7);
  bottom: var(--space-7);
}

/* Show the pause icon while playing, the play icon while paused */
.cs-hero__toggle .icon-play { display: none; }
.cs-hero__toggle[aria-pressed="true"] .icon-play { display: block; }
.cs-hero__toggle[aria-pressed="true"] .icon-pause { display: none; }

/* ==========================================================================
   Overview spec grid
   ========================================================================== */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
}

.spec-grid dd {
  margin-top: var(--space-2);
}

.cs-summary {
  margin-top: var(--space-8);
  max-width: var(--measure);
}

/* ==========================================================================
   Content blocks
   ========================================================================== */
/* Paragraph block under a section heading */
.cs-prose {
  margin-top: var(--space-6);
}

.cs-figure,
.cs-grid {
  margin-top: var(--space-8);
}

.cs-grid {
  display: grid;
  gap: var(--space-5);
}

.cs-grid--2 { grid-template-columns: repeat(2, 1fr); }
.cs-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* ==========================================================================
   Solution gallery (horizontal scroll)
   ========================================================================== */
.gallery {
  --gallery-inset: max(var(--gutter), calc((100% - var(--max-width)) / 2));

  position: relative;
  margin-top: var(--space-8);
}

.gallery__track {
  display: flex;
  gap: var(--space-5);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-inline: var(--gallery-inset);
  scroll-padding-inline: var(--gallery-inset);
  scrollbar-width: none;       /* hide the native bar; our progress bar replaces it */
  border-radius: var(--radius-lg);
}

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

.gallery__item {
  flex: 0 0 var(--gallery-item-width);
  scroll-snap-align: center;
}

.gallery__item .ph {
  height: var(--gallery-item-height);
}

/* Edge fades: shown only on a side that still has more to scroll */
.gallery::before,
.gallery::after {
  content: "";
  position: absolute;
  top: 0;
  z-index: 1;
  width: var(--space-10);
  height: var(--gallery-item-height);
  pointer-events: none;
  opacity: 0;
}

.gallery::before {
  left: 0;
  background: linear-gradient(to right, var(--surface-0), transparent);
}

.gallery::after {
  right: 0;
  background: linear-gradient(to left, var(--surface-0), transparent);
}

.gallery.can-scroll-left::before,
.gallery.can-scroll-right::after {
  opacity: 1;
}

/* Arrow buttons, vertically centred on the screens */
.gallery__btn {
  position: absolute;
  top: calc(var(--gallery-item-height) / 2);
  z-index: 2;
  transform: translateY(-50%);
}

.gallery__btn--prev { left: var(--gutter); }
.gallery__btn--next { right: var(--gutter); }

/* Thin progress bar under the gallery */
.gallery__progress {
  height: var(--gallery-progress-height);
  margin-top: var(--space-6);
  overflow: hidden;
  border-radius: var(--radius-pill);
  background-color: var(--hairline);
}

.gallery__progress-fill {
  height: 100%;
  background-color: var(--accent-current);
  transform: scaleX(0);
  transform-origin: left center;
}

@media (prefers-reduced-motion: no-preference) {
  .gallery::before,
  .gallery::after {
    transition: opacity var(--transition-mid) var(--ease-out);
  }
}

/* ==========================================================================
   End block
   ========================================================================== */
.cs-end__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: var(--space-6);
  align-items: start;
  margin-top: var(--space-7);
}

.cs-end__item .label {
  margin-bottom: var(--space-3);
}

.cs-end__item .actions {
  margin-top: 0;
}

.cs-end__item > .link-arrow {
  color: var(--ink-primary);
  font-size: var(--text-h4);
  line-height: var(--leading-h4);
  letter-spacing: var(--tracking-h4);
}
