@layer components {
  /* home carousel: native scroll-snap track; carousel.js adds the controls and the current-entry marker in the featured list */
  .c-carousel { min-inline-size: 0; }
  .c-carousel__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-muted) var(--surface-alt);
    touch-action: pan-x pan-y;
  }
  .c-carousel.is-enhanced .c-carousel__track { scrollbar-width: none; }
  .c-carousel.is-enhanced .c-carousel__track::-webkit-scrollbar { display: none; }
  @media (prefers-reduced-motion: no-preference) {
    .c-carousel__track { scroll-behavior: smooth; }
  }
  .c-carousel__slide { flex: 0 0 100%; min-inline-size: 0; scroll-snap-align: start; padding-inline-end: 1px; }
  /* Slide: the picture with only the title on it, over a scrim. Picture and title share one grid cell, so a long title
     grows the slide instead of being clipped. Every picture box is 3:2 (reserved before the image loads: no layout shift). */
  .c-carousel { position: relative; display: flex; flex-direction: column; }
  .c-carousel__track { flex: 1; }
  .c-carousel__slide { display: grid; }
  .c-slide { position: relative; display: grid; grid-template-areas: "stack"; block-size: 100%; background: var(--surface-inverse); color: var(--on-inverse); }
  .c-slide > * { grid-area: stack; min-inline-size: 0; }
  .c-slide__img { inline-size: 100%; block-size: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--surface-alt); }
  .c-slide__img--empty { background: var(--surface-alt) url("../../brand/placeholder-cover.svg") center / cover no-repeat; }
  .c-slide__body {
    align-self: end; z-index: 1; display: grid; gap: var(--space-2); justify-items: start;
    /* side padding clears the previous/next buttons (centred on the edges) */
    padding: var(--space-12) calc(var(--tap) + var(--space-3)) var(--space-4);
    background: linear-gradient(to top, rgba(17, 20, 23, 0.92) 0%, rgba(17, 20, 23, 0.72) 55%, rgba(17, 20, 23, 0) 100%);
  }
  .c-slide__title { font-size: var(--fs-card-sm); font-weight: var(--fw-medium); line-height: 1.25; letter-spacing: var(--track-card); text-wrap: balance; hyphens: auto; color: var(--on-inverse); }
  .c-slide__title a { color: inherit; text-decoration: none; }
  /* the whole slide is the link */
  .c-slide__title a::after { content: ""; position: absolute; inset: 0; }
  .c-slide:hover .c-slide__title a { text-decoration: underline; text-decoration-thickness: 0.0625em; text-underline-offset: 0.16em; }
  .c-slide:has(.c-slide__title a:focus-visible) { outline: var(--focus-width) solid var(--accent); outline-offset: calc(-1 * var(--focus-width)); }
  .c-slide__title a:focus-visible { outline: none; }
  @media (min-width: 48em) {
    .c-slide__img { aspect-ratio: 16 / 9; }
    .c-slide__body { padding: var(--space-16) calc(var(--tap) + var(--space-6)) var(--space-6); }
    .c-slide__title { font-size: var(--fs-h2); line-height: 1.18; }
  }

  /* Previous / next: on the picture, centred on the left and right edges. Own dark disc with a white ring, so they read on any photo. */
  .c-carousel__controls { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding-inline: var(--space-2); pointer-events: none; }
  .c-carousel__btn { display: grid; place-items: center; inline-size: var(--tap); block-size: var(--tap); padding: 0; border: 2px solid #fff; border-radius: 50%; background: rgba(17, 20, 23, 0.82); color: #fff; touch-action: manipulation; pointer-events: auto; transition: background-color 0.15s; }
  .c-carousel__btn:hover { background: var(--brand-strong); }
  /* ring: dark gap + accent outline, visible on light and dark photos */
  .c-carousel__btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); box-shadow: 0 0 0 var(--focus-offset) var(--ink); }
  @media (min-width: 48em) {
    .c-carousel__controls { padding-inline: var(--space-4); }
  }

  /* Sponsored box pager: pages of 4 cards on a native scroll-snap track, same controls as the carousel (carousel.js). Every page is a grid
     with fixed columns, so a short last page keeps the card width; the pages stretch to the tallest one, so the box never changes height. */
  .c-pager__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-muted) transparent;
    touch-action: pan-x pan-y;
  }
  .c-pager.is-enhanced .c-pager__track { scrollbar-width: none; }
  .c-pager.is-enhanced .c-pager__track::-webkit-scrollbar { display: none; }
  .c-pager__track:focus-visible { outline-offset: calc(-1 * var(--focus-width)); }
  @media (prefers-reduced-motion: no-preference) {
    .c-pager__track { scroll-behavior: smooth; }
  }
  .c-pager__page {
    flex: 0 0 100%; min-inline-size: 0; scroll-snap-align: start;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-4); align-content: start; align-items: start;
    padding-block-end: var(--space-2);
  }
  /* the box heading already says every item is sponsored: no badge, no reading time */
  .c-pager .c-badge, .c-pager .c-meta { display: none; }
  .c-pager .c-card { gap: var(--space-2); }
  .c-pager .c-card__title { font-size: var(--fs-rail); line-height: 1.3; letter-spacing: 0; }
  @media (min-width: 48em) {
    .c-pager__page { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
  }
  /* header row: heading left, previous / counter / next right (visible without scrolling, 44 px buttons) */
  .c-pager .c-section__head { align-items: center; }
  .c-pager[data-js] .c-section__head { min-block-size: var(--tap); } /* the controls appear with the script: reserve their height, no layout shift */
  .c-pager .c-section__title { flex: 1 1 0; min-inline-size: 0; } /* a narrow phone wraps the heading to two lines instead of pushing the controls down */
  .c-pager__controls { display: flex; align-items: center; gap: var(--space-2); }
  .c-pager__count { min-inline-size: 3em; text-align: center; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--ink); }

  /* The featured list marks the article shown in the carousel with a cyan stripe and a heavier title. */
  .c-picks > li.is-current { box-shadow: inset 3px 0 var(--brand); padding-inline-start: var(--space-3); }
  .c-picks > li.is-current .c-card__title { font-weight: var(--fw-strong); }
  .c-picks > li:first-child { padding-block-start: var(--space-2); } /* always: adding it with .is-current would shift the list on load */
  .c-carousel:not(.is-enhanced) ~ .l-home__featured li { padding-inline-start: 0; }

  /* Desktop: the featured list beside the carousel is no taller than the 16:9 slide, so the sponsored box starts right under the carousel. */
  @media (min-width: 64em) {
    .l-home__featured .c-picks > li { padding-block: var(--space-3); }
    .l-home__featured .c-card--horizontal { grid-template-columns: 5rem minmax(0, 1fr); gap: var(--space-3); }
    .l-home__featured .c-card--horizontal .c-card__body { gap: var(--space-1); }
    .l-home__featured .c-meta { display: none; }
  }
}
