/*
 * The shared button (snippet base/button). One component for every brand.
 * Brands theme it through tokens only; variants are modifiers on .btn.
 *
 * .btn          outline on paper, arrow (default, main CTA)
 * .btn--fill    black
 * .btn--brand   brand color (mint on Peanut Media)
 * .btn--ghost   white outline
 * .btn--link    text with arrow, no box
 * .btn--block   full width
 * Hover for boxed variants: invert to ink. Arrow nudges right.
 *
 * One size for every variant (Peanut Media design system, "Buttons",
 * 2026-10-24): body face, weight, size, tracking, padding and the label to
 * arrow gap all come from the brand's --btn-* tokens. .btn--sm and .btn--lg
 * no longer change the size (the classes are harmless where still printed).
 */

@layer components {
  .btn {
    --_bg: var(--btn-bg, var(--color-paper, #F7F6F2));
    --_fg: var(--btn-fg, var(--color-ink, #1A1818));
    --_border: var(--btn-border, var(--color-ink, #1A1818));
    --_hover-bg: var(--btn-hover-bg, var(--color-ink, #1A1818));
    --_hover-fg: var(--btn-hover-fg, var(--color-white, #FFFFFF));

    /* flex per the design system; fit-content keeps it the size of its label
       in a plain text column (a grid or flex parent can still stretch it with
       an explicit width, as .btn--block does) */
    display: flex;
    width: fit-content;
    align-items: center;
    justify-content: center;
    gap: var(--btn-gap, 0.625rem);
    padding: var(--btn-padding, 0.5625rem 0.875rem);
    border: 1px solid var(--_border);
    border-radius: var(--btn-radius, 0);
    background: var(--_bg);
    color: var(--_fg);
    font-family: var(--font-body, system-ui, sans-serif);
    font-size: var(--btn-font-size, 0.625rem);
    font-weight: var(--btn-weight, 500);
    line-height: 1.2;
    letter-spacing: var(--btn-tracking, 0.22em);
    text-transform: uppercase;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
  }

  .btn:hover {
    background: var(--_hover-bg);
    color: var(--_hover-fg);
  }

  .btn:focus-visible {
    outline: 3px solid var(--focus-ring, #1A1818);
    outline-offset: 3px;
  }

  /* Hover lift, press and the arrow nudge live in the site's motion layer (motion.css) */
  .btn__arrow {
    flex: none;
    width: var(--btn-arrow, 1.2em);
    height: var(--btn-arrow, 1.2em);
  }

  .btn--fill {
    --_bg: var(--color-ink, #1A1818);
    --_fg: var(--color-white, #FFFFFF);
    --_hover-bg: var(--color-white, #FFFFFF);
    --_hover-fg: var(--color-ink, #1A1818);
  }

  .btn--brand {
    --_bg: var(--color-brand, #B8E3D7);
    --_fg: var(--color-ink, #1A1818);
  }

  .btn--ghost {
    --_bg: var(--color-white, #FFFFFF);
  }

  /* Hover keeps the link's own color (ink on light, white on dark) and only
     shows the underline. No side padding: the label lines up with the text
     above it (design review #40, #65) */
  .btn--link {
    --_bg: transparent;
    --_border: transparent;
    --_hover-bg: transparent;
    --_hover-fg: currentColor;
    padding-inline: 0;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 0.35em;
  }

  .btn--link:hover {
    text-decoration-color: currentColor;
  }

  .btn--block {
    display: flex;
    width: 100%;
  }

  /* On dark sections, boxed buttons keep their own colors; text links follow the section */
  .btn--link {
    color: inherit;
  }
}
