/* ── Variables ────────────────────────────────── */
:root {
  --bg: #f5f2ed;
  --surface: #ffffff;
  --border: #d8d3c8;
  --text-primary: #1a1815;
  --text-secondary: #6b6660;
  --accent: #3d5a4a;
  --accent-light: #e8ede9;
  --tag-bg: #e4e1da;
  --radius: 6px;
  --card-radius: 8px;
  --transition: 0.32s cubic-bezier(0.4, 0, 0.2, 1);

  /* Dummy thumbnail colors per template */
  --t1-a: #c0cac8;
  --t1-b: #a8b8b4;
  --t2-a: #c8beb8;
  --t2-b: #b8aea8;
  --t3-a: #bcc4d0;
  --t3-b: #a8b4c4;
  --t4-a: #c4c0cc;
  --t4-b: #b4b0bc;
  --t5-a: #c8c4b0;
  --t5-b: #b8b4a0;
  --t6-a: #c0ccbc;
  --t6-b: #aabcb0;
}

/* ── Reset ────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
}
body {
  font-family: "DM Sans", sans-serif;
  background-color: #ffffff;
  background-image:
    linear-gradient(90deg, #d8d3c80f 2px, transparent 2px),
    linear-gradient(#d8d3c80f 2px, transparent 2px);
  background-position: 10px 10px;
  background-size: 4px 4px;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Page load ────────────────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.reveal {
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}
.d1 {
  animation-delay: 0.05s;
}
.d2 {
  animation-delay: 0.15s;
}
.d3 {
  animation-delay: 0.25s;
}

/* ── Header ───────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* background: rgba(245, 242, 237, 0.9); */
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 5vw;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  font-family: "Instrument Serif", serif;
  font-size: 1.15rem;
  white-space: nowrap;
}
.logo span {
  font-style: italic;
  color: var(--text-secondary);
}

/* ── Hero banner ──────────────────────────────── */
.hero {
  padding: 5rem 5vw 4rem;
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: 900px;
}
.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--accent);
}
h1 {
  font-family: "Instrument Serif", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.15;
  margin-bottom: 1rem;
}
h1 em {
  font-style: italic;
  color: var(--text-secondary);
}
.hero-desc {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 50ch;
  line-height: 1.8;
  margin-bottom: 2rem;
}

/* ── Filter bar ───────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-right: 0.25rem;
}
.filter-btn {
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}
.filter-btn:hover,
.filter-btn.active {
  background: var(--text-primary);
  color: var(--bg);
  border-color: var(--text-primary);
}

/* ── Main ─────────────────────────────────────── */
main {
  padding: 4rem 5vw;
}

/* ── Section label ────────────────────────────── */
.section-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.section-label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-count {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ── Card Grid ────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 4rem;
}

/* ── Template Card ────────────────────────────── */
.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}
.tpl-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
  border-color: var(--text-secondary);
}

/* Card staggered delays */
.tpl-card:nth-child(1) {
  animation-delay: 0.1s;
}
.tpl-card:nth-child(2) {
  animation-delay: 0.17s;
}
.tpl-card:nth-child(3) {
  animation-delay: 0.24s;
}
.tpl-card:nth-child(4) {
  animation-delay: 0.31s;
}
.tpl-card:nth-child(5) {
  animation-delay: 0.38s;
}
.tpl-card:nth-child(6) {
  animation-delay: 0.45s;
}

/* Thumbnail */
.tpl-thumb {
  height: 200px;
  position: relative;
  overflow: hidden;
}
/* Micro-wireframe inside thumbnail */
.tpl-thumb-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.tpl-card:hover .tpl-thumb-inner {
  transform: scale(1.03);
}

/* Dummy bars inside thumbnail */
.thumb-nav {
  height: 28px;
  flex-shrink: 0;
}
.thumb-hero {
  flex: 2;
}
.thumb-body {
  flex: 1;
  display: flex;
}
.thumb-body-block {
  flex: 1;
}

/* Labels on thumb */
.thumb-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

/* Overlay on hover */
.tpl-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 24, 21, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background var(--transition);
}
.tpl-card:hover .tpl-overlay {
  background: rgba(26, 24, 21, 0.45);
}
.overlay-btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: #fff;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity var(--transition),
    transform var(--transition),
    background var(--transition);
}
.tpl-card:hover .overlay-btn {
  opacity: 1;
  transform: translateY(0);
}
.overlay-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.overlay-btn:nth-child(2) {
  transition-delay: 0.04s;
}

/* Card body */
.tpl-body {
  padding: 1rem 1.25rem 1.25rem;
}
.tpl-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.tpl-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.tag {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--tag-bg);
  color: var(--text-secondary);
}
.tpl-updated {
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.tpl-name {
  font-family: "Instrument Serif", serif;
  font-size: 1.05rem;
  margin-bottom: 0.3rem;
}
.tpl-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 1rem;
}
.tpl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.tpl-features {
  display: flex;
  gap: 0.75rem;
}
.tpl-feature {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.tpl-feature svg {
  color: var(--accent);
}
.tpl-link {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: gap var(--transition);
}
.tpl-link:hover {
  gap: 0.5rem;
}
a {
  text-decoration: none;
  color: inherit;
}

/* ── Stats bar ────────────────────────────────── */
.stats-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.5rem 2rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 4rem;
  text-align: center;
}
.stat-item {
  position: relative;
}
.stat-item + .stat-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background: var(--border);
}
.stat-num {
  font-family: "Instrument Serif", serif;
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.3rem;
}
.stat-lbl {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Empty state ──────────────────────────────── */
.empty-card {
  border: 2px dashed var(--border);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  gap: 0.75rem;
  color: var(--text-secondary);
  min-height: 300px;
  cursor: pointer;
  transition:
    border-color var(--transition),
    background var(--transition);
}
.empty-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--tag-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
  transition: transform var(--transition);
}
.empty-card:hover .empty-icon {
  transform: scale(1.1);
}
.empty-text {
  font-size: 0.85rem;
}

/* ── Footer ───────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Filter animation ─────────────────────────── */
.tpl-card {
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition),
    opacity 0.25s ease,
    scale 0.25s ease;
}
.tpl-card.is-hidden {
  display: none;
}
.tpl-card.filter-exit {
  opacity: 0;
  scale: 0.96;
}
.tpl-card.filter-enter {
  animation: filterIn 0.35s ease forwards;
}
@keyframes filterIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Empty state when no match */
.no-results {
  display: none;
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}
.no-results.visible {
  display: block;
}
.no-results-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}
.no-results p {
  font-size: 0.875rem;
}

/* Count badge on section label */
.section-count {
  transition: opacity 0.2s ease;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  h1 {
    font-size: 2rem;
  }
}
