/* Base layer shared by every page: reset, type, links, buttons, header and footer. Components live in
   blocks.css (homepage) and guide.css (guide, download and 404). */

/* ---------- Reset and type ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text-base)/1.5 var(--font-sans);
  font-synthesis: none;
  text-spacing-trim: normal;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
img, picture, video { display: block; max-width: 100%; height: auto; }
p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; line-height: 1.3; text-wrap: balance; }
strong, b { font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.875em; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font: 400 0.8125em/1.5 var(--font-sans);
  text-align: center;
}
[hidden] { display: none !important; }
/* The sticky header covers the top of the viewport; anchored targets land below it. */
[id] { scroll-margin-top: calc(var(--header-h) + 1rem); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
:root { accent-color: var(--brand); }

a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
@media (hover: hover) {
  a:hover { color: var(--brand-hover); text-decoration-thickness: 2px; }
}

.icon { display: inline-block; width: 0.85em; height: 0.85em; flex: none; vertical-align: -0.05em; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip-link {
  position: absolute;
  z-index: 40;
  top: -4rem;
  left: 1rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--on-brand);
}
.skip-link:focus { top: 0.5rem; }

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

/* ---------- Buttons: pills, like the reference ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: 400 var(--text-base)/1.25 var(--font-sans);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), scale 120ms ease-out;
}
.button-large { min-height: 44px; padding: 0.75rem 1.35rem; }
.button-small { min-height: 32px; padding: 0.35rem 0.85rem; font-size: var(--text-sm); }
.button-primary { background: var(--brand); color: var(--on-brand); }
.button-secondary { border-color: var(--line); background: var(--chip); color: var(--ink); }
@media (hover: hover) {
  .button-primary:hover { background: var(--brand-hover); color: var(--on-brand); }
  .button-secondary:hover { background: var(--card-hover); color: var(--ink); }
}
@media (prefers-reduced-motion: no-preference) {
  .button:active { scale: 0.98; }
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }

/* ---------- Header ---------- */

.site-header { position: sticky; top: 0; z-index: 30; background: var(--paper); }
.header-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: var(--header-h); }
.brand { display: inline-flex; justify-self: start; }
.brand img { width: auto; height: 28px; }
.site-nav ul { display: flex; list-style: none; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.35rem 0.95rem;
  color: var(--ink);
  font-size: var(--text-sm);
  text-decoration: none;
}
.site-nav a[aria-current="page"] { color: var(--brand); }
@media (hover: hover) {
  .site-nav a:hover { color: var(--brand); }
}
.header-actions { display: flex; align-items: center; justify-self: end; gap: 0.5rem; }
.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 32px;
  min-inline-size: 28px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--transition), color var(--transition), background-color var(--transition);
}
@media (hover: hover) {
  .lang-switch:hover { border-color: var(--line-strong); background: var(--card); color: var(--ink); }
}
.header-cta[aria-current="page"] { background: var(--brand-hover); }

@media (pointer: coarse) {
  .lang-switch::after,
  .site-nav a::after {
    content: '';
    position: absolute;
    inset: -6px -4px;
  }
  .site-nav a { position: relative; }
}

/* ---------- Footer ---------- */

.site-footer { padding: var(--section-y) 0 1.9rem; background: var(--card); color: var(--ink); font-size: var(--text-sm); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 2rem; }
.footer-brand img { width: auto; height: 28px; margin-bottom: 0.75rem; }
.footer-brand p { color: var(--muted); }
.footer-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; }
.footer-heading { margin-bottom: 0.75rem; color: var(--muted); }
.footer-columns ul { display: grid; gap: 0.15rem; list-style: none; }
.footer-columns a { display: inline-flex; align-items: center; gap: 0.3em; padding-block: 0.3rem; color: var(--ink); text-decoration: none; }
@media (hover: hover) {
  .footer-columns a:hover { color: var(--brand); }
}
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; margin-top: 3.5rem; color: var(--muted); font-size: var(--text-xs); }

/* ---------- Scroll reveal (scripts/motion.js): vertical only, below the fold only ---------- */

.reveal-pending { opacity: 0; transform: translateY(12px); }
.reveal-in { opacity: 1; transform: none; transition: opacity 320ms ease-out, transform 320ms ease-out; }

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  body { font-size: 0.9375rem; }
  :root { --gutter: 18.75px; }
  .header-inner { grid-template-columns: auto 1fr auto; gap: 0.35rem; }
  .brand img { height: 22px; }
  .site-nav { justify-self: end; }
  .site-nav .nav-desktop { display: none; }
  .site-nav a { padding-inline: 0.4rem; white-space: nowrap; }
  .header-actions { gap: 0.35rem; }
  .lang-switch { padding-inline: 0.5rem; }
  .header-cta { padding-inline: 0.7rem; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .header-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 0.5rem; padding-block: 0.4rem; }
  .brand img { height: 20px; }
  .site-nav { order: 3; flex-basis: 100%; min-width: 0; justify-self: start; }
  .site-nav ul { gap: 0.25rem; margin-left: -0.4rem; }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .button, .lang-switch, .reveal-in { transition: none; }
}

@media print {
  .skip-link, .site-nav, .header-actions { display: none; }
  .site-header { position: static; }
}
