/* File: assets/css/base.css */
/* Reset + element defaults + typography. Tokens live in tokens.css. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--dag-header-h, 72px) + 12px);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--dag-font);
  font-size: 16px;
  line-height: var(--dag-lh);
  color: var(--dag-text);
  background: var(--dag-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

img { border-radius: inherit; }

/* ─── Headings ──────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--dag-gap-sm);
  font-family: var(--dag-font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--dag-text);
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 1rem + 1vw, 1.625rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.0625rem; }
h6 { font-size: 0.9375rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dag-muted); }

/* ─── Paragraphs / inline text ──────────────────────────── */
p {
  margin: 0 0 var(--dag-gap);
  max-width: var(--dag-max-prose);
  text-wrap: pretty;
}

small { font-size: 0.875em; color: var(--dag-muted); }
strong, b { font-weight: 700; color: var(--dag-text); }
em, i { font-style: italic; }

mark {
  background: rgba(11, 61, 145, 0.12);
  color: var(--dag-text);
  padding: 0 0.15em;
  border-radius: 3px;
}

/* ─── Code / mono ───────────────────────────────────────── */
code, kbd, samp, pre {
  font-family: var(--dag-font-mono);
  font-size: 0.9375em;
}

code {
  padding: 0.1em 0.35em;
  background: var(--dag-surface-2);
  border: 1px solid var(--dag-border);
  border-radius: var(--dag-radius-xs);
  color: var(--dag-text);
}

pre {
  margin: 0 0 var(--dag-gap);
  padding: var(--dag-gap);
  background: var(--dag-surface-2);
  border: 1px solid var(--dag-border);
  border-radius: var(--dag-radius-sm);
  overflow: auto;
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

/* ─── Links ─────────────────────────────────────────────── */
a {
  color: var(--dag-link);
  text-decoration: none;
  transition: color var(--anim-fast) var(--ease-out);
}

a:hover,
a:focus-visible {
  color: var(--dag-link-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1.5px;
}

/* ─── Lists ─────────────────────────────────────────────── */
ul, ol {
  margin: 0 0 var(--dag-gap);
  padding-left: 1.4em;
}

li + li { margin-top: 0.25em; }

/* ─── Quotes ────────────────────────────────────────────── */
blockquote {
  margin: 0 0 var(--dag-gap);
  padding: var(--dag-gap) var(--dag-gap-lg);
  border-left: 3px solid var(--dag-primary);
  background: var(--dag-surface-2);
  border-radius: 0 var(--dag-radius-sm) var(--dag-radius-sm) 0;
  color: var(--dag-text-2);
}

blockquote p:last-child { margin-bottom: 0; }

hr {
  border: 0;
  height: 1px;
  background: var(--dag-border);
  margin: var(--dag-gap-lg) 0;
}

/* ─── Tables ────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--dag-gap);
  font-size: 0.9375rem;
}

th, td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  border-bottom: 1px solid var(--dag-border);
  vertical-align: top;
}

th {
  font-weight: 600;
  background: var(--dag-surface-2);
  color: var(--dag-text);
}

tr:hover td { background: var(--dag-surface-2); }

/* ─── Form element defaults ─────────────────────────────── */
input, textarea, select, button {
  font: inherit;
  color: inherit;
}

textarea { resize: vertical; }

::placeholder {
  color: var(--dag-muted-2);
  opacity: 1;
}

input:disabled,
textarea:disabled,
select:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ─── Selection / focus ─────────────────────────────────── */
::selection {
  background: rgba(11, 61, 145, 0.18);
  color: var(--dag-text);
}

:focus-visible {
  outline: 2px solid var(--dag-primary);
  outline-offset: 2px;
  border-radius: var(--dag-radius-xs);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 3px;
}

/* ─── Container utility ─────────────────────────────────── */
.container,
.dag-container {
  width: min(100% - (var(--dag-gutter) * 2), var(--dag-container));
  margin-inline: auto;
}

/* ─── Section utility ───────────────────────────────────── */
.section,
.dag-section {
  padding-block: var(--dag-section);
}

.section--soft,
.dag-section--soft {
  background: var(--dag-surface-2);
}

.section--brand,
.dag-section--brand {
  background: var(--dag-secondary);
  color: var(--dag-secondary-contrast);
}

.section--brand h1,
.section--brand h2,
.section--brand h3,
.section--brand h4 { color: var(--dag-secondary-contrast); }

/* ─── Visually-hidden (a11y) ────────────────────────────── */
.sr-only,
.screen-reader-text {
  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 ─────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--dag-primary);
  color: var(--dag-primary-contrast);
  padding: 0.625rem 1rem;
  border-radius: 0 0 var(--dag-radius-sm) 0;
  z-index: 10000;
  font-weight: 600;
}

.skip-link:focus { top: 0; }

/* ─── Reduced motion ────────────────────────────────────── */
@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;
  }
}
