/* ============================================================
   AIUP - robot przewodnik po usługach (uslugi.html)
   Logika: robot.js. Klatki: zdjecia/robot/robot-sheet-{a,b,c}.webp
   Kolor sceny (--robot-accent) ustawia robot.js z marki aktywnej karty.
   ============================================================ */

@property --robot-accent {
  syntax: '<color>';
  inherits: true;
  initial-value: #0439C7;
}

.services-with-robot {
  --robot-accent: #0439C7;
  --robot-top: 96px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px) minmax(0, 1fr);
  column-gap: 1.75rem;
  row-gap: 1rem;
  align-items: start;
  transition: --robot-accent 0.6s ease;
}

/* ---------- Karty: zygzak wokół robota ----------
   Każda karta we własnym wierszu, naprzemiennie lewo/prawo.
   nth-of-type liczy <div>-y, więc bezpośrednimi dziećmi siatki mogą być poza
   kartami tylko elementy innego typu (<aside> robota, <svg> promienia). */
.services-with-robot .service-page-card {
  min-width: 0;
  padding: 1.1rem;
}
.services-with-robot .service-page-card:nth-of-type(1) { grid-column: 1; grid-row: 1; }
.services-with-robot .service-page-card:nth-of-type(2) { grid-column: 3; grid-row: 2; }
.services-with-robot .service-page-card:nth-of-type(3) { grid-column: 1; grid-row: 3; }
.services-with-robot .service-page-card:nth-of-type(4) { grid-column: 3; grid-row: 4; }
.services-with-robot .service-page-card:nth-of-type(5) { grid-column: 1; grid-row: 5; }
.services-with-robot .service-page-card:nth-of-type(6) { grid-column: 3; grid-row: 6; }
.services-with-robot .service-page-card:nth-of-type(7) { grid-column: 1; grid-row: 7; }

.services-with-robot .service-page-card h3 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
  line-height: 1.25;
}
.services-with-robot .service-page-card p {
  font-size: 0.8rem;
  line-height: 1.45;
  margin-bottom: 0;
  color: var(--text-secondary);
}
.services-with-robot .service-page-num {
  font-size: 1.25rem;
  margin-bottom: 0.3rem;
}

/* Aktywna karta - kolor marki (--accent ustawia robot.js na każdej karcie) */
.services-with-robot .service-page-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent),
              0 18px 40px -22px var(--accent);
}
@media (min-width: 901px) {
  /* aktywna karta przysuwa się do robota */
  .services-with-robot .service-page-card.is-active:nth-of-type(odd)  { transform: translateX(6px); }
  .services-with-robot .service-page-card.is-active:nth-of-type(even) { transform: translateX(-6px); }
}

/* ---------- Kolumna robota ---------- */
.robot-guide {
  grid-column: 2;
  grid-row: 1 / span 7;
  position: sticky;
  top: var(--robot-top);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
}

.robot-dockbar { display: none; }

/* ---------- Scena ---------- */
.robot-scene {
  position: relative;
  flex: none;
  width: min(100%, 400px, calc(100vh - 330px));
  min-width: 250px;
  aspect-ratio: 1 / 1;
  perspective: 900px;
}

.robot-set {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.robot-halo {
  position: absolute;
  inset: 2% 0 8%;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side at 50% 52%,
      color-mix(in srgb, var(--robot-accent) 26%, transparent) 0%,
      color-mix(in srgb, var(--robot-accent) 11%, transparent) 48%,
      transparent 76%),
    radial-gradient(circle closest-side at 72% 30%, rgba(225, 255, 1, 0.3) 0%, transparent 70%);
  animation: robotHalo 7s ease-in-out infinite;
}
@keyframes robotHalo {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}

/* Podest: pierścienie na „podłodze”. Tylna połowa chowa się za robotem,
   bo cała warstwa leży pod nim. */
