/**
 * ambe traders — Dispatch Relay (track & support)
 * Unique layout: split hero + orbit ring + terminal form
 * + horizontal route track + boarding-pass result
 */

.page-track-relay {
  --rl-ink: #0E1F18;
  --rl-forest: #0B3D2E;
  --rl-deep: #041912;
  --rl-mid: #1A5C45;
  --rl-lime: #C8E86C;
  --rl-gold: #E8C547;
  --rl-cream: #F7F9F4;
  --rl-paper: #FFFFFF;
  --rl-muted: #5C6F64;
  --rl-line: rgba(11, 61, 46, 0.1);
  --rl-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --rl-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
  background: var(--rl-cream);
}

.page-track-relay .page-main {
  padding-top: 0;
  overflow-x: clip;
}

.a51-relay { padding-bottom: 4rem; }

/* ——— Hero ——— */
.a51-relay-hero {
  position: relative;
  padding: clamp(2.5rem, 6vw, 4rem) 0 clamp(3rem, 7vw, 4.5rem);
  color: #fff;
  overflow: hidden;
  isolation: isolate;
}

.a51-relay-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    conic-gradient(from 250deg at 75% 20%, rgba(232, 197, 71, 0.18), transparent 45%),
    linear-gradient(140deg, var(--rl-deep) 0%, var(--rl-forest) 55%, #134832 100%);
}

.a51-relay-hero-bg::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--rl-cream);
  clip-path: polygon(0 100%, 100% 100%, 100% 0, 0 75%);
}

.a51-relay-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  align-items: center;
}

.a51-relay-eyebrow {
  margin: 0 0 0.85rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(200, 232, 108, 0.9);
}

.a51-relay-eyebrow--dark {
  color: var(--rl-forest);
}

.a51-relay-hero-copy h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  max-width: 16ch;
}

.a51-relay-lede {
  margin: 0 0 1.35rem;
  max-width: 42ch;
  font-size: 1.02rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.78);
}

.a51-relay-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.a51-relay-meta li {
  min-width: 84px;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
}

.a51-relay-meta strong {
  display: block;
  font-family: var(--a51-font-display);
  font-size: 1.25rem;
  color: var(--rl-lime);
  line-height: 1.1;
}

.a51-relay-meta span {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.a51-relay-meta-live {
  background: rgba(200, 232, 108, 0.15) !important;
  border-color: rgba(200, 232, 108, 0.35) !important;
}

/* Orbit progress ring */
.a51-relay-orbit {
  position: relative;
  width: min(100%, 220px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.a51-relay-orbit-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.a51-relay-orbit-track {
  stroke: rgba(255, 255, 255, 0.15);
}

.a51-relay-orbit-fill {
  stroke: var(--rl-lime);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s var(--rl-ease);
  filter: drop-shadow(0 0 8px rgba(200, 232, 108, 0.5));
}

.a51-relay-orbit-core {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.a51-relay-orbit-core strong {
  font-family: var(--a51-font-display);
  font-size: 2rem;
  color: var(--rl-lime);
  line-height: 1;
}

.a51-relay-orbit-core span {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

/* ——— Board ——— */
.a51-relay-board {
  margin-top: -1.25rem;
  position: relative;
  z-index: 2;
}

.a51-relay-board-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* Terminal form card */
.a51-relay-terminal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.35rem;
  border-radius: 24px;
  background: var(--rl-deep);
  color: #fff;
  box-shadow: 0 20px 48px rgba(4, 25, 18, 0.28);
}

.a51-relay-terminal-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.a51-relay-terminal-dot {
  width: 10px;
  height: 10px;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: var(--rl-lime);
  box-shadow: 0 0 0 4px rgba(200, 232, 108, 0.25);
  animation: a51RlPulse 2s ease-in-out infinite;
}

@keyframes a51RlPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.a51-relay-terminal-head h2 {
  margin: 0 0 0.2rem;
  font-size: 1.1rem;
  color: #fff;
}

.a51-relay-terminal-head p {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
}

.a51-relay-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.a51-relay-field span {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(200, 232, 108, 0.85);
}

.a51-relay-field input {
  padding: 0.75rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.a51-relay-field input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.a51-relay-field input:focus {
  border-color: var(--rl-lime);
  box-shadow: 0 0 0 3px rgba(200, 232, 108, 0.2);
}

.a51-relay-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-top: 0.25rem;
}

.a51-relay-reset {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--rl-lime);
}

.a51-relay-reset:hover { color: #fff; }

.a51-relay-desk {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}

.a51-relay-desk > span:first-child {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rl-lime);
}

.a51-relay-desk a {
  color: rgba(255, 255, 255, 0.85);
}

.a51-relay-desk a:hover { color: var(--rl-lime); }

.a51-relay-desk small {
  color: rgba(255, 255, 255, 0.5);
}

/* Horizontal route track */
.a51-relay-track {
  padding: 1.35rem;
  border-radius: 24px;
  background: #fff;
  border: 1px solid var(--rl-line);
  box-shadow: 0 16px 40px rgba(11, 61, 46, 0.07);
}

.a51-relay-track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.a51-relay-track-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.a51-relay-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--rl-cream);
  color: var(--rl-muted);
}

.a51-relay-pill--is-found {
  background: rgba(200, 232, 108, 0.35);
  color: var(--rl-forest);
}

.a51-relay-pill--is-miss {
  background: rgba(232, 100, 80, 0.15);
  color: #b33a2a;
}

.a51-relay-pill--is-idle {
  background: rgba(11, 61, 46, 0.08);
  color: var(--rl-muted);
}

.a51-relay-track-line {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding-top: 1.5rem;
}

.a51-relay-track-rail {
  position: absolute;
  top: 2.15rem;
  left: 12%;
  right: 12%;
  height: 4px;
  border-radius: 4px;
  background: var(--rl-cream);
  overflow: hidden;
}

.a51-relay-track-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--rl-forest), var(--rl-lime));
  border-radius: 4px;
  transition: width 1s var(--rl-ease);
}

