/* adia:element/type — Native HTML element defaults (the applied baseline).
   table/lists/blockquote/hr/code/pre/dl/details/strong/em/small/mark/
   del/ins/a/img — all via :where() (0,0,0) so component @scope always wins.
   Moved verbatim out of typography.css (v0.6.48 foundation reorg, ADR-0035).
   Phase B folds the element rules from resets.css in here too. */

/* ═══════════════════════════════════════════════════════════
   NATIVE ELEMENT DEFAULTS — semantic HTML baseline.
   Low specificity via :where() so component @scope always wins.

   Block:  table, lists, blockquote, hr, pre, dl, details
   Inline: strong/b, em/i, small, mark, del, ins, code, a
   Size:   smaller, larger/large (custom inline elements)
   Media:  img
   ═══════════════════════════════════════════════════════════ */

/* ── Tables ── */
:where(table) {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--a-body-size);
  line-height: var(--a-body-leading);
}

:where(th) {
  text-align: left;
  font-size: var(--a-ui-sm);
  font-weight: var(--a-weight-medium);
  color: var(--a-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--a-space-2) var(--a-space-3);
  border-bottom: 1px solid var(--a-border);
}

:where(td) {
  padding: var(--a-space-2) var(--a-space-3);
  border-bottom: 1px solid var(--a-border-subtle);
  vertical-align: top;
}

:where(tr:hover td) {
  background: var(--a-bg-muted);
}

/* ── Lists ── */
:where(ul, ol) {
  padding-inline-start: 1.5em;
  margin-block: 0.5em;
  font-size: var(--a-body-size);
  line-height: var(--a-body-leading);
  color: var(--a-fg);
}

:where(li) {
  margin-block: 0.25em;
}

:where(li::marker) {
  color: var(--a-fg-muted);
}

/* Semantic-list opt-out: `role="list"` restores the ARIA list role that
   `list-style: none` strips in Safari/VoiceOver, and removes the default
   indent so a de-listed list reads as plain content. An element-default
   *refinement*, not a floor-reset — its real specificity (0,1,1) beats the
   `:where(ul, ol)` default (0,0,0) within this layer, so it wins by
   specificity rather than by source order or by being unlayered. Relocated
   from styles/resets.css during the @layer migration (ADR-0038 step 2):
   under `@layer`, a rule in the low `reset` layer would lose to this
   unlayered/`elements`-layer default — the win must come from specificity,
   here, not from precedence trickery. */
ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

/* ── Blockquote ── */
:where(blockquote) {
  margin: 1em 0;
  padding: var(--a-space-3) var(--a-space-4);
  border-inline-start: 3px solid var(--a-border);
  color: var(--a-fg-subtle);
  font-style: italic;
}

:where(blockquote p) {
  margin: 0;
}

/* ── Horizontal rule ── */
:where(hr) {
  border: none;
  border-top: 1px solid var(--a-border-subtle);
  margin-block: var(--a-space-4);
}

/* ── Code (inline + block) ── */
:where(code) {
  font-family: var(--a-code-family);
  font-size: 0.9em;
  background: var(--a-bg-muted);
  padding: 0.125em 0.375em;
  border-radius: var(--a-radius-sm);
  color: var(--a-fg);
}

:where(pre) {
  font-family: var(--a-code-family);
  font-size: var(--a-code-size);
  line-height: var(--a-code-leading);
  background: var(--a-bg-muted);
  padding: var(--a-space-4);
  border-radius: var(--a-radius-md);
  overflow-x: auto;
  margin-block: var(--a-space-3);
}

