/* ==========================================================================
 *  guide.css - the guidance bar and the full-screen camera view.
 * ========================================================================== */

/* ---- "guide me" button inside a marker popup ---- */

.popup-go {
  display: block;
  width: 100%;
  margin-top: 9px;
  padding: 7px 12px;
  font: 800 12px/1 inherit;
  color: #fff;
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--pink-deep), var(--violet));
  box-shadow: 0 3px 12px rgba(150, 90, 200, .45);
  transition: transform .14s, box-shadow .14s;
}

.popup-go:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(150, 90, 200, .6);
}

/* ==========================================================================
 *  guidance bar, pinned top-centre so it clears the panel on both layouts
 * ========================================================================== */

.guide-bar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 28px);
  padding: 10px 17px;

  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, .6);
  background: linear-gradient(150deg,
                rgba(255, 255, 255, .72),
                rgba(253, 238, 245, .58));
  box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: blur(20px) saturate(175%);
  backdrop-filter: blur(20px) saturate(175%);
}

.guide-bar[hidden] { display: none; }

.guide-bar__text { min-width: 0; }

.guide-bar__name {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-bar__dist {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 1px;
}

.guide-bar.is-arrived .guide-bar__dist { color: var(--green); }

/* ==========================================================================
 *  camera view
 * ========================================================================== */

/* The map keeps the upper part of the screen and the camera sits underneath,
   so you can watch the arrow and the dashed line at the same time.
   Change --ar-height alone to re-balance the split. */
:root {
  --ar-height: 52%;

  /* Vertical room reserved at the bottom of the camera panel for the name,
     distance and hint. The arrow is kept clear of it. */
  --ar-info-space: 140px;
}

.ar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ar-height);
  z-index: 2000;
  background: #14101a;
  overflow: hidden;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -10px 30px rgba(20, 10, 30, .45);
}

.ar[hidden] { display: none; }

/* While the camera is open, shrink the map to the upper slice and hide the
   panel so nothing covers either half. The guidance bar stays at the top,
   over the map, where it now belongs. */
body.is-ar #map { bottom: var(--ar-height); }

body.is-ar .side { display: none; }

/* In landscape the split goes side by side instead: map left, camera right,
   which keeps both halves usable on a short viewport. */
@media (orientation: landscape) and (max-height: 560px) {
  .ar {
    top: 0;
    left: auto;
    width: 48%;
    height: 100%;
    border-radius: 20px 0 0 20px;
    box-shadow: -10px 0 30px rgba(20, 10, 30, .45);
  }
  body.is-ar #map { bottom: 0; right: 48%; }
  body.is-ar .guide-bar { left: 26%; }
}

.ar__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shown instead of the feed when the camera is unavailable or refused. */
.ar.is-nocam .ar__video { display: none; }

.ar.is-nocam {
  background: radial-gradient(circle at 50% 38%, #3b2a4d 0%, #17121f 70%);
}

/* Darkens the feed so the white arrow and text stay readable. */
.ar__veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
                rgba(10, 8, 15, .55) 0%,
                rgba(10, 8, 15, .15) 35%,
                rgba(10, 8, 15, .65) 100%);
  pointer-events: none;
}

.ar__close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: 42px;
  height: 42px;
  font-size: 19px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(20, 16, 26, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ---- the arrow ---- */

/* The arrow is centred in the space ABOVE the readouts rather than in the
   whole panel, so it can never sit on top of the name and distance. */
.ar__stage {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--ar-info-space);
  display: grid;
  place-items: center;
  pointer-events: none;
}

/* Tilting the arrow onto the ground plane is what sells the AR effect: it
   reads as painted on the street ahead instead of stuck to the glass.
   guide.js sets only --bearing; the tilt is composed here. */
.ar__arrow {
  --bearing: 0deg;
  --tilt: 58deg;
  --arrow-fill: url(#ar-grad);

  width: min(38vw, 21vh, 190px);
  height: min(38vw, 21vh, 190px);
  transform: perspective(560px) rotateX(var(--tilt)) rotate(var(--bearing));
  transition: transform .18s linear, opacity .2s;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .7))
          drop-shadow(0 0 22px rgba(150, 230, 255, .55));
}

