/* ============================================================================
   ReadyAED Design System — Foundations
   Reset, base typography, layout primitives, utilities.
   Load order: tokens.css -> base.css -> components.css
   ============================================================================ */

/* ---------------------------------------------------------------------------
   Reset
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -moz-tab-size: 4;
  tab-size: 4;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ul, ol {
  margin: 0;
}

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

/* The hidden attribute must always win, even against component display rules. */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  font-weight: var(--font-weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, svg, video, canvas {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }

p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

/* ---------------------------------------------------------------------------
   Brand art
   The system is light only. The navy lockup is the default art everywhere.
   Reverse and mono art are applied explicitly on navy surfaces (.panel--brand,
   .auth__brand) by referencing the reverse SVG file, never by theme.
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Focus — visible, high contrast, never removed
   --------------------------------------------------------------------------- */
:focus { outline: none; }

:focus-visible {
  outline: var(--border-accent) solid var(--focus-ring-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--navy-200);
  color: var(--navy-950);
}

/* ---------------------------------------------------------------------------
   Base typography
   --------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-wrap: balance;
}

h1 { font-size: var(--text-3xl); font-weight: var(--font-weight-black); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); letter-spacing: var(--tracking-normal); }
h5 { font-size: var(--text-md); letter-spacing: var(--tracking-normal); }
h6 {
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

p { text-wrap: pretty; }

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--duration-fast) var(--ease-standard);
}
a:hover { color: var(--color-link-hover); }

strong, b { font-weight: var(--font-weight-semibold); }
small { font-size: var(--text-sm); }

code, kbd, samp, pre, .u-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

code {
  font-size: 0.9em;
  background: var(--color-surface-subtle);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

pre {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  background: var(--color-surface-subtle);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  overflow-x: auto;
}
pre code { background: none; border: none; padding: 0; }

hr {
  border: none;
  border-top: var(--border-thin) solid var(--color-border);
  margin: var(--space-8) 0;
}

/* Human prose vs machine data ------------------------------------------------ */
.prose { max-width: var(--content-reading); font-size: var(--text-md); }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-10); font-size: var(--text-2xl); }
.prose h3 { margin-top: var(--space-8); font-size: var(--text-xl); }
.prose ul, .prose ol { padding-left: var(--space-6); }
.prose li + li { margin-top: var(--space-2); }

/* Editorial accent — marketing knowledge hub only, never inside the app. */
.editorial {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

/* Numeric data — serials, dates, counts, IDs */
.data, .u-data {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------------------
   Layout primitives
   --------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--page-margin);
}
.container--reading { max-width: var(--container-xl); }
.container--wide { max-width: var(--container-max); }
.container--full { max-width: none; }

/* Vertical rhythm */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-8); }

/* Horizontal group that wraps */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }

/* Auto grid, no breakpoint guessing */
.grid { display: grid; gap: var(--space-6); }
.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)); }
.grid--sidebar { grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-10); }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

@media (max-width: 1024px) {
  .grid--sidebar { grid-template-columns: 1fr; gap: var(--space-6); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Utilities
   --------------------------------------------------------------------------- */
.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;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: var(--z-toast);
  background: var(--color-action);
  color: var(--color-action-text);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  transition: top var(--duration-fast) var(--ease-standard);
}
.skip-link:focus { top: var(--space-4); color: var(--color-action-text); }

.u-text-secondary { color: var(--color-text-secondary); }
.u-text-muted { color: var(--color-text-muted); }
.u-text-sm { font-size: var(--text-sm); }
.u-text-lg { font-size: var(--text-lg); }
.u-text-center { text-align: center; }
.u-weight-semibold { font-weight: var(--font-weight-semibold); }
.u-weight-bold { font-weight: var(--font-weight-bold); }
.u-nowrap { white-space: nowrap; }
.u-full { width: 100%; }
@media (max-width: 560px) { .hide-sm { display: none !important; } }
.u-mt-0 { margin-top: 0; }
.u-mt-2 { margin-top: var(--space-2); }
.u-mt-4 { margin-top: var(--space-4); }
.u-mt-6 { margin-top: var(--space-6); }
.u-mt-8 { margin-top: var(--space-8); }
.u-mb-4 { margin-bottom: var(--space-4); }
.u-mb-6 { margin-bottom: var(--space-6); }

/* Section eyebrow — used sparingly, sentence case, not on every block */
.eyebrow {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent-strong);
  letter-spacing: var(--tracking-normal);
}

/* ---------------------------------------------------------------------------
   Motion preferences
   --------------------------------------------------------------------------- */
@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;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------------------
   Print — inspection reports and compliance packets get printed
   --------------------------------------------------------------------------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .no-print { display: none !important; }
  a { color: #000; text-decoration: underline; }
  .card, .panel { box-shadow: none !important; border: 1px solid #999 !important; }
  h1, h2, h3 { break-after: avoid; }
  table { break-inside: auto; }
  tr { break-inside: avoid; }
}

/* Site copy patch 2026-09-23 (orchestrator): design-system base.css has no img height reset,
   which stretches <img> with width/height attributes. Site-scoped fix pending DS amendment;
   see orchestration/state/escalations.md entry 9. Revert when the design system is updated. */
img { height: auto; }

/* Site copy patch 2026-09-23 (orchestrator) — see orchestration/state/escalations.md #9.
   Grid children need min-width: 0 so wide tables/figures scroll inside .table-wrap/cards
   instead of overflowing their grid column at 320-375 px. */
.grid > *,
.grid--2 > *,
.grid--3 > * { min-width: 0; }

/* Sticky header overlaps anchor targets (skip link, in-page links). Reserve header height. */
html { scroll-padding-top: 8rem; }
@media (max-width: 900px) { html { scroll-padding-top: 15rem; } }
