/* GPU Stack Inspector project page, set as a component datasheet.
   SPDX-License-Identifier: MIT */

@font-face {
    font-family: "Archivo";
    src: url("assets/fonts/archivo.woff2") format("woff2");
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("assets/fonts/ibm-plex-mono-400.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("assets/fonts/ibm-plex-mono-600.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}

:root {
    --paper: #ffffff;
    --ink: #17202e;
    --ink-soft: #4b5567;
    --rule: #cdd3dc;
    --panel: #eef2f6;
    --copper: #a4501c;
    --copper-soft: #f4e4d8;
    --pass: #23734a;
    --fail: #b8332a;
    --fail-soft: #fbe9e7;
    --warn: #8f6200;
    --warn-soft: #fbf1d9;
    --muted: #5d6b7e;

    --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

    /* 1.2 scale from 17px */
    --step--1: 0.875rem;
    --step-0: 1.0625rem;
    --step-1: 1.275rem;
    --step-2: 1.53rem;
    --step-3: clamp(1.9rem, 1.2rem + 3vw, 3.3rem);

    --gutter: clamp(1rem, 4vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: var(--step-0);
    line-height: 1.55;
    font-variation-settings: "wdth" 100;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--copper); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
    outline: 2px solid var(--copper);
    outline-offset: 3px;
}

code, pre { font-family: var(--mono); font-size: 0.86em; }
p code, li code, td code, th code {
    background: var(--panel);
    padding: 0.08em 0.3em;
    border-radius: 2px;
    overflow-wrap: anywhere;
}

h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 700; }
h2 {
    font-size: var(--step-2);
    font-stretch: 80%;
    font-variation-settings: "wdth" 80;
    line-height: 1.15;
    margin-bottom: 0.75rem;
}
h3 {
    font-size: var(--step-0);
    font-weight: 650;
    margin: 1.5rem 0 0.5rem;
}
p { margin: 0 0 1rem; max-width: 68ch; }

.wrap { width: min(1180px, 100% - 2 * var(--gutter)); margin-inline: auto; }

.fine { font-size: var(--step--1); color: var(--ink-soft); }
.section-lede { color: var(--ink-soft); }

/* ---------- masthead: the datasheet's header strip ---------- */

.masthead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--ink);
    color: var(--paper);
}
.masthead-row {
    display: flex;
    align-items: center;
    gap: 1rem 2rem;
    min-height: 3.5rem;
}
.part {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-variation-settings: "wdth" 75;
    font-size: var(--step-1);
    letter-spacing: 0.01em;
}
.part-mark { width: 1.6rem; height: 1.6rem; }
.part-rev {
    margin: 0;
    font-size: var(--step--1);
    color: #b9c2cf;
}
.masthead-nav { margin-left: auto; display: flex; gap: 1.25rem; }
.masthead-nav a { color: var(--paper); text-decoration: none; font-size: var(--step--1); font-weight: 600; }
.masthead-nav a:hover { text-decoration: underline; }
.masthead :focus-visible { outline-color: #f0b98e; }

@media (max-width: 760px) {
    .part-rev { display: none; }
}
@media (max-width: 460px) {
    .masthead-nav a:not(:last-child) { display: none; }
}

/* ---------- introduction: title on the left, features column on the right ---------- */

main > section { padding-block: clamp(2.5rem, 6vw, 4.5rem); border-bottom: 1px solid var(--rule); }
main > section:last-child { border-bottom: 0; }

.intro {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: start;
}
h1 {
    font-size: var(--step-3);
    font-weight: 800;
    font-variation-settings: "wdth" 72;
    line-height: 1.02;
    letter-spacing: -0.012em;
    margin-bottom: 1.5rem;
}
.lede { font-size: var(--step-1); line-height: 1.5; max-width: 40ch; }
@media (max-width: 1000px) { .lede { max-width: 52ch; } }

.command {
    display: flex;
    align-items: stretch;
    margin: 1.75rem 0 0.75rem;
    border: 1px solid var(--ink);
    max-width: 44rem;
}
.command code {
    flex: 1;
    min-width: 0;
    padding: 0.85rem 1rem;
    font-size: var(--step--1);
    overflow-x: auto;
    white-space: nowrap;
    background: var(--paper);
}
.copy {
    border: 0;
    border-left: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    font: 600 var(--step--1) var(--sans);
    padding: 0 1.1rem;
    cursor: pointer;
}
.copy:hover { background: #2a3548; }
.copy[data-state="done"] { background: var(--pass); }

.intro-side {
    border-left: 3px solid var(--ink);
    padding-left: 1.5rem;
}
.side-title {
    font-size: var(--step-0);
    font-variation-settings: "wdth" 100;
    font-weight: 700;
    margin: 0 0 0.5rem;
}
.side-title + .ticks { margin-bottom: 1.75rem; }
.ticks { list-style: none; margin: 0; padding: 0; font-size: var(--step--1); }
.ticks li { position: relative; padding-left: 1.1rem; margin-bottom: 0.45rem; }
.ticks li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 0.5rem;
    height: 2px;
    background: var(--copper);
}

@media (max-width: 860px) {
    .intro { grid-template-columns: minmax(0, 1fr); }
    .intro-side { border-left: 0; border-top: 3px solid var(--ink); padding: 1.25rem 0 0; }
}

/* ---------- figure 1: the block diagram ---------- */

.fig-no {
    display: inline-block;
    margin-right: 0.6rem;
    padding: 0.05em 0.45em;
    border: 1px solid currentColor;
    font-size: 0.7em;
    font-weight: 600;
    vertical-align: 0.18em;
    font-variation-settings: "wdth" 100;
}
.figure-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem 3rem; align-items: end; }
.figure-head p { color: var(--ink-soft); margin: 0; }
@media (max-width: 860px) { .figure-head { grid-template-columns: minmax(0, 1fr); } }

