/* ─────────────────────────────────────────────────────────────
   Starboard · Buttons family
   Button (primary / secondary / ghost / danger / link),
   ButtonGroup (attached + segmented), Toggle, ToggleGroup.
   Pairs with Buttons.jsx. Tokens come from colors_and_type.css.
   ───────────────────────────────────────────────────────────── */
@import url('../../colors_and_type.css');

/* ─── Button base ─── */
.ad-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2xs);
  font-family: 'Plus Jakarta Sans', var(--font-display);
  font-weight: 600; font-size: 14px; line-height: 1;
  height: 42px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: transparent; color: var(--fg-default);
  cursor: pointer; white-space: nowrap; user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  transition:
    background-color var(--duration-4) var(--ease-out),
    color var(--duration-4) var(--ease-out),
    border-color var(--duration-4) var(--ease-out),
    box-shadow var(--motion-focus-primary),
    transform var(--duration-2) var(--ease-out);
}
.ad-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }
.ad-btn:active:not(:disabled):not(.is-loading) { transform: translateY(1px) scale(0.98); }

.ad-btn__icon { display: inline-flex; flex: 0 0 auto; }
.ad-btn__icon svg { display: block; }
.ad-btn__label { display: inline-flex; align-items: center; }

/* ─── Sizes ─── */
.ad-btn--sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.ad-btn--lg { height: 48px; padding: 0 24px; font-size: 15px; }

/* ─── Variants ─── */
.ad-btn--primary {
  color: var(--fg-on-dark);
  background: var(--admiral-gradient-primary);
  box-shadow: var(--shadow-button);
}
/* Hover darkens the gradient bottom (#0A00CC → #08009E) per Style-Guide */
.ad-btn--primary:hover:not(:disabled) {
  background: var(--admiral-gradient-primary-hover);
  box-shadow: 0 6px 16px rgba(0,56,255,0.25);
}
/* Press swaps the blue lift for --shadow-sm (with the base scale 0.98) */
.ad-btn--primary:active:not(:disabled):not(.is-loading) { box-shadow: var(--shadow-sm); }
.ad-btn--primary:focus-visible { box-shadow: var(--shadow-focus-ring), var(--shadow-button); }

.ad-btn--secondary {
  color: var(--primary-700);
  background: var(--bg-elevated);
  border-color: var(--primary-600);
}
.ad-btn--secondary:hover:not(:disabled) { background: var(--primary-50); }

.ad-btn--ghost {
  color: var(--fg-default);
  background: transparent;
  border-color: var(--neutral-300);
}
.ad-btn--ghost:hover:not(:disabled) { background: var(--neutral-100); }

.ad-btn--danger {
  color: var(--fg-on-dark);
  background: var(--error-500);
}
.ad-btn--danger:hover:not(:disabled) { background: var(--error-700); }
/* Destructive press is firmer — scale 0.97 over --duration-2 (micro-interactions spec) */
.ad-btn--danger:active:not(:disabled):not(.is-loading) { transform: translateY(1px) scale(0.97); }

.ad-btn--link {
  height: auto; padding: 0; border: 0; border-radius: var(--radius-xs);
  color: var(--link);
  text-decoration: underline; text-underline-offset: 3px;
}
.ad-btn--link:hover:not(:disabled) { color: var(--link-hover); }
.ad-btn--link:active:not(:disabled) { transform: none; }

/* ─── Icon-only — square; component requires aria-label ─── */
.ad-btn--icon { width: 42px; padding: 0; }
.ad-btn--icon.ad-btn--sm { width: 36px; }
.ad-btn--icon.ad-btn--lg { width: 48px; }

/* ─── Disabled ─── */
.ad-btn:disabled,
.ad-btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.ad-btn--primary:disabled { box-shadow: none; }

