/* ==========================================================================
   base.css — reset, base typography, layout primitives, scrollbar, a11y
   Depends on tokens.css (load tokens.css first).
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: var(--fs-body); color: var(--c-text); }

img, svg { display: block; }

/* monochrome icons inherit text color, fixed geometry */
.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  color: inherit;
}
.icon--sm { width: 12px; height: 12px; }
.icon--lg { width: 22px; height: 22px; }
/* a couple of glyphs are solid (logo mark, dots) */
.icon--solid { fill: currentColor; stroke: none; }

/* ---- App layout primitives ---- */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* page header band */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 14px var(--sp-5) 0;
}
.page-head__title { font-size: var(--fs-title); font-weight: var(--fw-semibold); color: var(--c-text); }
.page-head__desc  { font-size: var(--fs-label); color: var(--c-text-secondary); margin-top: 3px; }

/* toolbar row */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 14px var(--sp-5) 0;
  border: 0;
}
.toolbar__spacer { flex: 1; }

/* generic vertical-only scroll region with themed scrollbar */
.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--c-scroll-thumb) transparent;
}
.scroll-y::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll-y::-webkit-scrollbar-track { background: transparent; }
.scroll-y::-webkit-scrollbar-thumb {
  background: var(--c-scroll-thumb);
  border-radius: var(--r-md);
  border: 2px solid var(--c-surface);
  background-clip: content-box;
}
.scroll-y::-webkit-scrollbar-thumb:hover {
  background: var(--c-scroll-thumb-hover);
  background-clip: content-box;
}

/* utility text */
.u-mono     { font-family: var(--font-mono); }
.u-muted    { color: var(--c-text-muted); }
.u-secondary{ color: var(--c-text-secondary); }
.u-faint    { color: var(--c-text-faint); }
.u-accent   { color: var(--c-accent); }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-nowrap   { white-space: nowrap; }

/* visually-hidden but available to assistive tech */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* focus visibility — accent ring, never removed silently */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: var(--focus-ring);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* shared keyframes */
@keyframes eml-skel  { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes eml-spin  { to { transform: rotate(360deg); } }
@keyframes eml-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes eml-drwr  { from { transform: translateX(24px);  opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes eml-drwrL { from { transform: translateX(-24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
