/*
 * ElboMotors — reset, typography and layout primitives.
 * Components live in components.css. Nothing here knows about a specific
 * block of the site.
 */

/* ------------------------------------------------------------------ reset */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem; /* sticky header must not cover anchors: one row on phones... */
}

@media (min-width: 64em) { html { scroll-padding-top: 9rem; } } /* ...two rows from 64em */

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;         /* diagonals and full-bleed must never scroll */
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------- typography */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-display);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-display);
  text-transform: uppercase;
  margin: 0 0 var(--sp-4);
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p  { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

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

strong, b { font-weight: var(--fw-semibold); }
small { font-size: var(--fs-sm); }

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.25rem; }
li + li { margin-top: var(--sp-1); }

blockquote {
  margin: var(--sp-6) 0;
  padding-left: var(--sp-5);
  border-left: 3px solid var(--c-accent);
  font-size: var(--fs-lg);
  color: var(--c-text);
}

hr { border: 0; border-top: 1px solid var(--c-line); margin: var(--sp-7) 0; }

code, pre, kbd {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
  font-size: 0.9em;
}
pre {
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  padding: var(--sp-4);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--sp-3) var(--sp-4); }

/* ------------------------------------------------------------ focus & a11y */

/*
 * Focus is visible and high contrast everywhere. On a dark theme with a hot
 * accent this is the first thing that breaks, so it is set once, globally,
 * and components must not remove it.
 */
:focus-visible {
  outline: 3px solid var(--c-accent-text);
  outline-offset: 2px;
  border-radius: 1px;
}
:focus:not(:focus-visible) { outline: none; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: var(--z-modal);
  background: var(--c-accent);
  color: var(--c-accent-ink);
  font-weight: var(--fw-semibold);
  padding: var(--sp-3) var(--sp-5);
  text-decoration: none;
}
.skip-link:focus { left: 50%; transform: translateX(-50%); color: var(--c-accent-ink); }

@media (forced-colors: active) {
  .btn, .card { border: 1px solid; }
}

/* ----------------------------------------------------------------- layout */

.wrap {
  width: min(100% - var(--gutter) * 2, var(--wrap));
  margin-inline: auto;
}
.wrap--narrow { width: min(100% - var(--gutter) * 2, var(--wrap-narrow)); }
.wrap--wide   { width: min(100% - var(--gutter) * 2, 1600px); }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: calc(var(--section-y) * 0.55); }
.section--surface { background: var(--c-surface); }

/*
 * Diagonal section edge. Achieved with clip-path so it costs no extra
 * markup and degrades to a straight edge where clip-path is unsupported.
 */
.section--slant-top {
  clip-path: polygon(0 var(--diagonal), 100% 0, 100% 100%, 0 100%);
  margin-top: calc(var(--diagonal) * -1);
  padding-top: calc(var(--section-y) + var(--diagonal));
}
.section--slant-bottom {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--diagonal)), 0 100%);
  padding-bottom: calc(var(--section-y) + var(--diagonal));
}

/*
 * Both edges at once. clip-path is a single property, so the two rules above
 * would overwrite each other and only the bottom slant would survive — the
 * top edge silently renders straight. This combined polygon is required, not
 * a convenience.
 */
.section--slant-top.section--slant-bottom {
  clip-path: polygon(
    0 var(--diagonal),
    100% 0,
    100% calc(100% - var(--diagonal)),
    0 100%
  );
}

.grid { display: grid; gap: var(--sp-5); }
@media (min-width: 40em)  { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 52em)  { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 64em)  { .grid--4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 52em)  { .grid--sidebar { grid-template-columns: 18rem 1fr; gap: var(--sp-7); } }
/* Next to a sidebar three columns only fit from 72em; below that the cards clip their footer. */
@media (min-width: 52em) and (max-width: 71.99em) { .grid--sidebar .grid--3 { grid-template-columns: repeat(2, 1fr); } }

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

.cluster {
  display: flex; flex-wrap: wrap;
  gap: var(--sp-3); align-items: center;
}

.full-bleed {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
}

.lead { font-size: var(--fs-lg); color: var(--c-muted); }
.muted { color: var(--c-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
