/* ===== корень: выбор марки ===== */
.pk-page .logo__mark rect { fill: var(--ink); }
.pk-page .logo__mark path { stroke: var(--bg); }

.pk-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px var(--gutter) 16px;
}

.pk-hdr {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 44px;
}

.pk-hdr__q {
  font-size: clamp(15px, 1.35vw, 18px);
  font-weight: 520;
  font-stretch: var(--wide);
  letter-spacing: -0.02em;
  color: var(--ink-2);
  text-align: center;
}

.pk-hdr__q span { white-space: nowrap; }

.pk-hdr__q span::after {
  content: "";
  display: inline-block;
  width: .5em;
  height: 2px;
  margin-left: .2em;
  background: currentColor;
  vertical-align: -.05em;
  animation: caret 1.1s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

.pk-hdr__right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

/* ===== две половины ===== */
.pk {
  --grow-open: 1.26;
  --grow-closed: .74;
  flex: 1;
  display: flex;
  gap: 12px;
  min-height: 520px;
}

.pk-side {
  --ground: 46px;
  --stage-now: 0px;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(20px, 2.6vw, 34px) clamp(20px, 2.6vw, 34px) 0;
  border-radius: var(--r-xl);
  --side-bg: var(--card);
  background: var(--side-bg);
  overflow: hidden;
  isolation: isolate;
  outline-offset: 4px;
  transition:
    flex-grow 1.1s var(--ease),
    opacity .9s var(--ease),
    filter .9s var(--ease),
    background-color .9s var(--ease),
    transform .6s var(--ease);
  animation: side-in 1.2s var(--ease) backwards;
}

.pk-side:nth-child(2) { animation-delay: .12s; }

@keyframes side-in {
  from { opacity: 0; transform: translateY(40px) scale(.98); }
}

.pk-side > * { position: relative; z-index: 1; }

.pk-side__spot,
.pk-side__grid {
  position: absolute !important;
  inset: 0;
  z-index: 0 !important;
  pointer-events: none;
  opacity: 0;
  transition: opacity .9s var(--ease);
}

/* мягкий свет, который следует за курсором */
.pk-side__spot {
  background: radial-gradient(560px circle at var(--mx, 50%) var(--my, 60%), color-mix(in srgb, var(--accent) 30%, transparent), transparent 62%);
}

/* «чертёжная» сетка вокруг курсора */
.pk-side__grid {
  background-image:
    linear-gradient(var(--line-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(380px circle at var(--mx, 50%) var(--my, 60%), #000, transparent 70%);
  mask-image: radial-gradient(380px circle at var(--mx, 50%) var(--my, 60%), #000, transparent 70%);
}

/* Model camera stays at 45 degrees. The underlying SVG faces right;
   mirroring the Audi drawing never changes its travel direction. */
.pk-side__car {
  --car-ink: color-mix(in srgb, var(--accent) 18%, var(--ink));
  --car-light: #f6fbff;
  --car-light-edge: #668fbb;
  --car-light-halo: #79b1e6;
  --car-w: var(--car-base-width, min(86%, 850px));
  --car-x: calc((100% - var(--car-w)) / 2 - 3%);
  position: absolute !important;
  z-index: 0 !important;
  left: var(--car-x);
  bottom: var(--ground);
  width: var(--car-w);
  aspect-ratio: var(--w) / var(--h);
  pointer-events: none;
  contain: layout style;
  transform: translateZ(0);
  opacity: 0;
  transition: opacity .45s ease-out;
}

[data-theme="dark"] .pk-side__car {
  --car-ink: color-mix(in srgb, var(--accent) 14%, var(--ink));
  --car-light: #f6fbff;
  --car-light-edge: #d6edff;
  --car-light-halo: #76baff;
}

.pk-side[data-drive="-1"] .pk-side__car { left: auto; right: var(--car-x); }
.pk-side[data-drive="-1"] .pk-side__car > svg { transform: scaleX(-1); }
.pk-side__car svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pk-side__car > svg { transition: opacity .18s linear; }
.car-ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s linear;
}
.pk-side[data-drive="-1"] .car-ink { transform: scaleX(-1); }
.pk-side__car.is-ink-painting > svg { opacity: 0; }
.pk-side__car.is-ink-painting .car-ink { opacity: 1; }
.pk-side__car.is-ink-painting .car-line { stroke-dashoffset: 0; transition: none !important; }
.pk-side__car.is-ink-painting .car-details { clip-path: none; opacity: 1; transition: none; }
.car-surface { fill: var(--side-bg); fill-opacity: .38; }

/* как у колец: штрих длиннее линии и сдвинут за её край — до старта ничего не видно */
.car-line {
  fill: none;
  stroke: var(--car-ink);
  stroke-width: .65px;
  stroke-opacity: calc(.66 * var(--depth, 1));
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 101 200;
  stroke-dashoffset: 102;
  transition: stroke-dashoffset 0s linear .6s;
}

.car-line--outline { stroke-width: 1.05px; stroke-opacity: .88; }
.car-line--panel { stroke-width: .75px; }
.car-line--wheel { stroke-width: .55px; stroke-opacity: calc(.48 * var(--depth, 1)); }
.car-line--detail { stroke-width: .38px; stroke-opacity: calc(.32 * var(--depth, 1)); }
.car-line--lamp { stroke-width: .55px; stroke-opacity: .55; }
.car-line--led { stroke: var(--car-light); stroke-width: 1.6px; stroke-opacity: 1; }
.car-line--static { stroke-dasharray: none; stroke-dashoffset: 0; transition: none !important; }
.car-details {
  clip-path: inset(0 0 0 100%);
  opacity: 0;
  transition: opacity .3s ease-out, clip-path 0s linear .45s;
}
.pk-side:is(:hover, :focus-visible, .is-lit) .car-details {
  clip-path: inset(0);
  opacity: 1;
  transition: clip-path 1.15s cubic-bezier(.33, 1, .68, 1) .12s, opacity .4s ease-out .12s;
}
.car-lamp {
  fill: var(--car-light);
  fill-rule: evenodd;
  stroke: var(--car-light-edge);
  stroke-width: .6px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.car-lamp--halo {
  fill: var(--car-light-halo);
  stroke: var(--car-light-halo);
  stroke-width: 1.5px;
  filter: blur(7px);
}
.car-lighting { opacity: 0; transition: opacity .35s ease-out; }
.car-glow { opacity: .58; }
.car-leds { opacity: 1; }
.car-accents { opacity: 0; transition: opacity .4s ease-out; }
.car-accents .car-lamp { fill: #dda668; stroke: #dda668; stroke-width: .3px; }

.pk-side:is(:hover, :focus-visible, .is-lit) .pk-side__car { opacity: .82; }

.pk-side:is(:hover, :focus-visible, .is-lit) .car-line {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--t, 1.2s) cubic-bezier(.33, 1, .68, 1) var(--d, 0s);
}

.pk-side:is(:hover, :focus-visible, .is-lit) .car-lighting {
  opacity: 1;
  animation: headlight-ignite 1.35s ease-in-out 3.1s backwards;
}
.pk-side:is(:hover, :focus-visible, .is-lit) .is-ink-ready .car-lighting { animation-delay: .08s; }
.pk-side__car.is-ink-painting .car-lighting {
  opacity: 0;
  animation: none !important;
}
.pk-side:is(:hover, :focus-visible, .is-lit) .car-accents { opacity: .18; transition-delay: 3.2s; }

/* A white light guide, with two soft dips before holding a steady light. */
@keyframes headlight-ignite {
  0% { opacity: 0; }
  22% { opacity: .94; }
  40% { opacity: .52; }
  62% { opacity: 1; }
  80% { opacity: .72; }
  100% { opacity: 1; }
}

/* picker.js measures the current car before the panels expand: its camera,
   scale and position stay continuous through the departure. */
.pk[data-leaving] .pk-side.is-chosen .pk-side__car { opacity: 1; }

/* если кликнули, пока контур ещё рисуется, — дорисовываем сразу, без задержек волны */
.pk[data-leaving] .pk-side.is-chosen .car-line { stroke-dashoffset: 0; transition: stroke-dashoffset .12s ease-out; }
.pk[data-leaving] .pk-side.is-chosen .car-lighting { opacity: 1; animation: none; }
.pk-side.is-driving .pk-side__car { visibility: hidden; }
.pk-car-departure {
  position: fixed !important;
  z-index: 90 !important;
  pointer-events: none;
  transition: none !important;
  will-change: transform;
}
.pk-car-departure .car-line { stroke-dashoffset: 0; transition: none; }
.pk-car-departure .car-details { clip-path: none; opacity: 1; transition: none; }
.pk-car-departure .car-lighting { opacity: 1; animation: none; }
.pk-car-departure.is-accelerating .car-wheel__spin { animation: wheel-drive .82s cubic-bezier(.45, 0, .9, .45) forwards; }
.car-pose .car-line { stroke-dasharray: none; stroke-dashoffset: 0; }
@keyframes wheel-drive { to { transform: rotate(-540deg); } }

/* фирменные полоски марки: выезжают сверху при наведении */
.pk-side__stripe {
  position: absolute !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2 !important;
  display: flex;
  height: 5px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.1s var(--ease);
}

.pk-side:nth-child(2) .pk-side__stripe { transform-origin: right; }
.pk-side__stripe i { flex: 1; }
.pk-side__stripe i:nth-child(1) { background: var(--s1, var(--accent)); }
.pk-side__stripe i:nth-child(2) { background: var(--s2, var(--accent)); }
.pk-side__stripe i:nth-child(3) { background: var(--s3, var(--accent)); }
.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__stripe { transform: scaleX(1); }

.pk-side__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  color: var(--ink-3);
}

.pk-side__logo { display: block; color: var(--ink); }

.pk-side__logo svg {
  width: clamp(44px, 9cqi, 68px);
  height: auto;
  fill: currentColor;
  transition: transform 1.1s var(--ease);
}

.pk-side__logo { transition: color .9s var(--ease); }

.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__logo { color: var(--accent); }

.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__logo svg { transform: rotate(var(--tilt, -12deg)) scale(1.06); }

.pk-side__word {
  font-size: clamp(4.5rem, min(34cqi, 31svh), 17rem);
  font-weight: 640;
  font-stretch: 140%;
  letter-spacing: -0.06em;
  line-height: .78;
  margin-left: -.04em;
  color: var(--ink);
  transition: color .9s var(--ease), transform 1.1s var(--ease);
  transform-origin: left bottom;
}

.pk-side__bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: var(--stage-now);
  transition: margin-bottom 1.1s var(--ease);
}

.pk-side__list {
  max-width: 34ch;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.4;
}

.pk-side__go {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r);
  background: var(--card-2);
  border: 1px solid var(--line-2);
  font-size: 14px;
  font-weight: 500;
  transition: background-color .6s var(--ease), color .6s var(--ease), border-color .6s var(--ease), transform .6s var(--ease);
}

.pk-side__go .i-arrow { transition: transform .6s var(--ease); }

/* бегущая строка кузовов */
.pk-side__ticker {
  display: flex;
  align-items: center;
  width: max-content;
  height: var(--ground);
  margin: 0 calc(clamp(20px, 2.6vw, 34px) * -1);
  border-top: 1px solid var(--line);
  color: var(--ink-4);
  font-size: 12px;
  white-space: nowrap;
  animation: ticker 48s linear infinite;
  transition: color .9s var(--ease), border-color .9s var(--ease);
}

.pk-side__ticker > span { display: flex; gap: 14px; padding-right: 14px; }
.pk-side__ticker i { font-style: normal; opacity: .5; }

@keyframes ticker { to { transform: translateX(-50%); } }

/* ===== наведение: выбранная половина растёт, вторая плавно гаснет =====
   После клика у половины нет :hover (pointer-events: none) — подсветку держит .is-chosen,
   пока машина уезжает. */
.pk-side:is(:hover, :focus-visible, .is-chosen) {
  --side-bg: color-mix(in srgb, var(--accent) 7%, var(--card));
}

.pk-side:is(:hover, :focus-visible, .is-lit) { --stage-now: var(--stage, 0px); }

.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__spot { opacity: 1; }
.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__grid { opacity: .85; }

.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__word { color: var(--accent); }

.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__go {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pk-side:is(:hover, .is-chosen) .pk-side__go .i-arrow { transform: translate(2px, -2px); }

.pk-side:is(:hover, :focus-visible, .is-chosen) .pk-side__ticker {
  color: var(--accent);
  border-color: var(--accent-line);
}

@media (hover: hover) and (min-width: 761px) {
  .pk:not([data-leaving]):has(.pk-side:hover) .pk-side:not(:hover),
  .pk:not([data-leaving]):has(.pk-side:focus-visible) .pk-side:not(:focus-visible) {
    flex-grow: var(--grow-closed);
    opacity: .22;
    filter: grayscale(1) blur(2px);
  }

  .pk:not([data-leaving]):has(.pk-side:hover) .pk-side:hover,
  .pk:not([data-leaving]):has(.pk-side:focus-visible) .pk-side:focus-visible {
    flex-grow: var(--grow-open);
  }
}

/* ===== уход на сайт марки ===== */
.pk[data-leaving] .pk-side { pointer-events: none; }
.pk[data-leaving] .pk-side.is-chosen { flex-grow: 40; filter: none; opacity: 1; }
.pk[data-leaving] .pk-side:not(.is-chosen) {
  flex-grow: .0001;
  opacity: 0;
  padding-inline: 0;
  margin-inline: -6px;
}
.pk[data-leaving] .pk-side.is-chosen .pk-side__word { transform: scale(1.04); }

.pk-shell.is-leaving .pk-hdr,
.pk-shell.is-leaving .pk-ftr {
  opacity: 0;
  transition: opacity .5s var(--ease);
}

.pk-ftr {
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  color: var(--ink-4);
  font-size: 12px;
  line-height: 1.4;
}

/* ===== телефоны ===== */
@media (max-width: 760px) {
  .pk-hdr { grid-template-columns: 1fr auto; }
  .pk-hdr__q {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
    font-size: clamp(26px, 8vw, 34px);
    font-weight: 580;
    color: var(--ink);
    letter-spacing: -0.035em;
    line-height: 1.05;
    padding: 18px 0 4px;
  }
  .pk-hdr__right .btn span { display: none; }
  .pk { flex-direction: column; min-height: 0; }
  /* высота по содержимому: слово, подпись, место под машину и строка кузовов.
     У overflow: hidden автоматического минимума нет — задаём его сами */
  .pk-side { gap: 16px; min-height: min-content; }
  .pk-side__word { font-size: clamp(5rem, 36cqi, 9rem); }
  .pk-side { --stage-now: var(--stage, 0px); }
  .pk-side__bottom { transition: none; }
  .pk-side:active { transform: scale(.985); }
  /* половины стоят друг под другом: при уходе ни одна не меняет размер, вторая только
     гаснет. Копия машины закреплена на экране — растущая половина сдвинула бы подпись
     прямо на неё, а схлопнувшаяся верхняя утащила бы нижнюю из-под машины */
  .pk[data-leaving] .pk-side.is-chosen,
  .pk[data-leaving] .pk-side:not(.is-chosen) { flex-grow: 1; }
  .pk[data-leaving] .pk-side:not(.is-chosen) { padding-inline: clamp(20px, 2.6vw, 34px); margin-inline: 0; }
  .pk-ftr { flex-direction: column; gap: 6px; }
  .pk-ftr span:last-child { text-align: left; }
  .pk-side__car { --car-w: var(--car-base-width, 96%); --car-x: calc((100% - var(--car-w)) / 2); }
  .car-line--detail { stroke-opacity: .22; }
}

@media (prefers-reduced-motion: reduce) {
  .car-line,
  .pk-side:is(:hover, :focus-visible, .is-lit) .car-line { stroke-dashoffset: 0; transition: none; }
  .car-details { clip-path: none; opacity: 1; transition: none; }
  .pk-side:is(:hover, :focus-visible, .is-lit) .car-lighting,
  .pk-side:is(:hover, :focus-visible, .is-lit) .car-accents,
  .pk-car-departure .car-wheel__spin { animation: none; transition: none; }
}
