/* ==========================================================
   Kai Mana — Button Contract (M2D)
   --------------------------------------------------
   Shared button styles. Three variants: primary, ghost, link.
   See: kai-mana/_shared/NOTES-buttons.md
   ========================================================== */

:root {
  --btn-pad-y:        var(--sp-3, 12px);
  --btn-pad-x:        var(--sp-5, 24px);
  --btn-gap:          var(--sp-2, 8px);
  --btn-radius:       var(--r-pill, 999px);
  --btn-border-w:     1px;
  --btn-fs:           var(--fs-body, 1rem);
  --btn-fw:           500;
  /* M3: animation tokens now resolve to shared animation.css */
  --btn-dur:          var(--dur-fast, 160ms);
  --btn-ease:         var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

/* ==========================================================
   Base
   ========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--btn-gap);
  font-family: var(--font-body, 'Work Sans', system-ui, sans-serif);
  font-size: var(--btn-fs);
  font-weight: var(--btn-fw);
  line-height: 1;
  padding: var(--btn-pad-y) var(--btn-pad-x);
  border-radius: var(--btn-radius);
  border: var(--btn-border-w) solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition:
    background var(--btn-dur) var(--btn-ease),
    border-color var(--btn-dur) var(--btn-ease),
    color var(--btn-dur) var(--btn-ease),
    transform var(--btn-dur) var(--btn-ease);
}

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

/* ==========================================================
   Focus ring (a11y — never remove)
   ========================================================== */

.btn:focus-visible {
  outline: 2px solid var(--km-foam, #e8f4f8);
  outline-offset: 3px;
}

/* ==========================================================
   Primary — filled, high emphasis
   ========================================================== */

.btn-primary {
  background: var(--km-foam, #e8f4f8);
  color: var(--km-text-inverse, #0b1f2a);
}

.btn-primary:hover {
  background: var(--km-foam-bright, #94e1d6);
}

/* ==========================================================
   Ghost — outlined, medium emphasis
   ========================================================== */

.btn-ghost {
  background: transparent;
  color: var(--km-text, #f0f8fa);
  border-color: var(--km-line, rgba(232, 244, 248, 0.2));
}

.btn-ghost:hover {
  background: var(--km-surface-2, rgba(232, 244, 248, 0.08));
  border-color: var(--km-foam, #e8f4f8);
}

/* ==========================================================
   Link — text-only, low emphasis
   ========================================================== */

.btn-link {
  background: none;
  padding: 0;
  color: var(--km-foam, #e8f4f8);
  text-decoration: underline;
  text-underline-offset: 4px;
  border: none;
}

.btn-link:hover {
  color: var(--km-foam-bright, #94e1d6);
}

/* ==========================================================
   Reduced motion
   ========================================================== */

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
  .btn:active {
    transform: none;
  }
}

/* ==========================================================
   M2F — Section accent override
   --------------------------------------------------
   Per Mauizoom's design review: primary CTA = section accent color.
   Pages set --section-accent on :root or a wrapper.
   Defaults to --km-foam so this is a no-op when unset.
   ========================================================== */

.btn-primary {
  background: var(--section-accent, var(--km-foam, #e8f4f8));
  color: var(--km-text-inverse, #0b1f2a);
}

.btn-primary:hover {
  background: var(--section-accent-bright, var(--km-foam-bright, #94e1d6));
}

/* ==========================================================
   M2F — Standardized links
   --------------------------------------------------
   Mauizoom's rule: never browser-default blue links.
   Links inherit section design language via --section-accent.
   ========================================================== */

a {
  color: var(--section-accent, var(--km-foam, #e8f4f8));
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--btn-dur) var(--btn-ease);
}

a:hover {
  color: var(--section-accent-bright, var(--km-foam-bright, #94e1d6));
}

/* Don't re-style links inside nav or button variants — they have their own rules.
   NOTE: exclude .btn-primary and .btn-ghost explicitly because .btn has the same
   specificity as the variant rules, so the LATER rule wins; we want the variants
   to keep their explicit colors. */
.km-menu a,
.km-header a,
.km-nav-strip a,
.km-footer a,
.btn:not(.btn-primary):not(.btn-ghost),
.btn-link {
  color: inherit;
  text-decoration: inherit;
}