﻿/* kc-v2 v1.5.7 -- buttons & links */
/* Full class contract and conventions: see README.md and kc-v2-base.css. */

/* ---------------------------------------------------------------------------
 * Buttons & Links
 * Figma gives exact hover/focus/disabled hex only for the Primary variant.
 * Success/Secondary/Ghost/Destructive hovers use filter: brightness() instead
 * of a fabricated hex -- an honest derivation rather than an invented value.
 * type="button" is mandatory on every non-submit <button class="kc-v2-btn">
 * (default is type="submit", and these apps are full of forms) -- see README.
 * ------------------------------------------------------------------------- */

.kc-v2-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--kc-v2-space-2);
  height: 42px; /* Figma spec. Fixed height + flex align-items: center for
                   vertical centering, not padding math -- padding alone drifts
                   out of sync the moment font-size/line-height changes (that's
                   how this got to ~51px), while a fixed height stays exact
                   regardless of label/icon/spinner content. */
  margin: 0; /* site.css ships `button { margin-right: 8px; }`. That is (0,0,1) and
                 loses to this class -- but only because this class now declares the
                 property. Before it did, every kc-v2 button on a Community page
                 carried a stray 8px right margin (KENT-59 Phase 0 spike). */
  padding: 0 var(--kc-v2-space-4);
  border: 1px solid transparent; /* reserved even on filled variants: forced-colors
                                     mode needs a real border to keep the button
                                     visible once background-color is stripped */
  border-radius: var(--kc-v2-radius-md);
  font-family: var(--kc-v2-font-family);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms, border-color 150ms, box-shadow 150ms, color 150ms;
}

.kc-v2-btn:visited {
  color: inherit;
}

.kc-v2-btn:hover,
.kc-v2-btn:focus,
.kc-v2-btn:active {
  text-decoration: none;
}

.kc-v2-btn:focus-visible {
  outline: var(--kc-v2-focus-ring-width) solid var(--kc-v2-focus-ring-color);
  outline-offset: var(--kc-v2-focus-ring-offset);
}

.kc-v2-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
}

/* Variants */

.kc-v2-btn--primary {
  background-color: var(--kc-v2-blue);
  color: var(--kc-v2-white);
}
.kc-v2-btn--primary:hover {
  background-color: var(--kc-v2-blue-dark);
  color: var(--kc-v2-white);
  box-shadow: 0 4px 14px rgba(0, 80, 157, 0.35);
}
.kc-v2-btn--primary:disabled,
.kc-v2-btn--primary[aria-disabled="true"] {
  background-color: var(--kc-v2-disabled-bg);
  color: var(--kc-v2-disabled-text);
}

.kc-v2-btn--success {
  background-color: var(--kc-v2-green);
  color: var(--kc-v2-white);
}
.kc-v2-btn--success:hover {
  background-color: var(--kc-v2-green);
  color: var(--kc-v2-white);
  filter: brightness(90%);
}
.kc-v2-btn--success:disabled,
.kc-v2-btn--success[aria-disabled="true"] {
  background-color: var(--kc-v2-disabled-bg);
  color: var(--kc-v2-disabled-text);
  filter: none;
}

.kc-v2-btn--secondary {
  background-color: var(--kc-v2-white);
  border-color: var(--kc-v2-blue);
  color: var(--kc-v2-blue);
}
.kc-v2-btn--secondary:hover {
  background-color: var(--kc-v2-ink-100);
  border-color: var(--kc-v2-blue);
  color: var(--kc-v2-blue);
}
.kc-v2-btn--secondary:disabled,
.kc-v2-btn--secondary[aria-disabled="true"] {
  background-color: var(--kc-v2-white);
  border-color: var(--kc-v2-ink-300);
  color: var(--kc-v2-ink-400);
}

.kc-v2-btn--ghost {
  background-color: transparent;
  color: var(--kc-v2-blue);
}
.kc-v2-btn--ghost:hover {
  background-color: var(--kc-v2-ink-100);
  color: var(--kc-v2-blue);
}
.kc-v2-btn--ghost:disabled,
.kc-v2-btn--ghost[aria-disabled="true"] {
  background-color: transparent;
  color: var(--kc-v2-ink-400);
}