.robot-pad {
  position: absolute;
  left: 0;
  bottom: -2.5%;
  width: 100%;
  height: auto;
  overflow: visible;
}
.robot-pad__fill { fill: color-mix(in srgb, var(--robot-accent) 7%, transparent); }
.robot-pad__ring {
  fill: none;
  stroke: color-mix(in srgb, var(--robot-accent) 46%, transparent);
  stroke-width: 1.5;
}
.robot-pad__dash {
  fill: none;
  stroke: color-mix(in srgb, var(--robot-accent) 36%, transparent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 3 11;
  animation: robotPadFlow 2.4s linear infinite;
}
@keyframes robotPadFlow { to { stroke-dashoffset: -56; } }
.robot-pad__ripple {
  fill: none;
  stroke: var(--robot-accent);
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.robot-pad.is-ripple .robot-pad__ripple { animation: robotRipple 0.8s ease-out; }
@keyframes robotRipple {
  0%   { opacity: 0.75; transform: scale(0.45); }
  100% { opacity: 0;    transform: scale(1.38); }
}
.robot-pad__node {
  fill: #E1FF01;
  stroke: var(--robot-accent);
  stroke-width: 1.5;
}
.robot-pad__node--b { fill: #fff; }

.robot-shadow {
  position: absolute;
  left: 27%;
  bottom: 7.4%;
  width: 46%;
  height: 6.5%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(10, 16, 36, 0.3), rgba(10, 16, 36, 0));
  animation: robotShadow 5.2s ease-in-out infinite;
}
@keyframes robotShadow {
  0%, 100% { transform: scale(1.06); opacity: 1; }
  50%      { transform: scale(0.88); opacity: 0.68; }
}

/* Robot: .robot-body (pochylenie, paralaksa - robot.js) > .robot-float (lewitacja)
   > .robot-hop (podskok) > canvas z klatkami */
.robot-body {
  position: absolute;
  left: 6%;
  bottom: 8.5%;
  width: 88%;
  aspect-ratio: 352 / 344;
  z-index: 2;
  transform-origin: 50% 94%;
  will-change: transform;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.robot-float,
.robot-hop {
  width: 100%;
  height: 100%;
  transform-origin: 50% 96%;
}
.robot-float { animation: robotFloat 5.2s ease-in-out infinite; }
@keyframes robotFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2.6%); }
}
.robot-hop.is-hop { animation: robotHop 0.6s cubic-bezier(0.33, 0.9, 0.4, 1) both; }
@keyframes robotHop {
  0%   { transform: translateY(0) scale(1, 1); }
  16%  { transform: translateY(1%) scale(1.05, 0.93); }
  46%  { transform: translateY(-7%) scale(0.97, 1.05); }
  74%  { transform: translateY(0) scale(1.04, 0.95); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* Dopóki robot.js nie narysuje pierwszej klatki, widać plakat w tym samym kadrze
   (kadr 352x344 wycięty z 420x354 - stąd rozmiar i pozycja tła). */
.robot-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: url('zdjecia/robot/robot-poster.png') 58.82% 20% / 119.32% 102.91% no-repeat;
}
.robot-canvas.is-live { background: none; }

/* Cząsteczki - płótno szersze niż scena, żeby mogły wylatywać na boki.
   Maska wygasza je przy krawędzi płótna, więc nie urywają się nagle. */
.robot-fx {
  position: absolute;
  left: -25%;
  top: -25%;
  width: 150%;
  height: 150%;
  z-index: 3;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle closest-side at center, #000 78%, transparent 100%);
  mask-image: radial-gradient(circle closest-side at center, #000 78%, transparent 100%);
}

/* ---------- Dymek ---------- */
.robot-bubble {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 0.8rem 1rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid color-mix(in srgb, var(--robot-accent) 28%, transparent);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  transform-origin: 50% 0;
}
.robot-bubble::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  background: var(--bg-card);
  border-top: 1px solid color-mix(in srgb, var(--robot-accent) 28%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--robot-accent) 28%, transparent);
  border-top-left-radius: 3px;
  transform: rotate(45deg);
}
.robot-bubble.is-pop { animation: robotBubblePop 0.34s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes robotBubblePop {
  0%   { transform: translateY(5px) scale(0.965); }
  100% { transform: none; }
}

.robot-bubble__cap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--robot-accent);
}
.robot-bubble__cap::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: robotLive 2s ease-out infinite;
}
@keyframes robotLive {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--robot-accent) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Tekst pisze się litera po literze. „Duch” z pełnym tekstem trzyma wysokość,
   więc dymek nie skacze w trakcie pisania. */
