/*
 * All Aboard — train console (bottom centre).
 *
 *   [ ◎ follow ]  ┌ speed gauge ┐  ║ throttle ║ [ GO ]
 *   [ ◀ REV    ]  │   TOOT  ●   │  ║  lever   ║ [STOP]
 *
 * A teal cab dashboard with brass rivets and inked toon outlines, matching the
 * stations. Left thumb: follow / reverse. Middle: the big press-and-hold TOOT.
 * Right hand: slide the lever up to go (or tap GO), STOP brakes.
 * Loaded after all-aboard.css, so it overrides the old right-hand stack.
 */

.aa-bar--console {
  --c-horn: 5.6rem;
  --c-btn: 3.1rem;
  --c-thr-h: 7.4rem;
  left: 0;
  right: 0;
  justify-content: center;
  align-items: flex-end;
  min-height: 0;
  padding: 0 0.6rem max(0.6rem, env(safe-area-inset-bottom));
}

.aa-console {
  --aa-ink: #263238;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem 0.65rem;
  border-radius: 1.7rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0 0.5rem, transparent 0.55rem),
    linear-gradient(180deg, #2a9d8f, #1f7a6f);
  border: 4px solid var(--aa-ink);
  box-shadow:
    inset 0 -6px 0 rgba(38, 50, 56, 0.25),
    0 6px 0 rgba(38, 50, 56, 0.35);
  pointer-events: auto;
  touch-action: none;
}
/* wood trim along the top edge, like the station eaves */
.aa-console::before {
  content: "";
  position: absolute;
  left: 1.3rem;
  right: 1.3rem;
  top: -0.6rem;
  height: 0.55rem;
  border-radius: 0.4rem 0.4rem 0 0;
  background: repeating-linear-gradient(90deg, #d7a86e 0 1.1rem, #c58b52 1.1rem 1.2rem);
  border: 3px solid var(--aa-ink);
  border-bottom: 0;
  z-index: -1;
}
.aa-console__rivet {
  position: absolute;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #ffd54f;
  border: 2px solid var(--aa-ink);
  pointer-events: none;
}
.aa-console__rivet.is-tl { top: 0.45rem; left: 0.5rem; }
.aa-console__rivet.is-tr { top: 0.45rem; right: 0.5rem; }
.aa-console__rivet.is-bl { bottom: 0.45rem; left: 0.5rem; }
.aa-console__rivet.is-br { bottom: 0.45rem; right: 0.5rem; }

.aa-console .aa-readouts {
  display: none;
}

/* ── left: follow + reverse ── */
.aa-console__side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding-left: 0.2rem;
}

.aa-cbtn {
  appearance: none;
  display: grid;
  place-items: center;
  width: var(--c-btn);
  min-width: 0;
  height: var(--c-btn);
  padding: 0;
  border: 4px solid var(--aa-ink);
  border-radius: 1rem;
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(38, 50, 56, 0.5);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.18),
    0 4px 0 var(--aa-ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.aa-cbtn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    0 1px 0 var(--aa-ink);
}
.aa-cbtn:disabled {
  opacity: 0.55;
  filter: saturate(0.6);
  cursor: default;
}

.aa-cbtn--follow {
  border-radius: 50%;
  background: #4db6ac;
}
.aa-cbtn--follow .aa-follow-icon {
  width: 1.7rem;
  height: 1.7rem;
}
/* looking around? it pulses orange: tap to jump back to the train */
.aa-cbtn--follow.is-free {
  background: #ff7043;
  animation: aa-follow-pulse 1.1s ease-in-out infinite;
}

.aa-cbtn--rev {
  grid-auto-flow: row;
  gap: 0;
  height: calc(var(--c-btn) + 0.4rem);
  background: #5c6bc0;
  font-size: 0.78rem;
}
.aa-cbtn--rev svg {
  width: 1.35rem;
  height: 1.35rem;
  margin-bottom: -0.1rem;
}
.aa-cbtn--rev.aa-btn--reverse-on {
  background: #ffd54f;
  color: var(--aa-ink);
  text-shadow: none;
}

