/* Debian buildd redesign demo: tokens, layout, components. */

:root {
	--red: #d70a53;
	--red-dark: #a80030;
	--red-soft: color-mix(in srgb, var(--red) 12%, transparent);

	--bg: #f7f6f4;
	--surface: #fff;
	--surface-2: #f2f0ed;
	--line: #e2ded8;
	--text: #17161a;
	--text-dim: #5f5c63;

	/* build states: red = broken, amber = waiting, teal = building, green = fine, grey = inert */
	--bad: #c0223f;
	--bad-bg: #fdecef;
	--warn: #8a5f00;
	--warn-bg: #fdf3e0;
	--good: #1c6b47;
	--good-bg: #e8f5ee;
	--live: #0b6478;
	--live-bg: #e5f4f8;
	--idle: #6a6770;
	--idle-bg: #eeecf0;

	--radius: 10px;
	--radius-lg: 16px;
	--shadow: 0 1px 2px rgb(23 22 26 / 6%), 0 8px 24px -12px rgb(23 22 26 / 18%);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
	--bg: #14131a;
	--surface: #1c1b22;
	--surface-2: #232229;
	--line: #322f3a;
	--text: #efedf2;
	--text-dim: #a5a1ae;

	--bad: #ff8b9d;
	--bad-bg: #3a1d25;
	--warn: #e8b45c;
	--warn-bg: #33280f;
	--good: #6fd3a2;
	--good-bg: #14301f;
	--live: #64c8dd;
	--live-bg: #102a31;
	--idle: #a9a5b3;
	--idle-bg: #2a2831;

	--shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 12px 28px -14px rgb(0 0 0 / 70%);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.55 var(--font);
	-webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration-color: color-mix(in srgb, var(--red) 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

code, .mono { font-family: var(--mono); font-size: .88em; }

.sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
	position: absolute; left: 12px; top: -48px; z-index: 50;
	background: var(--surface); padding: 10px 16px; border-radius: var(--radius);
	box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }

/* ---------- header ---------- */

.site-header {
	position: sticky; top: 0; z-index: 20;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: blur(12px) saturate(140%);
	border-bottom: 1px solid var(--line);
}

.header-bar { display: flex; align-items: center; gap: 16px; padding: 10px 0; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-swirl { width: 30px; height: 30px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-dim); }

.quick { display: flex; align-items: center; gap: 8px; margin-left: auto; position: relative; }

.quick input, .quick select, .field input {
	font: inherit; color: inherit; background: var(--surface-2);
	border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
	min-width: 0; transition: border-color .15s, background .15s;
}
.quick input { width: 220px; }
.quick input:focus-visible, .quick select:focus-visible, .field input:focus-visible,
.btn:focus-visible, .icon-btn:focus-visible, summary:focus-visible,
.chip:focus-visible, .page-actions a:focus-visible {
	outline: 2px solid var(--red); outline-offset: 2px;
	border-color: var(--red);
}

.btn {
	font: inherit; font-weight: 600; cursor: pointer;
	border-radius: 999px; border: 1px solid var(--line);
	background: var(--surface); color: var(--text); padding: 8px 16px;
}
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }

.icon-btn {
	display: grid; place-items: center; width: 36px; height: 36px; flex: none;
	border-radius: 50%; border: 1px solid var(--line);
	background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--red); color: var(--red); }
.icon-btn .sun { display: none; }
[data-theme="dark"] .icon-btn .sun { display: block; }
[data-theme="dark"] .icon-btn .moon { display: none; }

.site-nav { display: flex; gap: 4px; }
.site-nav a {
	padding: 8px 14px 10px; font-size: 14px; font-weight: 500; color: var(--text-dim);
	text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }

main { padding: 26px 0 64px; }
main:focus { outline: none; }

