/* ─────────────────────────────────────────────────────────────────────
   base.css — shared body/scrollbar/toast/reduced-motion rules.

   Loaded SECOND on every HTML, after tokens.css but before any
   page-specific stylesheet. Holds rules that apply to every dashboard.
   ───────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Focus rings — only when keyboard-navigated, never on mouse click. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline-offset: 3px;
}

/* Scrollbars */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: var(--muted-2); }
::-webkit-scrollbar-corner       { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ── Drawer backdrop ─────────────────────────────────────────────────
   Shared by chat drawers (history, agents, projects). Single element
   in index.html, toggled by yep.js. Other dashboards don't use it. */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 19;
  opacity: 0;
  transition: opacity var(--motion-base) var(--ease);
}
:root[data-theme="light"] .drawer-backdrop,
:root:not([data-theme]) .drawer-backdrop {
  background: rgba(0, 0, 0, 0.30);
}
.drawer-backdrop.open { opacity: 1; }
.drawer-backdrop[hidden] { display: none; }

/* ── Push-toast notifications ────────────────────────────────────────
   Server-pushed toasts arrive via the /api/push SSE channel. Stack
   top-right, newest on top. Each auto-dismisses after 6 s or on
   ×-click. Used by chat + dashboards. */
#push-toasts {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.push-toast {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  max-width: 360px;
  box-shadow: var(--shadow-3);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.45;
  animation: push-toast-in var(--motion-base) var(--ease);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.push-toast.fade-out {
  opacity: 0;
  transform: translateX(20px);
}
@keyframes push-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.push-toast span,
.push-toast a {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}
.push-toast a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.push-toast a:hover { color: var(--link-hover); }

.push-toast.success {
  border-color: rgba(76, 175, 80, 0.5);
  background: var(--bg-ok);
  color: var(--fg-ok);
}
.push-toast.error {
  border-color: rgba(224, 112, 112, 0.5);
  background: var(--bg-error);
  color: var(--error);
}
.push-toast.warn {
  border-color: var(--border-warn);
  background: var(--bg-warn);
  color: var(--fg-warn);
}

.push-toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  margin-top: -2px;
  border-radius: var(--radius-xs);
  transition: color var(--motion-fast);
}
.push-toast-close:hover { color: var(--text); }

@media (max-width: 640px) {
  #push-toasts {
    top: 8px;
    right: 8px;
    left: 8px;
  }
  .push-toast { max-width: 100%; }
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
