/* ==========================================================================
   Button component
   Single base size. Cards apply a larger size via .card .btn (in card.css).
   Color variants are context-named (filled-brown, outline-off-white, …).
   ========================================================================== */

:root {
  /* --- Typography --- */
  --btn-font-family: var(--body-font-family);
  --btn-font-size: var(--font-size-sm);
  --btn-font-weight: 500;
  --btn-font-style: var(--body-font-style);
  --btn-letter-spacing: var(--letter-spacing-standalone);
  --btn-line-height: 1;
  --btn-text-transform: uppercase;

  /* --- Shape --- */
  --btn-border-width: 1px;
  --btn-border-radius: var(--border-radius);
  --btn-border-radius-pill: 9999rem;
  --btn-transition:
    background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;

  /* --- Size --- */
  --btn-height: 2.9em;
  --btn-padding-inline: 1em;
  --btn-shaped-padding-inline: 2.5em;
}

/* --- Base --- */

.btn {
  --btn-current-font-size: var(--btn-font-size);
  --btn-current-letter-spacing: var(--btn-letter-spacing);
  --btn-current-height: var(--btn-height);
  --btn-current-padding-inline: var(--btn-padding-inline);
  --btn-current-shaped-padding-inline: var(--btn-shaped-padding-inline);
  --btn-current-border-radius: var(--btn-border-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-width: 0;
  height: var(--btn-current-height);
  padding: 0 var(--btn-current-padding-inline);
  border: none;
  border-radius: var(--btn-current-border-radius);
  background: var(--btn-bg, transparent);
  color: var(--btn-color, var(--wp--preset--color--warm-brown));
  font-family: var(--btn-font-family);
  font-size: var(--btn-current-font-size);
  font-weight: var(--btn-font-weight);
  font-style: var(--btn-font-style);
  letter-spacing: var(--btn-current-letter-spacing);
  line-height: var(--btn-line-height);
  text-align: center;
  text-decoration: none;
  text-transform: var(--btn-text-transform);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--btn-transition);
}

/* Inline SVG icon paired with a <span> label (leading or trailing).
   The base button lays them out via flex + gap; this rule just sizes
   the icon to the button text. .icon (circular, icon-only) keeps
   its own size override below. */
.btn > svg {
  display: block;
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
}

.btn:not([class*="filled-"]):hover,
.btn:not([class*="filled-"]):focus-visible {
  background-color: transparent;
  background-color: color-mix(in srgb, currentColor 10%, transparent);
}

.btn:not([class*="filled-"]):active {
  background-color: transparent;
  background-color: color-mix(in srgb, currentColor 18%, transparent);
}

/* --- Focus ring (keyboard) --- */

.btn:focus-visible {
  outline: 2px solid var(--focus-ring-color, var(--wp--preset--color--warm-brown));
  outline-offset: 2px;
}

/* --- Outline / filled shared shape padding --- */

.btn:is([class*="outline-"], [class*="filled-"]) {
  padding-inline: var(--btn-current-shaped-padding-inline);
}

/* --- Outline (shared) --- */

.btn[class*="outline-"] {
  --btn-bg: transparent;
  border: var(--btn-border-width) solid var(--btn-border-color, currentColor);
}

/* --- Outline colors --- */

.btn.outline-off-white {
  --btn-border-color: var(--wp--preset--color--off-white);
  --btn-border-color: color-mix(in srgb, var(--wp--preset--color--off-white) 80%, transparent);
  --btn-color: var(--wp--preset--color--off-white);
}

.btn.outline-brown {
  --btn-border-color: var(--wp--preset--color--warm-brown);
  --btn-border-color: color-mix(in srgb, var(--wp--preset--color--warm-brown) 80%, transparent);
  --btn-color: var(--wp--preset--color--warm-brown);
}

/* --- Filled colors ---
   Each variant declares its own --btn-bg-hover / --btn-bg-active so the
   shared filled hover rule below can darken the fill consistently:
   warm-brown darkens toward black; off-white darkens toward warm-brown
   so it sinks into the surface it sits on instead of going muddy. */

.btn.filled-brown {
  --btn-bg: var(--wp--preset--color--warm-brown);
  --btn-bg-hover: color-mix(in srgb, var(--wp--preset--color--warm-brown) 75%, black 25%);
  --btn-bg-active: color-mix(in srgb, var(--wp--preset--color--warm-brown) 58%, black 42%);
  --btn-color: var(--wp--preset--color--off-white);
}

.btn.filled-off-white {
  --btn-bg: var(--wp--preset--color--off-white);
  --btn-bg-hover: color-mix(
    in srgb,
    var(--wp--preset--color--off-white) 75%,
    var(--wp--preset--color--warm-brown) 25%
  );
  --btn-bg-active: color-mix(
    in srgb,
    var(--wp--preset--color--off-white) 58%,
    var(--wp--preset--color--warm-brown) 42%
  );
  --btn-color: var(--wp--preset--color--warm-brown);
}

/* --- Filled hover / focus / active --- */

.btn[class*="filled-"]:hover,
.btn[class*="filled-"]:focus-visible {
  background-color: var(--btn-bg-hover, var(--btn-bg));
}

.btn[class*="filled-"]:active {
  background-color: var(--btn-bg-active, var(--btn-bg));
}

/* --- Context size overrides ---
   Larger size for buttons inside cards or heroes from md+; weight
   returns to 400. Below md the card/hero buttons inherit the base
   size so they don't crowd the small viewport. */

@media (min-width: 40rem) {
  .card .btn,
  .hero .btn {
    --btn-current-font-size: var(--font-size-lg);
    --btn-current-height: 2.6667em;
    --btn-font-weight: 400;
  }
}

/* --- Icon variant (circular, fixed touch area + svg size) ---

   .btn.icon       — 48px touch area, 24px svg (default)
   .btn.icon.sm    — 40px touch area, 20px svg (small, e.g. inside text fields)

   The .btn.icon compound selector keeps a specificity edge over the
   filled/outline padding-inline rule above so icon-only wins. */

.btn.icon {
  --btn-current-border-radius: 50%;
  --btn-current-height: 3rem;
  aspect-ratio: 1;
  padding: 0;
  flex: 0 0 auto;
}

.btn.icon > svg {
  width: 1.5rem;
  height: 1.5rem;
}

.btn.icon.sm {
  --btn-current-height: 2.5rem;
}

.btn.icon.sm > svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* --- Disabled --- */

button.btn[disabled],
a.btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* --- Button group (inline row of buttons) --- */

.btn-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-16);
  width: 100%;
}
