/* ============================================================
   SlideVite template button system (.tpl-btn)

   Shared shape/interaction language for guest-facing CTAs in
   template iframes. Colors, fonts, and radii are driven by
   --tpl-btn-* CSS vars so each theme keeps its own palette:
   set them in the template's :root (index.css), mirroring the
   existing --tpl-title-* typography vars.

   Hierarchy (matches the product button system):
   - .tpl-btn--primary    the one most important action (RSVP Now)
   - .tpl-btn--secondary  supporting actions (Share, Copy Address)
   - .tpl-btn--ghost      low-priority actions (Copy Link)
   - .tpl-btn--lg         size bump for the page's headline CTA
   ============================================================ */

.tpl-btn {
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tpl-btn-height, 48px);
  max-width: 100%;
  padding: 0 var(--tpl-btn-px, 26px);
  border: 1px solid transparent;
  border-radius: var(--tpl-btn-radius, 9999px);
  font-family: var(--tpl-btn-font-family, inherit);
  font-size: var(--tpl-btn-font-size, 16px);
  font-weight: var(--tpl-btn-font-weight, 600);
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.tpl-btn:active {
  transform: scale(0.98);
}

.tpl-btn:focus-visible {
  outline: 2px solid var(--tpl-btn-accent, #1c1917);
  outline-offset: 2px;
}

.tpl-btn svg {
  flex-shrink: 0;
  /* Size icons here so they never depend on a per-template Tailwind build
     shipping .w-4/.h-4 (some purged builds omit them, which blows the icon up
     to its intrinsic size). Overridable per theme via --tpl-btn-icon-size. */
  width: var(--tpl-btn-icon-size, 1rem);
  height: var(--tpl-btn-icon-size, 1rem);
}

/* Size bump for the page's single headline CTA (e.g. RSVP Now).
   19px/700 is WCAG large text, so the gradient's lighter top stop only
   needs 3:1 contrast — md/sm primaries must keep every stop at 4.5:1. */
.tpl-btn--lg {
  min-height: var(--tpl-btn-lg-height, 56px);
  min-width: var(--tpl-btn-lg-min-width, 184px);
  max-width: min(100%, 400px);
  padding: 0 var(--tpl-btn-lg-px, 34px);
  font-size: var(--tpl-btn-lg-font-size, 19px);
  font-weight: var(--tpl-btn-lg-font-weight, 700);
}

/* Width policy: buttons hug their labels (never full-bleed) with minimum
   widths so short labels don't produce stubby pills. Heights, type scale,
   and padding are standardized across all templates; width varies only
   with the label, inside these bounds. */
.tpl-btn--primary,
.tpl-btn--secondary {
  min-width: var(--tpl-btn-min-width, 120px);
}

/* Fixed-width variant for a matched pair of actions (e.g. Share + Copy Link):
   both land on ONE consistent width (the --tpl-btn-fixed-width floor) rather
   than hugging to different sizes or stretching full-bleed via flex-1. The
   floor is a MIN, and the button grows to max-content if a longer label needs
   it — combined with white-space:nowrap this guarantees the label never wraps
   to two lines and never overflows the pill, whatever the theme's font.
   Center the pair with `items-center` on their flex row. */
.tpl-btn--fixed {
  width: max-content;
  min-width: var(--tpl-btn-fixed-width, 200px);
  max-width: 100%;
}

/* Some templates ship a purged Tailwind build that dropped .flex-col and the
   .gap-* the Share/Copy Link row uses to stack the pair with spacing (they
   weren't all in the original markup). Define them here so every template
   linking buttons.css gets them; templates that already define them (index.css
   loads after this) override with the identical value. */
.flex-col {
  flex-direction: column;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}

/* Primary: theme-accent vertical gradient + soft tinted depth.
   The gradient is the affordance treatment (light-from-above reads as
   pressable). Set --tpl-btn-primary-bg-top one shade LIGHTER than
   --tpl-btn-primary-bg, keeping the top stop at >= 4.5:1 contrast with the
   label. Omit -bg-top for a flat fill (the fallback chain collapses the
   gradient); the plain background declaration below covers old browsers. */
.tpl-btn--primary {
  background: var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917));
  background: linear-gradient(
    to bottom,
    var(--tpl-btn-primary-bg-top, var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917))),
    var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917))
  );
  color: var(--tpl-btn-primary-fg, #ffffff);
  box-shadow: var(
    --tpl-btn-primary-shadow,
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 1px 2px rgba(28, 25, 23, 0.14),
    0 6px 18px -5px rgba(28, 25, 23, 0.4)
  );
}

.tpl-btn--primary:hover {
  background: var(
    --tpl-btn-primary-bg-hover,
    var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917))
  );
  background: linear-gradient(
    to bottom,
    var(--tpl-btn-primary-bg-top-hover, var(--tpl-btn-primary-bg-hover, var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917)))),
    var(--tpl-btn-primary-bg-hover, var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917)))
  );
  box-shadow: var(
    --tpl-btn-primary-shadow-hover,
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 2px 4px rgba(28, 25, 23, 0.14),
    0 8px 22px -6px rgba(28, 25, 23, 0.45)
  );
}

.tpl-btn--primary:active {
  background: var(
    --tpl-btn-primary-bg-active,
    var(--tpl-btn-primary-bg-hover, var(--tpl-btn-primary-bg, var(--tpl-btn-accent, #1c1917)))
  );
}

/* Secondary: outlined, understated, same shape as primary */
.tpl-btn--secondary {
  background: var(--tpl-btn-secondary-bg, #ffffff);
  border-width: var(--tpl-btn-secondary-border-width, 1.5px);
  border-color: var(--tpl-btn-secondary-border, rgba(28, 25, 23, 0.28));
  color: var(--tpl-btn-secondary-fg, var(--tpl-btn-accent, #1c1917));
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 2px 8px -2px rgba(28, 25, 23, 0.08);
}

.tpl-btn--secondary:hover {
  background: var(--tpl-btn-secondary-bg-hover, rgba(28, 25, 23, 0.04));
  border-color: var(
    --tpl-btn-secondary-border-hover,
    var(--tpl-btn-secondary-border, rgba(28, 25, 23, 0.32))
  );
}

/* Ghost: minimal visual weight */
.tpl-btn--ghost {
  background: transparent;
  color: var(--tpl-btn-ghost-fg, var(--tpl-btn-accent, #1c1917));
}

.tpl-btn--ghost:hover {
  background: var(--tpl-btn-ghost-bg-hover, rgba(28, 25, 23, 0.06));
}
