/* ==========================================================================
   Kistal — reset + base element styles + layout primitives
   ========================================================================== */

/* ---------- Reset --------------------------------------------------------- */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h-sticky) + var(--sp-6));
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100svh;
  background: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1, 'cv05' 1;
}

img, picture, svg, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

input, button, textarea, select { font: inherit; color: inherit; }

button { background: none; border: none; cursor: pointer; }

/* ---------- Typography ---------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  color: var(--text-primary);
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); letter-spacing: var(--ls-hero); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }

p { text-wrap: pretty; }

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

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur) var(--ease);
}

a:hover { color: var(--link-hover); }

strong, b { font-weight: 600; color: var(--text-primary); }

small { font-size: var(--fs-sm); }

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

li + li { margin-top: var(--sp-2); }

li::marker { color: var(--c-blue-400); }

hr {
  border: none;
  border-top: var(--bw) solid var(--border);
  margin: var(--sp-12) 0;
}

blockquote {
  border-left: var(--bw-rule) solid var(--accent);
  padding-left: var(--sp-6);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--text-primary);
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--c-n-100);
  padding: 0.15em 0.4em;
  border-radius: var(--r-xs);
  color: var(--c-n-800);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th, td {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--bw) solid var(--border);
}

th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-base);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-primary);
  background: var(--bg-alt);
}

/* ---------- Focus --------------------------------------------------------- */

:focus { outline: none; }

:focus-visible {
  outline: var(--bw-thick) solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.on-dark :focus-visible,
[data-theme='dark'] :focus-visible {
  outline-color: var(--focus-ring-dark);
}

/* ---------- Layout primitives --------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--text { max-width: var(--container-text); }

.section { padding-block: var(--section-y); }
.section--lg { padding-block: var(--section-y-lg); }
.section--tight { padding-block: clamp(2.5rem, 4vw, 4rem); }

.section--alt  { background: var(--bg-alt); }
.section--mist { background: var(--bg-mist); }

.section--dark {
  background: var(--bg-dark);
  color: var(--text-on-dark);
}

.section--dark h1, .section--dark h2,
.section--dark h3, .section--dark h4 { color: var(--text-on-dark); }

.section--dark p { color: var(--c-blue-200); }

.section--dark a { color: var(--c-n-0); }

/* Grid */
.grid { display: grid; gap: var(--sp-6); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.grid--gap-lg { gap: var(--sp-10); }

/* Fixed column counts. Use where the item count is an exact multiple and an
   auto-fit grid would otherwise leave a ragged final row. */
.grid--2-fixed { grid-template-columns: 1fr; }
@media (min-width: 800px)  { .grid--2-fixed { grid-template-columns: repeat(2, 1fr); } }

.grid--3-fixed { grid-template-columns: 1fr; }
@media (min-width: 620px)  { .grid--3-fixed { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid--3-fixed { grid-template-columns: repeat(3, 1fr); } }

.flow > * + * { margin-top: var(--sp-4); }
.flow--lg > * + * { margin-top: var(--sp-6); }

.measure       { max-width: var(--measure); }
.measure--tight { max-width: var(--measure-tight); }

/* ---------- Utilities ------------------------------------------------------ */

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

.overline {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-size: var(--fs-overline);
  font-weight: 600;
  letter-spacing: var(--ls-overline);
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: var(--sp-4);
}

.overline::before {
  content: '';
  width: 28px;
  height: var(--bw-rule);
  background: var(--accent);
  flex: none;
}

.section--dark .overline { color: var(--c-n-0); }
.section--dark .overline::before { background: var(--accent); }

.lead {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--text-secondary);
  max-width: var(--measure);
}

.section--dark .lead { color: var(--c-blue-200); }

.text-center { text-align: center; }
.text-center .overline { justify-content: center; }
.text-center .lead,
.text-center .measure { margin-inline: auto; }

.nowrap { white-space: nowrap; }

/* ---------- Motion --------------------------------------------------------- */

/* Elements start hidden ONLY when JS has confirmed it can reveal them.
   Without JS, or with reduced motion, content is visible immediately. */
[data-reveal] {
  opacity: 1;
  transform: none;
}

html.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}

html.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ---------- Print ---------------------------------------------------------- */

@media print {
  .site-header, .site-footer nav, .utility-bar,
  .btn, .cta-band, .nav-toggle, .skip-link { display: none !important; }

  body { color: #000; background: #fff; font-size: 11pt; }
  a { color: #000; text-decoration: underline; }
  a[href^='http']::after { content: ' (' attr(href) ')'; font-size: 9pt; }
  .section { padding-block: 1rem; }
  h1, h2, h3 { break-after: avoid; }
  img { break-inside: avoid; }
}
