/* Base: reset, typography, layout primitives, global chrome (header, menu, footer).
   Spec: docs/design/DESIGN.md §3–§5. Animate transform/opacity only; no `transition: all`. */

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/var(--lh-body) var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main { flex: 1 0 auto; display: block; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, figure, dl, dd, blockquote { margin: 0; }
:where(h1, h2, h3) { font-family: var(--font-display); text-wrap: balance; }
p { text-wrap: pretty; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
.on-dark :focus-visible, .site-footer :focus-visible { outline-color: var(--focus-on-dark); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link { position: absolute; left: var(--s-4); top: -100px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: var(--s-3) var(--s-4); font-weight: 600; }
.skip-link:focus { top: var(--s-3); }
.skip-link:focus-visible { outline-color: var(--ink); }

.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

/* Eyebrow / mono label */
.label {
  font: 500 var(--step--1)/1.2 var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-transform: uppercase;
}
.label--sm { font-size: 0.75rem; }

/* Signature divider: road centre line. Used only in "Jak to działa", footer edge, form progress. */
.road { height: 4px; background: repeating-linear-gradient(90deg, var(--ink) 0 28px, transparent 28px 48px); }
.road--signal { background: repeating-linear-gradient(90deg, var(--accent-line) 0 28px, transparent 28px 48px); }

/* ---------- Buttons & links ------------------------------------------- */
.btn {
  --_bg: var(--ink); --_fg: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5);
  border: 0; border-radius: var(--r-1);
  background: var(--_bg); color: var(--_fg);
  font: 600 var(--step-0)/1 var(--font-body);
  text-decoration: none; cursor: pointer; text-align: center;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-fast) var(--ease-hover);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
/* Big full-width buttons: 3 % of 358 px reads as a wobble — press a little less. */
.btn--block:active, .btn--lg:active { transform: scale(0.985); }
.btn--signal { --_bg: var(--accent); --_fg: var(--accent-ink); }
.btn--ghost  { --_bg: transparent; --_fg: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn--block  { width: 100%; }
.btn--lg     { min-height: 56px; font-size: var(--step-1); }
.btn .arrow  { transition: transform var(--dur-fast) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { --_bg: #000; }
  .btn--signal:hover { --_bg: var(--accent-hover); }
  .btn--signal:active { --_bg: var(--accent-press); }
  .btn--ghost:hover { --_bg: var(--paper-sunk); }
  .btn:hover .arrow { transform: translateX(3px); }
}
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
/* Working, not disabled: full strength, re-clicks blocked, a spinner only if it takes > 250 ms. */
.btn[aria-busy="true"], .btn[aria-busy="true"][disabled] { opacity: 1; pointer-events: none; cursor: progress; } /* Turbo also sets [disabled] on the submitter */
.btn[aria-busy="true"] .arrow { display: none; }
.btn[aria-busy="true"]::after {
  content: ""; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: 0;
  animation: btn-spin 600ms linear infinite, spinner-in 160ms 250ms var(--ease-out) forwards;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@keyframes spinner-in { to { opacity: 1; } }
.btn__check { flex: none; margin-right: 6px; vertical-align: -3px; }
.on-dark .btn--ghost { --_fg: var(--on-asphalt); box-shadow: inset 0 0 0 1.5px var(--on-asphalt); }

.link { font-weight: 600; text-decoration: underline; text-decoration-thickness: 1.5px;
  text-underline-offset: 4px; text-decoration-color: var(--accent); color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .link:hover { color: var(--accent-hover); text-decoration-color: currentColor; } }
.on-dark .link { color: var(--on-asphalt); text-decoration-color: var(--accent-line); }

.icon-btn { width: var(--tap); height: var(--tap); display: grid; place-items: center; color: inherit;
  border: 0; background: transparent; border-radius: var(--r-1); cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Header ---------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-bottom: var(--hairline);
}
@supports (backdrop-filter: blur(8px)) {
  .site-header { background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(12px) saturate(1.4); }
}
.site-header .wrap { display: flex; align-items: center; gap: var(--s-5); height: var(--header-h); }
/* Logo = road-sign plate (Polish D-series: white on blue, thin white inner rule). Text stays live
   HTML (Archivo), so it is crisp and accessible; favicons use outlined "UJ" (public/icon.svg). */
.logo { display: inline-flex; align-items: center; flex: none; text-decoration: none; white-space: nowrap;
  font: 800 1.125rem/1 var(--font-display); font-stretch: 78%; letter-spacing: 0.005em;
  color: var(--accent-ink, #fff); background: var(--accent); border-radius: 5px; padding: 7px 11px 8px;
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 3.5px #fff; }
@media (min-width: 900px) { .logo { font-size: 1.25rem; padding: 8px 12px 9px; } }
.nav { display: none; margin-left: auto; gap: var(--s-6); }
.nav a { text-decoration: none; font-weight: 500; color: var(--ink-2); padding-block: var(--s-2); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
@media (hover: hover) and (pointer: fine) { .nav a:hover { color: var(--ink); } }
.header-actions { margin-left: auto; display: flex; gap: var(--s-1); margin-right: calc(var(--s-3) * -1); }
@media (min-width: 900px) {
  .nav { display: flex; }
  .header-actions { margin-left: var(--s-5); }
  .menu-btn { display: none; }
}

/* Mobile menu: full-height sheet from the top (native <dialog>: inert background + Esc for free) */
.menu {
  position: fixed; inset: 0 0 auto 0; margin: 0; width: 100%; max-width: none;
  height: 100vh; height: 100dvh; max-height: none;
  border: 0; padding: 0; background: var(--paper); color: var(--ink);
}
.menu::backdrop { background: var(--scrim); }
.menu[open]::backdrop { animation: fade-only var(--dur-base) var(--ease-out); }
.menu[open] { animation: menu-in var(--dur-base) var(--ease-out); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-12px); } }
.menu__head { display: flex; align-items: center; justify-content: space-between; height: var(--header-h);
  padding-inline: var(--gutter); border-bottom: var(--hairline); }
.menu__head .icon-btn { margin-right: calc(var(--s-3) * -1); }
.menu nav ul { list-style: none; margin: 0; padding: var(--s-5) var(--gutter); display: grid; }
.menu nav a { display: block; padding-block: var(--s-3); text-decoration: none;
  font: 700 var(--step-3)/1.05 var(--font-display); font-stretch: 80%; border-bottom: var(--hairline); }
.menu nav a[aria-current="page"] { box-shadow: inset 4px 0 0 var(--accent); padding-left: var(--s-3); }
.menu__foot { padding: 0 var(--gutter) var(--s-6); display: grid; gap: var(--s-3); }
.menu__foot p { color: var(--ink-3); font-size: var(--step--1); }

/* ---------- Page scaffolding ------------------------------------------ */
.section { padding-block: var(--section); }
.section-head { display: grid; gap: var(--s-3); margin-bottom: var(--s-6); }
.section-head :is(h1, h2) { font-size: var(--step-4); line-height: 0.95; font-weight: 800; font-stretch: 75%; }
.section-head p { color: var(--ink-2); max-width: 52ch; }
@media (min-width: 900px) { .section-head { grid-template-columns: 1fr auto; align-items: end; column-gap: var(--s-7); } }

.page-head { padding-block: var(--s-5) var(--s-7); display: grid; gap: var(--s-4); }
.page-head h1 { font-size: var(--step-5); line-height: var(--lh-tight); font-weight: 800; font-stretch: 72%; letter-spacing: -0.015em; }
.page-head .lead { font-size: var(--step-1); line-height: 1.4; color: var(--ink-2); max-width: 46ch; }
.page-head .meta { margin-top: calc(var(--s-1) * -1); }

.crumbs { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-4) 0; list-style: none; margin: 0;
  font: 500 var(--step--1)/1.4 var(--font-mono); color: var(--ink-3); }
.crumbs li + li::before { content: "/"; margin-right: var(--s-2); color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; padding-block: 6px; }
@media (hover: hover) and (pointer: fine) { .crumbs a:hover { text-decoration: underline; } }

.on-dark { background: var(--asphalt); color: var(--on-asphalt); }
.on-dark .label { color: var(--on-asphalt-2); }

.notice { padding: var(--s-4); border-radius: var(--r-1); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); font-size: var(--step--1); }
.notice--error { background: var(--error-wash); box-shadow: inset 4px 0 0 var(--error); color: var(--ink); }

.empty { padding: var(--s-7) 0; display: grid; gap: var(--s-3); justify-items: start; max-width: 46ch; }
.empty h3, .empty h2 { font-size: var(--step-2); font-weight: 700; font-stretch: 85%; }
.empty p { color: var(--ink-2); }

/* ---------- Footer ---------------------------------------------------- */
.site-footer { background: var(--asphalt); color: var(--on-asphalt-2); padding-block: 0 var(--s-6); margin-top: auto; }
.site-footer .road { margin-bottom: var(--s-7); }
.footer-grid { display: grid; gap: var(--s-6); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.footer-grid h2 { font: 500 var(--step--1)/1 var(--font-mono); text-transform: uppercase; color: var(--on-asphalt); margin-bottom: var(--s-3); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.footer-grid a { text-decoration: none; display: inline-block; padding-block: 6px; }
@media (hover: hover) and (pointer: fine) { .footer-grid a:hover, .footer-legal a:hover { color: var(--on-asphalt); text-decoration: underline; } }
.footer-brand { grid-column: 1 / -1; }
.footer-brand p { margin-top: var(--s-3); max-width: 46ch; font-size: var(--step--1); }
.footer-legal { margin-top: var(--s-7); padding-top: var(--s-4); border-top: 1px solid var(--asphalt-line); font-size: var(--step--1);
  display: grid; gap: var(--s-2); }
.footer-legal p { max-width: 90ch; }
.footer-legal a { color: var(--on-asphalt-2); }
@media (min-width: 900px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } .footer-brand { grid-column: auto; } }

/* ---------- Turbo ----------------------------------------------------- */
.turbo-progress-bar { height: 3px; background: var(--accent); }

/* View transitions: 180 ms root crossfade; the clicked car photo morphs into the model hero. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
::view-transition-group(car-photo) { animation-duration: 320ms; animation-timing-function: var(--ease-out); }
/* Card (16:9 / 16:10 / 64×40 thumb) → hero (16:10): crop instead of stretching, no snap at the end. */
::view-transition-image-pair(car-photo) { overflow: clip; border-radius: var(--r-2); }
::view-transition-old(car-photo), ::view-transition-new(car-photo) { height: 100%; object-fit: cover; object-position: 50% 62%; }

/* ---------- Reduced motion: keep meaning, drop movement ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .btn, .icon-btn, .chip, .letter { transition-property: background-color, color, border-color !important; }
  .btn:active, .icon-btn:active, .chip:active, .letter:active { transform: none !important; }
  .menu[open] { animation-name: fade-only; }
  .btn[aria-busy="true"]::after { animation-duration: 1.6s, 160ms; } /* the spinner carries meaning: slow, not gone */
  ::view-transition-group(*) { animation-duration: 0s !important; }
}
@keyframes fade-only { from { opacity: 0; } }

main:focus-visible { outline: none; }
.placeholder { background: var(--accent-soft); color: var(--ink); padding-inline: 3px; border-radius: 2px; font-family: var(--font-mono); font-size: 0.9em; }
.js .no-js-only { display: none !important; }
.no-js .reveal { grid-template-rows: 1fr; }