/* ─── Loading — spinner overlays a dimmed label; width preserved ─── */
.ad-btn.is-loading { cursor: progress; }
.ad-btn.is-loading .ad-btn__label,
.ad-btn.is-loading .ad-btn__icon { opacity: 0.4; transition: opacity var(--duration-4) var(--ease-out); }
.ad-btn__spinner {
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  opacity: 0.9;
  animation: ad-spin 0.7s linear infinite;
}
.ad-btn--sm .ad-btn__spinner { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
/* Mirrors .ad-spinner from components.css. The keyframe is redeclared
   with the SAME name and values so this family also works standalone —
   it is a shared kit keyframe, not a new one. */
@keyframes ad-spin { to { transform: rotate(360deg); } }

/* ─── ButtonGroup — attached ─── */
.ad-btngrp { display: inline-flex; align-items: stretch; }
.ad-btngrp > .ad-btn { border-radius: 0; box-shadow: none; }
.ad-btngrp > .ad-btn:first-child {
  border-start-start-radius: var(--radius-md);
  border-end-start-radius: var(--radius-md);
}
.ad-btngrp > .ad-btn:last-child {
  border-start-end-radius: var(--radius-md);
  border-end-end-radius: var(--radius-md);
}
.ad-btngrp > .ad-btn--sm:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.ad-btngrp > .ad-btn--sm:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
/* Neighbouring buttons share one border */
.ad-btngrp > .ad-btn + .ad-btn { margin-inline-start: -1px; }
/* Raise hovered / focused member above shared borders */
.ad-btngrp > .ad-btn:hover,
.ad-btngrp > .ad-btn:focus-visible { z-index: 1; }
/* Attached buttons never translate — the seam would crack */
.ad-btngrp > .ad-btn:active:not(:disabled) { transform: none; }

/* ─── ButtonGroup — segmented (single-select) ─── */
.ad-seg {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--neutral-100);
  border-radius: var(--radius-md);
}
.ad-seg__btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-3xs);
  height: 32px; padding: 0 14px;
  font-family: 'Plus Jakarta Sans', var(--font-display);
  font-weight: 600; font-size: 13px; line-height: 1;
  color: var(--fg-muted);
  background: transparent;
  border: 0; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  transition:
    background-color var(--duration-4) var(--ease-out),
    color var(--duration-4) var(--ease-out),
    box-shadow var(--duration-4) var(--ease-out);
}
.ad-seg__btn:hover { color: var(--fg-strong); }
.ad-seg__btn[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--fg-strong);
  box-shadow: var(--shadow-xs);
}
.ad-seg__btn:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }
.ad-seg__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ad-seg--sm .ad-seg__btn { height: 28px; padding: 0 10px; font-size: 12px; }

/* ─── Toggle — a pressed-state button ─── */
.ad-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2xs);
  height: 36px; padding: 0 12px;
  font-family: 'Plus Jakarta Sans', var(--font-display);
  font-weight: 600; font-size: 13px; line-height: 1;
  color: var(--fg-default);
  background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition:
    background-color var(--duration-4) var(--ease-out),
    color var(--duration-4) var(--ease-out),
    box-shadow var(--motion-focus-primary);
}
.ad-toggle:hover:not(:disabled) { background: var(--neutral-100); }
.ad-toggle[aria-pressed="true"] { background: var(--primary-50); color: var(--primary-700); }
.ad-toggle[aria-pressed="true"]:hover:not(:disabled) { background: var(--primary-100); }
.ad-toggle:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }
.ad-toggle:disabled { opacity: 0.5; cursor: not-allowed; background: transparent; }
.ad-toggle--sm { height: 30px; padding: 0 10px; font-size: 12px; }
.ad-toggle--icon { width: 36px; padding: 0; }

/* ─── ToggleGroup ─── */
.ad-tglgrp { display: inline-flex; gap: var(--space-3xs); }

/* Pill toggles — option-selection filters (vs ButtonGroup = grouped
   actions). Selected state reads at a glance: filled, stronger ink. */
.ad-tglgrp--pill .ad-toggle {
  border-radius: var(--radius-pill);
  border-color: var(--neutral-300);
  font-weight: 500;
}
.ad-tglgrp--pill .ad-toggle[aria-pressed="true"] {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: var(--fg-on-dark);
  font-weight: 600;
}
.ad-tglgrp--pill .ad-toggle[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--primary-700);
}
