/* Truck Race - OBS Browser Source, 1920x1080, transparante achtergrond.
   Racebaan = 1920x200 balk onderin, tekst als matrixbord gecentreerd erboven. */

:root {
  /* Thema's (truckrace-themes.css) overschrijven deze variabelen op body.theme-<key>. */
  --accent: #ffb21a;
  --accent-rgb: 255, 178, 26;
  --accent-dim: #a86a00;
  --panel-top: #121417;
  --panel-bottom: #08090b;
  --panel-border: #2c3036;
  --road-top: #30353c;
  --road-edge: #8b1f1a;
  --bulb-glow: #ffcf5a;
  --green-go: #3ee07f;
  --red-stop: #ff4d43;
  --asphalt: #1b1e23;
  --asphalt-2: #262a30;
  --paper: #f4f1e8;
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Work Sans", system-ui, sans-serif;
}

html, body {
  margin: 0;
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  background: transparent;
}

body.has-bg {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.35)),
    linear-gradient(160deg, #5d7385 0%, #8d9a8f 45%, #5a6150 100%);
}

.tr-stage {
  position: relative;
  width: 1920px;
  height: 1080px;
  font-family: var(--font-body);
  color: var(--paper);
}

/* ---------- Matrixbord boven de baan ---------- */

.tr-sign {
  position: absolute;
  left: 50%;
  bottom: 226px;
  min-width: 560px;
  max-width: 1080px;
  padding: 14px 36px 16px;
  transform: translate(-50%, 24px);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-display);
  color: var(--accent);
  background:
    radial-gradient(circle, rgba(var(--accent-rgb), 0.07) 1px, transparent 1.6px) 0 0 / 5px 5px,
    linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 6px solid var(--panel-border);
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 40px rgba(0, 0, 0, 0.8),
    0 18px 40px -12px rgba(0, 0, 0, 0.75);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.55), 0 0 2px rgba(var(--accent-rgb), 0.9);
}

.tr-sign.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Na de race: bord zakt mee met de baan, tot alleen de vlaggetjes nog zichtbaar zijn. */
.tr-sign.is-visible.is-lowered { transform: translate(-50%, 170px); }
.tr-sign.is-lowered:not(.is-visible) { transform: translate(-50%, 200px); }

.tr-sign__kicker {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--accent-dim);
  text-shadow: none;
}

.tr-sign__main {
  margin-top: 2px;
  font-size: 24px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tr-sign__main kbd {
  font: inherit;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--panel-bottom);
  background: var(--accent);
  text-shadow: none;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.45);
}

.tr-sign__main--huge {
  font-size: 46px;
  line-height: 1;
}

.tr-sign__main.is-go { color: var(--green-go); text-shadow: 0 0 18px rgba(62, 224, 127, 0.6); }
.tr-sign__main.is-winner i { margin-right: 14px; }

.tr-sign__foot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 26px;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.tr-sign__foot .is-urgent { color: var(--red-stop); text-shadow: 0 0 10px rgba(255, 77, 67, 0.6); }

.tr-sign__timer {
  font-variant-numeric: tabular-nums;
  padding: 0 16px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.tr-sign__standing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tr-sign__chip {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
}

.tr-lights {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 10px;
}

.tr-lights span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2a1414;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.6);
}

.tr-lights span.is-on { background: var(--red-stop); box-shadow: 0 0 20px var(--red-stop), inset 0 -4px 8px rgba(0, 0, 0, 0.3); }
.tr-lights.is-go span { background: var(--green-go); box-shadow: 0 0 20px var(--green-go), inset 0 -4px 8px rgba(0, 0, 0, 0.3); }

/* ---------- Racebaan (1920x200) ---------- */

