/* Working and unavailable states, and the result toasts (public/js/guard.js). */
.is-busy, [aria-disabled="true"], .is-disabled { cursor: not-allowed; }
.is-busy { cursor: progress; }
.btn.is-busy, button.is-busy:has(.spin) { opacity: .85; display: inline-flex; align-items: center; gap: .5rem; justify-content: center; }
[aria-disabled="true"]:not(.is-busy), .is-disabled { opacity: .5; }
.spin { width: 1em; height: 1em; flex: none; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Icon buttons (like, save) spin a ring around the icon while the server answers. */
button.is-busy:not(:has(.spin)) { position: relative; }
button.is-busy:not(:has(.spin))::after {
  content: ""; position: absolute; inset: 50% auto auto 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; opacity: .6;
  animation: spin .7s linear infinite; pointer-events: none;
}

.toasts { position: fixed; inset-inline: 0; bottom: 1.25rem; z-index: 120; display: grid; justify-items: center; gap: .5rem; padding-inline: 1rem; pointer-events: none; }
body[data-me] .toasts { bottom: calc(5rem + env(safe-area-inset-bottom)); }
@media (min-width: 961px) { body[data-me] .toasts { bottom: 1.25rem; } }
.toast {
  max-width: min(32rem, 100%); padding: .8rem 1.1rem; border-radius: var(--radius-sm); font-weight: 500;
  box-shadow: var(--shadow-lg); pointer-events: auto; animation: fadeUp .2s ease both; transition: opacity .25s, transform .25s;
}
.toast-err { background: #fdecea; color: #a1231b; border: 1px solid #f3b8b2; }
.toast-ok { background: var(--pine-soft); color: var(--pine); }
.toast-info { background: var(--sun-soft, #fff4d6); color: var(--ink, #1b2a3a); }
.toast.out { opacity: 0; transform: translateY(8px); }
html[data-theme="dark"] .toast-err { background: #3a1416; color: #ffc9c4; border-color: #6b2a2c; }

@media (prefers-reduced-motion: reduce) { .spin, button.is-busy:not(:has(.spin))::after { animation-duration: 1.6s; } }

/* Anything scrolled into view (a link target, keyboard focus) stops below the sticky header, never under it. */
html { scroll-padding-top: 84px; scroll-padding-bottom: 72px; }
@media (min-width: 961px) { html { scroll-padding-bottom: 0; } }

/* Field errors: under the field they are about, in the alert colour, with the field outlined. */
.field-err { margin: 6px 0 0; font-size: .85rem; line-height: 1.5; color: var(--danger, #b42318); display: flex; gap: 6px; align-items: flex-start; }
.field-err::before { content: "!"; flex: none; width: 1.15em; height: 1.15em; border-radius: 50%; background: currentColor; color: #fff; font-weight: 700; font-size: .75rem; display: inline-grid; place-items: center; margin-top: .2em; }
[aria-invalid="true"] { border-color: var(--danger, #b42318) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger, #b42318) 18%, transparent) !important; }

/* Files: remove a chosen file, follow an upload, and see the keyboard on a hidden file picker's button */
.file-clear { display: inline-flex; align-items: center; gap: .35rem; margin-block-start: .4rem; padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem; cursor: pointer; transition: background .15s, border-color .15s; }
.file-clear:hover { border-color: var(--danger, #b42318); color: var(--danger, #b42318); }
.file-clear[hidden] { display: none; }
.msg-form .file-clear { margin: 0; padding: .45rem; align-self: center; }
.file-clear.on-media { position: absolute; inset-block-start: .5rem; inset-inline-end: .5rem; margin: 0; padding: .4rem; background: rgb(0 0 0 / .6); color: #fff; border-color: transparent; }
.upload-bar { display: flex; align-items: center; gap: .6rem; margin-block-start: .6rem; width: 100%; flex-wrap: wrap; }
.upload-bar progress { flex: 1 1 140px; height: .5rem; accent-color: var(--accent); }
.upload-bar .num { min-width: 3ch; font-size: .85rem; color: var(--muted); }
label.focus-ring { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* Header search: when the menu leaves it too little room (longer English labels, narrower screens), it folds into
   a search button instead of being squeezed under the buttons next to it. It still opens the quick search. */
.nav-search { flex: 1 1 0; min-width: 44px; container-type: inline-size; }
@container (max-width: 170px) {
  .nav-search .input { width: 42px; min-width: 42px; padding: 0; color: transparent; cursor: pointer; border-radius: 50%; }
  .nav-search .input::placeholder { color: transparent; }
  .nav-search .ic { inset-inline-start: 21px; /* the middle of the 42px button, not of the wider slot */ transform: translate(-50%, -50%); }
  [dir="rtl"] .nav-search .ic { transform: translate(50%, -50%); }
}
.nav-search .ic { pointer-events: none; }
@media (max-width: 1440px) and (min-width: 1101px) { .nav { gap: .6rem; } .nav-links a { padding-inline: .6rem; } }

/* Touch: small controls get a finger-sized target; borderless fields inside a search bar still show the keyboard focus */
@media (pointer: coarse) {
  .slot-list form button { min-width: 32px; min-height: 32px; display: inline-grid; place-items: center; }
  label.check input[type=checkbox], label.chip input[type=checkbox], label.check input[type=radio] { width: 20px; height: 20px; }
}
.ts-field input:focus-visible, .ts-field select:focus-visible, .hero-search input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
@media (pointer: coarse) { label.check { display: inline-flex; align-items: center; gap: .45rem; min-height: 28px; } .prof-link { display: inline-block; padding-block: 2px; } }
