/* ============================================================================
   template.css — styles for generated /t/<slug> template pages + the
   spellbook crawlable index. Loaded after experience.css and app.css.
   ========================================================================== */

.tpl-page { padding-top: 0; }
.tpl-wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.tpl-crumbs {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
  color: var(--ink); opacity: 0.5;
  padding: clamp(5.5rem, 9vw, 7.5rem) 0 clamp(1.4rem, 3vw, 2rem);
}
.tpl-crumbs a { color: inherit; text-decoration: none; }
.tpl-crumbs a:hover { opacity: 0.75; text-decoration: underline; }
.tpl-crumbs span { opacity: 0.5; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.tpl-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(1.6rem, 4vw, 3.4rem);
  align-items: center;
  padding-bottom: clamp(2.5rem, 6vw, 4.5rem);
}
@media (max-width: 860px) { .tpl-hero { grid-template-columns: 1fr; } }

.tpl-preview {
  border: 2px solid var(--ink);
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 54px -30px rgba(10,10,10,0.35);
}
.tpl-preview .spell-preview { border-radius: 0; }

/* ── Category hub hero visual: a small stack of 3 real previews from the
   category, front tile autoplaying — fills the space beside the intro copy
   with actual content instead of empty page, same bordered-card language as
   everywhere else. Collapses to one flat tile on narrow viewports where
   there's no room for the overlap to read cleanly. */
.tpl-hub-stack { position: relative; min-height: clamp(220px, 26vw, 320px); }
.tpl-hub-tile {
  position: absolute;
  width: 62%;
  border: 2px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: var(--paper-pure);
  box-shadow: 0 20px 44px -26px rgba(10,10,10,0.35);
}
.tpl-hub-tile .spell-preview { border-radius: 0; }
.tpl-hub-tile--1 { top: 0; left: 0; transform: rotate(-6deg); z-index: 1; }
.tpl-hub-tile--2 { top: 16%; right: 0; width: 56%; transform: rotate(5deg); z-index: 2; }
.tpl-hub-tile--3 { bottom: 0; left: 20%; width: 66%; transform: rotate(-2deg); z-index: 3; }
@media (max-width: 860px) {
  .tpl-hub-stack { min-height: 0; }
  .tpl-hub-tile--1, .tpl-hub-tile--2 { display: none; }
  .tpl-hub-tile--3 { position: static; width: 100%; transform: none; }
}

.tpl-cat {
  display: inline-block;
  font-family: var(--font-body); font-weight: 700; font-size: 0.74rem;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--flame); margin-bottom: 1rem;
}
.tpl-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2rem, 4.4vw, 3.4rem); line-height: 1.05;
  letter-spacing: -0.03em; margin: 0 0 0.6rem; color: var(--ink);
  text-wrap: balance;
}
.tpl-author {
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
  color: var(--ink); opacity: 0.55; margin: 0 0 1.2rem;
}
.tpl-desc {
  font-family: var(--font-body); font-size: clamp(1rem, 1.5vw, 1.12rem);
  line-height: 1.6; color: var(--ink); opacity: 0.78; margin: 0 0 1.2rem; max-width: 48ch;
}
.tpl-context {
  font-family: var(--font-body); font-size: 0.92rem; line-height: 1.55;
  color: var(--ink); opacity: 0.65; margin: 0 0 1.8rem; max-width: 48ch;
}
.tpl-context a { color: var(--ink); font-weight: 700; text-underline-offset: 3px; }

.tpl-meta { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-bottom: 2rem; }
.tpl-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
  color: var(--ink); background: rgba(10,10,10,0.05);
  border-radius: 999px; padding: 0.42rem 0.85rem;
}