.robot-bubble__msg {
  position: relative;
  display: block;
  min-height: 3em;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-primary);
}
.robot-bubble__ghost {
  display: block;
  visibility: hidden;
}
.robot-bubble__typed {
  position: absolute;
  inset: 0;
}
.robot-bubble.is-typing .robot-bubble__typed::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  background: var(--robot-accent);
}

/* ---------- Kroki 01-07 ---------- */
.robot-steps {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 400px;
}
.robot-step {
  position: relative;
  flex: 1 1 0;
  padding-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.3s ease;
}
.robot-step::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  border-radius: 99px;
  background: rgba(var(--ink-rgb), 0.12);
  transform-origin: 50% 100%;
  transition: background 0.35s ease, transform 0.35s ease;
}
.robot-step:hover { color: var(--text-primary); }
.robot-step:hover::after { background: rgba(var(--ink-rgb), 0.3); }
.robot-step.is-done::after { background: color-mix(in srgb, var(--robot-accent) 42%, transparent); }
.robot-step.is-current { color: var(--robot-accent); }
.robot-step.is-current::after {
  background: var(--robot-accent);
  transform: scaleY(1.5);
}

/* ---------- Promień: robot → aktywna karta ---------- */
.robot-link {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.28s ease;
}
.robot-link.is-on { opacity: 1; }
.robot-link__line {
  fill: none;
  stroke: var(--robot-accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 0.1 9;
  opacity: 0.8;
  animation: robotLinkFlow 0.7s linear infinite;
}
@keyframes robotLinkFlow { to { stroke-dashoffset: -9.1; } }
.robot-link__dot {
  fill: #fff;
  stroke: var(--robot-accent);
  stroke-width: 2.5;
}
.robot-link__ping {
  fill: none;
  stroke: var(--robot-accent);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: robotPing 1.6s ease-out infinite;
}
@keyframes robotPing {
  0%   { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ============================================================
   Telefon i tablet: robot dokuje się pod nawigacją
   Na górze sekcji jest duży, z dymkiem nad głową. Przy przewijaniu maleje i siada w pasku, który
   zostaje do ostatniej karty. --p (0..1) to postęp dokowania, liczy go robot.js.
   Pudełko .robot-guide ma stale wysokość paska - reszta wystaje w dół,
   a miejsce na nią rezerwuje margines pierwszej karty. Dzięki temu nic nie skacze.
   ============================================================ */
@media (max-width: 900px) {
  .services-with-robot {
    --exp-h: 382px;
    --dock-h: 92px;
    --robot-top: 76px;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.9rem;
  }
  .services-with-robot .service-page-card:nth-of-type(n) {
    grid-column: 1;
    grid-row: auto;
  }
  .services-with-robot .service-page-card:nth-of-type(1) {
    margin-top: calc(var(--exp-h) - var(--dock-h) - 0.9rem + 14px);
  }

  .robot-guide {
    --p: 0;
    grid-column: 1;
    grid-row: auto;
    order: -1;
    display: block;
    height: var(--dock-h);
    z-index: 30;
    pointer-events: none;
  }

  .robot-dockbar {
    display: block;
    position: absolute;
    inset: 0;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid color-mix(in srgb, var(--robot-accent) 24%, transparent);
    box-shadow: var(--shadow-soft);
    opacity: calc((var(--p) - 0.45) * 3);
  }

  .robot-guide .robot-scene {
    position: absolute;
    top: 0;
    left: calc((50% - 125px) * (1 - var(--p)));
    width: 250px;
    min-width: 0;
    transform-origin: 0 0;
    /* 116px pod dymkiem → -21px w pasku (głowa wystaje nad jego krawędź) */
    transform: translateY(calc(116px - var(--p) * 137px)) scale(calc(1 - var(--p) * 0.52));
  }
  .robot-guide .robot-body { pointer-events: auto; }
  /* węższe płótno cząsteczek: na wąskim telefonie nie może wystawać poza ekran */
  .robot-guide .robot-fx {
    left: -10%;
    top: -10%;
    width: 120%;
    height: 120%;
  }
  .robot-guide .robot-set { opacity: calc(1 - var(--p) * 1.7); }

  .robot-guide .robot-bubble {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    width: auto;
    max-width: 440px;
    margin: 0 auto;
    opacity: calc(1 - var(--p) * 2.4);
    transform: translateY(calc(var(--p) * -30px));
  }
  /* dymek jest nad głową robota, więc ogonek celuje w dół */
  .robot-guide .robot-bubble::before {
    top: auto;
    bottom: -7px;
    transform: rotate(225deg);
  }
  .robot-guide .robot-bubble.is-pop { animation: none; }

  .robot-guide.is-docked .robot-bubble {
    left: 128px;
    right: 14px;
    top: 9px;
    max-width: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    opacity: calc((var(--p) - 0.62) * 2.8);
    transform: none;
  }
  .robot-guide.is-docked .robot-bubble::before { display: none; }
  .robot-guide.is-docked .robot-bubble__cap {
    margin-bottom: 0.15rem;
    font-size: 0.6rem;
    white-space: nowrap;   /* jedna linia - na najwęższych telefonach nazwa marki się przytnie */
    overflow: hidden;
  }
  .robot-guide.is-docked .robot-bubble__msg {
    min-height: 0;
    max-height: 3.9em;
    overflow: hidden;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .robot-guide .robot-steps {
    position: absolute;
    left: 128px;
    right: 14px;
    bottom: 9px;
    width: auto;
    max-width: none;
    gap: 3px;
    opacity: calc((var(--p) - 0.62) * 2.8);
  }
  .robot-guide .robot-step {
    height: 3px;
    padding: 0;
    font-size: 0;
  }
  .robot-guide .robot-step::after { height: 3px; }
  .robot-guide .robot-step.is-current::after { transform: none; }

  .robot-link { display: none; }

  /* przycisk pod trasą: długi napis ma się łamać, a nie rozpychać wąski ekran */
  .services-with-robot + div .btn {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    justify-content: center;
  }
}

/* ============================================================
   Robot „solo” - ten sam robot poza stroną Usług (data-robot-solo).
   Strona podaje tylko puste .robot-scene i .robot-bubble, resztę buduje robot.js.
   ============================================================ */
.robot-solo {
  --robot-accent: #0439C7;
  position: relative;
}
.robot-solo .robot-scene {
  width: 100%;
  min-width: 0;
}
.robot-bubble:empty { display: none; }
/* dymek robota solo ma zwykle jedno zdanie - bez zapasu wysokości, który trzyma przewodnik po usługach */
.robot-solo .robot-bubble__msg { min-height: 0; }

/* --- Pas z robotem (strona główna): robot po lewej wystaje nad kartę, obok dymek i tekst --- */
.robot-band {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 2rem;
  max-width: 860px;
  margin: calc(var(--space-xl) + 2.5rem) auto 0;
  padding: 1.1rem 2rem 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}
.robot-band .robot-scene { margin-top: -3.75rem; }
.robot-band__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
}
.robot-band .robot-bubble { max-width: none; }
/* dymek stoi obok robota, więc ogonek celuje w lewo */
.robot-band .robot-bubble::before {
  top: 26px;
  left: -7px;
  margin-left: 0;
  transform: rotate(-45deg);
}
.robot-band .eco-services {
  margin: 0;
  text-align: left;
}

/* --- Robot w bocznej kolumnie (kontakt): scena, pod nią dymek --- */
.robot-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.robot-side .robot-scene { max-width: 250px; }

@media (max-width: 700px) {
  .robot-band {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    padding: 1rem 1.1rem 1.25rem;
  }
  .robot-band .robot-scene {
    max-width: 220px;
    margin-top: -3.25rem;
  }
  .robot-band__text { align-items: stretch; }
  /* węższe płótno cząsteczek: nie może wystawać poza wąski ekran */
  .robot-solo .robot-fx {
    left: -10%;
    top: -10%;
    width: 120%;
    height: 120%;
  }
  /* robot jest nad dymkiem - ogonek wraca na górę */
  .robot-band .robot-bubble::before {
    top: -7px;
    left: 50%;
    margin-left: -6.5px;
    transform: rotate(45deg);
  }
  .robot-band .btn {
    justify-content: center;
    white-space: normal;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .services-with-robot { transition: none; }
  .robot-halo,
  .robot-shadow,
  .robot-float,
  .robot-pad__dash,
  .robot-link__line,
  .robot-link__ping,
  .robot-bubble__cap::before,
  .robot-hop.is-hop,
  .robot-bubble.is-pop,
  .robot-pad.is-ripple .robot-pad__ripple { animation: none; }
  .robot-pad__node { display: none; }
}