.a51-relay-track-line.is-found .a51-relay-track-fill {
  width: calc(var(--relay-pct, 0) * 1%);
}

.a51-relay-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  z-index: 1;
}

.a51-relay-node-code {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-family: ui-monospace, monospace;
  color: var(--rl-muted);
}

.a51-relay-node-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--rl-line);
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.3s var(--rl-snap);
}

.a51-relay-node-copy strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--rl-ink);
}

.a51-relay-node-copy span {
  display: block;
  font-size: 0.72rem;
  color: var(--rl-muted);
}

.a51-relay-node-copy small {
  display: block;
  font-size: 0.65rem;
  color: var(--rl-muted);
  opacity: 0.8;
}

.a51-relay-node.is-done .a51-relay-node-dot {
  background: var(--rl-lime);
  border-color: var(--rl-forest);
}

.a51-relay-node.is-current .a51-relay-node-dot {
  background: var(--rl-forest);
  border-color: var(--rl-lime);
  box-shadow: 0 0 0 6px rgba(200, 232, 108, 0.35);
  transform: scale(1.15);
}

.a51-relay-node.is-current .a51-relay-node-code { color: var(--rl-forest); }

.a51-relay-node.is-muted .a51-relay-node-dot {
  opacity: 0.5;
}

.a51-relay-node.is-muted .a51-relay-node-copy {
  opacity: 0.45;
}

/* ——— Result area ——— */
.a51-relay-result {
  margin-bottom: 1.5rem;
}

/* Boarding pass */
.a51-relay-pass {
  display: grid;
  grid-template-columns: auto 1fr;
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--rl-line);
  box-shadow: 0 18px 44px rgba(11, 61, 46, 0.1);
}

.a51-relay-pass-perforation {
  width: 12px;
  background:
    repeating-linear-gradient(
      180deg,
      var(--rl-cream) 0,
      var(--rl-cream) 6px,
      transparent 6px,
      transparent 12px
    );
  border-right: 2px dashed var(--rl-line);
}

.a51-relay-pass-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1.25rem 1rem;
  min-width: 88px;
  background: linear-gradient(180deg, var(--rl-forest), var(--rl-mid));
  color: #fff;
  text-align: center;
}

.a51-relay-pass-code {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--rl-lime);
}

.a51-relay-pass-stub strong {
  font-family: var(--a51-font-display);
  font-size: 1.75rem;
  color: var(--rl-lime);
  line-height: 1;
}

.a51-relay-pass-stub small {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.a51-relay-pass-body {
  padding: 1.35rem 1.5rem;
  min-width: 0;
}

.a51-relay-pass-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}

.a51-relay-pass-head h2 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.1rem, 2.5vw, 1.45rem);
  word-break: break-all;
}

.a51-relay-pass-status {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--rl-mid);
}