:where(pre code) {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ── Definition lists ── */
:where(dt) {
  font-weight: var(--a-weight-semibold);
  margin-block-start: 0.75em;
}

:where(dd) {
  margin-inline-start: 1.5em;
  color: var(--a-fg-subtle);
}

/* ── Details/Summary ── */
:where(summary) {
  cursor: pointer;
  font-weight: var(--a-weight-medium);
}

:where(details[open] summary) {
  margin-block-end: 0.5em;
}

/* ── Strong / Bold ──
   Semibold (600), not bold (700) — bold is the heading weight.
   Color bumps to --a-fg-strong for contrast against body text. */
:where(strong, b) {
  font-weight: var(--a-weight-semibold);
  color: var(--a-fg-strong);
}

/* ── Emphasis ── */
:where(em, i) {
  font-style: italic;
}

/* ── Small — de-emphasis in size and color ── */
:where(small) {
  font-size: 0.875em;
  color: var(--a-fg-subtle);
}

/* ── Mark — system highlight tokens ── */
:where(mark) {
  background: var(--a-highlight);
  color: var(--a-highlight-text);
  padding-inline: 0.125em;
  border-radius: 0.125em;
}

/* ── Deleted / Inserted — editorial change tracking ── */
:where(del) {
  text-decoration: line-through;
  color: var(--a-fg-muted);
}

:where(ins) {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.15em;
}

/* ── Links ── */
:where(a) {
  color: var(--a-link);
  text-decoration: none;
}

:where(a:hover) {
  color: var(--a-link-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

:where(a:visited) {
  color: var(--a-link-visited);
}

/* ── Size wrappers — custom inline elements for relative sizing ── */
:where(smaller) {
  font-size: 0.875em;
}

:where(larger, large) {
  font-size: 1.125em;
}

/* ── Images ── */
:where(img) {
  max-width: 100%;
  height: auto;
  border-radius: var(--a-radius-md);
}

/* ── Heading role defaults (h1–h6) ──
   Each native heading defaults to a sensible typographic role. Zero specificity
   via :where() (0,0,0) so [variant] and component @scope always win. Relocated
   from styles/type/roles.css during the @layer migration (ADR-0038 step 4) to
   consolidate all native h1–h6 styling in the element-defaults file / `elements`
   layer; co-located with the bare h1–h6 rule below, whose real specificity
   (0,0,1) intentionally wins line-height (1.1) over these (the relationship is
   specificity-decided, so it survives both rules landing in the same layer). */
:where(h1) {
  font-family: var(--a-title-family);
  font-weight: var(--a-title-weight);
  font-size: var(--a-title-size);
  line-height: var(--a-title-leading);
  letter-spacing: var(--a-title-tracking);
  color: var(--a-title-color);
}
:where(h2) {
  font-family: var(--a-heading-family);
  font-weight: var(--a-heading-weight);
  font-size: var(--a-heading-size);
  line-height: var(--a-heading-leading);
  letter-spacing: var(--a-heading-tracking);
  color: var(--a-heading-color);
}
:where(h3) {
  font-family: var(--a-section-family);
  font-weight: var(--a-section-weight);
  font-size: var(--a-section-size);
  line-height: var(--a-section-leading);
  letter-spacing: var(--a-section-tracking);
  color: var(--a-section-color);
}
:where(h4) {
  font-family: var(--a-subsection-family);
  font-weight: var(--a-subsection-weight);
  font-size: var(--a-subsection-size);
  line-height: var(--a-subsection-leading);
  letter-spacing: var(--a-subsection-tracking);
  color: var(--a-subsection-color);
}
:where(h5) {
  font-family: var(--a-caption-family);
  font-weight: var(--a-caption-weight);
  font-size: var(--a-caption-size);
  line-height: var(--a-caption-leading);
  letter-spacing: var(--a-caption-tracking);
  color: var(--a-caption-color);
}
:where(h6) {
  font-family: var(--a-label-family);
  font-weight: var(--a-label-weight);
  font-size: var(--a-label-size);
  line-height: var(--a-label-leading);
  letter-spacing: var(--a-label-tracking);
  color: var(--a-label-color);
}

/* ── Native element typography consolidated from resets.css ──
   (v0.6.48 reorg, ADR-0035). These are (0,0,1)/(0,1,1) and only compete
   with the :where() (0,0,0) defaults above, so specificity decides — the
   relocation from late (resets) to here (early) is winner-preserving. */
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
  line-height: 1.1;
}

p,
li,
figcaption {
  text-wrap: pretty;
}

a:not([class]) {
  text-underline-offset: 0.12em;
}
