/* ==========================================================================
   base.css — Reset refinements, typography and small utilities
   Loaded after Bootstrap and tokens.css.
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--tf-font-sans);
  font-feature-settings: "cv11", "ss01"; /* Inter: single-storey a, open digits */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--tf-bg);
  color: var(--tf-text);
  min-width: 320px;
  overflow-x: hidden;
}

/* Hide the page until the shared layout is injected (prevents layout flash).
   theme-init.js adds .tf-ready (also after a safety timeout). A <noscript>
   rule in each page restores visibility when JavaScript is disabled. */
html:not(.tf-ready) body {
  opacity: 0;
}
html.tf-ready body {
  opacity: 1;
  transition: opacity 120ms ease-out;
}

/* ---- Headings ------------------------------------------------------------ */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 650;
  letter-spacing: -0.014em;
  line-height: var(--tf-lh-tight);
  color: var(--tf-text);
}
h1, .h1 { font-size: var(--tf-fs-xl); }
h2, .h2 { font-size: var(--tf-fs-lg); }
h3, .h3 { font-size: var(--tf-fs-md); }
h4, .h4 { font-size: var(--tf-fs-base); }
h5, .h5 { font-size: var(--tf-fs-base); }
h6, .h6 { font-size: var(--tf-fs-sm); }

@media (min-width: 768px) {
  h1, .h1 { font-size: var(--tf-fs-2xl); }
}

p { margin-bottom: 0.75rem; }
small, .small { font-size: var(--tf-fs-sm); }
.fs-xs { font-size: var(--tf-fs-xs) !important; }

a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

hr { border-color: var(--tf-border); opacity: 1; }

code, kbd, pre { font-family: var(--tf-font-mono); }
code {
  font-size: 0.85em;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  background: var(--tf-surface-3);
  color: var(--tf-text);
}

/* Selection + scrollbars */
::selection { background: rgba(var(--tf-primary-rgb), 0.28); }
* { scrollbar-width: thin; scrollbar-color: var(--tf-border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--tf-border-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Focus (visible, consistent) ------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--tf-primary);
  outline-offset: 2px;
  border-radius: var(--tf-radius-sm);
}
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
  outline: none;
}

/* ---- Utilities ------------------------------------------------------------- */
.tnum { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--tf-text-muted) !important; }
.text-subtle { color: var(--tf-text-subtle) !important; }
.text-primary-tf { color: var(--tf-primary-text) !important; }
.fw-550 { font-weight: 550 !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.surface { background: var(--tf-surface); }
.surface-2 { background: var(--tf-surface-2); }
.border-tf { border: 1px solid var(--tf-border) !important; }

.icon {
  width: 1.125rem;
  height: 1.125rem;
  stroke-width: 1.75;
  flex: none;
  vertical-align: -0.2em;
}
.icon-sm { width: 0.9375rem; height: 0.9375rem; }
.icon-lg { width: 1.375rem; height: 1.375rem; }

.visually-hidden-focusable:focus {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 3000;
  padding: 0.5rem 0.875rem;
  background: var(--tf-primary);
  color: var(--tf-on-primary);
  border-radius: var(--tf-radius-sm);
  box-shadow: var(--tf-shadow-md);
}

kbd,
.kbd {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  min-width: 1.25rem;
  text-align: center;
  font-size: var(--tf-fs-xs);
  font-family: var(--tf-font-sans);
  font-weight: 550;
  color: var(--tf-text-muted);
  background: var(--tf-surface-2);
  border: 1px solid var(--tf-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  box-shadow: none;
}

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