/* Button – Figma "Button" (163:12). Height 44, padding 24, pill.
   Hover: surface grows 2px per side (via ::before, no layout shift), text stays 20px. */

.button {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  gap: var(--space-8);
  align-items: center;
  justify-content: center;
  height: 44px;
  padding-inline: var(--space-24);
  color: var(--color-text-primary);
  white-space: nowrap;
}

.button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--radius-pill);
  background: var(--color-surface-base);
  box-shadow: var(--shadow-button);
  transition: inset 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.button:hover::before {
  inset: -2px;
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-button-hover);
}

.button:focus-visible {
  outline: none;
}

.button:focus-visible::before {
  outline: 2px solid var(--color-interactive-primary);
  outline-offset: 2px;
}

.button--primary {
  color: var(--color-fixed-light);
}

.button--primary::before {
  background: var(--color-interactive-primary);
}

.button--primary:hover::before {
  background: var(--color-interactive-primary-hover);
}

/* Light (on dark surfaces, e.g. Cookie Notice): paper with shadow → hover chalk */
.button--light {
  color: var(--color-fixed-dark);
}

.button--light::before {
  background: var(--color-fixed-light);
}

.button--light:hover::before {
  background: var(--color-core-tone-chalk);
}

/* Secondary gray (Figma "Type=Secondary Gray"): chalk → fog */
.button--secondary {
  color: var(--color-fixed-dark);
}

.button--secondary::before {
  background: var(--color-surface-raised);
}

.button--secondary:hover::before {
  background: var(--color-core-tone-fog);
}

/* Secondary dark (Figma "Type=Secondary Dark") */
.button--dark {
  color: var(--color-fixed-light);
}

.button--dark::before {
  background: var(--color-fixed-dark);
}

.button--dark:hover::before {
  background: var(--color-core-tone-graphite);
}

/* Icon only (slider arrows): round, 44 × 44 */
.button--icon {
  width: 44px;
  padding-inline: 0;
}

.button--icon .button__icon {
  width: 20px;
  height: 20px;
}

.button--icon .icon--flip {
  rotate: 180deg;
}

.button--icon:hover .icon--flip {
  translate: -3px 0;
}

.button:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Button dock: white pill around a button, like the menu bar (paper, 4px padding, float shadow) */
.button-dock {
  display: inline-flex;
  padding: var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--color-fixed-light);
  box-shadow: var(--shadow-float);
}

.button-dock .button::before {
  box-shadow: none;
}

/* in a dock the whole pill grows on hover, so the button never leaves its white ground */
.button-dock {
  transition: scale 0.25s var(--ease-out-soft);
}

.button-dock:has(.button:hover) {
  scale: 1.05;
}

.button-dock .button:hover {
  scale: 1;
}

.button-dock .button:hover::before {
  inset: 0;
}

@media (prefers-reduced-motion: reduce) {
  .button-dock {
    transition: none;
  }
}


/* Trailing icon (e.g. arrow on "Alle Projekte"), nudges right on hover */
.button__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  transition: translate 0.2s ease;
}

.button:hover .button__icon {
  translate: 3px 0;
}

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

/* Hover (Leoš): button grows a little. Links and submit buttons always carry an arrow on the
   right (desktop and touch alike), it nudges right on hover like .button__icon.
   Buttons with their own icon and pure controls (Mehr zeigen, cookies) get none. */
.button {
  transition: scale 0.25s var(--ease-out-soft);
}

.button:hover {
  scale: 1.05;
}

a.button:not(:has(.button__icon))::after,
button.button[type="submit"]::after {
  content: "";
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: url("../icons/arrow-right.svg") center / 20px 20px no-repeat;
  mask: url("../icons/arrow-right.svg") center / 20px 20px no-repeat;
  transition: translate 0.2s ease;
}

a.button:not(:has(.button__icon)):hover::after,
button.button[type="submit"]:hover::after {
  translate: 3px 0;
}

/* Icon by context (one rule each, Leoš):
   → another page · ↓ further down this page · ↗ external · letter = to the inquiry · paper plane = sends a form */
button.button[type="submit"]::after {
  -webkit-mask-image: url("../icons/send.svg");
  mask-image: url("../icons/send.svg");
}

a.button.button--mail::after {
  -webkit-mask-image: url("../icons/mail.svg");
  mask-image: url("../icons/mail.svg");
}

a.button.button--down::after {
  -webkit-mask-image: url("../icons/arrow-down.svg");
  mask-image: url("../icons/arrow-down.svg");
}

a.button.button--external::after {
  -webkit-mask-image: url("../icons/arrow-up-right.svg");
  mask-image: url("../icons/arrow-up-right.svg");
}

button.button[type="submit"]:hover::after,
a.button.button--external:hover::after {
  translate: 2px -2px;
}

a.button.button--down:hover::after {
  translate: 0 3px;
}

/* pure controls (cookie settings) carry no icon */
button.button.button--plain::after {
  content: none;
}

/* touch screens: nothing grows or slides (a tap would otherwise leave the hover state stuck) */
@media (hover: none) {
  .button:hover,
  .button-dock:has(.button:hover) {
    scale: 1;
  }

  .button:hover::before {
    inset: 0;
    box-shadow: var(--shadow-button);
  }

  .button:hover .button__icon,
  .button--icon:hover .icon--flip,
  a.button:hover::after,
  button.button[type="submit"]:hover::after {
    translate: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .button::after {
    transition: none;
  }
}