.cases {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 1.75rem 0 0;
    border: 1px solid var(--ink);
    border-bottom: 0;
    width: fit-content;
    max-width: 100%;
}
.cases [role="tab"] {
    border: 0;
    border-right: 1px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    font: 600 var(--step--1) var(--sans);
    padding: 0.7rem 1.1rem;
    cursor: pointer;
}
.cases [role="tab"]:last-child { border-right: 0; }
.cases [role="tab"]:hover { background: var(--panel); }
.cases [role="tab"][aria-selected="true"] { background: var(--ink); color: var(--paper); }
.cases [role="tab"]:focus-visible { outline-offset: -4px; outline-color: var(--copper); }

.diagram {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    border: 1px solid var(--ink);
    background:
        linear-gradient(var(--paper), var(--paper)) padding-box,
        var(--ink);
}
@media (max-width: 960px) { .diagram { grid-template-columns: minmax(0, 1fr); } }

.stacks {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto repeat(3, minmax(4.25rem, auto)) 2.25rem repeat(3, minmax(3.25rem, auto));
    grid-template-areas:
        ".   ha    hb"
        "lpy apy   bpy"
        "lto ato   bto"
        "lli ali   bli"
        ".   sr    sr"
        "lsh shell shell"
        "ldr drv   drv"
        "lgp gpu   gpu";
    gap: 0.5rem 0.75rem;
    padding: 1.5rem;
    background-image:
        linear-gradient(to right, rgba(23, 32, 46, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(23, 32, 46, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
}
.layer-label {
    margin: 0;
    align-self: center;
    font-size: var(--step--1);
    font-weight: 600;
    color: var(--ink-soft);
    font-variation-settings: "wdth" 85;
}
.env-head {
    margin: 0 0 0.25rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}
.env-key {
    display: inline-grid;
    place-items: center;
    width: 1.4rem;
    height: 1.4rem;
    margin-right: 0.3rem;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.8rem;
}
.shared-rule {
    margin: 0;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--muted);
}
.shared-rule::before, .shared-rule::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--muted);
}

.block {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.6rem 0.8rem 0.6rem 1rem;
    background: var(--paper);
    border: 1px solid var(--ink);
    border-left-width: 4px;
    min-width: 0;
    transition: background-color 180ms ease, border-color 180ms ease;
}
.block-wide { flex-direction: row; justify-content: flex-start; align-items: baseline; flex-wrap: wrap; gap: 0.2rem 1rem; }
.block strong { font-weight: 650; font-size: var(--step-0); overflow-wrap: anywhere; }
.block span { font-size: var(--step--1); color: var(--ink-soft); overflow-wrap: anywhere; }
.block[data-state="fail"] {
    border-color: var(--fail);
    background:
        repeating-linear-gradient(135deg, transparent 0 7px, rgba(184, 51, 42, 0.08) 7px 9px),
        var(--fail-soft);
}
.block[data-state="warn"] {
    border-color: var(--warn);
    background:
        repeating-linear-gradient(135deg, transparent 0 7px, rgba(143, 98, 0, 0.09) 7px 9px),
        var(--warn-soft);
}
.block[data-state="fail"]::after, .block[data-state="warn"]::after {
    content: attr(data-code);
    position: absolute;
    top: -0.65rem;
    right: 0.6rem;
    padding: 0 0.35rem;
    font: 600 0.72rem var(--mono);
    color: var(--paper);
    background: var(--fail);
}
.block[data-state="warn"]::after { background: var(--warn); }
.block[data-state="empty"] { border-style: dashed; border-left-style: solid; }
.block[data-state="empty"] strong { color: var(--muted); font-weight: 500; }