.tpl-cta-row { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.tpl-cta {
  position: relative;
  isolation: isolate;
  font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  background: var(--ink); color: var(--paper-pure, #fff);
  border: 0; border-radius: 12px; padding: 0.95rem 1.7rem; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 0.6rem;
  transition: transform 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
}
/* animated gradient border ring — same "mouse-over gradient" as .btn::after */
.tpl-cta::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--mp-angle),
    var(--flame), var(--gold), var(--sky), var(--sapphire), var(--flame));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 260ms var(--ease);
  pointer-events: none;
  z-index: 1;
  animation: mp-border-spin 2.8s linear infinite paused;
}
@media (hover: hover) and (pointer: fine) {
  .tpl-cta:hover { transform: scale(1.03); background: transparent; color: var(--ink); }
  .tpl-cta:hover::after { opacity: 1; animation-play-state: running; }
}
.tpl-cta:active { transform: scale(0.97); transition-duration: 80ms; }
.tpl-cta:focus-visible { outline: 2px solid var(--sapphire); outline-offset: 3px; }
.tpl-cta-note { font-family: var(--font-body); font-size: 0.84rem; color: var(--ink); opacity: 0.55; }

.tpl-share {
  font-family: var(--font-body); font-weight: 700; font-size: 0.92rem;
  background: rgba(10,10,10,0.05); color: var(--ink);
  border: 0; border-radius: 12px; padding: 0.85rem 1.3rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.5rem;
  transition: background 160ms var(--ease), transform 160ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .tpl-share:hover { background: rgba(10,10,10,0.1); transform: scale(1.03); } }
.tpl-share:active { transform: scale(0.97); transition-duration: 80ms; }
.tpl-share:focus-visible { outline: 2px solid var(--sapphire); outline-offset: 3px; }

/* ── Spec strip ──────────────────────────────────────────────────────────── */
.tpl-specs {
  border-top: 2px solid rgba(10,10,10,0.08);
  border-bottom: 2px solid rgba(10,10,10,0.08);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  margin: 0 0 clamp(2.5rem, 6vw, 4.5rem);
}
@media (max-width: 640px) { .tpl-specs { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); grid-auto-columns: auto; } }
.tpl-spec { padding: 1.4rem clamp(0.8rem, 2vw, 1.6rem); }
.tpl-spec + .tpl-spec { border-left: 1px solid rgba(10,10,10,0.07); }
@media (max-width: 640px) { .tpl-spec + .tpl-spec { border-left: 0; } }
.tpl-spec-k { font-family: var(--font-body); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.45; margin-bottom: 0.45rem; }
.tpl-spec-v { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.2rem, 2.4vw, 1.7rem); color: var(--ink); }

/* ── Related ─────────────────────────────────────────────────────────────── */
.tpl-related { padding-bottom: clamp(4rem, 8vw, 7rem); }
.tpl-related-h {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: -0.02em; margin: 0 0 0.5rem; color: var(--ink);
}
.tpl-related-sub { font-family: var(--font-body); font-size: 0.95rem; opacity: 0.6; margin: 0 0 1.8rem; }
.tpl-rel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2.5vw, 1.6rem); align-items: stretch; }
@media (max-width: 820px) { .tpl-rel-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .tpl-rel-grid { grid-template-columns: 1fr; } }

/* One related-spell card — same visual language as the main gallery's
   .spell-card (border, tier badge, spelled-out source tag, steal button) so
   a spell looks and behaves identically whether it's found here or on
   /spellbook.html. The steal button is a sibling of .tpl-rel-link, not
   nested inside it, so pressing it never also triggers the card's link. */
.tpl-rel-card {
  display: flex; flex-direction: column;
  border: 2px solid var(--ink);
  border-radius: 16px; overflow: hidden;
  background: var(--paper-pure);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .tpl-rel-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -22px rgba(10,10,10,0.4); }
}
.tpl-rel-card:active { transform: translateY(-1px) scale(0.98); }
.tpl-rel-link { display: block; text-decoration: none; color: inherit; }
.tpl-rel-link:focus-visible { outline: 2px solid var(--sapphire); outline-offset: -2px; }
.tpl-rel-media { position: relative; }
.tpl-rel-media .spell-preview { border-radius: 0; }
.tpl-rel-body { padding: 0.95rem 1.1rem 0.6rem; display: grid; gap: 0.3rem; align-content: start; }
.tpl-rel-cat { font-family: var(--font-body); font-weight: 700; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--flame); }
.tpl-rel-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin: 0.35rem 0 0; color: var(--ink); line-height: 1.25; }
.tpl-rel-foot { margin-top: auto; padding: 0.7rem 1.1rem 1.1rem; }
.tpl-rel-foot .steal-btn { min-height: 40px; font-size: 0.78rem; }

