/* Hallmark · genre: atmospheric · macrostructure: Sidebar Filter · theme: Dusk (custom)
 * mode: dark-primary (light toggle) · nav: N10 scroll-morph · footer: Ft4 dense colophon
 * pre-emit critique: P5 H5 E4 S5 R5 V5
 *
 * Shared chrome: reset, type base, focus, nav, footer, buttons (8-state), toast,
 * cmd-k modal shell, and the card primitives the catalog grid is built from.
 * Page CSS imports this + tokens.css and adds only page-specific rules — never
 * redeclare nav/footer/button/card rules per page.
 */

*, *::before, *::after { box-sizing: border-box; }
/* The `hidden` attribute is only display:none by UA stylesheet, which any
 * component rule setting `display` silently outranks — the element stays
 * visible while every script and a11y tree believes it is hidden. This caught
 * two real ones: #no-results rendered "No skills match those filters" under a
 * full 57-card grid, and #back-to-top sat on screen at scroll 0. Both toggle
 * via el.hidden, so nothing in the JS looked wrong. Keep this above the
 * component layers. */
[hidden] { display: none !important; }
/* clip, never hidden — `hidden` on the root breaks position:sticky */
html, body { overflow-x: clip; }
html { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink-2);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur-short) var(--ease-in-out), color var(--dur-short) var(--ease-in-out);
}

h1, h2, h3, h4 {
  font-family: var(--font-display); color: var(--color-ink); font-weight: 600;
  font-style: normal; /* roman display only — italic headers are an AI tell */
  line-height: 1.15; margin: 0; letter-spacing: -0.01em;
  text-wrap: balance; overflow-wrap: anywhere; min-width: 0;
}
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
code, kbd, .mono { font-family: var(--font-mono); }

::selection { background: var(--color-accent-soft); color: var(--color-ink); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; transition: none; }

.skip-link {
  position: absolute; top: -48px; left: var(--space-md);
  background: var(--color-cta); color: var(--color-cta-ink);
  padding: var(--space-xs) var(--space-md); border-radius: var(--radius-control);
  font-size: var(--text-sm); font-weight: 600; text-decoration: none; z-index: var(--z-toast);
  transition: top var(--dur-short) var(--ease-out);
}
.skip-link:focus { top: var(--space-md); }

.wrap { max-width: 1320px; margin-inline: auto; padding-inline: var(--gutter); }

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

.eyebrow {
  font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--color-ink-3);
}

/* ============ NAV — N10 scroll-morph ============ */
/* The catalog's masthead sits under a transparent nav that morphs to an opaque
 * blurred bar past ~80px. Pages that start with ordinary content mark their nav
 * .is-solid in the HTML and opt out entirely. */
.nav {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out),
              backdrop-filter var(--dur-short) var(--ease-out);
}
.nav.is-stuck, .nav.is-solid {
  background: color-mix(in oklab, var(--color-paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom-color: var(--color-rule);
}
/* Before it sticks, a soft top scrim keeps the links legible without a solid
 * bar fighting the masthead underneath. */
.nav:not(.is-stuck):not(.is-solid)::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, oklch(0% 0 0 / 0.55), oklch(0% 0 0 / 0));
}
[data-theme="light"] .nav:not(.is-stuck):not(.is-solid)::before {
  background: linear-gradient(to bottom, oklch(100% 0 0 / 0.7), oklch(100% 0 0 / 0));
}
.nav-inner {
  position: relative; z-index: 1;
  max-width: 1320px; margin-inline: auto; padding-inline: var(--gutter);
  height: var(--nav-h); display: flex; align-items: center; gap: var(--space-lg);
}
.nav-brand {
  display: flex; align-items: center; gap: var(--space-xs); text-decoration: none;
  color: var(--color-ink); font-family: var(--font-display); font-weight: 600;
  font-size: var(--text-md); white-space: nowrap;
}
.nav-brand svg { color: var(--color-accent); }
/* nowrap is load-bearing: wrapping makes the links break onto a second line and
 * burst out of the fixed-height bar, which reads as broken chrome on phones. */
.nav-links { display: flex; align-items: center; gap: var(--space-lg); flex-wrap: nowrap; margin-inline-end: auto; min-width: 0; }
.nav-links a {
  text-decoration: none; color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 500;
  padding: var(--space-2xs) 0; border-bottom: 1px solid transparent;
  transition: color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out);
}
.nav-links a:hover { color: var(--color-ink); }
.nav-links a[aria-current="page"] { color: var(--color-ink); border-bottom-color: var(--color-accent); }
.nav-actions { display: flex; align-items: center; gap: var(--space-sm); }

