/*
 * base.css — Body defaults, typography, utility classes
 * References Layer 2 semantic tokens only — no hardcoded values
 * ─────────────────────────────────────────────────────────── */

/* ─── Body ─────────────────────────────────────────────────── */

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-page);
  transition: background-color var(--duration-300) var(--ease-default),
              color var(--duration-300) var(--ease-default);
}

/* ─── Typography Scale ─────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: var(--font-medium); }

p {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

small {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* ─── Links ────────────────────────────────────────────────── */

a {
  color: var(--primary);
  transition: color var(--duration-150) var(--ease-default);
}

a:hover {
  color: var(--primary-hover);
}

/* ─── Skip Link (accessibility) ────────────────────────────── */

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  inset-block-start: var(--space-4);
  z-index: var(--z-tooltip);
  padding: var(--space-2) var(--space-4);
  background-color: var(--primary);
  color: var(--text-on-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  transition: transform var(--duration-200) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ─── Utility: Visually Hidden ──────────────────────────────── */

.sr-only {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  padding: 0;
  margin: -0.0625rem;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Utility: Display States ───────────────────────────────── */

.is-hidden { display: none !important; }
.is-invisible { visibility: hidden; }

/* ─── Utility: Overflow Scroll ──────────────────────────────── */

.scroll-x { overflow-x: auto; }
.scroll-y { overflow-y: auto; }

/* ─── Divider ───────────────────────────────────────────────── */

.divider {
  border: none;
  border-block-start: 0.0625rem solid var(--border-default);
  margin-block: var(--space-4);
}

/* ─── Site Footer — copyright row under main (see layout.css) ─ */

.site-footer {
  padding: 0;
  border-block-start: 0.0625rem solid var(--border-default);
  background-color: var(--bg-surface);
}

.site-footer__meta {
  padding: var(--space-4) var(--content-padding);
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--content-max-width);
  margin-inline: auto;
}

.site-footer__copy,
.site-footer__version {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
}

/* ─── Lucide Icons — global SVG sizing ─────────────────────── */

svg[data-lucide] {
  display: block;
  flex-shrink: 0;
}

/* Context-specific icon sizes */
.sidebar__brand-icon    svg[data-lucide] { width: 1.25rem; height: 1.25rem; }
.sidebar__nav-icon      svg[data-lucide] { width: 1.125rem; height: 1.125rem; }
.sidebar__nav-chevron   svg[data-lucide] { width: 1rem; height: 1rem; }
.topnav__sidebar-toggle svg[data-lucide] { width: 1.25rem; height: 1.25rem; }
.topnav__search-icon    svg[data-lucide] { width: 1rem; height: 1rem; }
.topnav__icon-btn       svg[data-lucide] { width: 1.125rem; height: 1.125rem; }
.button__icon           svg[data-lucide] { width: 0.875rem; height: 0.875rem; }
.button--sm .button__icon svg[data-lucide] { width: 0.75rem; height: 0.75rem; }
.button--lg .button__icon svg[data-lucide] { width: 1rem; height: 1rem; }
.stat-card__icon        svg[data-lucide] { width: 1.125rem; height: 1.125rem; }
.stat-card__trend       svg[data-lucide] { width: 0.75rem; height: 0.75rem; }
.quick-actions__icon    svg[data-lucide] { width: 1.25rem; height: 1.25rem; }
.modal__close           svg[data-lucide] { width: 1rem; height: 1rem; }
.dropdown__item-icon    svg[data-lucide] { width: 1rem; height: 1rem; }

/* ─── Theme Toggle Icons — CSS-driven visibility ─────────────
   [data-theme] on <html> automatically shows the correct icon.
   JS never needs to touch these — CSS handles it entirely.

   Lucide replaces <i data-lucide> with <svg data-lucide>; the global
   rule `svg[data-lucide] { display: block }` beats plain `.icon-sun`,
   so these selectors must include [data-lucide] + .icon-* (higher specificity).
   ─────────────────────────────────────────────────────────── */

i[data-lucide].icon-sun,
svg[data-lucide].icon-sun {
  display: none;
}

i[data-lucide].icon-moon,
svg[data-lucide].icon-moon {
  display: block;
}

[data-theme="dark"] i[data-lucide].icon-sun,
[data-theme="dark"] svg[data-lucide].icon-sun {
  display: block;
}

[data-theme="dark"] i[data-lucide].icon-moon,
[data-theme="dark"] svg[data-lucide].icon-moon {
  display: none;
}

/* ─── Page Transition (body overlay during navigation) ─────── */

body.is-loading::after {
  content: '';
  position: fixed;
  inset: 0;
  background-color: var(--bg-page);
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-300) var(--ease-default);
}
