/* Trabant Nevelde — interakció-réteg (rally-futam, megfogható kocsi, hírcsík).
   Mobilelső: 360 px-en kezdődik, a futam két sávja egymás ALATT fut, így
   telefonon álló helyzetben is működik. Paletta: az app.css változóiból. */

/* ------------------------------------------------------------ 1. RALLY-PÁLYA */

.tni-palya {
  background: var(--panel);
  border: 1px solid var(--vonal);
  border-radius: var(--sugar);
  padding: 10px 10px 12px;
  margin-bottom: 12px;
  overflow: hidden;
}

.tni-palya-fej {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tni-palya-nev {
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tni-savok {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tni-sav {
  position: relative;
  height: 92px;
  border-radius: var(--sugar-kicsi);
  overflow: hidden;
  background: #20252b;
  border: 1px solid var(--vonal);
}

.tni-sav .tni-hatter {
  position: absolute;
  inset: 0;
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position-x: 0;
  opacity: .9;
}

.tni-sav .tni-ut {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .55) 0 18px, transparent 18px 44px) center / auto 3px no-repeat,
    linear-gradient(180deg, #33383d, #23272b);
}

.tni-sav .tni-versenyzo {
  position: absolute;
  left: 3px;
  bottom: 6px;
  width: 42%;
  min-width: 104px;
  max-width: 190px;
  line-height: 0;
  transform: translateX(0);
  will-change: transform;
}

.tni-sav .tni-versenyzo svg { width: 100%; height: auto; display: block; }

.tni-sav .tni-cimke {
  position: absolute;
  top: 4px;
  left: 8px;
  right: 20px;          /* a célvonal csíkja alá ne csússzon a százalék */
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .8rem;
  color: #f2f4f6;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  pointer-events: none;
}

.tni-sav .tni-en {
  background: var(--borostyan);
  color: #1a1400;
  border-radius: 999px;
  padding: 0 6px;
  font-size: .7rem;
  text-shadow: none;
}

.tni-sav.gyoztes { border-color: var(--siker); box-shadow: 0 0 0 2px rgba(90, 158, 111, .45) inset; }
.tni-sav.vesztes { opacity: .78; }

.tni-celvonal {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 2px;
  width: 12px;
  border-radius: 3px;
  background:
    repeating-conic-gradient(#f7f7f2 0 25%, #1e2226 0 50%) 0 0 / 12px 12px;
  opacity: .9;
  pointer-events: none;
}

.tni-szakasz {
  margin: 10px 0 6px;
  min-height: 2.6em;
  font-size: .95rem;
}
.tni-szakasz b { color: var(--borostyan); margin-right: 4px; }

.tni-tav {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.tni-tav i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--borostyan);
}

.tni-palya[data-ido="esos"] .tni-sav .tni-ut { filter: brightness(.85) saturate(.8); }
.tni-palya[data-ido="havas"] .tni-sav .tni-ut { filter: brightness(1.25) saturate(.5); }

/* a kocsi zötyög futás közben */
.tni-palya:not(.vege) .tni-versenyzo { animation: tni-zotyog .45s ease-in-out infinite; }
@keyframes tni-zotyog {
  0%, 100% { margin-bottom: 0; }
  50% { margin-bottom: 2px; }
}

.tni-palya.vege .tni-sav.gyoztes .tni-versenyzo { animation: tni-gyoztes .9s ease-out 1; }
@keyframes tni-gyoztes {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.7) drop-shadow(0 0 14px var(--borostyan)); }
  100% { filter: brightness(1); }
}

@media (min-width: 680px) {
  .tni-sav { height: 118px; }
  .tni-sav .tni-versenyzo { width: 32%; }
}

/* ------------------------------------------------- 2. KATTINTHATÓ ALKATRÉSZEK */

.tni-pont {
  fill: transparent;
  stroke: var(--borostyan);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  opacity: 0;
  cursor: pointer;
  transition: opacity 200ms ease;
}

/* Ami hiányzik, de nem kötelező: halk jelzés — „ezt még megveheted”. */
.tni-pont.hianyzik { opacity: .3; }

/* Ami kötelező és hiányzik: ez tartja állva a kocsit, ez lüktet. */
.tni-pont.hianyzik.kotelezo {
  opacity: .85;
  stroke: var(--rozsda);
  animation: tni-luktet 2.4s ease-in-out infinite;
}

.kocsi-szinpad:hover .tni-pont.megvan,
.kocsi-szinpad:focus-within .tni-pont.megvan { opacity: .16; }

