/* Showcase index for the 40 template sites.
   Self-contained: tokens, layout, components, motion, responsive. */

/* ── tokens ────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --surface: #fffdfa;
  --surface-2: #ece8e1;
  --ink: #16150f;
  --muted: #6b675e;
  --line: #ddd8ce;
  --accent: #b4552d;
  --accent-ink: #fffdfa;
  --positive: #2f7d57;
  --negative: #b23b32;
  --radius: 18px;
  --radius-sm: 10px;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --max: 1480px;
  --shadow: 0 1px 2px rgb(22 21 15 / 6%), 0 12px 32px -12px rgb(22 21 15 / 18%);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --step-0: 1rem;
  --step-1: clamp(1.15rem, 1.4vw, 1.35rem);
  --step-2: clamp(1.45rem, 2.2vw, 2rem);
  --step-3: clamp(2rem, 4vw, 3.25rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101012;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --ink: #f3f1ec;
  --muted: #a09c93;
  --line: #2c2c31;
  --accent: #e0a458;
  --accent-ink: #16150f;
  --positive: #63d39b;
  --negative: #ff8f7e;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 18px 40px -18px rgb(0 0 0 / 70%);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus-visible {
  top: 1rem;
}

.error-page {
  padding-block: 18vh;
}

.error-page h1 {
  margin: 1rem 0;
  font-size: var(--step-2);
  letter-spacing: -0.03em;
}

.error-page p {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

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

/* ── layout ────────────────────────────────────────────────────────── */
.wrap {
  width: min(var(--max), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-block: 0.9rem;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(14px) saturate(1.4);
  transition: border-color 0.3s var(--ease);
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-right: auto;
  text-decoration: none;
}

.brand-mark {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.header-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
}

.hero {
  padding-block: clamp(3rem, 8vw, 6rem) clamp(2rem, 4vw, 3rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow::before {
  content: "";
  width: 2rem;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  max-width: 20ch;
  margin: 1rem 0 0;
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  max-width: 58ch;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: var(--step-1);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* ── toolbar ───────────────────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 4.35rem;
  z-index: 15;
  padding-block: 0.85rem;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}

.chip:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.search {
  position: relative;
  margin-left: auto;
  min-width: min(260px, 100%);
}

.search input {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
}

.search svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.result-count {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ── grid ──────────────────────────────────────────────────────────── */
.grid-section {
  padding-block: clamp(1.5rem, 3vw, 2.5rem) clamp(3rem, 6vw, 5rem);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: clamp(1rem, 2vw, 1.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
}

.card.is-hidden {
  display: none;
}

.card-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-2);
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.6s var(--ease), filter 0.6s var(--ease);
}

.card:hover .card-media img {
  transform: scale(1.04);
}

.card-index {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgb(10 10 10 / 62%);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  backdrop-filter: blur(6px);
}

.card-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-swatches {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: rgb(255 255 255 / 78%);
  backdrop-filter: blur(8px);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgb(0 0 0 / 12%);
  background: var(--swatch, var(--surface-2));
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.1rem 1.15rem;
}

.card-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card-tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease),
    border-color 0.2s var(--ease);
}

.button:hover {
  border-color: var(--ink);
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.button--primary:hover {
  background: color-mix(in oklab, var(--accent) 84%, var(--ink));
  border-color: transparent;
}

.button svg {
  width: 0.85rem;
  height: 0.85rem;
}

.empty {
  padding: 4rem 1rem;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink);
  font-size: var(--step-1);
}

/* ── footer ────────────────────────────────────────────────────────── */
.site-footer {
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  justify-content: space-between;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

/* ── motion ────────────────────────────────────────────────────────── */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: var(--delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}

/* ── responsive ────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .header-meta {
    display: none;
  }

  .toolbar {
    position: static;
  }

  .search {
    margin-left: 0;
    flex: 1 1 100%;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .chip {
    white-space: nowrap;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: var(--ink);
  }
}