/* ---------- shared building blocks ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(26px, 4vw, 34px); line-height: 1.15; margin: 0; letter-spacing: -.02em; }
.page-head .lede { margin: 6px 0 0; max-width: 62ch; color: var(--text-dim); }
.page-head .spacer { flex: 1 1 auto; }

.eyebrow {
	margin: 0; font-size: 11.5px; font-weight: 650; letter-spacing: .09em;
	text-transform: uppercase; color: var(--text-dim);
}

.card {
	background: var(--surface); border: 1px solid var(--line);
	border-radius: var(--radius-lg); box-shadow: var(--shadow);
}

.card-body { padding: 16px 18px; }

.section { margin-top: 28px; }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
.section-hint { margin: 0; font-size: 13.5px; color: var(--text-dim); }

/* status pill */
.pill {
	display: inline-flex; align-items: center; gap: 6px;
	font-size: 12.5px; font-weight: 600; line-height: 1;
	padding: 6px 10px; border-radius: 999px; white-space: nowrap;
	background: var(--idle-bg); color: var(--idle);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.live { background: var(--live-bg); color: var(--live); }
.pill.idle { background: var(--idle-bg); color: var(--idle); }
.pill.lg { font-size: 13.5px; padding: 8px 13px; }
.pill.no-dot::before { display: none; }

.heat-red { color: var(--bad); font-weight: 600; }

.tag {
	display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px;
	border-radius: 6px; background: var(--surface-2); color: var(--text-dim);
}

/* ---------- glance strip ---------- */

.glance { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.metric { padding: 14px 16px; }
.metric .value {
	font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15;
	font-variant-numeric: tabular-nums;
}
.metric .value small { font-size: 15px; font-weight: 500; color: var(--text-dim); letter-spacing: 0; }
.metric .label { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.progress { margin-top: 12px; }

.bar {
	display: flex; height: 10px; border-radius: 999px; overflow: hidden;
	background: var(--surface-2); margin-bottom: 12px;
}
.bar > span { display: block; height: 100%; min-width: 3px; }
.bar > span + span { box-shadow: inset 1px 0 0 var(--surface); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-item b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- bug callout ---------- */

.bug {
	display: grid; gap: 4px; margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-lg);
	background: var(--bad-bg); border: 1px solid color-mix(in srgb, var(--bad) 28%, transparent);
}
.bug .eyebrow { color: var(--bad); }
.bug-title { margin: 0; font-weight: 550; }
.bug-meta { margin: 0; font-size: 12.5px; color: var(--text-dim); }

/* ---------- root causes (package page) ---------- */

.causes > .cause + .cause { border-top: 1px solid var(--line); }

.cause { padding: 14px 18px; }
.cause-main { display: grid; gap: 6px; }
.cause-dep {
	margin: 0; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
	word-break: break-all;
}
.cause-constraint {
	font-family: var(--font); font-size: 11.5px; font-weight: 600; padding: 2px 7px;
	border-radius: 6px; background: var(--surface-2); color: var(--text-dim);
}
.cause-arches { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; }
.cause-via { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.cause-via .mono { color: var(--text); }

.cause-chain { margin-top: 8px; }
.cause-chain > summary {
	cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-dim);
	list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 2px 0;
}
.cause-chain > summary::-webkit-details-marker { display: none; }
.cause-chain > summary::before { content: "▸"; transition: transform .15s; }
.cause-chain[open] > summary::before { transform: rotate(90deg); }
.cause-chain > summary:hover { color: var(--red); }

.chain-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.chain-note { margin: 0 0 4px; font-size: 12px; color: var(--text-dim); }
.chain-list pre {
	margin: 0; padding: 10px 12px; overflow-x: auto; border-radius: var(--radius);
	border: 1px solid var(--line); background: var(--surface-2);
	font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
}
.dep-missing { color: var(--bad); font-weight: 600; }

/* ---------- architecture groups (package page) ---------- */

.arch-groups { display: grid; gap: 14px; }
.group-label { margin: 0 0 6px; font-size: 12.5px; color: var(--text-dim); }
.arch-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.arch-chip {
	display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 999px;
	font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--line);
	background: var(--surface); cursor: default;
}
.arch-chip.good { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); color: var(--good); }
.arch-chip.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-bg); color: var(--bad); }
.arch-chip.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); color: var(--warn); }
.arch-chip.live { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); color: var(--live); }

/* ---------- architecture page ---------- */

.stale-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.stale-item {
	display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center;
	padding: 10px 14px; border-radius: var(--radius); box-shadow: none;
}
.stale-spacer { flex: 1 1 auto; }

.state-row { border-top: 1px solid var(--line); }
.state-row:first-child { border-top: 0; }
.state-row.no-hits { display: none; }

.state-summary {
	display: flex; align-items: center; gap: 10px;
	padding: 13px 18px; cursor: pointer; list-style: none;
}
.state-summary::-webkit-details-marker { display: none; }
.state-summary:hover { background: var(--surface-2); }
.state-count { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: auto; }
.state-count small { font-weight: 500; color: var(--text-dim); font-size: 12.5px; }
.state-hint { font-size: 12.5px; color: var(--text-dim); }
.chev { flex: none; transition: transform .15s; color: var(--text-dim); font-size: 12px; }
details[open] > .state-summary .chev { transform: rotate(90deg); }

.pkg-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 16px; }

.chip {
	display: inline-flex; align-items: baseline; gap: 6px;
	padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line);
	background: var(--surface); font-size: 13px; color: var(--text); text-decoration: none;
	transition: border-color .12s, background .12s;
}
.chip:hover { border-color: var(--red); background: var(--red-soft); text-decoration: none; }
.chip[hidden] { display: none; }
.chip-age { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.chip-age.heat-red { color: var(--bad); }
.chip-tries { font-size: 11px; font-weight: 700; color: var(--bad); }

.empty { margin: 0; padding: 4px 18px 16px; color: var(--text-dim); font-size: 13.5px; }

/* ---------- search suggestions ---------- */

.suggest {
	position: absolute; z-index: 30; top: calc(100% + 6px); right: 60px; margin: 0;
	padding: 6px; list-style: none;
	width: min(380px, calc(100vw - 40px)); max-height: 320px; overflow-y: auto;
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
	box-shadow: var(--shadow);
}
.suggest button {
	display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left;
	font: inherit; color: inherit; background: none; border: 0; border-radius: 7px;
	padding: 7px 10px; cursor: pointer;
}
.suggest button:hover, .suggest button:focus-visible { background: var(--surface-2); outline: none; }
.s-meta { margin-left: auto; font-size: 11.5px; color: var(--text-dim); }
.suggest-empty { padding: 8px 10px; font-size: 13px; color: var(--text-dim); }

/* ---------- page actions & footer ---------- */

.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-actions a {
	display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550;
	padding: 7px 12px; border-radius: 999px; background: var(--surface);
	border: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.page-actions a:hover { border-color: var(--red); color: var(--red); }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; font-size: 13px; color: var(--text-dim); }
.site-footer p { margin: 0 0 8px; max-width: 90ch; }
.site-footer code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
	.quick input { width: 130px; }
	.quick select { display: none; }
	.brand-sub { display: none; }
	.metric .value { font-size: 24px; }
	.page-head { margin-bottom: 18px; }
	.suggest { right: 0; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
	html { scroll-behavior: auto; }
}