.tni-pont:hover, .tni-pont:focus { opacity: 1; fill: rgba(240, 179, 35, .16); outline: none; }
.tni-pont:focus-visible { stroke-width: 3; fill: rgba(240, 179, 35, .22); }

@keyframes tni-luktet {
  0%, 100% { opacity: .45; stroke-width: 2; }
  50% { opacity: .95; stroke-width: 3; }
}

.tni-buborek {
  position: fixed;
  z-index: 60;
  width: min(280px, calc(100vw - 24px));
  background: var(--panel-2);
  border: 1px solid var(--vonal);
  border-radius: var(--sugar-kicsi);
  box-shadow: var(--arnyek);
  padding: 12px 12px 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.tni-buborek.nyitva { opacity: 1; transform: none; }
.tni-buborek p { margin: 0 0 6px; }
.tni-buborek .tni-b-nev { font-weight: 700; padding-right: 20px; }
.tni-buborek .tni-b-ar { font-weight: 700; color: var(--borostyan); }
.tni-buborek .tni-b-zar {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: 0;
  color: var(--szoveg-halvany);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.tni-buborek .hiba-szoveg { color: var(--rozsda); }

/* --------------------------------------------------- 2/b. A KOCSI REAGÁL */

/* új alkatrész: a helyére kerül */
.tni-erkezik {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: tni-erkezik .85s cubic-bezier(.2, 1.3, .4, 1) 1;
}
@keyframes tni-erkezik {
  0% { opacity: 0; transform: translateY(-26px) scale(.7); }
  60% { opacity: 1; transform: translateY(2px) scale(1.06); }
  100% { opacity: 1; transform: none; }
}

/* indítás: remegés + felszálló füstpamacs */
.kocsi-szinpad.tni-indul svg { animation: tni-remeg .12s linear 10; }
@keyframes tni-remeg {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.5px, .5px); }
  75% { transform: translate(1.5px, -.5px); }
}
.kocsi-szinpad.tni-indul::after {
  content: "";
  position: absolute;
  right: 6%;
  bottom: 22%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(182, 197, 211, .8), rgba(182, 197, 211, 0) 70%);
  animation: tni-pofa 1.4s ease-out 1 forwards;
  pointer-events: none;
}
@keyframes tni-pofa {
  0% { opacity: .9; transform: translate(0, 0) scale(.5); }
  100% { opacity: 0; transform: translate(42px, -48px) scale(2.2); }
}

/* mosás: csillanás fut végig a kocsin */
.kocsi-szinpad.tni-csillan::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .55) 50%, transparent 62%);
  animation: tni-csillan 1.2s ease-out 1 forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes tni-csillan {
  from { transform: translateX(-110%); }
  to { transform: translateX(110%); }
}

/* szintlépés: felugró jelző */
.tni-szintjelzo {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, 0);
  background: var(--borostyan);
  color: #1a1400;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--arnyek);
  pointer-events: none;
  z-index: 3;
  animation: tni-szintjelzo 2.2s ease-out 1 forwards;
}
@keyframes tni-szintjelzo {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(.7); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  35% { transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1); }
}

/* --------------------------------------------------------- 3. ÉLŐ VILÁG */

.tni-hircsik {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--vonal);
  border-radius: 999px;
  padding: 5px 12px 5px 6px;
  margin: -4px 0 12px;
  font-size: .86rem;
  color: var(--szoveg-halvany);
  overflow: hidden;
}

.tni-hircsik-cimke {
  flex: 0 0 auto;
  background: var(--rozsda);
  color: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.tni-hircsik-sav {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tni-hir { display: inline-block; }
.tni-hir.be { animation: tni-hir-be 420ms ease-out 1; }
@keyframes tni-hir-be {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------ csökkentett mozgás */

@media (prefers-reduced-motion: reduce) {
  .tni-palya:not(.vege) .tni-versenyzo,
  .tni-palya.vege .tni-sav.gyoztes .tni-versenyzo,
  .tni-pont.hianyzik,
  .tni-erkezik,
  .kocsi-szinpad.tni-indul svg,
  .kocsi-szinpad.tni-indul::after,
  .kocsi-szinpad.tni-csillan::before,
  .tni-hir.be {
    animation: none !important;
  }
  .tni-pont.hianyzik { opacity: .85; }
  .tni-szintjelzo { animation: none !important; opacity: 1; }
  .tni-buborek { transition: none; }
}
