/* "Fewer Draw Calls, the Same Picture": figures. Uses the Homepage tokens from home.css.
   Colour is functional only: ink = drawn, hollow = merged away, teal = what got better. */

.dc-fig { margin: 44px 0 48px; padding-top: 14px; border-top: 1px solid var(--hair); }
.dc-kicker { font: 500 12px/1.35 var(--mono); letter-spacing: .02em; color: var(--muted); }
.dc-fig figcaption { margin-top: 22px; padding-top: 12px; border-top: 1px dashed var(--dash); font-size: 15.5px; line-height: 1.6; color: var(--muted); }
.article-body .dc-fig p + p { margin-top: 0; }
.dc-gain { color: var(--teal); }

/* ---------- figure 1: one dot per draw call ---------- */
.dc-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 20px; margin-top: 14px; }
.dc-total { font-size: 26px; line-height: 1.2; font-weight: 560; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.dc-total small { font-size: 15px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.dc-switch { display: inline-flex; padding: 3px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--hair); }
.dc-switch button { font: 500 14px/1 var(--sans); padding: 8px 14px 9px; min-height: 36px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.dc-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.dc-switch button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dc-rows { margin-top: 18px; }
.dc-row { display: grid; grid-template-columns: 12.5em 1fr; gap: 6px 20px; padding: 12px 0; border-top: 1px solid var(--hair-2); }
.dc-row:first-child { border-top: 0; }
.dc-name { font-size: 15.5px; line-height: 1.35; }
.dc-name small { display: block; margin-top: 3px; font: 500 12px/1.4 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.dc-dots { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; min-height: 7px; }
.dc-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); box-shadow: inset 0 0 0 1px rgba(31, 36, 33, 0); }
.dc-key { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.dc-key span { display: inline-flex; align-items: center; gap: 8px; }
.dc-key i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.dc-key i.dc-ghost { background: transparent; box-shadow: inset 0 0 0 1px rgba(31, 36, 33, .4); }
@media (max-width: 640px) {
  .dc-row { grid-template-columns: 1fr; }
  .dc-dots { gap: 2px; }
  .dc-dots i { width: 6px; height: 6px; }
}

/* ---------- figure 2: the same frame, before and after ---------- */
.dc-shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.dc-shots div { margin: 0; }
.dc-shots img { display: block; width: 100%; height: auto; aspect-ratio: 1170 / 2532; border-radius: 10px; background: #1b1830; box-shadow: 0 0 0 1px var(--hair-2); }
.dc-shots p { margin-top: 10px; font-size: 14px; line-height: 1.4; }
.dc-shots p small { display: block; font: 500 11.5px/1.4 var(--mono); color: var(--muted); }
@media (max-width: 640px) { .dc-shots { gap: 8px; } .dc-shots p { font-size: 13px; } }

/* ---------- figure 3: where a cold first visit goes ---------- */
.dc-time { margin-top: 20px; font-variant-numeric: tabular-nums; }
.dc-trow { display: grid; grid-template-columns: 60px 1fr; gap: 14px; align-items: center; margin-bottom: 14px; }
.dc-trow > span { font-size: 14.5px; }
.dc-track { position: relative; height: 26px; }
.dc-seg { position: absolute; top: 0; bottom: 0; left: calc(var(--a) / 10.5 * 100%); width: calc((var(--b) - var(--a)) / 10.5 * 100%); }
.dc-load { background: rgba(31, 36, 33, .16); border-radius: 3px 0 0 3px; }
.dc-compile { background: rgba(31, 36, 33, .55); }
.dc-draw { background: var(--ink); }
.dc-shown { background: repeating-linear-gradient(90deg, rgba(31, 36, 33, .1) 0 1px, transparent 1px 6px); }
.dc-mark { position: absolute; top: -4px; bottom: -4px; left: calc(var(--t) / 10.5 * 100%); width: 2px; margin-left: -1px; background: var(--teal); border-radius: 1px; }
.dc-axis { position: relative; height: 18px; margin-left: 74px; font: 500 11.5px/1 var(--mono); color: var(--faint); }
.dc-axis span { position: absolute; left: calc(var(--t) / 10.5 * 100%); translate: -50% 0; }
.dc-axis span:first-child { translate: 0 0; }
.dc-tkey { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.dc-tkey span { display: inline-flex; align-items: center; gap: 8px; }
.dc-tkey i { width: 14px; height: 10px; border-radius: 2px; }
.dc-tkey i.dc-mark { position: static; width: 2px; height: 14px; margin: 0; }

/* ---------- the table of results, and the shader lines ---------- */
.dc-table { width: 100%; margin: 28px 0 8px; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.dc-table caption { text-align: left; font: 500 12px/1.35 var(--mono); letter-spacing: .02em; color: var(--muted); padding-bottom: 10px; }
.dc-table th, .dc-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--hair); text-align: right; vertical-align: top; line-height: 1.45; }
.dc-table thead th { font-weight: 500; color: var(--muted); font-size: 13.5px; }
.dc-table th:first-child, .dc-table td:first-child { text-align: left; }
.dc-table td small { display: block; font-size: 13px; color: var(--muted); }
.dc-scroll { overflow-x: auto; margin: 0 -2px; padding: 0 2px; }
.dc-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dc-table td + td { white-space: nowrap; }
@media (max-width: 640px) { .dc-table { font-size: 14.5px; } .dc-table td small { font-size: 12.5px; } }
.dc-code { margin: 24px 0 28px; padding: 16px 18px; border-radius: 10px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--hair); overflow-x: auto; font: 13.5px/1.6 var(--mono); }
.dc-code code { font: inherit; white-space: pre; }
.dc-code:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- the test, checked on the old version against itself ---------- */
.dc-stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.dc-stages img { display: block; width: 100%; height: auto; aspect-ratio: 900 / 506; border-radius: 6px; background: #000; }
.dc-stages p { margin-top: 10px; font-size: 14px; line-height: 1.4; }
.dc-stages p small { display: block; font: 500 11.5px/1.4 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .dc-stages { grid-template-columns: 1fr; gap: 18px; } }

/* ---------- time per frame: 10th–90th percentile bars, middle frame tick (scale 0–20 ms) ---------- */
.dc-ranges { margin-top: 16px; font-variant-numeric: tabular-nums; }
.dc-rview { margin: 16px 0 6px; font-size: 15px; font-weight: 560; }
.dc-rview:first-child { margin-top: 0; }
.dc-range { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; height: 28px; }
.dc-range > span { font-size: 13.5px; color: var(--muted); }
.dc-rtrack { position: relative; height: 12px; }
.dc-rbar { position: absolute; top: 0; bottom: 0; left: calc(var(--lo) / 20 * 100%); width: calc((var(--hi) - var(--lo)) / 20 * 100%); border-radius: 6px; background: rgba(31, 36, 33, .18); }
.dc-rmid { position: absolute; top: -3px; bottom: -3px; left: calc(var(--m) / 20 * 100%); width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); }
.dc-rtrack b { position: absolute; top: 50%; left: calc(var(--m) / 20 * 100%); translate: -50% -175%; font-size: 12.5px; font-weight: 600; line-height: 1; }
.dc-after .dc-rbar { background: rgba(29, 107, 95, .26); }
.dc-after .dc-rmid { background: var(--teal); }
.dc-after b { color: var(--teal); }
.dc-gpu-after .dc-rbar { background: rgba(31, 36, 33, .32); }
.dc-raxis { position: relative; height: 22px; margin: 10px 0 0 108px; font: 500 11.5px/1 var(--mono); color: var(--faint); border-top: 1px solid var(--hair); padding-top: 6px; }
.dc-raxis span { position: absolute; left: calc(var(--m) / 20 * 100%); translate: -50% 0; white-space: nowrap; }
.dc-raxis span:first-child { translate: 0 0; }
.dc-raxis span:nth-last-child(2) { translate: -100% 0; }
.dc-raxis i { position: absolute; left: calc(var(--m) / 20 * 100%); bottom: 100%; height: 300px; border-left: 1.5px dashed var(--dash); pointer-events: none; }
.dc-ranges { position: relative; overflow: hidden; }
.dc-key i.dc-rk { width: 14px; height: 8px; border-radius: 4px; background: rgba(31, 36, 33, .18); }
.dc-key i.dc-rk-mid { width: 3px; height: 14px; border-radius: 2px; background: var(--ink); }
.dc-key i.dc-rk-line { width: 0; height: 14px; border-radius: 0; background: none; border-left: 1.5px dashed var(--dash); }
@media (max-width: 640px) { .dc-range { grid-template-columns: 84px 1fr; } .dc-raxis { margin-left: 96px; } }

/* ---------- the short version, steps and "try it" boxes ---------- */
.article-body .dc-list { margin: 16px 0 20px; display: grid; gap: 10px; }
.dc-list li { position: relative; padding-left: 20px; line-height: 1.65; }
.dc-list li::before { content: ""; position: absolute; left: 3px; top: .72em; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.dc-list b { font-weight: 600; }
.article-body .dc-list :not(pre) > code, .dc-try :not(pre) > code { font: 500 .88em/1 var(--mono); padding: 2px 5px 3px; border-radius: 5px; background: rgba(31, 36, 33, .06); overflow-wrap: anywhere; }
.article-body h2[id^="step-"] { scroll-margin-top: 16px; }

/* the method: a numbered route, each stop linking to its step */
.dc-flow { counter-reset: step; margin-top: 16px; }
.dc-flow li { counter-increment: step; position: relative; padding: 0 0 4px 52px; }
.dc-flow li::before { content: counter(step); position: absolute; left: 0; top: 10px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 600 15px/1 var(--sans); background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); z-index: 1; }
.dc-flow li:not(:last-child)::after { content: ""; position: absolute; left: 15.25px; top: 42px; bottom: -10px; border-left: 1.5px solid var(--dash); }
.dc-flow a { display: block; padding: 10px 12px 12px; margin-left: -12px; border-radius: 10px; color: inherit; text-decoration: none; }
.dc-flow a:hover { background: rgba(31, 36, 33, .045); }
.dc-flow a:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.dc-flow b { display: block; font-size: 17px; line-height: 1.35; font-weight: 560; }
.dc-flow a:hover b { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.dc-flow span { display: block; margin-top: 3px; font-size: 15px; line-height: 1.5; color: var(--muted); }

/* what a reader can do on their own scene */
.dc-try { margin: 26px 0 8px; padding: 16px 20px 18px; border-radius: 12px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--hair); }
.article-body .dc-try p + p, .article-body .dc-try p + .dc-code { margin-top: 10px; }
.dc-try-title { font-size: 15px; font-weight: 600; color: var(--teal); }
.dc-try p, .dc-try li { font-size: 15.5px; line-height: 1.6; }
.article-body .dc-try .dc-list { margin: 8px 0 0; gap: 8px; }
.dc-try .dc-code { margin: 12px 0 0; background: var(--paper); }
@media (max-width: 640px) { .dc-try { padding: 14px 14px 16px; } .dc-flow li { padding-left: 46px; } }
