/*
 * The guide's landing page: the "Send it again" instrument, the chapter
 * cards with a still frame of each chapter's instrument, and the services
 * drawer with its map. Chrome, tags, buttons and the instrument come from
 * guide.css; the group colors the blocks wear are its data colors.
 */
main {
  width: min(100% - 2 * var(--gutter), var(--content));
}

.cta {
  margin: var(--space-5) 0 0;
  font-size: var(--text-lg);
}

.cta a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Chapter cards: square cells on hairline gutters, each with a still frame
   of its instrument whose packet steps once when the card is activated. */
.chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--line);
  list-style: none;
}

.toc--chapters {
  padding: 0;
  border: 0;
  background: none;
}

.chapter-cards .chapter-card {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  height: 100%;
  padding: var(--space-5);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.chapter-card:hover,
.chapter-card:focus-visible {
  background: var(--tint);
}

.chapter-card:hover strong {
  text-decoration-line: underline;
}

.chapter-card strong {
  font-size: var(--text-lg);
}

.card-text {
  color: var(--ink-2);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.card-still {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  margin-bottom: var(--space-2);
}

.still-block {
  fill: var(--bg);
  stroke: var(--line-strong);
}

.still-block--store {
  stroke: var(--data-storage);
}

.still-path {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.still-path--lookup {
  stroke: var(--data-lookup);
  stroke-dasharray: 4 3;
}

.still-dot {
  fill: var(--ink);
  transition: transform 600ms var(--ease);
}

.chapter-card:hover .still-dot,
.chapter-card:focus-visible .still-dot {
  transform: translateX(48px);
}

.chapter-cards li:nth-child(3) .chapter-card:hover .still-dot,
.chapter-cards li:nth-child(3) .chapter-card:focus-visible .still-dot {
  transform: translateX(94px);
}

.chapter-cards li:nth-child(2) .chapter-card:hover .still-dot,
.chapter-cards li:nth-child(2) .chapter-card:focus-visible .still-dot {
  transform: translate(-44px, 31px);
}

.still .still-dot {
  transition: none;
}

.services-drawer {
  margin-top: var(--section);
}

.drawer-wide > p {
  max-width: var(--prose);
  margin-top: 0;
  color: var(--ink-2);
}

.service-static {
  display: grid;
  gap: var(--space-4);
}

.service-static dt {
  font-weight: var(--weight-bold);
}

.service-static dd {
  margin: var(--space-1) 0 0;
  color: var(--ink-2);
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

/* The map: native buttons over a relationship layer. */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  margin-top: var(--space-5);
  border: 1px solid var(--line);
}

.scene {
  min-width: 0;
}

.map {
  position: relative;
  width: calc(100% - 40px);
  height: 560px;
  margin: 24px 20px 12px;
  background-image: radial-gradient(var(--data-grid) 1px, transparent 1px);
  background-size: 16px 16px;
}

.connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.connection {
  visibility: hidden;
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.4;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.connection.is-related {
  visibility: visible;
}

.connection.binding {
  stroke-dasharray: 4 4;
}

.connection.lookup {
  stroke-dasharray: 2 4;
}

.map .map-group {
  position: absolute;
  top: 0;
  left: calc(var(--column) * 25% + 1%);
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.map .map-group span {
  color: var(--node-color);
  font-family: var(--font-mono);
}

/* Geometry values are assigned by scenes.js. */
.map-group {
  --column: 0;
}

.map .node {
  --x: 0%;
  --y: 0%;
  position: absolute;
  top: var(--y);
  left: var(--x);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 21%;
  height: 15%;
  min-height: 66px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease);
}

.map .node:hover {
  transform: translateY(calc(-1 * var(--lift)));
}

.map .node[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--tint);
  color: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.map .node:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.map .node-top {
  margin-bottom: 3px;
}

.map .node-symbol {
  font-size: clamp(12px, 1.1vw, 16px);
}

.map .node strong {
  font-size: clamp(12px, 1.05vw, 16px);
}

.map .node-caption {
  margin-top: 3px;
  font-size: clamp(10px, 0.8vw, 12px);
  line-height: 1.2;
}

.map .node[data-node="workers"] {
  height: 20%;
}

.map .node[data-node="workers"] .node-symbol {
  font-size: 23px;
}

.map .node[data-node="workers"] strong {
  font-size: clamp(18px, 1.6vw, 26px);
}

.map .node[data-node="browser"] {
  border-style: dashed;
}

.scene .map-note {
  margin: 0;
  padding: 0 24px 18px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.detail {
  padding: 26px 24px;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.detail .eyebrow {
  margin: 0 0 18px;
}

.detail h2 {
  margin: 0 0 8px;
  font-size: var(--text-2xl);
}

.detail .analogy {
  margin: 0 0 22px;
  color: var(--ink);
}

.detail p,
.detail dd {
  color: var(--ink-2);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.detail dl {
  margin: 22px 0;
}

.detail dt,
.detail-note strong {
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.detail dt {
  margin-top: 18px;
}

.detail dd {
  margin: 6px 0 0;
}

.detail-note {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.detail-note p {
  margin: 6px 0 18px;
}

.example {
  display: block;
  margin: 20px 0 12px;
  padding: 12px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: var(--text-xs);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.detail .source-link {
  display: block;
  padding: 7px 0;
  font-size: var(--text-xs);
}

@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  /* Keep captions legible when the relationship layer stretches. */
  .map {
    height: 680px;
  }

  .map .node {
    min-height: 110px;
  }

  .map .node strong {
    font-size: 15px;
  }

  .map .node-caption {
    font-size: 12px;
  }

  .map .node-symbol {
    font-size: 15px;
  }
}

@media (max-width: 620px) {
  .map {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: auto;
    height: auto;
    margin: 16px 14px;
    background: none;
  }

  .connections,
  .map .map-group {
    display: none;
  }

  .map .node,
  .map .node[data-node="workers"] {
    position: relative;
    inset: auto;
    width: auto;
    height: auto;
    min-height: 103px;
    padding: 10px;
  }

  .map .node strong,
  .map .node[data-node="workers"] strong {
    font-size: 14px;
  }

  .map .node[data-node="workers"] .node-symbol {
    font-size: 15px;
  }

  .map .node-caption {
    font-size: 11px;
    line-height: 1.4;
  }

  .map .node[data-node="browser"] {
    grid-row: 1;
    grid-column: 1 / -1;
    min-height: 85px;
  }

  .map .node[data-node="workers"] {
    grid-row: 4;
    grid-column: 1 / -1;
    min-height: 92px;
  }

  .scene .map-note {
    padding: 0 15px 18px;
  }

  .detail {
    padding: 24px 20px;
  }
}
