/* ============================================================
   KANPEKI UNIVERSE — TEMPLATES
   Browser (sidebar + filters + paged cards) on the landing page,
   plus the template detail page. Namespaced `tpl-`.
   Brand palette is inherited from style.css tokens; literal hex
   fallbacks are included so this file also works standalone.
   ============================================================ */

.tpl-scope {
  /* Deep Midnight Blue / Indigo Nebula / Peach / Cosmic Lilac /
     Deep Plum / Starlight Silver */
  --tpl-bg: var(--bg, #0C0E1A);
  --tpl-nebula: var(--nebula, #242A46);
  --tpl-card: var(--card, #13162a);
  --tpl-peach: var(--peach, #FBC48F);
  --tpl-lilac: var(--lilac, #7D6FB3);
  --tpl-plum: var(--plum, #4E2F53);
  --tpl-silver: var(--silver, #C5C8D3);
  --tpl-silver-dim: var(--silver-dim, #8d92a6);
  --tpl-border: var(--border, rgba(125, 111, 179, .22));
  --tpl-border-soft: var(--border-soft, rgba(197, 200, 211, .08));
  --tpl-maxw: var(--maxw, 1120px);
  --tpl-ease: var(--ease, cubic-bezier(.22, .61, .36, 1));
  --tpl-gap: 16px;
  --tpl-rule: rgba(197, 200, 211, .16);
}

/* ──────────────────────────────────────────────────────────
   1. BROWSER SHELL — sidebar (search + filters) | results
   ────────────────────────────────────────────────────────── */

/* The browser band runs wider than the page's 1120px --maxw so three
   cards fit at their full width. The section heading keeps .wrap. */
.tpl-wrap {
  max-width: 1420px;
}

.tpl-browser {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  border-top: 1px solid var(--tpl-rule);
  border-bottom: 1px solid var(--tpl-rule);
}

/* ── Sidebar ── */
.tpl-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--tpl-rule);
  padding: 24px 24px 24px 0;
}

.tpl-search-block {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--tpl-rule);
}

.tpl-search-label {
  display: block;
  font-size: 14px;
  color: var(--tpl-silver);
  margin-bottom: 14px;
}

.tpl-search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.tpl-search-field svg {
  position: absolute;
  left: 14px;
  color: var(--tpl-bg);
  pointer-events: none;
}

.tpl-search-field input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--tpl-bg);
  padding: 11px 16px 11px 40px;
  border-radius: 100px;
  border: 1px solid transparent;
  background: #fff;
  transition: box-shadow .25s var(--tpl-ease), border-color .25s var(--tpl-ease);
}

.tpl-search-field input::placeholder {
  color: #6f7383;
}

.tpl-search-field input:focus {
  outline: none;
  border-color: var(--tpl-peach);
  box-shadow: 0 0 0 3px rgba(251, 196, 143, .28);
}

/* Hide the native clear button so the field keeps its shape */
.tpl-search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ── Filter buttons ── */
.tpl-filters {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding-top: 8px;
}

.tpl-filter {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 18px 18px 18px 16px;
  text-align: left;
  cursor: pointer;
  color: var(--tpl-silver);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  transition:
    background .3s var(--tpl-ease),
    border-color .3s var(--tpl-ease),
    color .3s var(--tpl-ease);
}

.tpl-filter-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.3px;
  color: #fff;
}

.tpl-filter-sub {
  font-size: 13px;
  line-height: 1.45;
  color: var(--tpl-silver-dim);
}

.tpl-filter:hover {
  background: rgba(36, 42, 70, .5);
}

.tpl-filter.is-active {
  background: var(--tpl-nebula);
  border-color: var(--tpl-border);
}

.tpl-filter.is-active .tpl-filter-sub {
  color: var(--tpl-silver);
}

.tpl-filter:focus-visible {
  outline: 2px solid var(--tpl-peach);
  outline-offset: 2px;
}

/* ── Results column ── */
.tpl-results {
  position: relative;
  min-width: 0;
  padding: 30px 0 26px 24px;
}

/* ──────────────────────────────────────────────────────────
   2. CARDS — three at a time, swipe/snap on touch
   ────────────────────────────────────────────────────────── */

.tpl-track {
  display: flex;
  gap: var(--tpl-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  /* room for the right-oriented shadow + hover lift */
  padding: 6px 24px 30px 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tpl-track::-webkit-scrollbar {
  display: none;
}

/* Applied by templates-carousel.js only once the pointer has actually
   travelled past the drag threshold — never on a plain press, or the
   pointer-events rule below would swallow the card's click. */
.tpl-track.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  scroll-behavior: auto;
  user-select: none;
}

.tpl-track.is-dragging .tpl-card {
  pointer-events: none;
}

.tpl-card {
  flex: 0 0 min(92%, 390px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(168deg, rgba(78, 47, 83, .62), var(--tpl-nebula) 72%);
  border: 1px solid rgba(251, 196, 143, .34);
  /* shadow cast to the right */
  box-shadow:
    16px 14px 30px rgba(0, 0, 0, .55),
    6px 4px 0 rgba(12, 14, 26, .45);
  transition:
    transform .35s var(--tpl-ease),
    border-color .35s var(--tpl-ease),
    box-shadow .35s var(--tpl-ease);
}

.tpl-card:hover,
.tpl-card:focus-within {
  transform: translateY(-6px);
  border-color: var(--tpl-peach);
  box-shadow:
    22px 20px 40px rgba(0, 0, 0, .6),
    6px 4px 0 rgba(12, 14, 26, .45),
    0 0 34px rgba(251, 196, 143, .2);
}

/* ── Card media — full-bleed; the card's radius clips the top corners ── */
.tpl-card-media {
  display: block;
  position: relative;
  /* Sized for 1000×1000 square covers. */
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 0%, var(--tpl-nebula), var(--tpl-bg));
}

.tpl-card-media img {
  width: 100%;
  height: 100%;
  /* `contain` so the whole cover is visible — nothing is cropped.
     A true 800×1100 asset fills the box exactly; other ratios
     letterbox against the gradient behind. */
  object-fit: contain;
  display: block;
  transition: transform .5s var(--tpl-ease);
}

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

.tpl-cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--tpl-lilac);
}

/* ── Card body ── */
.tpl-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 18px 18px 20px;
}