/* ── Admin inline editor ─────────────────────────────────────────────────── */
.tpl-edit-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--font-body); font-weight: 700; font-size: 0.8rem;
  color: var(--sapphire); background: rgba(65,100,255,0.08);
  border: 1px solid rgba(65,100,255,0.25); border-radius: 999px;
  padding: 0.4rem 0.9rem; margin-bottom: 1rem; cursor: pointer;
}
.tpl-edit-btn:hover { background: rgba(65,100,255,0.14); }

.tpl-editor { display: none; margin: 0 0 2rem; padding: 1.4rem; border: 1px solid rgba(65,100,255,0.25); border-radius: 14px; background: rgba(65,100,255,0.03); }
.tpl-editor.is-open { display: block; }
.tpl-editor h2 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; margin: 0 0 1rem; color: var(--ink); }
.tpl-field { display: block; margin-bottom: 0.9rem; }
.tpl-field > span { display: block; font-family: var(--font-body); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.5; margin-bottom: 0.35rem; }
.tpl-field input, .tpl-field textarea, .tpl-field select {
  width: 100%; box-sizing: border-box; font-family: var(--font-body); font-size: 16px;
  padding: 0.6rem 0.75rem; border: 1px solid rgba(10,10,10,0.15); border-radius: 9px; background: #fff; color: var(--ink);
}
.tpl-field textarea { min-height: 5.5rem; resize: vertical; line-height: 1.5; }
.tpl-editor-row { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.tpl-editor-row .tpl-field { flex: 1; min-width: 140px; }
.tpl-editor-actions { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.4rem; }
.tpl-save { font-family: var(--font-body); font-weight: 700; font-size: 0.9rem; background: var(--sapphire); color: #fff; border: 0; border-radius: 9px; padding: 0.6rem 1.3rem; cursor: pointer; }
.tpl-save:disabled { opacity: 0.55; cursor: default; }
.tpl-republish { font-family: var(--font-body); font-weight: 700; font-size: 0.9rem; background: var(--ink); color: #fff; border: 0; border-radius: 9px; padding: 0.6rem 1.3rem; cursor: pointer; }
.tpl-editor-msg { font-family: var(--font-body); font-size: 0.84rem; font-weight: 600; opacity: 0.7; }

/* ── Spellbook crawlable index (no-JS fallback + SEO) ────────────────────── */
.sb-index { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) clamp(3rem, 6vw, 5rem); }
.sb-index details { border-top: 2px solid rgba(10,10,10,0.08); padding-top: 1.4rem; }
.sb-index summary { font-family: var(--font-body); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.04em; color: var(--ink); opacity: 0.6; cursor: pointer; }
.sb-index summary:hover { opacity: 0.85; }
.sb-index-list { list-style: none; margin: 1.2rem 0 0; padding: 0; columns: 3; column-gap: 2rem; }
@media (max-width: 720px) { .sb-index-list { columns: 1; } }
.sb-index-list li { break-inside: avoid; margin-bottom: 0.4rem; }
.sb-index-list a { font-family: var(--font-body); font-size: 0.86rem; color: var(--ink); opacity: 0.65; text-decoration: none; }
.sb-index-list a:hover { opacity: 1; color: var(--flame); text-decoration: underline; }

/* ── Creator profile (/u/<slug>) — ink hero, sibling of pricing.html ──────── */
.up-hero {
  background: var(--ink);
  color: var(--paper);
  position: relative;
  overflow: hidden;
  padding: clamp(7rem, 15vw, 11rem) var(--gutter) clamp(3.5rem, 7vw, 5.5rem);
}
.up-hero-inner { max-width: var(--maxw); margin: 0 auto; position: relative; z-index: 1; }
.up-crumbs {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
  color: var(--paper); opacity: 0.45; margin-bottom: clamp(1.6rem, 3vw, 2.4rem);
}
.up-crumbs a { color: inherit; text-decoration: none; }
.up-crumbs a:hover { opacity: 0.8; text-decoration: underline; }
.up-eyebrow {
  display: inline-block; font-family: var(--font-body); font-weight: 800;
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 1rem;
}
.up-name {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 6rem); line-height: 0.98;
  letter-spacing: -0.03em; color: var(--paper); margin: 0 0 clamp(1rem, 2vw, 1.6rem);
  text-wrap: balance;
}
.up-name em { font-style: normal; color: var(--gold); }
.up-sub {
  font-family: var(--font-body); font-weight: 400;
  font-size: clamp(1rem, 1.8vw, 1.2rem); line-height: 1.55;
  color: rgba(244,241,233,0.62); max-width: 52ch; margin: 0; text-wrap: balance;
}

/* stats row, dark, mirrors about.html .about-stats */
.up-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(1rem, 2vw, 1.25rem);
  margin-top: clamp(2.4rem, 5vw, 3.6rem);
  max-width: 640px;
}
@media (max-width: 600px) { .up-stats { grid-template-columns: 1fr 1fr; } }
.up-stat { padding-top: clamp(1rem, 2.2vw, 1.4rem); border-top: 2px solid rgba(244,241,233,0.18); }
.up-stat-num {
  font-family: var(--font-display); font-weight: 800; line-height: 1;
  font-size: clamp(2rem, 4vw, 3rem); color: var(--paper);
  letter-spacing: -0.03em; margin: 0 0 0.35rem;
}
.up-stat-num span { color: var(--flame); }
.up-stat-label { font-size: 0.78rem; font-weight: 600; color: rgba(244,241,233,0.42); line-height: 1.4; }