/* ── middle: speed gauge + the big TOOT ── */
.aa-console__middle {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.aa-gauge {
  width: 3.7rem;
  height: 2.1rem;
  margin: -1.65rem 0 0.15rem;
  padding: 0.15rem 0.25rem 0;
  border-radius: 2.2rem 2.2rem 0.5rem 0.5rem;
  background: #1f7a6f;
  border: 3px solid var(--aa-ink);
  border-bottom: 0;
  pointer-events: none;
}
.aa-gauge svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.aa-gauge__needle {
  transform-origin: 32px 32px;
  transform: rotate(-80deg);
  transition: transform 0.25s ease-out;
}

.aa-console .aa-horn {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd54f, #ffa000 70%);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(38, 50, 56, 0.45);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  width: var(--c-horn);
  height: var(--c-horn);
  border: 5px solid #fff;
  box-shadow:
    0 0 0 4px var(--aa-ink),
    0 6px 0 4px var(--aa-ink);
}
.aa-console .aa-horn__icon {
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: -0.2rem;
  overflow: visible;
}
.aa-console .aa-horn__steam {
  opacity: 0;
}
.aa-console .aa-horn__label {
  line-height: 1;
}
.aa-console .aa-horn.is-down {
  transform: translateY(4px) scale(0.95);
  box-shadow:
    0 0 0 4px var(--aa-ink),
    0 2px 0 4px var(--aa-ink);
}
.aa-console .aa-horn.is-hint:not(.is-down) {
  animation: aa-console-horn-hint 0.9s ease-in-out infinite;
}
@keyframes aa-console-horn-hint {
  50% {
    transform: scale(1.08);
    box-shadow:
      0 0 0 4px var(--aa-ink),
      0 6px 0 4px var(--aa-ink),
      0 0 0 14px rgba(255, 213, 79, 0.65);
  }
}

/* ── right: throttle lever + GO / STOP ── */
.aa-console__drive {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.35rem;
  border-radius: 1.2rem;
  background: rgba(38, 50, 56, 0.22);
  box-shadow: inset 0 3px 0 rgba(38, 50, 56, 0.25);
}
.aa-console .aa-throttle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: var(--c-thr-h);
  touch-action: none;
  user-select: none;
}
.aa-console .aa-throttle--disabled {
  opacity: 0.45;
}
.aa-console .aa-throttle__track {
  position: relative;
  height: 100%;
  overflow: hidden;
  width: 2.5rem;
  border: 4px solid var(--aa-ink);
  border-radius: 1.3rem;
  background:
    repeating-linear-gradient(180deg, transparent 0 0.85rem, rgba(38, 50, 56, 0.18) 0.85rem 0.95rem),
    #fffaf0;
  box-shadow: inset 0 3px 0 rgba(38, 50, 56, 0.2);
}
.aa-console .aa-throttle--go .aa-throttle__track {
  background:
    repeating-linear-gradient(180deg, transparent 0 0.85rem, rgba(38, 50, 56, 0.18) 0.85rem 0.95rem),
    #e8f5e9;
}
.aa-console .aa-throttle__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  background: #43a047;
  border-radius: 0 0 1rem 1rem;
  pointer-events: none;
}
.aa-console .aa-throttle--stop .aa-throttle__fill {
  background: #e53935;
}
.aa-console .aa-throttle__knob {
  appearance: none;
  position: absolute;
  left: 50%;
  bottom: 4px;
  z-index: 2;
  padding: 0;
  border-radius: 999px;
  cursor: grab;
  touch-action: none;
  width: 2.15rem;
  height: 2.15rem;
  margin-left: -1.075rem;
  border: 4px solid var(--aa-ink);
  background: radial-gradient(circle at 35% 30%, #fff59d, #ffca28 60%, #ffa000);
  box-shadow: 0 3px 0 var(--aa-ink);
}
.aa-console__gostop {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.aa-cbtn--go,
.aa-cbtn--stop {
  width: 3.7rem;
  height: calc((var(--c-thr-h) - 0.5rem) / 2);
  border-radius: 1.1rem;
  font-size: 1.05rem;
}
.aa-cbtn--go {
  background: #43a047;
}
.aa-cbtn--stop {
  background: #e53935;
  font-size: 0.95rem;
}

/* Station card sits just above the console */
.aa-station-menu {
  left: 50% !important;
  right: auto !important;
  box-sizing: border-box;
  width: min(34rem, calc(100% - 1.2rem));
  transform: translateX(-50%) !important;
  /* --console-top is measured by game.js (console height + its wood trim) */
  bottom: calc(var(--console-top, 10rem) + 0.5rem) !important;
  padding-right: 0.65rem;
}

/* Small phones */
@media (max-width: 370px) {
  .aa-bar--console {
    --c-horn: 4.9rem;
    --c-btn: 2.8rem;
    --c-thr-h: 6.6rem;
  }
  .aa-console {
    gap: 0.45rem;
    padding: 0.55rem 0.6rem 0.6rem;
  }
  .aa-cbtn--go,
  .aa-cbtn--stop {
    width: 3.3rem;
  }
}

/* Phone on its side: a slimmer console */
@media (max-height: 500px) and (orientation: landscape) {
  .aa-bar--console {
    --c-horn: 4.4rem;
    --c-btn: 2.5rem;
    --c-thr-h: 5.4rem;
    padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  }
  .aa-console {
    gap: 0.5rem;
    padding: 0.4rem 0.6rem 0.45rem;
  }
  .aa-console__side {
    flex-direction: column;
    gap: 0.3rem;
  }
  .aa-cbtn--rev {
    height: var(--c-btn);
  }
  .aa-cbtn--rev svg {
    width: 1.05rem;
    height: 1.05rem;
  }
  .aa-cbtn--follow .aa-follow-icon {
    width: 1.4rem;
    height: 1.4rem;
  }
  .aa-gauge {
    width: 3.1rem;
    height: 1.75rem;
    margin-top: -1.3rem;
  }
  .aa-console .aa-horn__icon {
    width: 1.9rem;
    height: 1.9rem;
  }
  .aa-console .aa-horn {
    font-size: 0.85rem;
  }
  .aa-console .aa-throttle__knob {
    width: 1.8rem;
    height: 1.8rem;
    margin-left: -0.9rem;
  }
  .aa-cbtn--go,
  .aa-cbtn--stop {
    width: 3.2rem;
    font-size: 0.9rem;
  }
  .aa-cbtn--stop {
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aa-cbtn--follow.is-free,
  .aa-console .aa-horn.is-hint:not(.is-down) {
    animation: none;
  }
  .aa-gauge__needle {
    transition: none;
  }
}
