---
import Base from '../../layouts/Base.astro';
import SectionBanner from '../../components/SectionBanner.astro';
import RecordRow from '../../components/RecordRow.astro';
import CategoryNav from '../../components/CategoryNav.astro';
import SheetFilter from '../../components/SheetFilter.astro';
import SectionJump from '../../components/SectionJump.astro';
import { CATEGORIES } from '../../lib/taxonomy';
import { allSheets, allTools, sheetHref, isReportGuide, sheetFacets } from '../../lib/sheets';
import { url } from '../../lib/url';
/* Every sheet, once, under the shelf it canonically lives on. A cross-listed
sheet (`alsoIn`) appears on each of its shelves' own pages but only once
here, so the count in the banner is the count of sheets, not of listings. */
const sheets = await allSheets();
const tools = await allTools();
const shelves = CATEGORIES
.map((c) => ({ ...c, items: sheets.filter((s) => s.data.category === c.slug) }))
.filter((c) => c.items.length > 0);
const facetRows = shelves.flatMap((c) => c.items.map((s) => sheetFacets(s, c.slug)));
const groups = shelves.map((c) => ({ key: c.slug, label: c.title, count: c.items.length, accent: c.accent }));
const total = facetRows.length;
---
<Base
title="All sheets — DÆMON//SEC"
description={`Every cheatsheet in the vault — ${total} sheets across ${shelves.length} shelves — in one index you can filter by text, tag, tool and difficulty.`}
>
<SectionBanner
n="02"
label="Index"
title="All sheets"
blurb="Every sheet in the vault, in one place. Search it, or narrow it by tag, tool, difficulty and shelf."
accent="foam"
stats={[
{ label: 'Sheets', value: total, accent: true },
{ label: 'Shelves', value: String(shelves.length).padStart(2, '0') },
{ label: 'Tools covered', value: tools.length },
]}
/>
<div class="wrap">
<nav class="breadcrumb" style="margin-top:1.6rem;">
<a href={url('')}>~</a><span class="sep">/</span><span class="accent-text">sheets</span>
</nav>
<div style="margin:1.4rem 0 0;"><CategoryNav active="all" /></div>
<SheetFilter rows={facetRows} scope="all sheets" accent="love" groups={groups} groupLabel="Shelves" />
<SectionJump items={groups} label="Shelves" />
<div style="margin-bottom:3rem;">
{shelves.map((c, ci) => (
<section class="subcat" id={`sec-${c.slug}`} data-sf-section={c.slug}>
<div class="section-head" style="margin-bottom:0.9rem;">
<div>
<p class="eyebrow" style={`--acc: var(--${c.accent});`}>
<span class="eyebrow__n">{String(ci + 1).padStart(2, '0')}</span>
<span class="eyebrow__mark">^:</span>
<span data-sf-of={`sec:${c.slug}`} data-total={c.items.length}>{c.items.length} {c.items.length === 1 ? 'sheet' : 'sheets'}</span>
<span class="eyebrow__rule" aria-hidden="true"></span>
</p>
<h2>{c.title}</h2>
</div>
<a class="shelf-link" href={url(c.slug)} style={`--acc: var(--${c.accent});`}>Open shelf →</a>
</div>
<div class="index">
{c.items.map((entry, i) => (
<RecordRow
href={url(sheetHref(entry))}
n={String(i + 1).padStart(2, '0')}
title={entry.data.title}
reportGuide={isReportGuide(entry)}
kind={entry.data.difficulty}
accent={c.accent}
meta={entry.data.updated ?? entry.id.split('/').pop()}
facets={sheetFacets(entry, c.slug)}
/>
))}
</div>
</section>
))}
</div>
</div>
</Base>
<style>
.subcat + .subcat { margin-top: clamp(2.2rem, 4.5vw, 3.4rem); }
.shelf-link {
flex: none;
font-family: var(--font-mono);
font-size: var(--step-micro);
letter-spacing: var(--track-micro);
text-transform: uppercase;
color: var(--acc);
padding-bottom: 0.35rem;
}
.shelf-link:hover { text-decoration: underline; text-underline-offset: 4px; }
</style>