/* Base layer + shared components used by all three fronts. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--p-color-bg);
  color: var(--p-color-text);
  font-family: var(--p-font-family-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }

.display { font-family: var(--p-font-family-display); font-weight: 400; letter-spacing: 0.02em; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--p-color-border-focus);
  outline-offset: 2px;
  border-radius: var(--p-border-radius-100);
}

/* ---------- Buttons (Polaris hierarchy: primary / secondary / plain / critical) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--p-space-200);
  min-height: 44px;
  padding: var(--p-space-200) var(--p-space-500);
  border-radius: var(--p-border-radius-200);
  background: var(--p-color-bg-surface-secondary);
  border: 1px solid var(--p-color-border);
  color: var(--p-color-text);
  font-weight: var(--p-font-weight-semibold);
  font-size: var(--p-font-size-body-md);
  transition: background var(--p-motion-duration-150) var(--p-motion-ease),
              transform var(--p-motion-duration-150) var(--p-motion-ease);
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover { background: var(--p-color-bg-surface-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--p-color-bg-fill-brand);
  border-color: transparent;
  color: var(--p-color-text-brand-on-bg-fill);
  box-shadow: var(--p-shadow-200);
}
.btn--primary:hover { background: var(--p-color-bg-fill-brand-hover); }

.btn--critical {
  background: transparent;
  border-color: var(--p-color-border-critical);
  color: var(--p-color-text-critical);
}
.btn--critical:hover { background: rgba(239, 68, 68, 0.12); }

.btn--plain {
  background: transparent;
  border-color: transparent;
  color: var(--p-color-text-secondary);
  min-height: 36px;
}
.btn--plain:hover { background: var(--p-color-bg-surface-hover); color: var(--p-color-text); }

.btn--sm { min-height: 36px; padding: var(--p-space-100) var(--p-space-300); font-size: var(--p-font-size-body-sm); }
.btn--lg { min-height: 56px; padding: var(--p-space-300) var(--p-space-600); font-size: var(--p-font-size-body-lg); }

/* ---------- Card */
.card {
  background: var(--p-color-bg-surface);
  border: 1px solid var(--p-color-border-secondary);
  border-radius: var(--p-border-radius-300);
  box-shadow: var(--p-shadow-100);
  padding: var(--p-space-400);
}
.card__title {
  font-size: var(--p-font-size-heading-md);
  font-weight: var(--p-font-weight-bold);
  color: var(--p-color-text);
  margin-bottom: var(--p-space-300);
  display: flex;
  align-items: center;
  gap: var(--p-space-200);
}

/* ---------- Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--p-space-100);
  padding: 2px var(--p-space-200);
  border-radius: var(--p-border-radius-full);
  font-size: var(--p-font-size-body-xs);
  font-weight: var(--p-font-weight-semibold);
  background: var(--p-color-bg-surface-secondary);
  color: var(--p-color-text-secondary);
  border: 1px solid var(--p-color-border);
}
.badge--success { background: rgba(34, 197, 94, 0.15); color: var(--p-color-text-success); border-color: rgba(34, 197, 94, 0.4); }
.badge--warning { background: rgba(255, 202, 58, 0.15); color: var(--p-color-text-warning); border-color: rgba(255, 202, 58, 0.4); }
.badge--critical { background: rgba(239, 68, 68, 0.15); color: var(--p-color-text-critical); border-color: rgba(239, 68, 68, 0.4); }
.badge--info { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.4); }

/* ---------- Banner */
.banner {
  display: flex;
  gap: var(--p-space-300);
  align-items: flex-start;
  padding: var(--p-space-300) var(--p-space-400);
  border-radius: var(--p-border-radius-200);
  border: 1px solid var(--p-color-border);
  background: var(--p-color-bg-surface-secondary);
  font-size: var(--p-font-size-body-sm);
}
.banner--warning { border-color: rgba(255, 202, 58, 0.5); background: rgba(255, 202, 58, 0.08); }
.banner--critical { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.08); }
.banner--success { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.08); }

/* ---------- Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 8, 14, 0.7);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: var(--p-space-400);
}
.modal {
  background: var(--p-color-bg-surface);
  border: 1px solid var(--p-color-border);
  border-radius: var(--p-border-radius-300);
  box-shadow: var(--p-shadow-300);
  max-width: 420px;
  width: 100%;
  padding: var(--p-space-500);
}
.modal__actions { display: flex; justify-content: flex-end; gap: var(--p-space-300); margin-top: var(--p-space-500); }

.input {
  width: 100%;
  min-height: 44px;
  padding: var(--p-space-200) var(--p-space-300);
  font: inherit;
  border-radius: var(--p-border-radius-200);
  border: 1px solid var(--p-color-border);
  background: var(--p-color-bg-surface-secondary);
  color: var(--p-color-text);
}
.input:focus { outline: 2px solid var(--p-color-border-focus); }

/* ---------- Utility */
.row { display: flex; align-items: center; gap: var(--p-space-300); }
.stack { display: flex; flex-direction: column; gap: var(--p-space-300); }
.grow { flex: 1; }
.muted { color: var(--p-color-text-secondary); }
.center { text-align: center; }
.hidden { display: none !important; }
/* the `hidden` attribute must win over components that set their own display (flex/grid) */
[hidden] { display: none !important; }

/* ---------- Team chip */
.team-chip {
  display: inline-flex; align-items: center; gap: var(--p-space-200);
  padding: var(--p-space-100) var(--p-space-300);
  border-radius: var(--p-border-radius-full);
  font-weight: var(--p-font-weight-bold);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ---------- Connection dot */
.conn-dot {
  position: fixed; top: 10px; right: 10px; z-index: 60;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--p-color-bg-fill-critical);
  transition: background var(--p-motion-duration-300);
}
.conn-dot.on { background: var(--p-color-bg-fill-success); }

/* ---------- Pause overlay */
.pause-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--p-space-400);
  background: rgba(6, 8, 14, 0.82);
  backdrop-filter: blur(4px);
  font-size: var(--p-font-size-heading-2xl);
}
