/* ============================================================
   Track Animation — Bobblehead Runners
   ============================================================ */

.running-track {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 200px;
    margin: 20px auto 8px;
    border: 3px solid rgba(128, 128, 128, .2);
    border-radius: 100px;
    overflow: visible;
}

.running-track__lane {
    position: absolute;
    inset: 10px;
    border: 2px dashed rgba(128, 128, 128, .15);
    border-radius: 90px;
}

/* ── Runner container ──────────────────────────────────────── */
.track-runner {
    position: absolute;
    width: 40px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: run-around var(--duration, 15s) linear infinite;
    animation-delay: var(--delay, 0s);
    will-change: top, left, transform;
    z-index: 2;
}

/* ── Head ──────────────────────────────────────────────────── */
.track-runner__head {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid;
    animation: head-bobble 0.4s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
    flex-shrink: 0;
}

.track-runner__head--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .8rem;
    color: #fff;
    animation: head-bobble 0.4s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    flex-shrink: 0;
}

/* ── Body / torso (tiny line) ──────────────────────────────── */
.track-runner__body {
    width: 3px;
    height: 8px;
    background: currentColor;
    border-radius: 2px;
    margin-top: 1px;
    opacity: .7;
}

/* ── Legs ──────────────────────────────────────────────────── */
.track-runner__legs {
    display: flex;
    gap: 4px;
    margin-top: 1px;
}

.track-runner__leg {
    width: 3px;
    height: 16px;
    background: currentColor;
    border-radius: 2px;
    transform-origin: top center;
    opacity: .8;
}

.track-runner__leg--left {
    animation: leg-run-left 0.3s ease-in-out infinite;
}

.track-runner__leg--right {
    animation: leg-run-right 0.3s ease-in-out infinite;
}

/* ── Name tag ──────────────────────────────────────────────── */
.track-runner__name {
    font-size: .55rem;
    font-weight: 700;
    white-space: nowrap;
    margin-top: 3px;
    opacity: .75;
    letter-spacing: .02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

/* ── Section label ─────────────────────────────────────────── */
.running-track__label {
    text-align: center;
    font-size: .65rem;
    font-weight: 600;
    opacity: .4;
    margin-top: 4px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

/* ============================================================
   Keyframes
   ============================================================ */

/* Oval path — goes clockwise starting from left-middle */
@keyframes run-around {
    0%   { top: 50%;   left: 0%;   transform: translateX(-50%) translateY(-50%); }
    12%  { top: 15%;   left: 20%;  transform: translateX(-50%) translateY(-50%); }
    25%  { top: 0%;    left: 50%;  transform: translateX(-50%) translateY(-50%); }
    38%  { top: 15%;   left: 80%;  transform: translateX(-50%) translateY(-50%); }
    50%  { top: 50%;   left: 100%; transform: translateX(-50%) translateY(-50%); }
    62%  { top: 85%;   left: 80%;  transform: translateX(-50%) translateY(-50%); }
    75%  { top: 100%;  left: 50%;  transform: translateX(-50%) translateY(-50%); }
    88%  { top: 85%;   left: 20%;  transform: translateX(-50%) translateY(-50%); }
    100% { top: 50%;   left: 0%;   transform: translateX(-50%) translateY(-50%); }
}

/* Head bobs up and down while running */
@keyframes head-bobble {
    0%   { transform: translateY(0px)   rotate(-3deg); }
    25%  { transform: translateY(-3px)  rotate(0deg);  }
    50%  { transform: translateY(0px)   rotate(3deg);  }
    75%  { transform: translateY(-2px)  rotate(0deg);  }
    100% { transform: translateY(0px)   rotate(-3deg); }
}

/* Alternating leg swing */
@keyframes leg-run-left {
    0%   { transform: rotate(-22deg); }
    50%  { transform: rotate(22deg);  }
    100% { transform: rotate(-22deg); }
}

@keyframes leg-run-right {
    0%   { transform: rotate(22deg);  }
    50%  { transform: rotate(-22deg); }
    100% { transform: rotate(22deg);  }
}

/* Entrance fade-in for the whole track block */
@keyframes track-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.running-track {
    animation: track-fade-in .6s ease-out both;
}

/* ── Track Speech Bubbles ──────────────────────────────────── */
.track-bubble {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: rgba(255, 255, 255, .9);
    color: #333;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: .55rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.track-bubble.visible {
    opacity: 1;
}

.track-bubble::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid rgba(255, 255, 255, .9);
}

@media (max-width: 640px) {
  .running-track {
    height: 140px;
  }
  .track-runner__head {
    width: 28px !important;
    height: 28px !important;
  }
  .track-runner__name {
    font-size: .5rem;
  }
  .track-runner__body {
    height: 4px;
  }
  .track-runner__leg {
    height: 10px;
  }
  .track-bubble {
    font-size: .5rem;
    padding: 2px 6px;
  }
}
