/* Base element styles (ADR 0033). */

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

body {
  margin: 0;
  background: var(--kp-bg);
  color: var(--kp-text);
  font-family: var(--kp-font-body);
  font-size: var(--kp-text-md);
  line-height: var(--kp-leading);
}

:where(h1, h2, h3) { font-family: var(--kp-font-heading); font-weight: 600; line-height: var(--kp-leading-heading); color: var(--kp-text); text-wrap: balance; }
:where(h1) { font-size: var(--kp-text-2xl); margin: 0 0 var(--kp-space-4); }
:where(h2) { font-size: var(--kp-text-xl); margin: var(--kp-space-6) 0 var(--kp-space-3); }
:where(h3) { font-size: var(--kp-text-lg); margin: var(--kp-space-5) 0 var(--kp-space-2); }
:where(h4, h5, h6) { font-size: var(--kp-text-md); font-weight: 600; line-height: var(--kp-leading-heading); margin: var(--kp-space-4) 0 var(--kp-space-2); }
:where(p) { margin: 0 0 var(--kp-space-3); }
:where(ul, ol) { margin: 0 0 var(--kp-space-3); padding-inline-start: 1.5rem; }
:where(strong, b) { font-weight: 700; }
:where(img) { max-width: 100%; height: auto; }

:where(a) { color: var(--kp-primary); text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
:where(a:hover) { color: var(--kp-primary-hover); text-decoration-thickness: 2px; }

:where(hr) { border: 0; border-block-start: 1px solid var(--kp-border); margin: var(--kp-space-5) 0; }

:where(table) { border-collapse: collapse; font-variant-numeric: tabular-nums; }
:where(th, td) { padding: var(--kp-space-2) var(--kp-space-3); border-block-end: 1px solid var(--kp-border); text-align: start; vertical-align: baseline; }
:where(thead th) { position: sticky; inset-block-start: 0; background: var(--kp-surface); font-size: var(--kp-text-sm); font-weight: 600; color: var(--kp-text-muted); }
:where(caption) { text-align: start; font-weight: 600; padding-block-end: var(--kp-space-2); }

:where(code, kbd, samp, pre) { font-family: var(--kp-font-mono); font-size: 0.9375em; }
:where(code, kbd) { background: var(--kp-surface-sunk); border-radius: var(--kp-radius-sm); padding: 0.1em 0.35em; }
:where(pre) { background: var(--kp-surface-sunk); border-radius: var(--kp-radius-md); padding: var(--kp-space-3) var(--kp-space-4); overflow-x: auto; }
:where(pre) code { background: none; padding: 0; }

:where(summary) { display: flex; align-items: center; gap: var(--kp-space-2); min-height: var(--kp-target); font-weight: 600; cursor: pointer; list-style: none; }
:where(summary)::-webkit-details-marker { display: none; }
:where(summary)::before { content: ""; flex: none; width: 0.45em; height: 0.45em; border-inline-end: 2px solid currentColor; border-block-end: 2px solid currentColor; transform: rotate(-45deg); transition: transform var(--kp-duration) var(--kp-ease); }
:where(details[open] > summary)::before { transform: rotate(45deg); }

:where(dialog) { color: var(--kp-text); background: var(--kp-surface); border: 0; border-radius: var(--kp-radius-lg); box-shadow: var(--kp-shadow-3); padding: var(--kp-space-5); max-width: min(32rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; }
:where(dialog)::backdrop { background: var(--kp-backdrop); }

:where(fieldset) { border: 1px solid var(--kp-border); border-radius: var(--kp-radius-md); padding: var(--kp-space-3) var(--kp-space-4) var(--kp-space-4); margin: 0 0 var(--kp-space-4); min-width: 0; }
:where(legend) { font-weight: 600; padding: 0 var(--kp-space-1); }

:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"], [type="image"], [type="button"], [type="submit"], [type="reset"]), select, textarea) {
  font: inherit;
  font-size: var(--kp-text-md);
  line-height: 1.3;
  color: var(--kp-text);
  background: var(--kp-surface);
  border: 1px solid var(--kp-control-border);
  border-radius: var(--kp-radius-sm);
  padding: var(--kp-space-2) var(--kp-space-3);
  min-height: var(--kp-target);
  max-width: 100%;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}
:where(textarea) { min-height: 6rem; resize: vertical; }
:where(input, textarea)::placeholder { color: var(--kp-text-muted); opacity: 1; }
:where(input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"]) { border-color: var(--kp-danger); box-shadow: inset 0 0 0 1px var(--kp-danger); }
:where(input:disabled, select:disabled, textarea:disabled) { opacity: 0.5; cursor: not-allowed; }
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--kp-primary); width: 1.5rem; height: 1.5rem; margin: 0; }
:where(output) { font-variant-numeric: tabular-nums; }

:where(button, input[type="button"], input[type="submit"], input[type="reset"]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--kp-space-2);
  min-height: var(--kp-target);
  padding: var(--kp-space-2) var(--kp-space-4);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: var(--kp-text);
  background: var(--kp-surface);
  border: 1px solid var(--kp-control-border);
  border-radius: var(--kp-radius-sm);
  cursor: pointer;
  text-align: center;
}
:where(button, input[type="button"], input[type="submit"], input[type="reset"]):where(:hover:not(:disabled)) { background: var(--kp-surface-sunk); }
:where(button[aria-pressed="true"]) { background: var(--kp-selected); color: var(--kp-primary); border-color: var(--kp-primary); }
:where(button, input[type="button"], input[type="submit"], input[type="reset"]):where(:disabled) { opacity: 0.5; cursor: not-allowed; }

::selection { background: var(--kp-selected); color: var(--kp-text); }

:focus-visible { outline: 2px solid var(--kp-focus); outline-offset: 2px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--kp-focus) 25%, transparent); }
main:focus, main:focus-visible { outline: none; box-shadow: none; }

[hidden] { display: none !important; }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--kp-text-muted); }

@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; }
}
