/* Expertise rail: six compact paper cards on one strip.
   Desktop experience — the section pins and scrolling down slides the strip left
   (HorizontalRail); the card at the reading position lifts off the page.
   Static mode — the same strip, swiped or scrolled sideways, snapping card by card. */

.rail__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
}

.rail__head .section-head {
  flex: 1;
}

.rail__head .title {
  max-width: 24ch;
}

/* Progress: a crease that fills with fern as the strip travels. */
.rail__progress {
  position: relative;
  flex: none;
  width: min(12rem, 24%);
  height: 2px;
  margin-bottom: var(--space-3);
  background: var(--color-border);
}

.rail__progress-fill {
  position: absolute;
  inset: 0;
  background: var(--color-primary);
  transform: scaleX(var(--rail-progress, 0));
  transform-origin: 0 50%;
}

.rail__viewport {
  margin-top: var(--space-6);
  padding-block: var(--space-4) var(--space-7);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary) transparent;
}

.rail__viewport:focus-visible {
  outline-offset: calc(-1 * var(--focus-width));
}

/* The strip starts and ends on the content column's edges. */
.rail__track {
  --rail-inset: max(var(--gutter), calc((100vw - var(--size-content)) / 2));
  display: flex;
  gap: var(--space-5);
  width: max-content;
  padding-inline: var(--rail-inset);
}

/* ─── The card: illustration on top, the field and its services below ─── */

.expertise {
  display: grid;
  grid-template-rows: auto 1fr;
  flex: none;
  width: clamp(16.5rem, 21vw, 21rem);
  scroll-snap-align: start;
  scroll-margin-inline-start: var(--rail-inset);
  transform: translateY(calc(var(--focus, 0) * -10px));
  transition: box-shadow var(--duration-base) var(--ease-fold);
}

.expertise {
  --ear-scale: 0;
}

.expertise[data-active] {
  --ear-scale: 1;
  box-shadow: var(--paper-shadow-lift);
}

/* The art was flat-fielded to --paper-050, the card surface: contained, never cropped. */
.expertise__art {
  height: clamp(7.5rem, 22vh, 13rem);
  padding: var(--space-3) var(--space-3) 0;
}

.expertise__art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.expertise__body {
  display: grid;
  align-content: start;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-5) var(--space-5);
}

.expertise__index {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.2;
  color: var(--color-accent-text);
}

.expertise__title {
  min-height: 2.2em;
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
  line-height: 1.1;
}

.points li {
  padding-block: 5px;
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  line-height: 1.35;
}

/* ─── Desktop experience: the pinned stage ─── */

html[data-mode="experience"] .section--expertise {
  padding-top: clamp(var(--space-8), 10vh, var(--space-9));
}

html[data-mode="experience"] .rail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100vh;
  padding-top: var(--header-height);
}

html[data-mode="experience"] .rail__viewport {
  overflow: hidden;
  scroll-snap-type: none;
}

html[data-mode="experience"] .rail__track {
  will-change: transform;
}

@media (max-height: 820px) {
  html[data-mode="experience"] .rail__viewport {
    margin-top: var(--space-4);
    padding-block: var(--space-3) var(--space-5);
  }

  html[data-mode="experience"] .expertise__title {
    font-size: var(--text-lg);
  }
}

/* ─── Static mode ─── */

html[data-mode="static"] .rail__progress {
  display: none;
}

@media (max-width: 820px) {
  .rail__head .title {
    max-width: 18ch;
  }

  .expertise {
    width: min(80vw, 20rem);
  }

  .expertise__art {
    height: 10rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .expertise {
    transform: none;
  }
}