.tr-track {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1920px;
  height: 200px;
  transform: translateY(210px);
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tr-track.is-visible { transform: translateY(0); }
.tr-track.is-visible.is-lowered { transform: translateY(170px); } /* alleen de vlaggetjes (bovenste 30px) blijven staan */

.tr-bunting {
  position: absolute;
  inset: 0 0 auto 0;
  height: 30px;
  z-index: 2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='30'%3E%3Cpath d='M0 3 Q60 11 120 3 Q180 11 240 3' fill='none' stroke='%23e9e2cf' stroke-width='1.6'/%3E%3Cpath d='M16 6 L44 7 L30 26Z' fill='%23d9463f'/%3E%3Cpath d='M76 7 L104 6 L90 26Z' fill='%23ffb21a'/%3E%3Cpath d='M136 6 L164 7 L150 26Z' fill='%232f6bd1'/%3E%3Cpath d='M196 7 L224 6 L210 26Z' fill='%2314a876'/%3E%3C/svg%3E") repeat-x;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.45));
}

.tr-bulbs {
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  z-index: 3;
  background: radial-gradient(circle at 60px 3px, #fff3c4 0 2.4px, transparent 3.2px) 0 0 / 120px 6px repeat-x;
  filter: drop-shadow(0 0 4px var(--bulb-glow));
  animation: tr-chase 1.2s steps(2) infinite;
}

@keyframes tr-chase {
  from { background-position: 0 0; }
  to { background-position: 120px 0; }
}

.tr-road {
  position: absolute;
  inset: 22px 0 0 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 3px, transparent 3px 11px),
    linear-gradient(180deg, var(--road-top) 0%, var(--asphalt-2) 28%, var(--asphalt) 100%);
  border-top: 3px solid var(--road-edge);
  box-shadow: inset 0 10px 18px -8px rgba(0, 0, 0, 0.8);
}

.tr-startbox {
  position: absolute;
  inset: 0 auto 0 0;
  width: 320px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.1));
}

.tr-startline {
  position: absolute;
  top: 58px;
  bottom: 0;
  left: 320px;
  width: 5px;
  background: rgba(244, 241, 232, 0.8);
}

.tr-finish {
  position: absolute;
  top: 58px;
  bottom: 0;
  left: 1800px;
  width: 18px;
  background: conic-gradient(#f4f1e8 25%, #111 0 50%, #f4f1e8 0 75%, #111 0) 0 0 / 18px 18px;
  opacity: 0.9;
}

.tr-finish-flag {
  position: absolute;
  top: 26px;
  left: 1797px;
  font-size: 28px;
  color: #f4f1e8;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
}

.tr-laneline {
  position: absolute;
  left: 320px;
  right: 120px;
  height: 0;
  border-top: 2px dashed rgba(244, 241, 232, 0.14);
}

.tr-lanes {
  position: absolute;
  inset: 0;
}

/* ---------- Trucks ---------- */

.tr-truck {
  position: absolute;
  top: 0;
  left: 0;
  width: 120px;
  height: 70px;
  transform-origin: 0 0;
  will-change: transform;
}

.tr-truck.is-parking { transition: transform 1.5s cubic-bezier(0.15, 0.7, 0.25, 1); }

.tr-truck svg { display: block; width: 120px; height: 70px; overflow: visible; }

.tk-cab { fill: var(--c); }
.tk-cab-dark { fill: var(--c); filter: brightness(0.72); }
.tk-wheel { transform-box: fill-box; transform-origin: center; }

.tr-truck.is-turbo::before {
  content: "";
  position: absolute;
  top: 18px;
  right: 100%;
  width: 90px;
  height: 34px;
  background: repeating-linear-gradient(180deg, transparent 0 5px, rgba(255, 210, 120, 0.85) 5px 7px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
  mask-image: linear-gradient(90deg, transparent, #000);
  animation: tr-speed 0.25s linear infinite;
}

@keyframes tr-speed {
  from { transform: translateX(10px); opacity: 0.6; }
  to { transform: translateX(-10px); opacity: 1; }
}

.tr-truck.is-turbo .tk-exhaust-fire { opacity: 1; }
.tk-exhaust-fire { opacity: 0; transition: opacity 0.2s; }

.tr-truck.is-pech svg { animation: tr-shake 0.18s linear infinite; }

.tr-truck.is-pech::after {
  content: "";
  position: absolute;
  left: 44px;
  top: -34px;
  width: 50px;
  height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 60%, rgba(70, 70, 70, 0.9) 0 12px, transparent 13px),
    radial-gradient(circle at 60% 40%, rgba(90, 90, 90, 0.85) 0 14px, transparent 15px),
    radial-gradient(circle at 75% 70%, rgba(60, 60, 60, 0.8) 0 10px, transparent 11px);
  animation: tr-smoke 0.9s ease-out infinite;
}

@keyframes tr-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-1px, 1px) rotate(-1deg); }
  75% { transform: translate(1px, -1px) rotate(1deg); }
}