.a51-relay-pass-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin: 0 0 1.15rem;
}

.a51-relay-pass-grid div {
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: var(--rl-cream);
}

.a51-relay-pass-grid dt {
  margin: 0 0 0.2rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rl-muted);
}

.a51-relay-pass-grid dd {
  margin: 0;
  font-weight: 800;
  color: var(--rl-ink);
  font-size: 0.95rem;
}

.a51-relay-pass-wide {
  grid-column: 1 / -1;
}

.a51-relay-pass-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.a51-relay-pass-links a:not(.a51-btn) {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--rl-forest);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Alert / waiting */
.a51-relay-alert,
.a51-relay-waiting {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem;
  align-items: start;
  padding: 1.5rem 1.75rem;
  border-radius: 22px;
  background: #fff;
  border: 1px solid var(--rl-line);
  box-shadow: 0 12px 32px rgba(11, 61, 46, 0.06);
}

.a51-relay-alert-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(232, 100, 80, 0.12);
  color: #c0392b;
  font-size: 1.5rem;
  font-weight: 800;
}

.a51-relay-alert h2,
.a51-relay-waiting h2 {
  margin: 0 0 0.45rem;
  font-size: 1.2rem;
}

.a51-relay-alert p,
.a51-relay-waiting p {
  margin: 0 0 1rem;
  color: var(--rl-muted);
  line-height: 1.55;
}

.a51-relay-waiting-belt {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.5rem;
}

.a51-relay-waiting-belt span {
  width: 48px;
  height: 8px;
  border-radius: 4px;
  background: var(--rl-cream);
  animation: a51RlBelt 1.4s ease-in-out infinite;
}

.a51-relay-waiting-belt span:nth-child(2) { animation-delay: 0.15s; }
.a51-relay-waiting-belt span:nth-child(3) { animation-delay: 0.3s; }
.a51-relay-waiting-belt span:nth-child(4) { animation-delay: 0.45s; }
.a51-relay-waiting-belt span:nth-child(5) { animation-delay: 0.6s; }

@keyframes a51RlBelt {
  0%, 100% { background: var(--rl-cream); transform: scaleX(0.6); }
  50% { background: var(--rl-lime); transform: scaleX(1); }
}

.a51-relay-tips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.a51-relay-tips li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.88rem;
  color: var(--rl-muted);
}

.a51-relay-tips li span {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--rl-cream);
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--rl-forest);
  font-family: ui-monospace, monospace;
}

/* Shortcuts grid */
.a51-relay-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.a51-relay-shortcut {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1rem;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--rl-line);
  transition: transform 0.25s var(--rl-snap), border-color 0.2s, box-shadow 0.25s;
}

.a51-relay-shortcut:hover {
  transform: translateY(-4px);
  border-color: var(--rl-lime);
  box-shadow: 0 14px 32px rgba(11, 61, 46, 0.1);
}

.a51-relay-shortcut-icon {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  font-family: ui-monospace, monospace;
  color: var(--rl-forest);
  opacity: 0.55;
}

.a51-relay-shortcut strong {
  font-size: 0.92rem;
  color: var(--rl-ink);
}

.a51-relay-shortcut small {
  font-size: 0.75rem;
  color: var(--rl-muted);
}

/* ——— Responsive ——— */
@media (max-width: 960px) {
  .a51-relay-hero-grid { grid-template-columns: 1fr; }
  .a51-relay-orbit { max-width: 180px; }
  .a51-relay-board-grid { grid-template-columns: 1fr; }
  .a51-relay-track-line {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 1.5rem;
  }
  .a51-relay-track-rail { display: none; }
  .a51-relay-pass { grid-template-columns: 1fr; }
  .a51-relay-pass-perforation { display: none; }
  .a51-relay-pass-stub {
    flex-direction: row;
    justify-content: flex-start;
    gap: 1rem;
    min-width: 0;
  }
  .a51-relay-pass-grid { grid-template-columns: 1fr 1fr; }
  .a51-relay-shortcuts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .a51-relay-track-line { grid-template-columns: 1fr; }
  .a51-relay-pass-grid { grid-template-columns: 1fr; }
  .a51-relay-shortcuts { grid-template-columns: 1fr; }
  .a51-relay-alert,
  .a51-relay-waiting { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .a51-relay-terminal-dot,
  .a51-relay-waiting-belt span,
  .a51-relay-orbit-fill { animation: none !important; transition: none !important; }
}
