/* --- BUTTONS — the one button system of the console and the sign-in pages ---
 *
 * A button is .btn plus one variant, and optionally a size and .btn-full. Each variant has
 * one job:
 *   btn-primary         starts a job: an enrichment, a scraper or a tool. Nothing else, so
 *                       it stays the most noticeable button on a page
 *   btn-secondary       labelled CSV downloads and the support form. btn-download adds the
 *                       download icon; background and border stay the secondary's
 *   btn-outline         every other action (Speichern, Abbrechen, Filter anwenden, …)
 *   btn-dashed          the outline with a dashed border
 *   btn-outline-accent  what we want customers to do: Aufladen, Weiter zu Stripe, Kaufen,
 *                       and Meine Firmen's Anreichern, which looks like Kaufen
 *   btn-danger          stops, deletes or deactivates something
 *   btn-warning         outline in the warning colour
 * The sign-in pages use btn-primary and btn-secondary at btn-lg for their forms.
 * Primary, secondary, outline and dashed are the landing page's (Portal's buttons.css).
 * Sizes: btn-sm (32px), none (38px), btn-lg (3.2rem). btn-full fills its container.
 *
 * Icon-only buttons are not .btn: btn-icon (the icon alone), btn-icon-danger (red on hover,
 * swaps its icon), btn-icon-bare (larger icon, a shade behind it on hover).
 * A download icon's arrow (.dl-arrow) drops while its button is .downloading.
 *
 * buttons.html at the repo root shows every one of them.
 */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 1.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

/* 0.6 keeps the sign-in page's resend label readable during its cooldown (4.5:1) */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Sizes --- */

.btn-sm {
  height: 32px;
  padding: 0 1rem;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.btn-lg {
  height: 3.2rem;
  padding: 0 2rem;
  gap: 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.btn-full {
  width: 100%;
}

/* --- Primary --- */

/* Black on the accent, as on the landing page: 7.3:1, where white was 2.9:1 */
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  transition:
    transform 0.4s ease,
    box-shadow 0.4s ease;
}

.btn-primary svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-primary:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 0 0 8px rgba(255, 106, 0, 0.2);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.94);
  box-shadow: 0 0 0 14px rgba(255, 106, 0, 0.1);
  transition:
    transform 0.1s ease,
    box-shadow 0.4s ease;
}

/* --- Secondary: the accent sweeps in from the left --- */

.btn-secondary {
  overflow: hidden;
  isolation: isolate;
  background: rgba(255, 106, 0, 0.4);
  color: var(--text);
  transition: transform 0.4s ease;
}

.btn-secondary::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: 0 50%;
  border-radius: inherit;
  background: var(--accent);
  transition: transform 0.475s;
  z-index: -1;
}

.btn-secondary:hover:not(:disabled) {
  transform: scale(1.02);
}

.btn-secondary:hover:not(:disabled)::before {
  transform: scaleX(1);
}

.btn-secondary:active:not(:disabled) {
  transform: scale(0.92);
}

/* The download icon: a tray and an arrow (.dl-arrow), which drops while .downloading,
   here and wherever else the icon stands (the job lists' downloads) */
.btn-download svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  overflow: hidden;
}

.dl-arrow {
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.downloading .dl-arrow {
  animation: dlArrowCycle 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes dlArrowCycle {
  0% {
    transform: translateY(0);
    opacity: 1;
  }

  40% {
    transform: translateY(8px);
    opacity: 0;
  }

  41% {
    transform: translateY(-8px);
    opacity: 0;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Outline: outline, dashed, outline-accent, danger, warning --- */

.btn-outline,
.btn-dashed,
.btn-outline-accent,
.btn-danger,
.btn-warning {
  background: transparent;
  transition:
    transform 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.btn-outline:active:not(:disabled),
.btn-dashed:active:not(:disabled),
.btn-outline-accent:active:not(:disabled),
.btn-danger:active:not(:disabled),
.btn-warning:active:not(:disabled) {
  transform: scale(0.98);
  transition-duration: 0.1s;
}

.btn-outline,
.btn-dashed {
  border-color: rgba(204, 204, 204, 0.5);
  color: var(--muted);
}

.btn-outline:hover:not(:disabled),
.btn-dashed:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.75);
  color: var(--text);
}

.btn-dashed {
  border-style: dashed;
}

.btn-outline-accent {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline-accent:hover:not(:disabled) {
  background: var(--accent-dim);
}

/* Red text on the dark background (5.1:1); white on --error would be 3.8:1.
   After .btn-outline, so "btn btn-outline btn-danger" is a danger button */
.btn-danger {
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--error);
  background: var(--error-dim);
}

.btn-warning {
  border-color: rgba(245, 158, 11, 0.5);
  color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
  border-color: var(--warning);
  background: var(--warning-dim);
}

/* --- Icon-only buttons --- */

/* The icon alone, no border or background, in a target of 24px (the job rows' actions) */
.btn-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-control);
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  color: var(--accent);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Holding .icon-default and .icon-hover, which it swaps on hover (stop, delete) */
.btn-icon.btn-icon-danger {
  position: relative;
  color: var(--dim);
  width: auto;
  height: auto;
}

.btn-icon-danger svg {
  width: 20px;
  height: 20px;
}

.btn-icon-danger .icon-hover {
  position: absolute;
  opacity: 0;
  transform: scale(0.8);
}

.btn-icon-danger .icon-default,
.btn-icon-danger .icon-hover {
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.btn-icon.btn-icon-danger:hover {
  color: var(--error);
}

.btn-icon-danger:hover .icon-default {
  opacity: 0;
  transform: scale(0.8);
}

.btn-icon-danger:hover .icon-hover {
  opacity: 1;
  transform: scale(1);
}

/* Asking to be clicked again before it acts (api-keys.js) */
.btn-icon.confirming {
  color: var(--error);
  animation: confirmPulse 0.6s ease infinite;
}

@keyframes confirmPulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* Bare, with .icon-copy and .icon-copied, which .copied swaps */
.btn-icon-bare {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition:
    color 0.25s ease,
    background 0.25s ease;
}

.btn-icon-bare:hover {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.btn-icon-bare:active {
  transform: scale(0.88);
  transition: transform 0.1s ease;
}

.btn-icon-bare svg {
  width: 26px;
  height: 26px;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.btn-icon-bare .icon-copied {
  position: absolute;
  opacity: 0;
  transform: scale(0.8);
}

.btn-icon-bare.copied {
  color: var(--accent);
}

.btn-icon-bare.copied .icon-copy {
  opacity: 0;
  transform: scale(0.8);
}

.btn-icon-bare.copied .icon-copied {
  opacity: 1;
  transform: scale(1);
}