@keyframes tr-smoke {
  from { transform: translateY(8px) scale(0.6); opacity: 0.9; }
  to { transform: translateY(-14px) scale(1.2); opacity: 0; }
}

.tr-truck__trophy {
  position: absolute;
  left: 76px;
  top: -34px;
  font-size: 28px;
  color: #ffd24a;
  filter: drop-shadow(0 0 8px rgba(255, 210, 74, 0.8));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
}

.tr-truck.is-winner .tr-truck__trophy { opacity: 1; transform: none; }

.tr-label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 162px;
  height: 18px;
  padding: 0 7px 0 2px;
  border-radius: 5px;
  font: 600 13px/18px var(--font-body);
  white-space: nowrap;
  color: #fff;
  background: rgba(10, 11, 13, 0.8);
  will-change: transform;
}

.tr-label.is-parking { transition: transform 1.5s cubic-bezier(0.15, 0.7, 0.25, 1); }
.tr-label.is-hidden { display: none; } /* meer dan 10 trucks: alleen top 10 een bordje */

.tr-canvas { position: absolute; inset: 0; z-index: 5; pointer-events: none; }

.tr-label span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tr-label b {
  flex: none;
  min-width: 14px;
  padding: 0 2px;
  border-radius: 3px;
  font: 700 11px/14px var(--font-display);
  text-align: center;
  color: #111;
  background: var(--c);
}

/* ---------- Confetti bij de uitslag (hele beeld) ---------- */

.tr-confetti {
  position: absolute;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}

.tr-confetti i {
  position: absolute;
  top: 0;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: tr-fall linear both;
}

@keyframes tr-fall {
  from { transform: translate3d(0, -20px, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  to { transform: translate3d(var(--dx), 1100px, 0) rotate(var(--rot)); opacity: 0; }
}

/* ---------- Stand tijdens de race (links) ---------- */

.tr-standings {
  --row: 40px;
  position: absolute;
  left: 32px;
  bottom: 236px;
  width: 340px;
  padding: 12px 12px 14px;
  font-family: var(--font-display);
  text-transform: uppercase;
  background:
    radial-gradient(circle, rgba(var(--accent-rgb), 0.06) 1px, transparent 1.6px) 0 0 / 5px 5px,
    linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  border: 5px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px #000, 0 18px 40px -12px rgba(0, 0, 0, 0.75);
  transform: translateX(calc(-100% - 60px));
  transition: transform 0.6s cubic-bezier(0.5, 0, 0.75, 0);
}

.tr-standings.is-visible {
  transform: translateX(0);
  transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tr-standings__head {
  padding: 0 6px 8px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--accent-dim);
}

.tr-standings__list {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
  transition: height 0.3s;
}

.tr-standings__row {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--row) - 4px);
  padding: 0 10px 0 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.tr-standings__pos {
  flex: none;
  width: 28px;
  font-size: 22px;
  font-weight: 700;
  text-align: right;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
  font-variant-numeric: tabular-nums;
}

.tr-standings__chip {
  flex: none;
  min-width: 22px;
  padding: 0 3px;
  box-sizing: border-box;
  height: 22px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  font-style: normal;
  color: #111;
  background: var(--c);
}

.tr-standings__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--paper);
}

.tr-standings__done {
  flex: none;
  font-size: 16px;
  color: var(--paper);
  opacity: 0;
  transition: opacity 0.3s;
}

