/* DECODE — base
   Reset, font stacks, type scale, focus, reduced motion.
   Element selectors live only in this file. */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--panel-0);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: var(--leading-body);
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-color: var(--hairline-strong) var(--panel-0);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-size: var(--step-1);
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

/* ---------- Text ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

h1 { font-size: var(--step-5); font-weight: 600; letter-spacing: var(--tracking-display); }
h2 { font-size: var(--step-4); letter-spacing: var(--tracking-display); }
h3 { font-size: var(--step-3); }
h4 { font-size: var(--step-2); }
h5 { font-size: var(--step-1); font-weight: 600; }
h6 { font-size: var(--step-0); font-weight: 600; }

p, li, dd, dt, td, th, figcaption, label, legend {
  max-width: var(--measure);
  overflow-wrap: anywhere;
}

p + p {
  margin-top: var(--space-4);
}

small {
  font-size: var(--step--1);
}

strong, b {
  font-weight: 600;
}

em, i {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.08em; /* serif italic sits visually small; compensate */
}

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

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color var(--dur-micro) var(--ease-out);
}

a:hover {
  text-decoration-color: var(--ink);
}

ul, ol {
  padding-left: 1.25em;
}

/* ---------- Mono and numbers ---------- */
code, kbd, samp, pre, .num, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "kern" 1;
}

code, kbd, samp {
  font-size: 0.92em;
}

pre {
  font-size: var(--step-0);
  line-height: 1.5;
  overflow-x: auto;
  padding: var(--space-4);
  background: var(--panel-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-panel);
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Media ---------- */
img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

svg {
  fill: none;
}

/* ---------- Tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--step-0);
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--hairline);
}

th {
  font-weight: 500;
  color: var(--ink-2);
}

td.num, th.num {
  text-align: right;
}

/* ---------- Forms: inherit type, nothing else ---------- */
button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

/* ---------- Focus ---------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: 2px;
}

::selection {
  background: var(--ink);
  color: var(--panel-0);
}

/* ---------- Hidden wins over any display rule ---------- */
[hidden] {
  display: none !important;
}

/* ---------- Utilities used by base markup ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--panel-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-input);
  transform: translateY(-200%);
  transition: transform var(--dur-micro) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-micro: 0ms;
    --dur-ui: 0ms;
    --dur-data: 0ms;
    --dur-orchestrated: 0ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Print ---------- */
@media print {
  html {
    background: #fff;
    color: #000;
  }
}
