/* ============================================================
   Billy Digitals — Template Experience
   A smooth 3D coverflow carousel of sample styles + an in-site
   viewer overlay (opens templates inside the page, with a back
   button). Live animated background. Fully responsive.
   ============================================================ */

#templates { position: relative; overflow: hidden; }
.tx-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; display: block; }
#templates > .container { position: relative; z-index: 1; }

/* Hide the original grid once the carousel is live (kept for no-JS / SEO). */
.tx-live #templatesGrid { display: none; }

/* ---------- Coverflow carousel ---------- */
.tcf-wrap { max-width: 1180px; margin: 26px auto 0; }
.tcf {
  position: relative; margin: 0 auto; perspective: 1700px;
  touch-action: pan-y; outline: none; /* height set by JS */
}
.tcf-track { position: absolute; inset: 0; transform-style: preserve-3d; }

.tcf-card {
  position: absolute; left: 50%; top: 50%;
  border: 0; padding: 0; background: none; cursor: pointer;
  border-radius: 18px; overflow: visible;
  box-shadow: 0 30px 60px -22px rgba(0, 0, 0, 0.8);
  will-change: transform, opacity; transform: translate(-50%, -50%);
  -webkit-tap-highlight-color: transparent;
}
.tcf-thumb {
  position: relative; display: grid; place-items: center; width: 100%; height: 100%;
  border-radius: 18px; overflow: hidden;
  background: linear-gradient(150deg, var(--t1, #2b7fff), var(--t2, #22d3ee));
}
.tcf-thumb .shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tcf-thumb .emoji { font-size: clamp(2.4rem, 6vw, 3.6rem); filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.4)); }
.tcf-thumb::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, rgba(4, 7, 16, 0.84) 2%, rgba(4, 7, 16, 0.15) 36%, transparent 62%),
    radial-gradient(circle at 72% 14%, rgba(255, 255, 255, 0.22), transparent 55%);
}
.tcf-info { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 15px 18px; text-align: left; }
.tcf-name { display: block; color: #fff; font-weight: 700; font-size: clamp(1rem, 1.5vw, 1.18rem); letter-spacing: -0.01em; }
.tcf-cat { display: block; color: #b9c6df; font-size: 0.8rem; margin-top: 2px; }
.tcf-open {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(0.9); z-index: 3;
  font-size: 0.82rem; font-weight: 700; color: #04121f; white-space: nowrap;
  background: linear-gradient(135deg, #7cc4ff, #22d3ee); padding: 9px 18px; border-radius: 999px;
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none;
  box-shadow: 0 10px 26px -8px rgba(34, 211, 238, 0.7);
}
.tcf-card.front { box-shadow: 0 42px 84px -24px rgba(0, 0, 0, 0.9); }
.tcf-card.front .tcf-open { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tcf-card.front .tcf-name { font-size: clamp(1.08rem, 1.7vw, 1.3rem); }

/* ---------- Live electric border on the focused tile ---------- */
@property --tcfA { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
/* moving arc of current running around the card edge (masked ring) */
.tcf-card::before {
  content: ""; position: absolute; inset: 0; z-index: 4; border-radius: 18px;
  padding: 2px; pointer-events: none; opacity: 0;
  background:
    conic-gradient(from var(--tcfA),
      transparent 0 34%,
      var(--t2, #38bdf8) 44%, #eafcff 50%, #ffffff 52%, #eafcff 54%, var(--t1, #a855f7) 60%,
      transparent 70% 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  filter: drop-shadow(0 0 7px var(--t2, #38bdf8)) drop-shadow(0 0 15px var(--t1, #a855f7)) drop-shadow(0 0 3px #fff);
  transition: opacity .35s ease;
}
/* soft, wider halo that breathes with the current */
.tcf-card::after {
  content: ""; position: absolute; inset: -2px; z-index: 3; border-radius: 20px;
  padding: 6px; pointer-events: none; opacity: 0;
  background:
    conic-gradient(from calc(var(--tcfA) * -1),
      transparent 0 55%, var(--t1, #a855f7) 70%, var(--t2, #38bdf8) 82%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  filter: blur(3px) drop-shadow(0 0 16px var(--t2, #38bdf8));
  transition: opacity .35s ease;
}
.tcf-card.front::before { opacity: 1; animation: tcfArc 2.4s linear infinite; }
.tcf-card.front::after  { opacity: .85; animation: tcfArc 3.6s linear infinite reverse; }
.tcf-card.front:hover::before { animation-duration: 1.3s; }
@keyframes tcfArc { to { --tcfA: 360deg; } }

/* flying spark residues that lift off the lit edge */
.tcf-sparks { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; }
.tcf-card.front .tcf-sparks { opacity: 1; }
.tcf-sparks i {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: #eafcff; box-shadow: 0 0 6px 1px var(--t2, #38bdf8);
}
.tcf-card.front .tcf-sparks i { animation: tcfSpark 1.8s ease-out infinite; }
.tcf-sparks i:nth-child(1) { left: 14%; bottom: 3%; animation-delay: .0s; }
.tcf-sparks i:nth-child(2) { left: 42%; bottom: 3%; animation-delay: .5s; }
.tcf-sparks i:nth-child(3) { left: 68%; bottom: 3%; animation-delay: 1s; }
.tcf-sparks i:nth-child(4) { left: 88%; bottom: 3%; animation-delay: 1.4s; }
.tcf-sparks i:nth-child(5) { left: 28%; top: 3%; animation-delay: .8s; }
.tcf-sparks i:nth-child(6) { left: 78%; top: 3%; animation-delay: .3s; }
@keyframes tcfSpark {
  0%   { opacity: 0; transform: translateY(0) scale(.6); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px) translateX(6px) scale(.2); }
}
@media (prefers-reduced-motion: reduce) {
  .tcf-card.front::before, .tcf-card.front::after, .tcf-card.front .tcf-sparks i { animation: none; }
}

/* arrows */
.tcf-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 300;
  width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(160, 180, 255, 0.25); background: rgba(10, 16, 32, 0.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #eaf2ff; font-size: 1.8rem; line-height: 1; display: grid; place-items: center;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}
.tcf-arrow:hover { background: rgba(43, 127, 255, 0.3); border-color: rgba(56, 189, 248, 0.6); }
.tcf-arrow:active { transform: translateY(-50%) scale(0.92); }
.tcf-arrow.prev { left: clamp(4px, 3vw, 44px); }
.tcf-arrow.next { right: clamp(4px, 3vw, 44px); }

.tcf-hint { text-align: center; margin-top: 16px; color: #8497b3; font-size: 0.84rem; letter-spacing: 0.02em; }
.tcf-hint b { color: #dbe6fb; }

/* ---------- In-site viewer overlay ---------- */
.tx-overlay {
  position: fixed; inset: 0; z-index: 3000;
  background: #06070d; display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(.2,.7,.2,1), visibility 0.35s;
}
.tx-overlay.open { opacity: 1; visibility: visible; transform: none; }
.tx-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 10px clamp(12px, 3vw, 22px); background: #0a0c15;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08); color: #eaf0fb;
}
.tx-back {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.04);
  color: #fff; font: inherit; font-weight: 600; font-size: 0.92rem;
  padding: 9px 15px 9px 12px; border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.tx-back:hover { background: rgba(43, 127, 255, 0.16); border-color: rgba(43, 127, 255, 0.5); transform: translateX(-2px); }
.tx-back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.tx-bar .tx-title { font-weight: 700; letter-spacing: -0.01em; }
.tx-bar .tx-title .tx-cat { color: #8497b3; font-weight: 500; margin-left: 8px; font-size: 0.85rem; }
.tx-bar .tx-spacer { flex: 1; }
.tx-bar .tx-cta {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  font-weight: 700; font-size: 0.88rem; color: #04121f;
  background: linear-gradient(135deg, #2b7fff, #22d3ee); padding: 9px 16px; border-radius: 999px;
}
.tx-bar .tx-newtab { color: #9fb0c9; text-decoration: none; font-size: 0.84rem; }
.tx-bar .tx-newtab:hover { color: #fff; }
.tx-frame-wrap { flex: 1 1 auto; position: relative; background: #06070d; }
.tx-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.tx-loader {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
  color: #63728c; font-size: 0.82rem; letter-spacing: 0.16em; text-transform: uppercase;
  background: #06070d; transition: opacity 0.4s ease;
}
.tx-loader.gone { opacity: 0; pointer-events: none; }
body.tx-locked { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) { .tx-bar .tx-newtab { display: none; } }
@media (max-width: 640px) {
  .tcf-arrow { width: 44px; height: 44px; font-size: 1.5rem; }
  .tcf-arrow.prev { left: 6px; } .tcf-arrow.next { right: 6px; }
  .tx-bar .tx-cta { display: none; }
  /* keep the viewer chrome to one slim line so it never eats the preview */
  .tx-bar { padding: 6px 10px; gap: 9px; }
  .tx-back { padding: 7px 13px 7px 10px; font-size: 0.82rem; white-space: nowrap; }
  .tx-back svg { width: 15px; height: 15px; }
  .tx-bar .tx-title { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .tx-bar .tx-title .tx-cat { display: none; }
}
