/* The marketing primer: its tables and the funnel; the column of text it
   shares with the guides is in reading.css. On a phone a table of more than two columns turns each row
   into a card. Colours follow docs/design/brief.md: lime is growth, orange an
   important event. */

/* Every other section is a grey band (.band in style.css), so a run of
   tables does not read as one. */
.primer section {
  padding-block: clamp(1.75rem, 5vw, 2.75rem);
}

.primer section > :last-child {
  margin-bottom: 0;
}

.primer h2 {
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
}

.primer .note {
  font-size: 1rem;
  color: var(--muted);
}

/* The formula: each part in a grey box, an arrow down to the next; the last,
   the growth it leads to, in lime. */
.formula {
  display: grid;
  gap: 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.formula li {
  position: relative;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.formula li:last-child {
  font-weight: 700;
  background: var(--lime);
}

/* The arrow sits in the middle of the gap, centred under the box above. */
.formula li + li::before {
  content: "↓" / "";
  position: absolute;
  top: -2.125rem;
  inset-inline: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 2rem;
  text-align: center;
}

.primer table {
  width: 100%;
  margin: 0 0 1.5rem;
  border-collapse: collapse;
}

.primer th,
.primer td {
  padding: 0.75rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.primer thead th {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 2px solid var(--text);
}

/* The funnel: under each stage's number a line that narrows with the stage;
   the purchase, the event it leads to, in orange. */
.funnel {
  --width: 100%;
}

.funnel tbody td:nth-of-type(1) {
  padding-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(var(--lime), var(--lime)) left bottom 0.5rem / var(--width) 0.375rem no-repeat;
}

.funnel tbody tr:nth-child(2) {
  --width: 70%;
}

.funnel tbody tr:nth-child(3) {
  --width: 45%;
}

.funnel tbody tr:nth-child(4) {
  --width: 25%;
}

.funnel tbody tr:last-child td:nth-of-type(1) {
  background-image: linear-gradient(var(--orange), var(--orange));
}

/* The economics: figures of one width, so they line up; a marked row in
   bold, its figure underlined in lime, as growth is; the last row, the sum,
   under a heavier line. */
.metrics td {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.primer .marked > * {
  font-weight: 800;
}

.primer .marked td {
  text-decoration: underline 0.375rem var(--lime);
  text-decoration-skip-ink: none;
  text-underline-offset: 0.35em;
}

.metrics tbody tr:last-child > * {
  border-top: 2px solid var(--text);
  border-bottom: 0;
}

.rules li,
.primer ul li {
  margin-bottom: 0.5rem;
}

/* After the closing block, the guides that go further: a short list between
   two lines, as the contents are. */
.related {
  margin-bottom: clamp(1rem, 4vw, 2rem);
  padding-block: 1.25rem;
  border-block: 1px solid var(--line);
}

.related h2 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  letter-spacing: 0;
  color: var(--muted);
}

.related ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related a {
  color: inherit;
  text-decoration: none;
}

.related a:hover,
.related a:focus-visible {
  text-decoration: underline;
}

/* On a phone each row of a wide table is a card: its first cell as the
   heading, every other cell under the name of its column. */
@media (max-width: 40rem) {
  .stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .stack tr {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
  }

  .stack th,
  .stack td {
    display: block;
    padding: 0.25rem 0;
    border: 0;
  }

  .stack td::before {
    content: attr(data-label) ": ";
    font-family: var(--font-sans);
    font-weight: 700;
    color: var(--muted);
  }
}
