/* ==========================================================================
   FOUNDEROWN · base.css
   Reset · typography engine · focus discipline · utility primitives
   Depends on: tokens.css only.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. MODERN RESET
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--sp-6));
  tab-size: 4;
}

html,
body {
  min-height: 100%;
}

body {
  background-color: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-snug);
  font-feature-settings: "cv11" 1, "ss01" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
}

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

/* Media defaults */
img,
picture,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

svg {
  fill: currentColor;
}

/* Form control inheritance */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
}

/* Long-word safety */
p,
h1,
h2,
h3,
h4,
h5,
h6,
li,
dd,
figcaption,
blockquote {
  overflow-wrap: break-word;
  hyphens: none;
}

/* Lists: opt-in markers */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* Tables */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* --------------------------------------------------------------------------
   2. TYPOGRAPHY
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
}
h2 {
  font-size: var(--text-2xl);
}
h3 {
  font-size: var(--text-xl);
}
h4 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-snug);
}
h5 {
  font-size: var(--text-md);
  letter-spacing: var(--tracking-snug);
}
h6 {
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-snug);
}

p {
  color: var(--text-secondary);
  text-wrap: pretty;
}

p.lead {
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

small {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

strong,
b {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

em,
i {
  font-style: italic;
}

a {
  color: var(--accent-indigo-strong);
  text-decoration-color: var(--accent-indigo-line);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color var(--dur-1) var(--ease-out),
    text-decoration-color var(--dur-1) var(--ease-out);
}

a:hover {
  color: var(--accent-indigo);
  text-decoration-color: currentColor;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-ligatures: none;
}

code {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xs);
  padding: 0.12em 0.4em;
  color: var(--accent-indigo-strong);
}

pre {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  overflow-x: auto;
  line-height: var(--leading-snug);
  color: var(--text-secondary);
  box-shadow: var(--sh-inset);
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: 1em;
}

kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  padding: 0.1em 0.45em;
  font-size: 0.8em;
  color: var(--text-secondary);
}

mark {
  background: var(--accent-amber-soft);
  color: var(--text-primary);
  border-radius: var(--r-xs);
  padding: 0 0.25em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin-block: var(--sp-8);
}

blockquote {
  border-left: 2px solid var(--accent-indigo-line);
  padding-left: var(--sp-5);
  color: var(--text-secondary);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}

/* Numeric data: tabular everywhere it matters */
.num,
[data-num],
.kpi__value,
.metric,
.telemetry-value,
td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: var(--tracking-normal);
}

/* --------------------------------------------------------------------------
   3. FOCUS DISCIPLINE
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-indigo-strong);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-indigo-strong);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: var(--z-toast);
  transform: translateY(-160%);
  background: var(--accent-indigo);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  box-shadow: var(--sh-pop);
  transition: transform var(--dur-2) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline-color: var(--white);
}

/* --------------------------------------------------------------------------
   4. SELECTION & SCROLLBARS
   -------------------------------------------------------------------------- */
::selection {
  background: var(--accent-indigo);
  color: var(--white);
  text-shadow: none;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid var(--bg-void);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* --------------------------------------------------------------------------
   5. ACCESSIBILITY UTILITIES
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Keep content available to screen readers while visually hidden until focus */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[hidden] {
  display: none !important;
}

[aria-busy="true"],
[data-loading="true"] {
  cursor: progress;
}

[aria-disabled="true"],
:disabled {
  opacity: 0.55;
}

/* Live regions: reserve no space, announce politely */
[aria-live] {
  contain: none;
}

/* --------------------------------------------------------------------------
   6. TEXT UTILITIES (small, documented set)
   -------------------------------------------------------------------------- */
.text-muted {
  color: var(--text-muted);
}
.text-faint {
  color: var(--text-faint);
}
.text-emerald {
  color: var(--accent-emerald-strong);
}
.text-amber {
  color: var(--accent-amber-strong);
}
.text-rose {
  color: var(--accent-rose-strong);
}
.text-indigo {
  color: var(--accent-indigo-strong);
}
.text-mono {
  font-family: var(--font-mono);
}
.text-center {
  text-align: center;
}
.text-balance {
  text-wrap: balance;
}

.caps-label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   7. LAYOUT UTILITIES
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.stack > * + * {
  margin-top: var(--stack-gap, var(--sp-4));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--sp-3));
}

.flow > * + * {
  margin-top: var(--flow-gap, 1em);
}

/* --------------------------------------------------------------------------
   8. STATIC "GLASS FALLBACK"
   If backdrop-filter is unsupported, surfaces stay opaque and legible.
   -------------------------------------------------------------------------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: var(--bg-elevated) !important;
  }
}
