---
import Base from '../../layouts/Base.astro';
import SectionBanner from '../../components/SectionBanner.astro';
import Icon from '../../components/Icon.astro';
import { allTags, allTools, tagSlug, toolHref } from '../../lib/sheets';
import { url } from '../../lib/url';
const tags = await allTags();
const tools = await allTools();
---
<Base title="Tags & Tools — DÆMON//SEC" description="Browse every cheatsheet by tag or tool.">
<SectionBanner
n="06"
label="Cross-reference"
title="Tags & Tools"
blurb="Jump into the vault by topic or by the tool you're reaching for."
accent="foam"
stats={[
{ label: 'Tags', value: String(tags.length).padStart(2, '0'), accent: true },
{ label: 'Tools', value: String(tools.length).padStart(2, '0') },
]}
/>
<div class="wrap">
<nav class="breadcrumb" style="margin-top:1.6rem;">
<a href={url('')}>~</a><span class="sep">/</span><span class="muted">index</span>
</nav>
<!-- Seven hundred chips is a wall; this narrows both clouds as you type.
Borrows the sheet filter's search field (filter.css). -->
<div class="sf" data-cloud-filter style="--sf-acc: var(--foam); margin-bottom:0;">
<div class="sf__bar">
<label class="sf__search">
<Icon name="search" />
<span class="sr-only">Filter tags and tools</span>
<input type="search" data-cloud-q placeholder="Filter tags and tools" autocomplete="off" spellcheck="false" />
</label>
<span class="sf__count" data-cloud-count aria-live="polite">{tags.length + tools.length} shown</span>
</div>
</div>
<section class="section" style="margin-top:2rem;">
<div class="section-head">
<div>
<p class="eyebrow" style="--acc: var(--iris);">
<span class="eyebrow__n">01</span>
<span class="eyebrow__mark">^:</span>
<span data-cloud-n data-unit="tags">{tags.length} tags</span>
<span class="eyebrow__rule" aria-hidden="true"></span>
</p>
<h2>By tag</h2>
</div>
</div>
<div class="cloud">
{tags.map((t) => (
<a class="tag-pill cloud-item" data-name={t.tag.toLowerCase()} href={url(`tags/${tagSlug(t.tag)}`)}>{t.tag}<span class="cnt">{t.count}</span></a>
))}
<p class="cloud-empty muted mono" hidden>No tag matches.</p>
</div>
</section>
<section class="section">
<div class="section-head">
<div>
<p class="eyebrow" style="--acc: var(--gold);">
<span class="eyebrow__n">02</span>
<span class="eyebrow__mark">^:</span>
<span data-cloud-n data-unit="tools">{tools.length} tools</span>
<span class="eyebrow__rule" aria-hidden="true"></span>
</p>
<h2>By tool</h2>
</div>
</div>
<div class="cloud">
{tools.map((t) => (
<a class="tag-pill cloud-item" data-name={t.key} href={url(toolHref(t.tool))}>{t.tool}<span class="cnt">{t.count}</span></a>
))}
<p class="cloud-empty muted mono" hidden>No tool matches.</p>
</div>
</section>
</div>
</Base>
<script>
// Type-to-filter over both clouds. Every chip is in the HTML, so with JS
// off the page is simply the full index it always was.
function initCloudFilter() {
const root = document.querySelector<HTMLElement>('[data-cloud-filter]');
if (!root || root.dataset.bound) return;
root.dataset.bound = '1';
const input = root.querySelector<HTMLInputElement>('[data-cloud-q]');
const count = root.querySelector<HTMLElement>('[data-cloud-count]');
const clouds = [...document.querySelectorAll<HTMLElement>('.cloud')].map((cloud) => ({
items: [...cloud.querySelectorAll<HTMLElement>('.cloud-item')],
empty: cloud.querySelector<HTMLElement>('.cloud-empty'),
label: cloud.closest('section')?.querySelector<HTMLElement>('[data-cloud-n]') ?? null,
}));
if (!input) return;
const apply = () => {
const terms = input.value.toLowerCase().split(/\s+/).filter(Boolean);
let total = 0;
for (const { items, empty, label } of clouds) {
let shown = 0;
for (const item of items) {
const name = item.dataset.name ?? '';
const ok = terms.every((t) => name.includes(t));
item.hidden = !ok;
if (ok) shown += 1;
}
total += shown;
if (empty) empty.hidden = shown > 0;
if (label) {
const unit = label.dataset.unit ?? '';
label.textContent = shown === items.length ? `${shown} ${unit}` : `${shown} of ${items.length} ${unit}`;
}
}
if (count) count.textContent = `${total} shown`;
};
input.addEventListener('input', apply);
input.addEventListener('keydown', (e) => {
if (e.key !== 'Escape' || !input.value) return;
e.stopPropagation();
input.value = '';
apply();
});
}
document.addEventListener('astro:page-load', initCloudFilter);
if (document.readyState !== 'loading') initCloudFilter();
else document.addEventListener('DOMContentLoaded', initCloudFilter, { once: true });
</script>
<style>
.cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cloud-item[hidden] { display: none; }
.cloud-empty { font-size: 0.84rem; padding: 0.4rem 0; }
.cloud-item { display: inline-flex; align-items: center; gap: 0.5rem; }
/* The count is a second register inside the chip, not a badge on it —
square, hairline-separated, same 10px mono. */
.cloud-item .cnt {
padding-left: 0.5rem;
border-left: 1px solid var(--rule);
color: var(--fg-faint);
}
.cloud-item:hover .cnt { color: inherit; border-left-color: currentColor; }
/* Corner ticks on hover only: the full .corners object on every pill in a
cloud of dozens is bracket noise, so the pills take the record-row
convention — the brackets arrive with the pointer. Same geometry as
.corners (10px L-ticks, -3px offset), keyed to currentColor so the ticks
flip to cream when the pill inverts on hover. */
.cloud-item { position: relative; }
.cloud-item:hover::before,
.cloud-item:hover::after {
content: "";
position: absolute;
inset-block: -3px;
width: 10px;
pointer-events: none;
}
.cloud-item:hover::before {
inset-inline-start: -3px;
background:
linear-gradient(currentColor 0 0) left top / 10px 1px no-repeat,
linear-gradient(currentColor 0 0) left top / 1px 10px no-repeat,
linear-gradient(currentColor 0 0) left bottom / 10px 1px no-repeat,
linear-gradient(currentColor 0 0) left bottom / 1px 10px no-repeat;
}
.cloud-item:hover::after {
inset-inline-end: -3px;
background:
linear-gradient(currentColor 0 0) right top / 10px 1px no-repeat,
linear-gradient(currentColor 0 0) right top / 1px 10px no-repeat,
linear-gradient(currentColor 0 0) right bottom / 10px 1px no-repeat,
linear-gradient(currentColor 0 0) right bottom / 1px 10px no-repeat;
}
</style>