/* WLF buttons. Source: zen-code:/root/zen/projects/wlf-staging,
   src/styles/components.css + tokens.css and components/ui/button.tsx.
   Read 2026-09-23, HEAD a9bb92ae. No runtime dependency on staging.
   Existing .btn classes are adapters; routes and event handlers stay intact. */
:root {
  --wlf-button-light: 203 89% 44%;
  --wlf-button-base: 205 100% 35%;
  --wlf-button-depth: 205 100% 25%;
  --wlf-button-radius: 8px;
  --wlf-button-ease: cubic-bezier(.23, 1, .32, 1);
}

/* Staging's decision size, with the app's 56px touch target. */
:is(#app, #modal-layer) .btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  min-width: 0;
  padding: 12px 24px;
  border: 2px solid transparent;
  border-radius: var(--wlf-button-radius);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 180ms var(--wlf-button-ease),
    color 180ms var(--wlf-button-ease), border-color 180ms var(--wlf-button-ease),
    box-shadow 180ms var(--wlf-button-ease), filter 180ms var(--wlf-button-ease),
    transform 140ms var(--wlf-button-ease);
}

:is(#app, #modal-layer) .btn .icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  pointer-events: none;
}

/* Match staging's trust 3D surface and three shadow layers. */
:is(#app, #modal-layer) .btn.btn-primary {
  background: linear-gradient(to bottom right,
    hsl(var(--wlf-button-light)), hsl(var(--wlf-button-base)));
  color: #fff;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 3px 0 hsl(var(--wlf-button-depth) / .8),
    0 6px 16px hsl(var(--wlf-button-base) / .4),
    inset 0 1px 0 rgb(255 255 255 / .5);
}

:is(#app, #modal-layer) .btn.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}

:is(#app, #modal-layer) .btn.btn-light {
  background: var(--ink);
  border-color: transparent;
  color: var(--bg);
  box-shadow: none;
}

:is(#app, #modal-layer) .btn.btn-danger {
  background: var(--error);
  color: var(--bg);
  box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
  :is(#app, #modal-layer) .btn.btn-primary:hover:not(:disabled):not([aria-disabled="true"]) {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 0 hsl(var(--wlf-button-depth) / .8),
      0 8px 24px hsl(var(--wlf-button-base) / .5),
      inset 0 1px 0 rgb(255 255 255 / .55);
  }
  :is(#app, #modal-layer) .btn.btn-secondary:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--raised);
    border-color: var(--muted);
    color: var(--ink);
  }
  :is(#app, #modal-layer) .btn.btn-light:hover:not(:disabled):not([aria-disabled="true"]),
  :is(#app, #modal-layer) .btn.btn-danger:hover:not(:disabled):not([aria-disabled="true"]) {
    filter: brightness(.94);
  }
}

:is(#app, #modal-layer) .btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: scale(.98);
}
:is(#app, #modal-layer) .btn.btn-primary:active:not(:disabled):not([aria-disabled="true"]) {
  filter: brightness(.95);
  transform: translateY(1px);
  box-shadow: 0 1px 0 hsl(var(--wlf-button-depth) / .7),
    0 2px 6px hsl(var(--wlf-button-base) / .3),
    inset 0 1px 0 rgb(255 255 255 / .4);
}

:is(#app, #modal-layer) .btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

/* :disabled remains a native semantic state; aria-disabled is presentation
   support only and must be paired with application behavior on future links. */
:is(#app, #modal-layer) .btn.btn:disabled,
:is(#app, #modal-layer) .btn.btn[aria-disabled="true"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
  opacity: .55;
  box-shadow: none;
  filter: none;
  transform: none;
  cursor: not-allowed;
}

/* Keep circular controls and navigation geometry; unify their press feedback. */
:is(#app, #modal-layer) :is(.icon-btn, .quiet-icon, .fp-adjust) {
  touch-action: manipulation;
  transition: background-color 180ms var(--wlf-button-ease),
    transform 140ms var(--wlf-button-ease);
}
:is(#app, #modal-layer) :is(.icon-btn, .quiet-icon, .fp-adjust):active:not(:disabled) {
  transform: scale(.98);
}
:is(#app, #modal-layer) :is(.icon-btn, .quiet-icon, .fp-adjust):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  :is(#app, #modal-layer) :is(.btn, .icon-btn, .quiet-icon, .fp-adjust) {
    transition: none;
  }
  :is(#app, #modal-layer) .btn.btn:hover:not(:disabled):not([aria-disabled="true"]),
  :is(#app, #modal-layer) .btn.btn:active:not(:disabled):not([aria-disabled="true"]),
  :is(#app, #modal-layer) :is(.icon-btn, .quiet-icon, .fp-adjust):active:not(:disabled) {
    transform: none;
  }
}

@media (forced-colors: active) {
  :is(#app, #modal-layer) .btn.btn {
    border: 2px solid ButtonText;
    background: ButtonFace;
    color: ButtonText;
    box-shadow: none;
    filter: none;
  }
  :is(#app, #modal-layer) .btn.btn:disabled {
    border-color: GrayText;
    color: GrayText;
    opacity: 1;
  }
  :is(#app, #modal-layer) .btn:focus-visible { outline-color: Highlight; }
}