@media (prefers-reduced-motion: reduce) { .block { transition: none; } }

.block-layer { display: none; }

@media (max-width: 560px) {
    .stacks {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: auto repeat(3, minmax(4rem, auto)) 2rem repeat(3, auto);
        grid-template-areas:
            "ha    hb"
            "apy   bpy"
            "ato   bto"
            "ali   bli"
            "sr    sr"
            "shell shell"
            "drv   drv"
            "gpu   gpu";
        padding: 1rem;
        gap: 0.4rem 0.5rem;
    }
    .layer-label { display: none; }
    .block-layer { display: block; flex-basis: 100%; font-style: normal; font-size: 0.72rem; color: var(--muted); }
    .block { padding: 0.5rem 0.6rem 0.5rem 0.75rem; }
    .block strong { font-size: var(--step--1); }
    .block span { font-size: 0.8rem; }
}

.verdict {
    padding: 1.5rem;
    border-left: 1px solid var(--ink);
    background: var(--panel);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
@media (max-width: 960px) { .verdict { border-left: 0; border-top: 1px solid var(--ink); } }
.verdict-command { margin: 0; }
.verdict-command code {
    display: block;
    padding: 0.6rem 0.8rem;
    background: var(--ink);
    color: #e7ecf3;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre;
}
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.finding { margin: 0; }
.finding-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin: 0 0 0.3rem; }
.badge {
    display: inline-block;
    min-width: 3.4rem;
    padding: 0.05rem 0.4rem;
    font: 600 0.72rem var(--mono);
    text-align: center;
    color: var(--paper);
    background: var(--muted);
}
.badge-fail { background: var(--fail); }
.badge-warn { background: var(--warn); }
.badge-pass { background: var(--pass); }
.finding-code { font: 600 0.8rem var(--mono); }
.finding-summary { font-weight: 650; margin: 0 0 0.3rem; }
.finding p { font-size: var(--step--1); margin: 0 0 0.3rem; }
.finding .next { color: var(--ink); }
.finding .next::before { content: "Do: "; font-weight: 650; }

/* ---------- figure 2 and other two-column sections ---------- */

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: start;
}
@media (max-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

.listing {
    margin: 0 0 1rem;
    padding: 1rem 1.1rem;
    background: var(--ink);
    color: #e7ecf3;
    overflow-x: auto;
    line-height: 1.7;
}
.terminal { margin: 0; border: 1px solid var(--ink); background: #0c0c0c; }
.terminal img { display: block; width: 100%; height: auto; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; margin-bottom: 1rem; border: 1px solid var(--ink); }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th, td { text-align: left; vertical-align: top; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--rule); }
thead th { background: var(--ink); color: var(--paper); font-weight: 650; border-bottom: 0; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 600; }
.ratings tbody th { width: 34%; }
.ratings .num { font-family: var(--mono); font-weight: 600; white-space: nowrap; width: 8rem; }
.checks th[scope="rowgroup"] { background: var(--panel); border-right: 1px solid var(--rule); width: 11rem; }
.checks td:nth-child(2), .checks tr > td:first-child { white-space: nowrap; }

/* ---------- colophon ---------- */

.colophon { background: var(--ink); color: #d5dbe4; font-size: var(--step--1); }
.colophon-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; padding-block: 1.75rem; }
.colophon p { margin: 0; }
.colophon a { color: #f0b98e; }
.colophon :focus-visible { outline-color: #f0b98e; }

@media (max-width: 560px) {
    .cases { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .cases [role="tab"] { border-bottom: 1px solid var(--ink); }
    .cases [role="tab"]:nth-child(2n) { border-right: 0; }
}