/* spellbook grid, paper background */
.up-grid-section { background: var(--paper); padding: clamp(4rem, 8vw, 6.5rem) var(--gutter); }
.up-grid-inner { max-width: var(--maxw); margin: 0 auto; }
.up-grid-h {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem); letter-spacing: -0.02em;
  margin: 0 0 0.5rem; color: var(--ink);
}
.up-grid-h em { font-style: normal; color: var(--flame); }
.up-grid-sub { font-family: var(--font-body); font-size: 0.95rem; opacity: 0.6; margin: 0 0 2rem; }
.up-empty {
  font-family: var(--font-body); font-size: 0.98rem; opacity: 0.6;
  padding: clamp(2rem, 4vw, 3rem) 0;
}

/* CTA — mirrors .plan-cta styling, ink border + flame fill */
.up-cta-section {
  background: var(--ink); color: var(--paper);
  padding: clamp(3.5rem, 7vw, 6rem) var(--gutter);
  text-align: center;
}
.up-cta-inner { max-width: 640px; margin: 0 auto; }
.up-cta-h {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.6rem, 3.6vw, 2.6rem); letter-spacing: -0.02em;
  margin: 0 0 0.8rem; color: var(--paper); text-wrap: balance;
}
.up-cta-h em { font-style: normal; color: var(--gold); }
.up-cta-sub { font-family: var(--font-body); font-size: 0.94rem; color: rgba(244,241,233,0.55); margin: 0 0 1.8rem; }
.up-cta-btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-body); font-weight: 800; font-size: 1rem;
  background: var(--flame); color: var(--ink);
  border: 2px solid var(--flame); border-radius: 999px;
  padding: 0.9rem 2rem; text-decoration: none;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
}
.up-cta-btn:hover { background: var(--gold); border-color: var(--gold); transform: translateY(-2px); }
.up-cta-note { display: block; font-family: var(--font-body); font-size: 0.78rem; color: rgba(244,241,233,0.4); margin-top: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
  .tpl-cta, .tpl-share, .tpl-rel-card, .up-cta-btn { transition: none; }
  .tpl-cta:hover, .tpl-cta:active, .tpl-share:hover, .tpl-share:active, .tpl-rel-card:hover, .tpl-rel-card:active, .up-cta-btn:hover { transform: none; }
}