.ar__arrow path {
  fill: var(--arrow-fill);
  fill-opacity: .92;
  stroke: rgba(255, 255, 255, .95);
  stroke-width: 4;
  stroke-linejoin: round;
  transition: fill .25s;
}

.ar.is-near    .ar__arrow { --arrow-fill: #ffd166; }
.ar.is-arrived .ar__arrow { --arrow-fill: var(--green); }

/* Holographic rings on the ground beneath the arrow, sharing its tilt. */
.ar__ring {
  position: absolute;
  width: min(46vw, 25vh, 230px);
  height: min(46vw, 25vh, 230px);
  border-radius: 50%;
  border: 2px solid rgba(158, 246, 255, .5);
  transform: perspective(560px) rotateX(var(--tilt, 58deg));
  animation: arRing 3s ease-out infinite;
  pointer-events: none;
}

.ar__ring--wide { animation-delay: 1.5s; }

@keyframes arRing {
  0%   { opacity: .0; transform: perspective(560px) rotateX(58deg) scale(.55); }
  35%  { opacity: .75; }
  100% { opacity: 0;  transform: perspective(560px) rotateX(58deg) scale(1.25); }
}

/* On arrival the bearing means nothing, so stop pointing and pulse flat on. */
.ar.is-arrived .ar__arrow {
  transform: perspective(560px) rotateX(0deg);
  animation: arArrived 1.4s ease-in-out infinite;
}

@keyframes arArrived {
  50% { transform: perspective(560px) rotateX(0deg) scale(1.12); }
}

/* ---- HUD chrome ---- */

/* ---- 3D layer ---- */

/* Transparent WebGL canvas between the camera feed and the readouts. */
.ar__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Once real meshes are rendering, the flat SVG arrow and its CSS rings are
   redundant - hide them rather than double up. */
.ar.is-3d .ar__arrow,
.ar.is-3d .ar__ring { display: none; }

/* Very faint scanlines over the feed. */
.ar__scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(158, 246, 255, .05) 0px,
    rgba(158, 246, 255, .05) 1px,
    transparent 1px,
    transparent 4px
  );
}

/* ---- readouts ---- */

.ar__info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(26px, env(safe-area-inset-bottom));
  padding: 0 20px;
  text-align: center;
  color: #fff;
  pointer-events: none;
}

/* Target name as a translucent HUD chip rather than loose text. */
.ar__name {
  display: inline-block;
  padding: 5px 13px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #eafcff;
  border: 1px solid rgba(158, 246, 255, .45);
  border-radius: 999px;
  background: rgba(10, 26, 38, .45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .9);
}

.ar__name:empty { display: none; }

.ar__dist {
  font-size: clamp(28px, 5.5vh, 42px);
  font-weight: 800;
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;   /* digits stop jittering as you walk */
  margin-top: 9px;
  color: #fff;
  text-shadow: 0 0 18px rgba(158, 246, 255, .75),
               0 3px 16px rgba(0, 0, 0, .9);
}

/* thin glowing rule under the distance */
.ar__dist::after {
  content: "";
  display: block;
  width: 78px;
  height: 2px;
  margin: 7px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(158, 246, 255, .95), transparent);
}

.ar.is-arrived .ar__dist {
  color: var(--green);
  text-shadow: 0 0 20px rgba(63, 191, 127, .8), 0 3px 16px rgba(0, 0, 0, .9);
}

.ar__hint {
  font: 600 11px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: .3px;
  color: #b8ecf5;
  margin-top: 9px;
  min-height: 15px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .9);
}

@media (prefers-reduced-motion: reduce) {
  .ar__arrow { transition: none; }
  .ar.is-arrived .ar__arrow,
  .ar__ring { animation: none; }
  .ar__ring { opacity: .35; }
  .popup-go { transition: none; }
}
