/*
  Button — Figma "Buttons" (2290:7260, component set 2218:14272).

  Axes: hierarchy (data-variant primary/secondary/tertiary/filled), background
  (data-background light/dark), size (data-size medium/small), display
  (data-display: absent = with the arrow circle, "no-icon" = plain filled pill
  (legacy, same look as the filled variant but without icons),
  "icon-only" = round icon button). Every variant only redefines the custom
  properties on the base rule.

  The arrow circle is drawn with pseudo-elements, so the saved markup of the
  static block stays as it is:
    ::after  — the circle (fill or outline): absolutely positioned at the end
               of the pill, as tall as the button, with the pill's radius
    ::before — the 16px arrow, centred over the circle
  On hover primary widens the circle to the whole pill (one element, so its
  edge and colour always line up); secondary moves the outline from the
  circle to the pill. Labels never wrap.
*/
.button {
  --button-text: var(--color-himbeere-80);
  --button-text-hover: var(--color-neutral-0);
  --button-bg: transparent;
  --button-bg-hover: var(--color-himbeere-60);
  --button-border-color: transparent;
  --button-border-color-hover: transparent;
  --button-circle-bg: var(--color-himbeere-60);
  --button-circle-border: var(--color-himbeere-60);
  --button-circle-border-hover: var(--button-circle-border);
  --button-arrow: var(--color-neutral-0);
  --button-border-width: 1px;
  /* Figma: 20px start padding; above/below the label 20px on desktop, 16px
     on phones (the mobile drafts use button/s throughout) — the fluid
     Button-Y token (spacing.json), with the fluid btn type size. */
  --button-x-padding: 1.25rem;
  --button-y-padding: var(--space-button-y);
  --button-font-size: var(--size-btn);
  --button-radius: var(--radius-pill);
  --button-gutter: var(--space-l);
  /* The circle: label cap height + padding above and below (Figma 54/45px). */
  --button-circle-size: calc(1cap + 2 * var(--button-y-padding));

  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: stretch;
  gap: var(--button-gutter);
  /* End padding = room for the circle. */
  padding: 0 calc(var(--button-circle-size) + var(--button-gutter)) 0 var(--button-x-padding);
  border: var(--button-border-width) solid var(--button-border-color);
  border-radius: var(--button-radius);
  background-color: var(--button-bg);
  color: var(--button-text);
  font-family: inherit;
  font-size: var(--button-font-size);
  font-weight: var(--font-bold);
  line-height: 1;
  text-decoration: none;
  /* Long labels wrap (phones) instead of being cut — but only when the
     button's own container is narrower than the label: as a flex item (repel,
     cluster) it doesn't shrink, so a neighbouring paragraph wraps first. */
  max-inline-size: 100%;
  flex-shrink: 0;
  cursor: pointer;
  transition:
    background-color var(--transition-base),
    color var(--transition-base),
    border-color var(--transition-base);
}
.button .button-text {
  position: relative;
  z-index: 1;
  align-self: center;
  min-inline-size: 0;
  /* Balanced lines when a label wraps; trimmed to the caps, so one line is
     exactly as tall as before whatever the line height. */
  text-wrap: balance;
  line-height: 1.2;
  padding-block: var(--button-y-padding);
  text-box-trim: trim-both;
  text-box-edge: cap alphabetic;
}
/*
  The circle, over the pill's border at the end. It has the pill's radius, so
  a square box is a circle and the widened box (primary hover) is the pill.
*/
.button::after {
  content: "";
  position: absolute;
  z-index: 0;
  /* A circle of its own size, centred on the pill's height — the pill grows
     when the label wraps, the circle doesn't. */
  inset-block-start: 50%;
  inset-inline-end: calc(var(--button-border-width) * -1);
  translate: 0 -50%;
  inline-size: calc(var(--button-circle-size) + 2 * var(--button-border-width));
  block-size: calc(var(--button-circle-size) + 2 * var(--button-border-width));
  border: var(--button-border-width) solid var(--button-circle-border);
  border-radius: var(--button-radius);
  background-color: var(--button-circle-bg);
  transition:
    inline-size 450ms cubic-bezier(0.22, 1, 0.36, 1),
    block-size 450ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color var(--transition-base);
}
/* The arrow, centred over the circle. */
.button::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset-block: 0;
  inset-inline-end: 0;
  inline-size: var(--button-circle-size);
  background-color: var(--button-arrow);
  -webkit-mask: url(../../assets/icons/arrow-right.svg) center / 1rem no-repeat;
  mask: url(../../assets/icons/arrow-right.svg) center / 1rem no-repeat;
}
@media (hover: hover) {
  .button:hover {
    background-color: var(--button-bg-hover);
    border-color: var(--button-border-color-hover);
    color: var(--button-text-hover);
    text-decoration: none;

    &::after {
      border-color: var(--button-circle-border-hover);
    }
  }
}
/* Primary: the circle widens to fill the pill (the pill itself stays clear). */
.button:not([data-variant="secondary"], [data-variant="tertiary"], [data-variant="filled"], [data-display], .wpforms-submit) {
  --button-bg-hover: transparent;

  @media (hover: hover) {
    &:hover::after {
      inline-size: calc(100% + 2 * var(--button-border-width));
      block-size: calc(100% + 2 * var(--button-border-width));
    }
  }

  /* Keyboard focus: same fill, white label. */
  &:focus-visible {
    color: var(--button-text-hover);

    &::after {
      inline-size: calc(100% + 2 * var(--button-border-width));
      block-size: calc(100% + 2 * var(--button-border-width));
    }
  }
}
.button:focus-visible {
  outline: 2px solid var(--button-circle-border);
  outline-offset: 2px;
}
.button[data-size="small"] {
  /* Figma button/s: 16px above and below the label at every width (43px
     circle); --space-l shrinks to 8px on phones. */
  --button-y-padding: 1rem;
  --button-font-size: var(--size-btn-s);
}
/* ---- secondary: outlined circle; on hover the outline wraps the pill ---- */
.button[data-variant="secondary"] {
  --button-bg-hover: transparent;
  --button-text-hover: var(--button-text);
  --button-circle-bg: transparent;
  --button-arrow: var(--color-himbeere-80);
  --button-border-color-hover: var(--color-himbeere-60);
  --button-circle-border-hover: transparent;
}
/* ---- tertiary: text + small arrow, colour change on hover ---- */
.button[data-variant="tertiary"] {
  --button-text: var(--color-primary-100);
  --button-text-hover: var(--color-primary-60);
  --button-bg-hover: transparent;
  --button-x-padding: 0;
  --button-y-padding: 0;
  --button-radius: var(--radius-xs, 2px);
  padding-inline-end: 0;

  &::before {
    content: none;
  }

  /* The circle becomes the plain 16px arrow after the label, in the flow. */
  &::after {
    position: static;
    translate: none;
    align-self: center;
    inline-size: 1rem;
    block-size: 1rem;
    margin: 0;
    border: 0;
    border-radius: 0;
    background-color: currentColor;
    -webkit-mask: url(../../assets/icons/arrow-right.svg) center / contain no-repeat;
    mask: url(../../assets/icons/arrow-right.svg) center / contain no-repeat;
  }
}
/* External link (new tab): the arrow points out (Figma partner links). */
.button[data-variant="tertiary"][target="_blank"]::after {
  -webkit-mask-image: url(../../assets/icons/arrow-top-right.svg);
  mask-image: url(../../assets/icons/arrow-top-right.svg);
}
/* Same for the arrow in the circle of primary/secondary buttons (Desi). */
.button:not([data-variant="tertiary"])[target="_blank"]::before {
  -webkit-mask-image: url(../../assets/icons/arrow-top-right.svg);
  mask-image: url(../../assets/icons/arrow-top-right.svg);
}
/* ---- on dark surfaces: white label, white outline ---- */
.button[data-background="dark"] {
  --button-text: var(--color-neutral-0);
}
.button[data-background="dark"][data-variant="secondary"] {
  --button-circle-border: var(--color-neutral-0);
  --button-arrow: var(--color-neutral-0);
  --button-border-color-hover: var(--color-neutral-0);
}
.button[data-background="dark"][data-variant="tertiary"] {
  --button-text-hover: var(--color-primary-10);
}
/*
  Filled pill, no circle — the "Gefüllt" variant (icons before/after the label
  show), the legacy no-icon display ("Jetzt spenden" in the footer) and the
  WPForms submit buttons (wpforms.php adds .button to them).
*/
.button:is([data-variant="filled"], [data-display="no-icon"], .wpforms-submit) {
  --button-bg: var(--color-himbeere-60);
  --button-bg-hover: var(--color-himbeere-80);
  --button-text: var(--color-neutral-0);
  --button-text-hover: var(--color-neutral-0);
  padding-inline-end: var(--button-x-padding);

  &::before,
  &::after {
    content: none;
  }
}
.button:is([data-variant="filled"], [data-display="no-icon"])[data-size="small"] {
  /* Figma button/s filled: 18px each side. */
  --button-x-padding: 1.125rem;
}
.button[data-display="no-icon"] .button__icon {
  display: none;
}
/* Filled: icons sit inline with the label, centred on it. */
.button[data-variant="filled"] .button__icon {
  align-self: center;
}
/*
  Round icon button (12px padding around the icon). The label stays as the
  accessible name, visually hidden.
*/
.button[data-display="icon-only"] {
  --button-bg: var(--color-himbeere-60);
  --button-bg-hover: var(--color-himbeere-80);
  --button-text: var(--color-neutral-0);
  --button-text-hover: var(--color-neutral-0);
  align-items: center;
  padding: 12px;

  &::before,
  &::after {
    content: none;
  }
}
.button[data-display="icon-only"] .button-text {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
svg.button__icon {
  block-size: 1lh;
}
@media (prefers-reduced-motion: reduce) {
  .button,
  .button::after {
    transition: none;
  }
}