.cmdk-trigger {
  display: flex; align-items: center; gap: var(--space-sm);
  background: var(--color-cta-2); border: 1px solid var(--color-rule-2); border-radius: var(--radius-control);
  padding: var(--space-xs) var(--space-sm); font-size: var(--text-sm); color: var(--color-ink-2);
  cursor: pointer; min-height: 40px;
  transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.cmdk-trigger:hover { border-color: var(--color-ink-3); background: var(--color-cta-2-hover); }
.cmdk-trigger-kbd { font-family: var(--font-mono); font-size: var(--text-xs); border: 1px solid var(--color-rule-2); border-radius: 4px; padding: 1px 5px; color: var(--color-ink-3); }
@media (max-width: 30rem) { .cmdk-trigger-label { display: none; } .cmdk-trigger { padding-inline: var(--space-sm); } }

.theme-toggle, .icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; background: var(--color-cta-2);
  border: 1px solid var(--color-rule-2); border-radius: var(--radius-control);
  color: var(--color-ink-2); cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.theme-toggle:hover, .icon-btn:hover { border-color: var(--color-ink-3); background: var(--color-cta-2-hover); color: var(--color-ink); }
[data-theme="dark"] .icon-sun, [data-theme="light"] .icon-moon { display: none; }

.github-link { display: none; }
@media (min-width: 48rem) {
  .github-link {
    display: inline-flex; align-items: center; height: 40px; padding-inline: var(--space-sm);
    border: 1px solid var(--color-rule-2); border-radius: var(--radius-control);
    text-decoration: none; color: var(--color-ink-2); font-size: var(--text-sm); font-weight: 500;
    background: var(--color-cta-2);
    transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
  }
  .github-link:hover { border-color: var(--color-ink-3); background: var(--color-cta-2-hover); }
}

@media (max-width: 60rem) { .nav-links { gap: var(--space-md); } }
/* Below ~44rem the bar can hold the wordmark, one link, and the actions —
 * "Submit a skill" and "Changelog" go first, "Bundles" next. Everything stays
 * reachable through the wordmark -> catalog and the ⌘K palette. */
@media (max-width: 44rem) {
  .nav-links a:not([data-nav="catalog"]):not([data-nav="bundles"]) { display: none; }
  .nav-inner { gap: var(--space-md); }
}
@media (max-width: 30rem) {
  .nav-links a:not([data-nav="catalog"]) { display: none; }
  .nav-inner { gap: var(--space-sm); }
  .nav-brand { font-size: var(--text-sm); }
}

/* ============ CMD-K PALETTE ============ */
.cmdk-backdrop {
  position: fixed; inset: 0; background: oklch(0% 0 0 / 0.62);
  z-index: var(--z-modal); display: flex; align-items: flex-start; justify-content: center;
  padding-top: min(14vh, 120px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-short) var(--ease-out);
}
.cmdk-backdrop.is-open { opacity: 1; pointer-events: auto; }
.cmdk-modal {
  width: min(620px, calc(100vw - 2rem)); max-height: min(64vh, 520px);
  background: var(--color-paper-2); border: 1px solid var(--color-rule-2); border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(-6px) scale(0.98); transition: transform var(--dur-short) var(--ease-out);
}
.cmdk-backdrop.is-open .cmdk-modal { transform: none; }
.cmdk-input-row { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-md); border-bottom: 1px solid var(--color-rule); }
.cmdk-input-row svg { color: var(--color-ink-3); flex-shrink: 0; }
.cmdk-input { flex: 1; min-width: 0; border: none; background: none; font-family: var(--font-body); font-size: var(--text-lg); color: var(--color-ink); }
/* The input sits inside an already-outlined modal, so its own ring is drawn on
 * the row rather than the field — but it must still be visible. Removing the
 * outline outright left keyboard users with no focus indicator at all. */
.cmdk-input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }
.cmdk-input-row kbd { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); border: 1px solid var(--color-rule-2); border-radius: 4px; padding: 1px 5px; }
.cmdk-results { overflow-y: auto; padding: var(--space-xs); }
.cmdk-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm); border-radius: var(--radius-control); cursor: pointer; }
.cmdk-row-name { font-size: var(--text-sm); color: var(--color-ink); font-weight: 500; white-space: nowrap; }
.cmdk-row-desc { font-size: var(--text-xs); color: var(--color-ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-inline-end: var(--space-md); flex: 1; }
.cmdk-row[aria-selected="true"] { background: var(--color-paper-3); }
.cmdk-row mark { background: var(--color-accent-soft); color: var(--tier-core-ink); border-radius: 2px; }
.cmdk-empty { padding: var(--space-xl) var(--space-md); text-align: center; color: var(--color-ink-3); font-size: var(--text-sm); }
.cmdk-hint { padding: var(--space-xs) var(--space-md) var(--space-md); text-align: center; font-size: var(--text-xs); color: var(--color-ink-4); border-top: 1px solid var(--color-rule); }
.cmdk-hint code { color: var(--color-ink-3); }
.cmdk-suggest {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--color-accent); font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.cmdk-suggest:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* ============ BUTTONS — full 8-state ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  height: 40px; padding-inline: var(--space-md); border-radius: var(--radius-control);
  font-size: var(--text-sm); font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  transition: transform var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out),
              background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.btn-lg { height: 48px; padding-inline: var(--space-lg); font-size: var(--text-md); }
