/*
 * Channel grid.
 *
 * Round 3 (docs/prototypes/redesign-3): one panel, ruled into cells, instead of
 * a row of identical floating cards. The panel is surface-1 on the page, a cell
 * steps up to surface-2 under the pointer -- a nested surface is always lighter
 * than what holds it (CLAUDE.md §4a). Each channel's icon sits on the tinted
 * tile the pricing view uses (.ch .ico): --vc-tint behind, --vc-accent on it.
 *
 * Tokens only.
 */

.vc-channels {
  color: var(--vc-fg);
}

.vc-channels__head:not(.vc-section-head--split) {
  margin-block-end: clamp(2.5rem, 5vw, 3.5rem);
}

/* A section label, not a shouted eyebrow: sentence case, no tracking. */
.vc-channels__eyebrow {
  margin: 0 0 var(--vc-space-xs);
  font-size: var(--vc-text-sm);
  font-weight: var(--vc-weight-medium);
  line-height: var(--vc-leading-snug);
  color: var(--vc-fg-2);
}

/* The panel. Its edge is drawn by ::after, above the cells, so a hovered
   cell's surface-2 cannot paint over the hairline at the panel's rim. */
.vc-channels__panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--vc-radius-lg);
  background: var(--vc-surface-1);
  box-shadow: var(--vc-shadow-lg);
}

.vc-channels__panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--vc-line);
  pointer-events: none;
}

/*
 * Rules between cells: every cell draws a hairline on its top and start edge,
 * and the list is pulled up and left by one pixel so the first row's and first
 * column's lines fall under the panel's clip. A ragged last row just shows
 * panel -- no grey slab where a cell is missing.
 */
.vc-channels__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: -1px 0 0 -1px;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .vc-channels__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Column count comes from the item count via vc_grid_columns(), so six cells
   go 3 + 3 and four go on one row. */
@media (min-width: 68rem) {
  .vc-channels__grid {
    grid-template-columns: repeat(var(--vc-grid-count, 3), minmax(0, 1fr));
  }

  /*
   * Three columns that do not divide the count: six tracks, a card spans two,
   * and the first row absorbs the remainder -- 5 cards go 2 + 3, 7 go 1 + 3 + 3
   * -- so no row ends in an empty cell.
   */
  .vc-channels__grid--thirds {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .vc-channels__grid--thirds > .vc-channels__item {
    grid-column: span 2;
  }

  .vc-channels__grid--thirds > .vc-channels__item:first-child:nth-last-child(3n + 2),
  .vc-channels__grid--thirds > .vc-channels__item:first-child:nth-last-child(3n + 2) + .vc-channels__item {
    grid-column: span 3;
  }

  .vc-channels__grid--thirds > .vc-channels__item:first-child:nth-last-child(3n + 1) {
    grid-column: 1 / -1;
  }
}

/* Two columns and an odd count: the first card takes the first row. */
@media (min-width: 40rem) and (max-width: 67.99rem) {
  .vc-channels__grid > .vc-channels__item:first-child:nth-last-child(odd) {
    grid-column: 1 / -1;
  }
}

.vc-channels__item {
  display: flex;
  border-block-start: 1px solid var(--vc-line);
  border-inline-start: 1px solid var(--vc-line);
}

.vc-channels .vc-channel-card {
  display: flex;
  flex-direction: column;
  gap: var(--vc-space-xs);
  inline-size: 100%;
  padding: var(--vc-space-md);
  color: inherit;
  text-decoration: none;
}

@media (min-width: 40rem) {
  .vc-channels .vc-channel-card {
    padding: var(--vc-space-lg);
  }
}

.vc-channel-card__top {
  display: flex;
  align-items: center;
  gap: var(--vc-space-xs);
}

/* The pricing view's channel tile: 34px, radius 10, tint behind an accent icon. */
.vc-channel-card__tile {
  display: grid;
  flex: none;
  place-items: center;
  inline-size: 2.125rem;
  block-size: 2.125rem;
  border-radius: var(--vc-radius-md);
  background: var(--vc-tint);
  color: var(--vc-accent);
}

.vc-channel-card__tile .vc-channel-icon {
  inline-size: 1.0625rem;
  block-size: 1.0625rem;
}

.vc-channels .vc-channel-card__title {
  margin: 0;
  font-family: var(--vc-font-display);
  font-size: var(--vc-text-lg);
  font-weight: var(--vc-weight-semibold);
  line-height: var(--vc-leading-card);
  letter-spacing: var(--vc-tracking-snug);
  color: var(--vc-fg);
}

.vc-channel-card__desc {
  margin: 0;
  max-width: 42ch;
  font-size: var(--vc-text-base);
  line-height: var(--vc-leading-normal);
  color: var(--vc-fg-2);
}

/* The prototype's .more, inside the card: the whole cell is the link. */
.vc-channel-card__more {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-block-start: auto;
  padding-block-start: var(--vc-space-2xs);
  font-size: var(--vc-text-sm);
  font-weight: var(--vc-weight-emphasis);
  color: var(--vc-link);
}

.vc-channel-card__more svg {
  flex: none;
  inline-size: 0.875rem;
  block-size: 0.875rem;
}

/*
 * One column (a phone): ten channels stacked were ~1,750px. The label is only
 * a visual cue -- the whole card is the link, and the label is aria-hidden --
 * so it goes, and its arrow moves up beside the title, centred on the tile.
 */
@media (max-width: 39.99rem) {
  .vc-channels .vc-channel-card--linked {
    position: relative;
  }

  .vc-channels .vc-channel-card--linked .vc-channel-card__top {
    padding-inline-end: var(--vc-space-md);
  }

  .vc-channels .vc-channel-card__more {
    position: absolute;
    inset-block-start: calc(var(--vc-space-md) + (2.125rem - 0.875rem) / 2);
    inset-inline-end: var(--vc-space-md);
    padding: 0;
  }

  .vc-channel-card__more-label {
    display: none;
  }
}

/* Hover: the cell steps up a surface. Its own :hover, so theme.json's link
   hover (underline, link colour) never reaches the card's text (§3a). */
.vc-channels .vc-channel-card--linked:hover {
  background: var(--vc-surface-2);
  color: inherit;
  text-decoration: none;
}

.vc-channels .vc-channel-card--linked:hover .vc-channel-card__tile {
  background: var(--vc-tint-2);
}

.vc-channels .vc-channel-card--linked:hover .vc-channel-card__more {
  color: var(--vc-link-hover);
}

/* Inside the panel's clip an outer focus ring would be cut off at the rim. */
.vc-channels .vc-channel-card--linked:focus-visible {
  outline: 2px solid var(--vc-link);
  outline-offset: -2px;
  border-radius: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .vc-channels .vc-channel-card--linked,
  .vc-channel-card__tile {
    transition: background-color var(--vc-base) var(--vc-ease);
  }

  .vc-channel-card__more svg {
    transition: transform var(--vc-base) var(--vc-ease);
  }

  .vc-channels .vc-channel-card--linked:hover .vc-channel-card__more svg {
    transform: translateX(3px);
  }
}

@media (forced-colors: active) {
  .vc-channels__panel::after {
    border: 1px solid CanvasText;
  }

  .vc-channels__item {
    border-color: CanvasText;
  }
}