.tpl-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.3px;
  color: #fff;
  margin-bottom: 10px;
}

.tpl-card-name-link {
  color: inherit;
  text-decoration: none;
  transition: color .25s var(--tpl-ease);
}

.tpl-card-name-link:hover {
  color: var(--tpl-peach);
}

.tpl-card-media:focus-visible,
.tpl-card-name-link:focus-visible {
  outline: 2px solid var(--tpl-peach);
  outline-offset: 2px;
}

.tpl-card-tagline {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tpl-silver);
  flex: 1;
  margin-bottom: 16px;
}

.tpl-price {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.5px;
  color: #fff;
  margin-bottom: 16px;
}

.tpl-price.is-free {
  color: var(--tpl-peach);
}

/* ── Card actions: see details (secondary) + duplicate (primary) ── */
.tpl-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tpl-card-cta,
.tpl-card-dup {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 100px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition:
    background .25s var(--tpl-ease),
    color .25s var(--tpl-ease),
    border-color .25s var(--tpl-ease);
}

/* Secondary — stays on the site */
.tpl-card-cta {
  color: var(--tpl-peach);
  background: transparent;
  border-color: rgba(251, 196, 143, .45);
}

.tpl-card-cta:hover {
  background: rgba(251, 196, 143, .12);
  border-color: var(--tpl-peach);
}

/* Primary — straight to the Notion Marketplace */
.tpl-card-dup {
  color: #0C0E1A;
  background: var(--tpl-peach);
  border-color: var(--tpl-peach);
}

.tpl-card-dup:hover {
  background: #fff;
  border-color: #fff;
}

.tpl-card-cta:focus-visible,
.tpl-card-dup:focus-visible {
  outline: 2px solid var(--tpl-peach);
  outline-offset: 2px;
}

.tpl-card-cta svg,
.tpl-card-dup svg {
  transition: transform .25s var(--tpl-ease);
}

.tpl-card:hover .tpl-card-cta svg {
  transform: translateX(3px);
}

.tpl-card-dup:hover svg {
  transform: translate(2px, -2px);
}

/* `display` is set by author rules above, so [hidden] needs an explicit
   counterpart to actually hide these. */
.tpl-track[hidden],
.tpl-controls[hidden],
.tpl-empty[hidden] {
  display: none;
}

/* ── Empty state ── */
.tpl-empty {
  padding: 60px 20px 70px;
  text-align: center;
  color: var(--tpl-silver-dim);
  font-size: 15px;
}

/* ──────────────────────────────────────────────────────────
   3. CONTROLS — arrows + page segments
   ────────────────────────────────────────────────────────── */

.tpl-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tpl-nav-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tpl-nav {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: #0C0E1A;
  background: #fff;
  border: 1px solid transparent;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  transition:
    opacity .25s var(--tpl-ease),
    background .25s var(--tpl-ease),
    transform .25s var(--tpl-ease);
}

.tpl-nav:hover:not(:disabled) {
  background: var(--tpl-peach);
  transform: scale(1.08);
}

.tpl-nav:focus-visible {
  outline: 2px solid var(--tpl-peach);
  outline-offset: 3px;
}

