/*
 * API map.
 *
 * Round 3 (docs/prototypes/redesign-3): the channel grid's ruled panel --
 * surface-1 on the page, a cell one step lighter under the pointer -- with the
 * tinted icon tile of the pricing view. The one loud thing is the endpoint
 * signatures: the prototype's "at a glance" code chip (whatsapp.src.html .glance
 * code -- a blue-tinged field, a link-blue hairline, light lavender text) grown
 * into a small block of calls, each a method badge and a path in Google Sans
 * Code. Everything else is quiet: sentence case, fg-2 copy, no tracked capitals.
 *
 * Each row of cells shares its tracks through subgrid, so titles, sentences,
 * call blocks and links line up across a row however long each one runs.
 *
 * Tokens only. The few one-off shades are color-mix()ed from tokens, and each
 * text/background pair has a row in scripts/check-contrast.py.
 */

.vc-api-map {
  /* Component-local, defined here and nowhere else. */
  --vc-api-calls: color-mix(in srgb, var(--vc-surface-2) 93%, var(--vc-blue));
  --vc-api-calls-hover: color-mix(
    in srgb,
    var(--vc-surface-3) 93%,
    var(--vc-blue)
  );
  --vc-api-calls-edge: color-mix(in srgb, var(--vc-link) 16%, transparent);
  --vc-api-path: color-mix(in srgb, var(--vc-fg) 70%, var(--vc-accent));

  color: var(--vc-fg);
}

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

/* The one eyebrow (CLAUDE.md §4a). */
.vc-api-map__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 cannot
   paint over the hairline at the rim. */
.vc-api-map__panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--vc-radius-lg);
  background: var(--vc-surface-1);
  box-shadow: var(--vc-shadow-lg);
}

.vc-api-map__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: each cell draws its top and start edge, and the list is
 * pulled up and left by a pixel so the outer ones fall under the panel's clip.
 */
.vc-api-map__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: -1px 0 0 -1px;
  padding: 0;
  list-style: none;
}

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

