/* ============================================================================
   base.css — reset, typography, layout primitives, accessibility foundations.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--brand-font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-default);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--brand-font-heading);
  color: var(--text-strong);
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-3);
  letter-spacing: -.018em;
  font-weight: 640;
}
h1 { font-size: var(--fs-4xl); letter-spacing: -.03em; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-primary-hover); }

small { font-size: var(--fs-sm); }
strong { font-weight: 640; color: var(--text-strong); }
code, kbd { font-family: var(--brand-font-mono); font-size: .92em; }

img, svg, video { max-width: 100%; height: auto; display: block; }

ul, ol { margin: 0 0 var(--space-4); padding-left: 1.15em; }
li { margin-bottom: var(--space-2); }
li:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--border-faint); margin: var(--space-6) 0; }

/* --- Focus: visible, always. Accessibility foundations ignore feature flags. */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand-primary); color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius-md) 0; font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Layout primitives ---------------------------------------------------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--space-5); }
.container--narrow { max-width: var(--container-narrow); }

.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }

.row { display: flex; gap: var(--space-4); }
.row--between { justify-content: space-between; }
.row--center { align-items: center; }
.row--wrap { flex-wrap: wrap; }

.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* Content + sidebar. Lives here rather than app.css because both the marketing
   article pages and the app use it, and marketing pages never load app.css. */
.split { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: var(--space-5); align-items: start; }
@media (max-width: 1050px) { .split { grid-template-columns: 1fr; } }

.section { padding-block: var(--space-9); }
.section--tight { padding-block: var(--space-7); }
.section--sunken { background: var(--surface-sunken); }
.section--ink { background: var(--surface-inverse); color: #c9d3df; }
.section--ink h2, .section--ink h3, .section--ink h1 { color: #fff; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-balance { text-wrap: balance; }
.measure { max-width: 62ch; }
.measure-tight { max-width: 48ch; }

.lede { font-size: var(--fs-lg); line-height: 1.55; color: var(--text-muted); }

@media (max-width: 900px) {
  :root { --fs-4xl: 2.25rem; --fs-5xl: 2.75rem; --fs-3xl: 1.875rem; --fs-2xl: 1.5rem; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .section { padding-block: var(--space-7); }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
}

/* [hidden] must win. Any component that sets `display: flex` or `grid` beats
   the user agent's `[hidden] { display: none }`, which is how an empty alert
   box ends up rendered on the sign-in page with nothing in it. This is the
   one place in the codebase !important is the correct tool: hidden means
   hidden, and no component gets a vote. */
[hidden] { display: none !important; }