.tpl-nav:disabled {
  opacity: .3;
  cursor: default;
}

.tpl-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.tpl-dot {
  width: 64px;
  height: 4px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  background: rgba(125, 111, 179, .45);
  transition: background .3s var(--tpl-ease);
}

.tpl-dot.is-active {
  background: var(--tpl-peach);
}

.tpl-dot:focus-visible {
  outline: 2px solid var(--tpl-peach);
  outline-offset: 3px;
}

/* ──────────────────────────────────────────────────────────
   4. BROWSER RESPONSIVE
   ────────────────────────────────────────────────────────── */

/* Three cards across once the results column is wide enough */
@media (min-width: 900px) {
  .tpl-card {
    flex: 0 0 calc((100% - var(--tpl-gap) * 2) / 3);
  }
}

/* Sidebar stacks above the results on narrow screens */
@media (max-width: 899px) {
  .tpl-browser {
    grid-template-columns: 1fr;
  }

  .tpl-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--tpl-rule);
    padding: 24px 0;
  }

  .tpl-search-block {
    padding-bottom: 22px;
  }

  .tpl-filters {
    flex-direction: row;
    gap: 10px;
    padding-top: 16px;
  }

  .tpl-filter {
    flex: 1;
    min-height: 0;
    padding: 14px;
    border: 1px solid var(--tpl-border-soft);
  }

  .tpl-filter-title {
    font-size: 17px;
  }

  .tpl-filter-sub {
    font-size: 12px;
  }

  .tpl-results {
    padding: 26px 0 24px;
  }

  .tpl-track {
    padding-right: 20px;
  }
}

@media (max-width: 560px) {
  .tpl-filters {
    flex-direction: column;
  }

  .tpl-card {
    flex: 0 0 min(90%, 374px);
  }
}

/* ──────────────────────────────────────────────────────────
   5. DETAIL PAGE
   ────────────────────────────────────────────────────────── */

.tpl-detail {
  position: relative;
  z-index: 1;
}

.tpl-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--tpl-silver-dim);
  transition: color .2s var(--tpl-ease);
}

.tpl-back:hover {
  color: var(--tpl-peach);
}

/* ── Hero ── */
.tpl-hero {
  padding: 130px 0 20px;
  text-align: center;
}

.tpl-hero-media {
  position: relative;
  max-width: 880px;
  margin: 36px auto 0;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--tpl-border);
  background: linear-gradient(150deg, var(--card-2, #171b32), var(--tpl-card));
  box-shadow:
    0 40px 100px rgba(0, 0, 0, .6),
    0 0 70px rgba(251, 196, 143, .1),
    0 0 140px rgba(125, 111, 179, .12);
  /* entrance animation — applied via .is-loaded from JS */
  opacity: 0;
  transform: scale(.965) translateY(18px);
  transition:
    opacity 1s var(--tpl-ease),
    transform 1s var(--tpl-ease);
}

.tpl-hero-media.is-loaded {
  opacity: 1;
  transform: none;
}

.tpl-hero-media img {
  display: block;
  width: 100%;
  height: auto;
}

/* Soft peach/lilac aura behind the hero image */
.tpl-hero-glow {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(760px, 92vw);
  height: min(420px, 52vw);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(closest-side, rgba(251, 196, 143, .17), transparent 72%),
    radial-gradient(closest-side, rgba(125, 111, 179, .2), transparent 78%);
  filter: blur(28px);
}

/* ── Reveal-on-scroll primitive ── */
.tpl-reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity .75s var(--tpl-ease),
    transform .75s var(--tpl-ease);
}

.tpl-reveal.is-in {
  opacity: 1;
  transform: none;
}

/* ── Intro block ── */
.tpl-intro {
  padding: 70px 0 0;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}

.tpl-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 18px;
  color: var(--tpl-peach);
  background: rgba(251, 196, 143, .1);
  border: 1px solid rgba(251, 196, 143, .25);
}

.tpl-badge .tpl-badge-price {
  padding-left: 9px;
  margin-left: 1px;
  border-left: 1px solid rgba(251, 196, 143, .3);
  color: #fff;
}

.tpl-intro h1 {
  font-size: clamp(32px, 5.4vw, 54px);
  letter-spacing: -1.2px;
  margin-bottom: 14px;
}

.tpl-intro .tpl-tagline {
  font-family: 'Allura', cursive;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.3;
  color: var(--tpl-peach);
  margin-bottom: 22px;
}

.tpl-intro .tpl-desc {
  font-size: clamp(15px, 1.9vw, 17px);
  line-height: 1.75;
  color: var(--tpl-silver-dim);
}

/* ── Section scaffolding ── */
.tpl-block {
  padding: 90px 0 0;
}

.tpl-block-head {
  max-width: 620px;
  margin: 0 auto 36px;
  text-align: center;
}