/* Two columns and an odd count: the first area takes the first row. */
@media (min-width: 42rem) and (max-width: 68.74rem) {
  .vc-api-map__grid > .vc-api-map__item:first-child:nth-last-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 68.75rem) {
  .vc-api-map__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* A count three does not divide: six tracks, the first row absorbs the
     remainder (as channel-grid), so no row ends in an empty cell. */
  .vc-api-map__grid--thirds {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .vc-api-map__grid--thirds > .vc-api-map__item {
    grid-column: span 2;
  }

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

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

/* --- A cell --------------------------------------------------------------- */

.vc-api-map__item {
  display: flex;
  flex-direction: column;
  gap: var(--vc-space-sm);
  min-width: 0;
  padding: var(--vc-space-md);
  border-block-start: 1px solid var(--vc-line);
  border-inline-start: 1px solid var(--vc-line);
}

/* The full 32px only at three columns: in two, and on a phone, the 24px is
   what lets a host such as link-shortener-api.veloconnect.me hold one line. */
@media (min-width: 68.75rem) {
  .vc-api-map__item {
    padding: var(--vc-space-lg);
  }
}

/* Title, sentence, calls, link: four rows shared across the row of cells. */
@supports (grid-template-rows: subgrid) {
  .vc-api-map__item {
    display: grid;
    grid-row: span 4;
    grid-template-rows: subgrid;
    row-gap: var(--vc-space-sm);
  }
}

.vc-api-map__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-api-map__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-api-map__tile .vc-channel-icon {
  inline-size: 1.0625rem;
  block-size: 1.0625rem;
}

.vc-api-map .vc-api-map__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-api-map__desc {
  margin: 0;
  max-width: 44ch;
  font-size: var(--vc-text-sm);
  line-height: var(--vc-leading-normal);
  color: var(--vc-fg-2);
}

/* --- The calls: the part that carries the section -------------------------- */

.vc-api-map__calls {
  display: flex;
  flex-direction: column;
  gap: var(--vc-space-2xs);
  min-width: 0;
  margin: var(--vc-space-3xs) 0 0;
  padding: var(--vc-space-xs) var(--vc-space-sm);
  list-style: none;
  border-radius: var(--vc-radius-md);
  background: var(--vc-api-calls);
  box-shadow: inset 0 0 0 1px var(--vc-api-calls-edge);
}

.vc-api-map__calls--empty {
  padding: 0;
  background: none;
  box-shadow: none;
}

/* Names without a verb -- webhook events -- are tokens, not calls: quiet
   pills on one wrapped line, in a block as tall as they need rather than
   stretched to the tallest call list in the row. */
.vc-api-map__calls--names {
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  align-self: start;
  column-gap: var(--vc-space-2xs);
}

.vc-api-map__calls--names .vc-api-map__path {
  padding: 0 0.375em;
  border-radius: var(--vc-radius-sm);
  background: color-mix(in srgb, var(--vc-link) 10%, transparent);
}

.vc-api-map__call {
  min-width: 0;
}

/* The host, where it is not api.veloconnect.me: a quiet line above its calls. */
.vc-api-map__host {
  display: block;
  margin-block-end: var(--vc-space-3xs);
  font-family: var(--vc-font-mono);
  font-size: var(--vc-text-xs);
  line-height: var(--vc-leading-normal);
  color: var(--vc-fg-2);
}

.vc-api-map .vc-api-map__sig {
  display: flex;
  align-items: baseline;
  gap: var(--vc-space-xs);
  padding: 0;
  background: none;
  font-family: var(--vc-font-mono);
  font-size: var(--vc-text-xs);
  line-height: var(--vc-leading-normal);
}

/*
 * The method badge: its verb in its own colour on a 14% wash of that colour --
 * distinct at a glance, quiet beside the path. A fixed width, so the paths in
 * a block share one left edge.
 */
.vc-api-map__method {
  --vc-api-verb: var(--vc-accent);

  flex: none;
  min-inline-size: 6ch;
  padding: 0 0.375em;
  border-radius: var(--vc-radius-sm);
  background: color-mix(in srgb, var(--vc-api-verb) 14%, transparent);
  color: var(--vc-api-verb);
  font-size: calc(var(--vc-text-xs) - 0.125rem);
  font-weight: var(--vc-weight-semibold);
  line-height: 1.8;
  text-align: center;
}

.vc-api-map__method--get {
  --vc-api-verb: var(--vc-ok);
}

.vc-api-map__method--post {
  --vc-api-verb: var(--vc-accent);
}

.vc-api-map__method--put,
.vc-api-map__method--patch {
  --vc-api-verb: var(--vc-warn);
}

.vc-api-map__method--delete {
  --vc-api-verb: var(--vc-bad);
}

/* A long path wraps at a slash (render.php's <wbr>), inside its own column;
   anywhere is the last resort that keeps it from widening the page. */
.vc-api-map__path {
  min-width: 0;
  font-weight: var(--vc-weight-medium);
  color: var(--vc-api-path);
  overflow-wrap: anywhere;
}

/* A segment and its slash (render.php): atomic, so the line breaks between
   segments and never at the hyphen inside one. A unit wider than the line
   still wraps inside itself (overflow-wrap above), never past the box. */
.vc-api-map__seg {
  display: inline-block;
  max-inline-size: 100%;
}

.vc-api-map__param {
  color: var(--vc-fg-2);
}

/* --- The link ------------------------------------------------------------- */

.vc-api-map .vc-api-map__more {
  display: inline-flex;
  align-items: center;
  align-self: start;
  justify-self: start;
  gap: var(--vc-space-2xs);
  font-size: var(--vc-text-sm);
  font-weight: var(--vc-weight-emphasis);
  color: var(--vc-link);
  text-decoration: none;
}

.vc-api-map .vc-api-map__more svg {
  flex: none;
  inline-size: 0.875rem;
  block-size: 0.875rem;
}

/* Its own :hover, so theme.json's link hover never reaches it (§3a). */
.vc-api-map .vc-api-map__more:hover {
  color: var(--vc-link-hover);
  text-decoration: none;
}

.vc-api-map .vc-api-map__more:focus-visible {
  outline: 2px solid var(--vc-link);
  outline-offset: 3px;
  border-radius: var(--vc-radius-sm);
}

/* Without subgrid the cell is a column; the link sinks to its foot. */
@supports not (grid-template-rows: subgrid) {
  .vc-api-map .vc-api-map__more {
    margin-block-start: auto;
  }
}

/* --- Hover: the cell steps up a surface, and everything on it with it ------ */

.vc-api-map__item:hover,
.vc-api-map__item:focus-within {
  background: var(--vc-surface-2);
}

.vc-api-map__item:hover .vc-api-map__tile,
.vc-api-map__item:focus-within .vc-api-map__tile {
  background: var(--vc-tint-2);
}

.vc-api-map__item:hover .vc-api-map__calls:not(.vc-api-map__calls--empty),
.vc-api-map__item:focus-within
  .vc-api-map__calls:not(.vc-api-map__calls--empty) {
  background: var(--vc-api-calls-hover);
}

@media (prefers-reduced-motion: no-preference) {
  .vc-api-map__item,
  .vc-api-map__tile,
  .vc-api-map__calls {
    transition: background-color var(--vc-base) var(--vc-ease);
  }

  .vc-api-map .vc-api-map__more svg {
    transition: transform var(--vc-base) var(--vc-ease);
  }

  .vc-api-map .vc-api-map__more:hover svg {
    transform: translateY(2px);
  }
}

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

  .vc-api-map__item {
    border-color: CanvasText;
  }

  .vc-api-map__calls:not(.vc-api-map__calls--empty),
  .vc-api-map__method {
    outline: 1px solid CanvasText;
  }
}