.kc-v2-btn--destructive {
  background-color: var(--kc-v2-error);
  color: var(--kc-v2-white);
}
.kc-v2-btn--destructive:hover {
  background-color: var(--kc-v2-error);
  color: var(--kc-v2-white);
  filter: brightness(90%);
}
.kc-v2-btn--destructive:disabled,
.kc-v2-btn--destructive[aria-disabled="true"] {
  background-color: var(--kc-v2-disabled-bg);
  color: var(--kc-v2-disabled-text);
  filter: none;
}

/* Added in KENT-44 1.2.0. Both signed-in Figma frames (54:446, 100:2) draw "Log out" in the site
   header as a red OUTLINE, not the solid --destructive fill: it is a destructive action that sits
   permanently in the chrome, so it has to stay legible without competing with the step's primary
   button. Solid red in the header would out-shout "Next" on every screen.
   Reusable as the general "destructive but not the page's main action" treatment -- cancel,
   remove, sign out -- so it belongs with the variants rather than in a view. */
.kc-v2-btn--destructive-outline {
  background-color: var(--kc-v2-white);
  border-color: var(--kc-v2-error);
  color: var(--kc-v2-error);
}
.kc-v2-btn--destructive-outline:hover {
  background-color: var(--kc-v2-error-bg);
  border-color: var(--kc-v2-error);
  color: var(--kc-v2-error);
}
.kc-v2-btn--destructive-outline:disabled,
.kc-v2-btn--destructive-outline[aria-disabled="true"] {
  background-color: var(--kc-v2-white);
  border-color: var(--kc-v2-ink-300);
  color: var(--kc-v2-ink-400);
}

/* Quiet: no border or fill until hover or focus (KENT-115). For an icon button repeated on every row
   of a table, where a bordered box per row reads heavier than the data. Composes with a colour
   variant, which supplies the icon colour and the hover state. */
.kc-v2-btn--quiet:not(:hover):not(:focus-visible) {
  border-color: transparent;
  background-color: transparent;
}

/* Added in Phase 4 for the spotlight card's white CTA on a colored/gradient
   background -- a genuinely reusable pattern (any component on a solid or
   dark background needs a "button that reads on color"), not something
   specific to cards, so it lives here with the other button variants rather
   than duplicated as card-only CSS. */
.kc-v2-btn--on-color {
  background-color: var(--kc-v2-white);
  color: var(--kc-v2-blue);
}
.kc-v2-btn--on-color:hover {
  background-color: var(--kc-v2-white);
  color: var(--kc-v2-blue);
  filter: brightness(96%);
}
.kc-v2-btn--on-color:disabled,
.kc-v2-btn--on-color[aria-disabled="true"] {
  background-color: rgba(255, 255, 255, 0.6);
  color: var(--kc-v2-ink-400);
  filter: none;
}

/* Shared disabled/aria-disabled behavior: no pointer, no hover affordance.
   aria-disabled (not the native disabled attribute) is used whenever the button
   must stay focusable and explain itself -- see README point 11. Native
   :disabled already blocks interaction and needs no pointer-events rule;
   aria-disabled does NOT block a click by itself (this is not a native HTML
   behavior) -- the page's click handler must check the attribute itself
   before acting. Never pointer-events: none here either way. */
.kc-v2-btn:disabled {
  cursor: not-allowed;
}
.kc-v2-btn[aria-disabled="true"] {
  cursor: not-allowed;
}

/* Sizes (md is the unmodified base above) */

.kc-v2-btn--sm {
  height: 34px; /* explicit, not inherited from .kc-v2-btn's 42px -- same
                   fixed-height reasoning, sized to what this variant's own
                   padding used to produce before that padding was zeroed */
  padding: 0 var(--kc-v2-space-3);
  border-radius: var(--kc-v2-radius-sm);
  font-size: 13px;
  line-height: 16px;
}