.tr-standings__row.is-finished { background: rgba(var(--accent-rgb), 0.1); }
.tr-standings__row.is-finished .tr-standings__done { opacity: 1; }

/* ---------- Wachttijd tot de volgende race (onderin) ---------- */

.tr-next {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1920px;
  height: 60px;
  transform: translateY(70px);
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.tr-next.is-visible { transform: translateY(0); }

.tr-next__truck {
  --c: var(--accent);
  position: absolute;
  left: 0;
  bottom: 2px; /* wielen net op de onderrand van het beeld */
  width: 72px;
  height: 42px;
  will-change: transform;
}

.tr-next__truck svg { display: block; width: 72px; height: 42px; overflow: visible; }

.tr-next__timer {
  position: absolute;
  left: calc(100% + 10px);
  bottom: 6px;
  padding: 3px 12px;
  border-radius: 8px;
  white-space: nowrap;
  font: 600 20px/1.2 var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
  background: rgba(8, 9, 11, 0.85);
  border: 2px solid var(--panel-border);
  font-variant-numeric: tabular-nums;
}

.tr-next__timer b { font-weight: 700; color: var(--paper); text-shadow: none; }

/* Dicht bij de rechterrand: timer achter de truck. */
.tr-next__truck.is-flipped .tr-next__timer { left: auto; right: calc(100% + 10px); }

/* ---------- Thema-extra's (vorm per thema in truckrace-themes.js) ---------- */

.tr-sign__kicker i { margin-right: 8px; color: var(--accent); text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5); }

/* Confetti als icoon (spook, hartje, sneeuwvlok...) */
.tr-confetti i.is-icon {
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  font-size: var(--s, 16px);
  color: var(--col);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Vuurwerk: vonken die vanuit een punt uitwaaieren en wegzakken */
.tr-confetti i.is-spark {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--col);
  box-shadow: 0 0 8px 2px var(--col);
  animation-name: tr-burst;
  animation-timing-function: cubic-bezier(0.15, 0.7, 0.3, 1);
}

@keyframes tr-burst {
  from { transform: translate3d(0, 0, 0) scale(1.4); opacity: 0; }
  4% { opacity: 1; }
  70% { opacity: 1; }
  to { transform: translate3d(var(--dx), calc(var(--dy) + 60px), 0) scale(0.4); opacity: 0; }
}

/* Sfeerlaag over het hele beeld: sneeuw, blaadjes, hartjes, mist... Alleen zichtbaar
   zolang de baan in beeld is; daarbuiten verborgen (en zonder rendering). */
.tr-ambient {
  position: absolute;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}

.tr-ambient.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.8s ease;
}

.tr-ambient i {
  position: absolute;
  top: 0;
  left: var(--x);
  font-size: var(--s);
  color: var(--c);
  opacity: var(--o);
  animation: var(--anim) var(--d) linear var(--delay) infinite;
  will-change: transform;
}

.tr-ambient i.is-dot {
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--c);
}

.tr-ambient i.is-fog {
  top: var(--y);
  left: -700px;
  width: 640px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--c), transparent);
  filter: blur(8px);
}

@keyframes tr-amb-fall {
  from { transform: translate3d(0, -30px, 0) rotate(0); }
  to { transform: translate3d(var(--dx), 1110px, 0) rotate(var(--rot)); }
}

@keyframes tr-amb-rise {
  from { transform: translate3d(0, 1100px, 0) scale(0.6); opacity: 0; }
  15% { opacity: var(--o); }
  to { transform: translate3d(var(--dx), 0, 0) scale(1); opacity: 0; }
}

@keyframes tr-amb-twinkle {
  0%, 100% { transform: translateY(var(--y)) scale(0.3); opacity: 0; }
  50% { transform: translateY(var(--y)) scale(1); opacity: var(--o); }
}

@keyframes tr-amb-drift {
  from { transform: translateX(0); }
  to { transform: translateX(2700px); }
}
