/* ==========================================================================
   Base - element defaults and typography scale
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--dv-font-sans);
  font-size: var(--dv-fs-base);
  line-height: var(--dv-lh-base);
  color: var(--dv-text);
  background-color: var(--dv-bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography scale - identical on every page */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--dv-font-sans);
  color: var(--dv-text);
  font-weight: var(--dv-fw-semibold);
  line-height: var(--dv-lh-tight);
  letter-spacing: var(--dv-ls-tight);
  margin-bottom: var(--dv-space-2);
}
h1, .h1 { font-size: var(--dv-fs-2xl); }
h2, .h2 { font-size: var(--dv-fs-xl); }
h3, .h3 { font-size: var(--dv-fs-lg); }
h4, .h4 { font-size: var(--dv-fs-md); }
h5, .h5 { font-size: var(--dv-fs-base); }
h6, .h6 { font-size: var(--dv-fs-sm); }

p { margin-bottom: var(--dv-space-3); }
small, .small { font-size: var(--dv-fs-sm); }
.text-xs { font-size: var(--dv-fs-xs) !important; }
.text-sm { font-size: var(--dv-fs-sm) !important; }
.text-base { font-size: var(--dv-fs-base) !important; }
.text-md { font-size: var(--dv-fs-md) !important; }
.text-muted, .text-body-secondary { color: var(--dv-muted) !important; }
.text-secondary-emphasis { color: var(--dv-text-2) !important; }
.fw-medium { font-weight: var(--dv-fw-medium) !important; }
.fw-semibold { font-weight: var(--dv-fw-semibold) !important; }
.text-overline {
  font-size: var(--dv-fs-xs);
  font-weight: var(--dv-fw-semibold);
  letter-spacing: var(--dv-ls-caps);
  text-transform: uppercase;
  color: var(--dv-muted);
}

/* Links never underline - not at rest, on hover, focus or active. Hover is signalled by colour.
   Covers Bootstrap's own underlined link styles (.btn-link, .alert-link, link utilities). */
a { color: var(--dv-primary-text); text-decoration: none; transition: color var(--dv-transition); }
a:hover { color: var(--dv-primary-active); }
:root[data-bs-theme="dark"] a:hover { color: #c7d2fe; }
a, a:hover, a:focus, a:active,
.btn-link, .btn-link:hover, .btn-link:focus, .btn-link:active,
.alert-link, .alert-link:hover, .link-underline, .link-underline:hover,
.page-link, .page-link:hover, .nav-link, .nav-link:hover, .dropdown-item, .dropdown-item:hover {
  text-decoration: none !important;
}

code, kbd, pre, samp { font-family: var(--dv-font-mono); }
code {
  font-size: 0.85em;
  background: var(--dv-inline-code-bg);
  color: var(--dv-inline-code-text);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
pre code { background: none; color: inherit; padding: 0; }
kbd {
  font-size: var(--dv-fs-xs);
  background: var(--dv-surface);
  color: var(--dv-text-2);
  border: 1px solid var(--dv-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  box-shadow: none;
}

hr { border-color: var(--dv-border); opacity: 1; }
::selection { background: rgba(var(--dv-primary-rgb), 0.18); }

/* Visible, consistent focus indicator (UI-020) */
:focus-visible {
  outline: 2px solid var(--dv-primary);
  outline-offset: 2px;
}
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible { outline: none; }

/* Skip link (UI-017) */
.skip-link {
  position: absolute;
  left: var(--dv-space-4);
  top: -100px;
  z-index: 2000;
  background: var(--dv-primary);
  color: #fff;
  padding: var(--dv-space-2) var(--dv-space-4);
  border-radius: var(--dv-radius);
  font-weight: var(--dv-fw-semibold);
}
.skip-link:focus { top: var(--dv-space-3); color: #fff; }

/* Thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--dv-border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--dv-border-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

@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;
  }
}

/* Small helpers that depend on tokens */
.surface { background: var(--dv-surface); }
.surface-2 { background: var(--dv-surface-2); }
.border-dv { border: 1px solid var(--dv-border) !important; }
.rounded-dv { border-radius: var(--dv-radius) !important; }
.rounded-dv-lg { border-radius: var(--dv-radius-lg) !important; }
.min-w-0 { min-width: 0 !important; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.font-mono { font-family: var(--dv-font-mono) !important; }