/* ---------------------------------------------------------------------------
 * Icon-only button (1.5.1, KENT-44 QA)
 *
 * A square action with no visible label, for a table row where a text button costs more vertical
 * space than the data it sits beside. QA asked for this specifically: the Edit/Remove pair on the
 * Business License employee grids made every row as tall as a 34px button.
 *
 * 28px, not 24px: 24x24 is the WCAG 2.2 target-size MINIMUM, and sizing exactly to a minimum leaves
 * nothing for the 1px border, so the activating box lands at 22px of content. 28px clears it with
 * room and is still 6px shorter than --sm.
 *
 * COMPOSES with the colour variants -- use it alongside --secondary or --destructive-outline, which
 * supply the border and fill. This rule only changes geometry.
 *
 * THE PAGE MUST SUPPLY AN ACCESSIBLE NAME. There is no visible text, so an icon-only button with no
 * aria-label is an unlabelled control: the a11y sweeps assert every button has a name, and this
 * variant is the easiest way to fail that. Pair it with aria-label (and title, so a sighted mouse
 * user gets the same information on hover).
 * ------------------------------------------------------------------------- */
.kc-v2-btn--icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: var(--kc-v2-radius-sm);
  flex-shrink: 0;
}

.kc-v2-btn--icon svg {
  width: 16px;
  height: 16px;
  /* The icon inherits the variant's text colour rather than hard-coding a fill, so --secondary and
     --destructive-outline each tint their own icon. Contract rule 8. */
  stroke: currentColor;
  fill: none;
}
.kc-v2-btn--sm svg {
  width: 14px;
  height: 14px;
}

.kc-v2-btn--lg {
  height: 54px; /* explicit, not inherited from .kc-v2-btn's 42px -- see --sm */
  padding: 0 var(--kc-v2-space-5);
  border-radius: var(--kc-v2-radius-lg);
  font-size: 16px;
  line-height: 20px;
}

/* Loading/pending state.
 *
 * A button is sized by its label -- this component never sets a width, so buttons across a
 * page stay consistent and a wording change or longer translation just works.
 *
 * The one exception is while loading: swapping the label for a spinner would shrink the
 * button under the user's cursor, and a button that moves mid-submit invites a second click
 * (a double-submit on a tax filing is a duplicate return, not a cosmetic issue). The page
 * therefore pins a width for the duration of the busy state and releases it afterwards --
 * and that width must be MEASURED from the rendered label, not hardcoded. See setBusy() in
 * KentonCountyPublic's CommunityHome.js for the reference implementation. This class only
 * supplies the spinner's appearance. */
.kc-v2-btn[aria-busy="true"] {
  cursor: wait;
}
.kc-v2-btn__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--kc-v2-white);
  animation: kc-v2-spin 700ms linear infinite;
}
.kc-v2-btn--secondary .kc-v2-btn__spinner,
.kc-v2-btn--ghost .kc-v2-btn__spinner {
  border-color: rgba(0, 80, 157, 0.25);
  border-top-color: var(--kc-v2-blue);
}
@keyframes kc-v2-spin {
  to { transform: rotate(360deg); }
}

/* Text links (inline, within body copy) */
/* ---------------------------------------------------------------------------
 * Anchors styled as buttons
 *
 * `<a class="kc-v2-btn kc-v2-btn--primary">` is a normal, supported shape -- the
 * Community home page's "Forms & Rates" action is exactly this. But a variant's
 * colour is declared at (0,1,0), and site.css ships
 *
 *     a:link, a:visited, a:active, a:hover { color: #333; }
 *
 * at (0,1,1). So every anchor-button rendered with host-grey label text instead of
 * its variant colour -- white on the filled variants, which is the difference
 * between readable and not. Measured in the KENT-59 Phase 0 spike after the button
 * markup was added to it; the <button> form was never affected, which is why this
 * did not surface until an <a> was tested.
 *
 * Each variant is restated at (0,2,1) for the four link states the host names.
 * Verbose, but the alternative -- a blanket `a.kc-v2-btn { color: inherit }` --
 * would inherit from the *container*, not the variant, and silently produce the
 * wrong colour rather than an obviously wrong one.
 * ------------------------------------------------------------------------- */