.btn-sm { height: 34px; padding-inline: var(--space-sm); font-size: var(--text-xs); }

/* Primary is a light fill with dark ink (~16:1). The crimson accent is the
 * brand signal, not a text-bearing surface — see design.md. */
.btn-primary, .btn-primary.is-hover { background: var(--color-cta); color: var(--color-cta-ink); }
.btn-primary:hover, .btn-primary.is-hover { background: var(--color-cta-hover); }
.btn-primary:active, .btn-primary.is-active { transform: translateY(1px); }
.btn-primary:disabled, .btn-primary.is-disabled { background: var(--color-paper-3); color: var(--color-ink-4); cursor: not-allowed; }
.btn-primary[data-state="loading"] { color: transparent; position: relative; }
.btn-primary[data-state="loading"]::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--color-cta-ink); border-top-color: transparent; animation: spin 700ms linear infinite; }
.btn-primary[data-state="error"] { background: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary[data-state="success"] { background: var(--color-success); color: var(--color-cta-ink); }

.btn-secondary { background: var(--color-cta-2); color: var(--color-ink); }
.btn-secondary:hover, .btn-secondary.is-hover { background: var(--color-cta-2-hover); }
.btn-secondary:active, .btn-secondary.is-active { transform: translateY(1px); }
.btn-secondary:disabled { color: var(--color-ink-4); cursor: not-allowed; }

.btn-outline { background: transparent; color: var(--color-ink-2); border-color: var(--color-rule-2); }
.btn-outline:hover, .btn-outline.is-hover { border-color: var(--color-ink-3); color: var(--color-ink); }
.btn-outline:active, .btn-outline.is-active { transform: translateY(1px); }
.btn-outline:disabled, .btn-outline.is-disabled { color: var(--color-ink-4); border-color: var(--color-rule); cursor: not-allowed; }
.btn-outline.copied, .btn-outline.is-success { border-color: var(--color-success); color: var(--color-success); }

.btn:focus-visible, .btn.is-focus { outline: 2px solid var(--color-focus); outline-offset: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ POSTER — the catalog's atom ============ */
/* Artwork is generated, never stock: a deterministic hue from the skill name
 * drives a two-stop wash, with the monogram as the only mark. */
.poster {
  position: relative; display: flex; flex-direction: column;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--color-paper-2); border: 1px solid var(--color-rule);
  border-radius: var(--radius-card); overflow: hidden; padding: 0;
  color: inherit; font-family: inherit;
  transition: transform var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
}
.poster:hover, .poster:focus-visible { transform: translateY(-4px) scale(1.02); box-shadow: var(--shadow-lift); border-color: var(--color-rule-2); z-index: var(--z-raised); }
.poster:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.poster:active { transform: translateY(-1px) scale(1.005); }

.poster-art {
  aspect-ratio: var(--poster-ratio); width: 100%;
  display: flex; align-items: center; justify-content: center;
  background-image: linear-gradient(145deg, var(--art-a), var(--art-b));
  position: relative; isolation: isolate;
}
.poster-mono {
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-2xl);
  color: oklch(100% 0 0 / 0.92); letter-spacing: -0.02em;
  text-shadow: 0 1px 12px oklch(0% 0 0 / 0.35);
}
.poster-body { padding: var(--space-sm) var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: var(--space-2xs); flex: 1; }
.poster-name { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600; color: var(--color-ink); overflow-wrap: anywhere; }
.poster-desc {
  font-size: var(--text-xs); color: var(--color-ink-3); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.poster-foot { display: flex; align-items: center; gap: var(--space-xs); margin-top: auto; padding-top: var(--space-xs); }

/* A copy-install action that lives on the card itself, so the common case
 * never requires opening the detail overlay. */
.poster-quick {
  position: absolute; top: var(--space-xs); right: var(--space-xs); z-index: 2;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs);
  height: 30px; min-width: 30px; padding-inline: var(--space-xs);
  border: 1px solid oklch(100% 0 0 / 0.22); border-radius: var(--radius-control);
  background: oklch(0% 0 0 / 0.55); color: oklch(100% 0 0 / 0.92);
  font-size: var(--text-xs); font-family: var(--font-body); cursor: pointer;
  opacity: 0; transition: opacity var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.poster:hover .poster-quick, .poster:focus-within .poster-quick { opacity: 1; }
.poster-quick:hover { background: oklch(0% 0 0 / 0.78); }
/* Touch has no hover — never hide an action behind it. */
@media (hover: none) { .poster-quick { opacity: 1; } }
.poster-quick:focus-visible { opacity: 1; outline: 2px solid var(--color-focus); outline-offset: 1px; }

.tier-badge {
  display: inline-flex; align-items: center; height: 20px; padding-inline: var(--space-xs);
  border-radius: 4px; font-family: var(--font-mono); font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500;
}
.tier-badge.core { background: var(--tier-core-bg); color: var(--tier-core-ink); }
.tier-badge.featured { background: var(--tier-featured-bg); color: var(--tier-featured-ink); }
.tier-badge.utility { background: var(--tier-utility-bg); color: var(--tier-utility-ink); }

/* ============ CARD GRID — the results pane's only layout ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-w), 100%), 1fr));
  gap: var(--space-md);
}
@media (max-width: 30rem) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--card-w-sm), 100%), 1fr)); gap: var(--space-sm); }
}

/* Skeletons — shown while skills-index.json is in flight, so the grid has shape
 * before it has data instead of a bare "Loading…" string. */
.skeleton { background: var(--color-paper-2); border: 1px solid var(--color-rule); border-radius: var(--radius-card); overflow: hidden; }
.skeleton-art { aspect-ratio: var(--poster-ratio); background: linear-gradient(90deg, var(--color-paper-2) 25%, var(--color-paper-3) 37%, var(--color-paper-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-line { height: 10px; margin: var(--space-sm); border-radius: 3px; background: linear-gradient(90deg, var(--color-paper-2) 25%, var(--color-paper-3) 37%, var(--color-paper-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-line.short { width: 55%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-art, .skeleton-line { animation: none; } }

/* ============ MY LIST — visitor-local, never a global count ============ */
.mylist-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs);
  height: 30px; min-width: 30px; padding-inline: var(--space-xs);
  border: 1px solid var(--color-rule-2); border-radius: var(--radius-control);
  background: transparent; color: var(--color-ink-3); cursor: pointer; font-size: var(--text-xs);
  transition: color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out);
}
.mylist-btn:hover { color: var(--color-ink); border-color: var(--color-ink-3); }
.mylist-btn[aria-pressed="true"] { color: var(--color-accent); border-color: var(--color-accent); }
.mylist-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: var(--space-lg); left: 50%; transform: translate(-50%, 12px);
  background: var(--color-cta); color: var(--color-cta-ink); font-size: var(--text-sm); font-weight: 500;
  padding: var(--space-sm) var(--space-md); border-radius: var(--radius-control);
  opacity: 0; z-index: var(--z-toast); pointer-events: none; box-shadow: var(--shadow-lift);
  transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ REVEAL ============ */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity var(--dur-long) var(--ease-out), transform var(--dur-long) var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { transition: opacity 150ms linear; transform: none; }
  .poster:hover, .poster:focus-visible { transform: none; }
}

/* ============ FOOTER — Ft4 dense colophon ============ */
.footer { border-top: 1px solid var(--color-rule); padding-block: var(--space-xl); margin-top: var(--space-2xl); }
.footer-inner {
  max-width: 1320px; margin-inline: auto; padding-inline: var(--gutter);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: var(--space-lg); align-items: start;
}
.footer-col { display: flex; flex-direction: column; gap: var(--space-2xs); min-width: 0; }
.footer-word { color: var(--color-ink); font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.footer-note, .footer-meta { font-size: var(--text-sm); color: var(--color-ink-3); }
.footer-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-ink-4); }
.footer-code {
  font-size: var(--text-xs); color: var(--color-graphite-ink-2); background: var(--color-graphite);
  border: 1px solid var(--color-graphite-rule); border-radius: var(--radius-control);
  padding: var(--space-xs) var(--space-sm); overflow-x: auto; white-space: nowrap;
}
.footer-meta a { color: var(--color-ink-2); text-decoration: underline; text-underline-offset: 2px; }
.footer-meta a:hover { color: var(--color-ink); }

/* ============ MOBILE HIT TARGETS ============ */
@media (max-width: 40rem) {
  .btn, .icon-btn, .theme-toggle, .cmdk-trigger, .mylist-btn, .poster-quick { min-height: 44px; }
  .poster-quick { min-width: 44px; }
}
