/* ==========================================================================
   Blue Care Health OS — Base
   Font faces (self-hosted, file:// safe), reset, base element styles.
   ========================================================================== */

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/IBMPlexSans-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/IBMPlexSans-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/IBMPlexSans-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/IBMPlexSans-Bold.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/IBMPlexMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/IBMPlexMono-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/IBMPlexMono-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/IBMPlexSerif-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/IBMPlexSerif-SemiBold.woff2') format('woff2');
}

/* ---- Reset ---- */
/* The HTML `hidden` attribute must always win, even over classes that set
   their own `display` (e.g. `.empty-state{display:flex}`) — author rules
   otherwise beat the UA [hidden] default at equal specificity and the
   element silently reappears despite being marked hidden. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, picture, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; text-align: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; border-spacing: 0; }
fieldset { border: none; padding: 0; }

/* ---- Root ---- */
html {
  height: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--duration-base) var(--ease-out),
              color var(--duration-base) var(--ease-out);
}

/* ---- Typography base ---- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p { text-wrap: pretty; max-width: 72ch; }
p.no-measure { max-width: none; }

small, .text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--ink-muted); }
.text-secondary { color: var(--ink-secondary); }

/* Baseline icon size — every BC.icon() SVG carries this class, so a
   missing contextual size rule falls back to 16px instead of the SVG's
   intrinsic ~300x150 default. Contextual rules (.badge svg, .btn svg, …)
   are more specific or load later in the cascade and win as intended. */
.ico { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; }

code, .mono, .font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'zero' 1;
  letter-spacing: -0.01em;
}

/* ---- Links ---- */
a.link {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--brand) 40%, transparent);
  text-underline-offset: 2px;
  transition: color var(--duration-fast) var(--ease-out);
}
a.link:hover { color: var(--brand-hover); }

/* ---- Focus ---- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Selection ---- */
::selection {
  background: var(--brand-subtle-strong);
  color: var(--ink);
}

/* ---- Scrollbars (subtle, not reinvented) ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ---- Utility layout primitives ---- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -48px;
  left: var(--space-4);
  z-index: var(--z-toast);
  background: var(--ink);
  color: var(--surface);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  transition: top var(--duration-base) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); }

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