a.kc-v2-btn--primary:link,
a.kc-v2-btn--primary:visited,
a.kc-v2-btn--primary:hover,
a.kc-v2-btn--primary:active,
a.kc-v2-btn--success:link,
a.kc-v2-btn--success:visited,
a.kc-v2-btn--success:hover,
a.kc-v2-btn--success:active,
a.kc-v2-btn--destructive:link,
a.kc-v2-btn--destructive:visited,
a.kc-v2-btn--destructive:hover,
a.kc-v2-btn--destructive:active {
  color: var(--kc-v2-white);
}

a.kc-v2-btn--secondary:link,
a.kc-v2-btn--secondary:visited,
a.kc-v2-btn--secondary:hover,
a.kc-v2-btn--secondary:active,
a.kc-v2-btn--ghost:link,
a.kc-v2-btn--ghost:visited,
a.kc-v2-btn--ghost:hover,
a.kc-v2-btn--ghost:active,
a.kc-v2-btn--on-color:link,
a.kc-v2-btn--on-color:visited,
a.kc-v2-btn--on-color:hover,
a.kc-v2-btn--on-color:active {
  color: var(--kc-v2-blue);
}

/* An unmodified .kc-v2-btn (no variant) still needs its own answer, and text
   decoration has to be restated for the same reason -- this is the exact case
   README rule #5 cites. */
a.kc-v2-btn:link,
a.kc-v2-btn:visited,
a.kc-v2-btn:hover,
a.kc-v2-btn:focus,
a.kc-v2-btn:active {
  text-decoration: none;
}

/* ELEMENT-QUALIFIED and declared at every link state, for the reason README rule #5
   already warns about in the abstract -- this is the concrete case that caught it.

   site.css ships:   a:link, a:visited, a:active, a:hover { color: #333; }

   That is (0,1,1). A bare `.kc-v2-link` is (0,1,0), so the host won regardless of
   load order and kc-v2 links rendered host-grey instead of #00509D on every
   Community page (KENT-59 Phase 0 spike). `a.kc-v2-link:link` is (0,2,1) and wins.

   Every state the host names has to be answered explicitly: declaring colour once
   on the base selector is not enough when the host declares it on four pseudo-classes.

   `padding` is here for the same reason -- site.css's bare `a { padding: 0 3px; }`
   was adding 3px either side of every link inside kc-v2 chrome. */
a.kc-v2-link,
a.kc-v2-link:link,
a.kc-v2-link:visited,
a.kc-v2-link:hover,
a.kc-v2-link:focus,
a.kc-v2-link:active {
  color: var(--kc-v2-blue);
  padding: 0;
  background: transparent;
}
a.kc-v2-link,
a.kc-v2-link:link,
a.kc-v2-link:visited {
  text-decoration: none;
}
a.kc-v2-link:hover,
a.kc-v2-link:focus,
a.kc-v2-link:active {
  text-decoration: underline;
}
a.kc-v2-link:focus-visible {
  outline: var(--kc-v2-focus-ring-width) solid var(--kc-v2-focus-ring-color);
  outline-offset: var(--kc-v2-focus-ring-offset);
}

@media (forced-colors: active) {
  .kc-v2-btn {
    border-color: ButtonText;
  }
  .kc-v2-btn:disabled,
  .kc-v2-btn[aria-disabled="true"] {
    border-color: GrayText;
    color: GrayText;
  }
}

/* prefers-reduced-motion: see kc-v2-base.css's file header for why this is a
   scoped override rather than the common `* { !important }` snippet. */
@media (prefers-reduced-motion: reduce) {
  .kc-v2-btn {
    transition-duration: 0.01ms;
  }
  .kc-v2-btn__spinner {
    /* Slowed, not stopped -- a loading spinner conveys system status, not
       decorative motion, so removing it entirely could read as the page
       having frozen rather than still working. */
    animation-duration: 3s;
  }
}

@media print {
  .kc-v2-btn {
    display: none;
  }
}
