/* =============================================================================
   Buttons — docs/design-system/buttons.md (source of truth), motion.md,
   elevation.md. Raleway 700 / 16px / uppercase, 4px radius, hover = lift + glow.

   `buttons.md` supersedes the older sketch in `static-app-scaffolding.md`
   (14px, radius 8px): 16px and --border-radius-sm win.

   Dark grounds: outline buttons flip to the white outline under
   :where(.cta-section, .bg-dark, [data-tone='dark']). `data-tone="dark"` is the
   design-system attribute; the two class names are the dark bands that exist in
   the markup today, kept in :where() so they carry no specificity and W4 can
   override them freely.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Base — every filled and outline variant shares this
   --------------------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 150px;
  max-width: 100%;
  padding: 0.875rem 1.75rem; /* 14px 28px */
  border: none;
  border-radius: var(--border-radius-sm);
  background-color: transparent;
  color: var(--color-primary);
  font-size: 1rem;
  font-weight: 700;
  line-height: 140%;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  will-change: transform;
  transition: transform var(--duration-base) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard),
              background-color var(--duration-base) var(--ease-standard),
              border-color var(--duration-base) var(--ease-standard),
              color var(--duration-base) var(--ease-standard);
}

/* Shared hover lift and press. Variants add their own fill and glow.
   `.btn--text-link` opts out of both further down. */
.btn:hover {
  transform: var(--lift-sm);
}

.btn:active {
  transform: var(--press);
  box-shadow: none;
  transition-duration: var(--duration-instant);
}

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

.btn:disabled,
.btn[aria-disabled='true'] {
  background-color: var(--color-disabled-bg);
  color: var(--color-disabled-text);
  box-shadow: none;
  transform: none;
  cursor: default;
  pointer-events: none;
}

/* Legacy inline <svg> inside a button — no width/height attributes, so without
   this they lay out at the SVG default 300 × 150. Sprite icons carry `.icon`
   and are sized by icon.css; they are excluded so `.icon--16|24|32` wins. */
.btn svg:not(.icon) {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}

/* ---------------------------------------------------------------------------
   Division (EdTech) — the site's primary action.
   `.btn--primary` and `.btn--division` are the same variant; W2 put
   `.btn--division` on the nav CTA, the rest of the markup still says
   `.btn--primary`. Both spellings must keep working.
   The brand #268279 is dark, so white text is correct here — the EdTech
   contrast rule applies to the light *accent*, not to the brand.
   --------------------------------------------------------------------------- */
.btn--primary,
.btn--division {
  background-color: var(--color-division-brand);
  color: var(--color-white);
}

.btn--primary:hover,
.btn--division:hover {
  background-color: var(--color-division-brand-hover);
  color: var(--color-white);
  /* shadowButtonGlow($fill) = 0 12px 24px rgba($fill, .35) — elevation.md.
     No --shadow-button-glow-division token exists yet, so it is composed from
     the division token here. See the report. */
  box-shadow: 0 12px 24px color-mix(in srgb, var(--color-division-brand) 35%, transparent);
}

.btn--primary:active,
.btn--division:active {
  background-color: var(--color-division-brand-pressed);
  color: var(--color-white);
}

/* ---------------------------------------------------------------------------
   White — primary action on dark backgrounds
   --------------------------------------------------------------------------- */
.btn--white {
  background-color: var(--color-white);
  color: var(--color-primary);
}

.btn--white:hover {
  background-color: var(--color-white);
  color: var(--color-primary);
  box-shadow: var(--shadow-button-glow-white);
}

.btn--white:active {
  background-color: var(--color-button-white-pressed);
  color: var(--color-primary);
}

/* ---------------------------------------------------------------------------
   Outline — 1px border painted with an inset box-shadow so the 1px → 2px
   hover change costs no layout (buttons.md).
   `.btn--ghost` is the frozen name, `.btn--outline-blue` the design-system one,
   `.btn--secondary` the old alias kept alive for two remaining call sites.
   --------------------------------------------------------------------------- */
.btn--ghost,
.btn--outline-blue,
.btn--secondary {
  background-color: transparent;
  color: var(--color-primary);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

.btn--ghost:hover,
.btn--outline-blue:hover,
.btn--secondary:hover {
  color: var(--color-primary);
  background-color: color-mix(in srgb, var(--color-control-hover-bg) 15%, transparent);
  box-shadow: inset 0 0 0 2px var(--color-primary), var(--shadow-button-glow-outline);
}

.btn--ghost:active,
.btn--outline-blue:active,
.btn--secondary:active {
  background-color: color-mix(in srgb, var(--color-primary-light) 25%, transparent);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Outline White — explicit class, and the automatic flip on dark grounds */
.btn--outline-white,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--ghost,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--outline-blue,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--secondary {
  background-color: transparent;
  color: var(--color-white);
  box-shadow: inset 0 0 0 1px var(--color-white);
}

.btn--outline-white:hover,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--ghost:hover,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--outline-blue:hover,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--secondary:hover {
  color: var(--color-white);
  background-color: color-mix(in srgb, var(--color-white) 15%, transparent);
  box-shadow: inset 0 0 0 2px var(--color-white), var(--shadow-button-glow-outline);
}

.btn--outline-white:active,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--ghost:active,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--outline-blue:active,
:where(.cta-section, .bg-dark, [data-tone='dark']) .btn--secondary:active {
  background-color: color-mix(in srgb, var(--color-white) 25%, transparent);
  box-shadow: inset 0 0 0 2px var(--color-white);
}

/* Outline variants keep a border instead of a disabled fill */
.btn--ghost:disabled,
.btn--outline-blue:disabled,
.btn--outline-white:disabled,
.btn--secondary:disabled,
.btn--ghost[aria-disabled='true'],
.btn--outline-blue[aria-disabled='true'],
.btn--outline-white[aria-disabled='true'],
.btn--secondary[aria-disabled='true'] {
  background-color: transparent;
  color: var(--color-disabled-text);
  box-shadow: inset 0 0 0 1px var(--color-disabled-border);
}

/* ---------------------------------------------------------------------------
   Text Link — inline CTA ("READ MORE"). 12px/700/uppercase, trailing 16px
   arrow that slides on hover. No lift, no glow, no min-width.
   --------------------------------------------------------------------------- */
.btn--text-link {
  gap: var(--space-1);
  min-width: 0;
  padding: 0;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
  color: var(--color-accent-cyan-dark);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.btn--text-link:hover {
  transform: none;
  background-color: transparent;
  box-shadow: none;
  color: var(--color-link-hover);
}

.btn--text-link:active {
  transform: none;
  background-color: transparent;
  box-shadow: none;
  color: var(--color-link-pressed);
}

.btn--text-link:disabled,
.btn--text-link[aria-disabled='true'] {
  background-color: transparent;
  box-shadow: none;
  color: var(--color-disabled-text);
}

.btn--text-link .icon,
.btn--text-link svg {
  transition: transform var(--duration-base) var(--ease-standard);
}

.btn--text-link:hover .icon,
.btn--text-link:hover svg {
  transform: translateX(var(--nudge-arrow));
}

/* ---------------------------------------------------------------------------
   Size modifiers — the design system has one button size; these two exist in
   the markup and stay as padding-only adjustments.
   --------------------------------------------------------------------------- */
.btn--lg {
  padding: var(--space-4) var(--space-8);
}

.btn--sm {
  min-width: 0;
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
}
