/* The shared look of buttons and small controls (owner, 2026-11-28): our own CSS, shaped after Meta's Astryx design system, with depth.
   Astryx: MIT License, Copyright (c) 2026 Meta Platforms, Inc.
   Canonical file: infra/web-kit/ui.css; each app that uses it keeps an identical copy at shared/web-kit/ui.css (change both in one commit),
   loaded AFTER the app's own stylesheet. It styles the app's class names and takes every colour from the app's variables, so palettes and
   looks keep working: --brand, --brand-ink, --surface, --surface-2, --hover, --ink, --muted, --border, --border-strong, --ok, --bad.
   Depth: every button is raised; the big actions (.btn-lg, .btn-deep, an order's Accept) are deep, with a base they sink into. */

.btn { --fill: var(--surface); position: relative; border: 0; font-weight: 600; -webkit-tap-highlight-color: transparent; transition: transform .1s, box-shadow .1s, filter .12s; }
.btn-primary { --fill: var(--brand); } .btn-ok, .btn-success { --fill: var(--ok); } .btn-warning { --fill: var(--warn); } .btn-danger { --fill: var(--bad); } .btn-dark { --fill: var(--ink); }

/* raised: a lit top edge and a soft shadow; pressing pushes it in */
.btn:not(.btn-ghost):not([disabled]) {
  background: linear-gradient(rgba(255,255,255,.14), rgba(0,0,0,.07)), var(--fill);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 1px 2px rgba(0,0,0,.18), 0 4px 10px color-mix(in srgb, var(--fill) 28%, rgba(0,0,0,.06));
}
.btn-primary:not([disabled]), .btn-ok:not([disabled]), .btn-success:not([disabled]), .btn-warning:not([disabled]), .btn-danger:not([disabled]) { color: #fff; }
.btn-primary:not([disabled]) { color: var(--brand-ink, #fff); }
.btn-dark:not([disabled]) { color: var(--surface); }
.btn-outline:not([disabled]) { color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 1px var(--border), 0 1px 2px rgba(0,0,0,.14), 0 3px 8px rgba(0,0,0,.08); }
.btn-danger-outline:not([disabled]) { color: var(--bad); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 1px color-mix(in srgb, var(--bad) 55%, transparent), 0 1px 2px rgba(0,0,0,.14), 0 3px 8px rgba(0,0,0,.08); }
@media (hover: hover) { .btn:not([disabled]):hover { filter: brightness(1.05); } .btn-ghost:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); } }
.btn:not(.btn-ghost):not([disabled]):active { transform: translateY(1px) scale(.99); box-shadow: inset 0 2px 5px rgba(0,0,0,.28); }
.btn-ghost:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* deep: the big actions */
.btn-lg:not(.btn-ghost):not([disabled]), .btn-deep:not([disabled]), .ocard [data-a="accept"]:not([disabled]) {
  --base: color-mix(in srgb, var(--fill) 62%, #000);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 0 var(--base), 0 8px 14px rgba(0,0,0,.22);
  margin-bottom: 4px;
}
.btn-lg.btn-outline:not([disabled]) { --base: var(--border-strong); }
.btn-lg:not(.btn-ghost):not([disabled]):active, .btn-deep:not([disabled]):active, .ocard [data-a="accept"]:not([disabled]):active {
  transform: translateY(3px); box-shadow: inset 0 1px 3px rgba(0,0,0,.25), 0 1px 0 var(--base);
}

/* working: ui.js marks the pressed button until the server answers */
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy > * { visibility: hidden; }
.btn.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2.5px solid #fff; border-right-color: transparent; animation: ui-spin .7s linear infinite; }
.btn-outline.busy::after, .btn-ghost.busy::after, .btn-danger-outline.busy::after { border-color: var(--brand); border-right-color: transparent; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* typing */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }

/* switching views */
.seg { border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border-radius: 9px; min-height: 34px; }
.seg button.on { box-shadow: 0 1px 1px rgba(0,0,0,.1), 0 2px 8px rgba(0,0,0,.12); }

/* status, notices, cards, messages */
.badge { border-radius: 6px; }
.badge-success::before, .badge-warning::before, .badge-danger::before, .badge-primary::before { content: ""; width: 7px; height: 7px; margin-right: .35rem; border-radius: 50%; background: currentColor; flex: none; }
.alert { border-radius: 12px; }
.card { box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 3px 12px rgba(0,0,0,.08); }
.toast { border-radius: 12px; box-shadow: 0 2px 2px rgba(0,0,0,.14), 0 8px 24px rgba(0,0,0,.22); }
.modal-box { border-radius: 16px; }

@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn.busy::after { animation-duration: 2s; } }
