/**
 * Tactical Feedback — Empty states, loaders, alerts/toasts
 *
 * Three primitives, token-driven, BEM:
 *   .tactical-empty  — missing-data placeholder (no border, tonal surface)
 *   .tactical-loader — CSS-only spinner / pulse / bar / skeleton, HTMX-aware
 *   .tactical-alert  — inline banner + floating toast (glass + ambient shadow)
 *
 * Rules:
 *   - No 1px solid borders; containment via tonal surface tiers.
 *   - Empty-state typography: Label-MD scale with --on-surface-variant.
 *   - Loader animations respect prefers-reduced-motion.
 *   - Toasts: --te-glass-popover-bg + 16px backdrop-blur + --te-shadow-lg.
 *   - Z-index via --z-* token scale only (toasts use --z-toast).
 */

/* Empty state */
.tactical-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1.25rem;
  background: var(--surface-container-low);
  border-radius: var(--te-radius-md);
  text-align: center;
  font-family: var(--te-font);
  color: var(--on-surface-variant);
}

.tactical-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.25rem;
  color: var(--on-surface-variant);
  opacity: 0.55;
  font-size: 1.5rem;
  line-height: 1;
}

.tactical-empty__title {
  margin: 0;
  font-size: var(--te-label-size);
  font-weight: var(--te-label-weight);
  letter-spacing: var(--te-label-spacing);
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.tactical-empty__body {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--on-surface-variant);
  max-width: 32ch;
}

.tactical-empty--inline       { padding: 1rem 0.875rem; }
.tactical-empty--block        { padding: 3rem 1.5rem; }
.tactical-empty--transparent  { background: transparent; }
.tactical-empty--row {
  display: table-cell;
  padding: 1.25rem 0.875rem;
  background: transparent;
  border-radius: 0;
}

/* Loader — spinner default */
.tactical-loader {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--outline) 30%, transparent);
  border-top-color: var(--primary-container);
  animation: tactical-spin 0.75s linear infinite;
}

.tactical-loader--sm { width: 0.875rem; height: 0.875rem; border-width: 1.5px; }
.tactical-loader--lg { width: 1.75rem; height: 1.75rem; border-width: 2.5px; }

/* HTMX integration — opacity-driven to avoid layout shift on insertion. */
.tactical-loader.htmx-indicator,
.tactical-loader[data-htmx-indicator] {
  opacity: 0;
  transition: opacity var(--te-transition-fast);
}
.htmx-request .tactical-loader.htmx-indicator,
.htmx-request.tactical-loader.htmx-indicator,
.tactical-loader[data-htmx-indicator].htmx-request,
.htmx-request .tactical-loader[data-htmx-indicator] { opacity: 1; }

/* Pulse — ambient activity dot */
.tactical-loader--pulse {
  width: 0.5rem;
  height: 0.5rem;
  border: none;
  background: var(--primary-container);
  animation: tactical-pulse 1.2s ease-in-out infinite;
}

/* Bar — top-of-list HTMX refresh indicator */
.tactical-loader--bar {
  display: block;
  width: 100%;
  height: 2px;
  border: none;
  border-radius: 1px;
  background: transparent;
  overflow: hidden;
  position: relative;
  animation: none;
}
.tactical-loader--bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--primary-container);
  transform-origin: left;
  animation: tactical-bar 1.1s ease-in-out infinite;
}

/* Skeleton — shimmer placeholder */
.tactical-loader--skeleton {
  display: block;
  width: 100%;
  height: 0.875rem;
  border-radius: var(--te-radius-sm);
  border: none;
  background: linear-gradient(
    90deg,
    var(--surface-container) 0%,
    var(--surface-container-high) 50%,
    var(--surface-container) 100%
  );
  background-size: 200% 100%;
  animation: tactical-shimmer 1.4s ease-in-out infinite;
}

/* Inline loader+label row (e.g. "Loading odds…") */
.tactical-loader-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--te-font);
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
}

@keyframes tactical-spin    { to { transform: rotate(360deg); } }
@keyframes tactical-pulse   { 0%, 100% { opacity: 0.4; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1); } }
@keyframes tactical-bar     { 0% { transform: scaleX(0); } 50% { transform: scaleX(0.65); } 100% { transform: scaleX(1); } }
@keyframes tactical-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Alert — inline banner */
.tactical-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--te-radius-md);
  background: var(--surface-container);
  color: var(--on-surface);
  font-family: var(--te-font);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.tactical-alert__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.tactical-alert__body {
  flex: 1 1 auto;
  min-width: 0;
}

.tactical-alert__title {
  margin: 0 0 0.125rem;
  font-size: var(--te-label-size);
  font-weight: var(--te-label-weight);
  letter-spacing: var(--te-label-spacing);
  text-transform: uppercase;
}

.tactical-alert__message { margin: 0; }

.tactical-alert__close {
  flex: 0 0 auto;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.125rem;
  margin: -0.125rem -0.125rem -0.125rem 0;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  line-height: 1;
  font-size: 1.125rem;
}
.tactical-alert__close:hover { opacity: 1; }

/* Tone modifiers — tonal layering, no borders. */
.tactical-alert--success { background: var(--success-container); color: var(--on-success-container); }
.tactical-alert--danger,
.tactical-alert--error   { background: var(--error-container);   color: var(--on-error-container); }
.tactical-alert--warning { background: var(--warning-container); color: var(--on-warning-container); }
.tactical-alert--info    { background: var(--info-container);    color: var(--on-info-container); }
.tactical-alert--goal    { background: var(--tertiary-container); color: var(--on-tertiary-container); }

/* Floating toast — glass + ambient shadow */
.tactical-alert--toast {
  position: fixed;
  z-index: var(--z-toast);
  min-width: 260px;
  max-width: 420px;
  background: var(--te-glass-popover-bg);
  box-shadow: var(--te-shadow-lg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--te-transition-fast),
    transform var(--te-transition-base);
}
.tactical-alert--toast.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Stacking region for portaled toasts (bottom-right). */
.tactical-toast-region {
  position: fixed;
  inset: auto 1.25rem 1.25rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: var(--z-toast);
  pointer-events: none;
}
.tactical-toast-region > .tactical-alert--toast { position: static; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  .tactical-loader,
  .tactical-loader--pulse,
  .tactical-loader--bar::after,
  .tactical-loader--skeleton { animation: none; }
  .tactical-alert--toast { transition: none; transform: none; }
}