.tpl-block-head .tpl-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--tpl-lilac);
  margin-bottom: 12px;
}

.tpl-block-head h2 {
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -.8px;
  margin-bottom: 12px;
}

.tpl-block-head p {
  color: var(--tpl-silver-dim);
  font-size: 15.5px;
}

/* ── "What's inside" list ── */
.tpl-inside-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
  list-style: none;
}

.tpl-inside-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 22px;
  border-radius: 16px;
  background: var(--tpl-card);
  border: 1px solid var(--tpl-border-soft);
  transition: border-color .3s var(--tpl-ease), transform .3s var(--tpl-ease);
}

.tpl-inside-item:hover {
  border-color: rgba(251, 196, 143, .3);
  transform: translateX(3px);
}

.tpl-inside-check {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--tpl-peach);
  background: rgba(251, 196, 143, .12);
}

.tpl-inside-item h3 {
  font-size: 15.5px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.tpl-inside-item p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--tpl-silver-dim);
}

/* ── Interactive widgets highlight ── */
.tpl-widgets {
  position: relative;
  border-radius: 26px;
  padding: 44px 26px 46px;
  margin-top: 10px;
  background:
    radial-gradient(110% 130% at 50% 0%, rgba(125, 111, 179, .16), transparent 62%),
    var(--tpl-card);
  border: 1px solid var(--tpl-border);
}

.tpl-widgets-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 820px;
  margin: 0 auto;
}

.tpl-widget-card {
  padding: 22px;
  border-radius: 16px;
  background: rgba(12, 14, 26, .55);
  border: 1px solid var(--tpl-border-soft);
  transition: border-color .3s var(--tpl-ease), transform .3s var(--tpl-ease);
}

.tpl-widget-card:hover {
  border-color: rgba(251, 196, 143, .32);
  transform: translateY(-4px);
}

.tpl-widget-card .tpl-widget-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-bottom: 14px;
  background: var(--tpl-peach);
  box-shadow: 0 0 12px rgba(251, 196, 143, .8);
}

.tpl-widget-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

.tpl-widget-card p {
  font-size: 13.8px;
  line-height: 1.6;
  color: var(--tpl-silver-dim);
}

/* ── Final CTA ── */
.tpl-cta {
  text-align: center;
  padding: 90px 0 40px;
}

.tpl-cta h2 {
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -.8px;
  margin-bottom: 12px;
}

.tpl-cta p {
  color: var(--tpl-silver-dim);
  font-size: 15.5px;
  max-width: 480px;
  margin: 0 auto 28px;
}

.tpl-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 32px;
  border-radius: 100px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  color: #0C0E1A;
  background: var(--tpl-peach);
  border: 1px solid var(--tpl-peach);
  box-shadow: 0 10px 34px rgba(251, 196, 143, .24);
  transition: transform .25s var(--tpl-ease), box-shadow .25s var(--tpl-ease);
}

.tpl-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 44px rgba(251, 196, 143, .36);
}

.tpl-cta-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.tpl-cta-note {
  display: block;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--tpl-silver-dim);
  opacity: .8;
}

.tpl-foot-back {
  text-align: center;
  padding: 20px 0 90px;
}

/* ── Detail page responsive ── */
@media (min-width: 760px) {
  .tpl-inside-list {
    grid-template-columns: 1fr 1fr;
  }

  .tpl-widgets-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .tpl-widgets {
    padding: 52px 40px 56px;
  }
}

@media (max-width: 560px) {
  .tpl-hero {
    padding: 110px 0 10px;
  }

  .tpl-hero-media {
    border-radius: 18px;
  }

  .tpl-block {
    padding: 70px 0 0;
  }

  .tpl-inside-item {
    padding: 18px;
  }
}

/* ──────────────────────────────────────────────────────────
   6. REDUCED MOTION
   ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  .tpl-reveal,
  .tpl-hero-media {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .tpl-card,
  .tpl-card-media img,
  .tpl-card-name-link,
  .tpl-card-cta,
  .tpl-card-dup,
  .tpl-card-cta svg,
  .tpl-card-dup svg,
  .tpl-filter,
  .tpl-inside-item,
  .tpl-widget-card,
  .tpl-cta-btn,
  .tpl-nav,
  .tpl-dot {
    transition: none !important;
  }

  .tpl-card:hover,
  .tpl-card:focus-within,
  .tpl-nav:hover:not(:disabled),
  .tpl-inside-item:hover,
  .tpl-widget-card:hover,
  .tpl-cta-btn:hover {
    transform: none !important;
  }

  .tpl-card:hover .tpl-card-media img,
  .tpl-card:hover .tpl-card-cta svg,
  .tpl-card-dup:hover svg {
    transform: none !important;
  }
}
