/* MSU-IIT Way Finder — visual system
   Identity: maroon & gold, campus-signage micro-labels, a single confident
   route line. System typography (works fully offline, no font downloads). */
:root {
  --maroon: #7a1f2b;
  --maroon-d: #5c141f;
  --gold: #e0a82e;
  --gold-d: #c8901c;
  --cream: #f5f0e8;
  --ink: #241a1c;
  --muted: #7c6f70;
  --paper: #ffffff;
  --ok: #2f7d43;
  --warn: #c0602a;
  --shadow: 0 6px 24px rgba(36, 26, 28, 0.18);
  --shadow-sm: 0 2px 10px rgba(36, 26, 28, 0.14);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#map { position: fixed; inset: 0; z-index: 0; background: #e8e4dc; }

/* ---------- eyebrow / signage labels ---------- */
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gold-d);
}

/* ---------- top bar / search ---------- */
.topbar {
  position: fixed; z-index: 500;
  top: env(safe-area-inset-top, 0); left: 0; right: 0;
  padding: 12px 12px 0;
  display: flex; justify-content: center;
  pointer-events: none;
}
.search-wrap {
  pointer-events: auto;
  width: 100%; max-width: 560px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 8px;
  color: var(--cream);
  flex-wrap: wrap;
}
.brand-mark {
  width: 22px; height: 22px; flex: none;
  background: var(--gold);
  border-radius: 50% 50% 50% 2px;
  transform: rotate(-45deg);
  box-shadow: inset 0 0 0 5px var(--maroon), 0 1px 4px rgba(0,0,0,.35);
}
.brand-text {
  font-size: 15px; font-weight: 500;
  color: var(--maroon-d);
  background: var(--cream);
  padding: 3px 10px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.brand-text b { color: var(--maroon); letter-spacing: .02em; }
.chips { display: flex; gap: 6px; margin-left: auto; }
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.9); color: var(--muted);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.chip.ok { background: #e7f3ea; color: var(--ok); }
.chip.warn { background: #fbeadd; color: var(--warn); }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 0 12px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}
.search-box:focus-within { border-color: var(--gold); }
.search-ico { width: 20px; height: 20px; fill: var(--maroon); flex: none; }
#search {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 16px; font-family: inherit; color: var(--ink);
  padding: 14px 0;
}
#search::placeholder { color: #a99f9c; }
.clear {
  border: 0; background: #efe9e0; color: var(--maroon);
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 18px; line-height: 1; cursor: pointer;
}

.suggestions {
  list-style: none; margin: 8px 0 0; padding: 6px;
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 46vh; overflow-y: auto;
}
.sugg {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 10px; border-radius: 10px; cursor: pointer;
}
.sugg:hover, .sugg:focus { background: var(--cream); }
.sugg-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff; }
.sugg-label { flex: 1; font-size: 15px; }
.sugg-dist { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- floating action buttons ---------- */
.fabs {
  position: fixed; z-index: 500;
  left: 12px; bottom: calc(18px + env(safe-area-inset-bottom, 0));
  display: flex; flex-direction: column; gap: 10px;
}
.fab {
  width: 50px; height: 50px; border-radius: 14px; border: 0;
  background: var(--paper); color: var(--maroon);
  box-shadow: var(--shadow); cursor: pointer;
  display: grid; place-items: center;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 24px; height: 24px; fill: currentColor; }
#save-offline-btn { color: var(--gold-d); }

.save-progress {
  position: fixed; z-index: 500; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0));
  background: var(--maroon-d); color: var(--cream);
  font-size: 12.5px; font-weight: 600;
  padding: 9px 14px; border-radius: 999px; box-shadow: var(--shadow);
}

/* ---------- bottom trip sheet ---------- */
.trip {
  position: fixed; z-index: 600;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto; max-width: 560px;
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(36,26,28,.22);
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom, 0));
  animation: rise .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.trip::before {
  content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 4px; border-radius: 4px; background: #e3ddd3;
}
.trip-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: var(--cream); color: var(--maroon); font-size: 20px; cursor: pointer;
}
.trip-head { margin: 6px 0 2px; }
.trip-head h2 { margin: 2px 0 0; font-size: 21px; color: var(--maroon); line-height: 1.15; padding-right: 34px; }

.trip-banner { display: none; }
.trip-banner.show {
  display: block; margin: 10px 0 2px;
  font-size: 13px; font-weight: 700; letter-spacing: .01em;
  padding: 9px 12px; border-radius: 10px;
}
.trip-banner.warn { background: #fbeadd; color: var(--warn); }
.trip-banner.ok { background: #e7f3ea; color: var(--ok); }

.trip-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 14px 0 10px;
}
.stat {
  background: var(--cream); border-radius: 14px;
  padding: 11px 12px; display: flex; flex-direction: column; gap: 3px;
}
.stat-val { font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.stat:first-child .stat-val { color: var(--maroon); }

.trip-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
}
.trip-foot #trip-mode { color: var(--ink); font-weight: 600; }
.route-swatch {
  width: 22px; height: 5px; border-radius: 3px; background: var(--maroon); flex: none;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 700; left: 50%; bottom: 26px;
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff;
  font-size: 13.5px; line-height: 1.35;
  padding: 12px 16px; border-radius: 12px; max-width: 84vw;
  box-shadow: var(--shadow); pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- map markers (Leaflet divIcons) ---------- */
.dest-pin .pin {
  width: 22px; height: 22px; background: var(--maroon);
  border: 3px solid var(--gold); border-radius: 50% 50% 50% 2px;
  transform: rotate(-45deg);
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.user-marker { position: relative; width: 26px; height: 26px; }
.user-dot {
  position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px; border-radius: 50%;
  background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.user-pulse {
  position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(26,115,232,.35);
  display: none;
}
/* Compass heading arrow — a triangle that points where you're facing. Hidden
   until a heading is known (device compass, or GPS course when moving), so it
   gracefully falls back to a plain dot. Rotates around the dot centre. */
.user-heading {
  position: absolute; inset: 0;
  transform-origin: 50% 50%;
  transition: transform .12s linear;
  opacity: 0; pointer-events: none;
}
.user-heading::before {           /* solid arrowhead */
  content: ""; position: absolute; left: 50%; top: -3px; transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid #1a73e8;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.35));
}
.user-heading::after {            /* faint beam/cone behind the arrow */
  content: ""; position: absolute; left: 50%; top: -12px; transform: translateX(-50%);
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 22px solid rgba(26,115,232,.18);
}
.user-marker.has-heading .user-heading { opacity: 1; }
/* Pulse only while actively navigating — no wasted animation frames otherwise */
body.navigating .user-pulse { display: block; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* ---------- modal / dialogs ---------- */
#modal-root { position: fixed; inset: 0; z-index: 900; }
.modal-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(36,26,28,.45); padding: 20px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper); width: 100%; max-width: 420px;
  border-radius: 18px; padding: 20px 20px 16px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; color: var(--maroon); font-size: 18px; }
.modal-body p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.modal-body .muted { color: var(--muted); font-size: 13px; }
.modal-body ul { margin: 6px 0 10px; padding-left: 18px; }
.modal-body li { margin: 3px 0; line-height: 1.45; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.modal-btn {
  border: 0; border-radius: 11px; padding: 10px 16px;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.modal-btn.primary { background: var(--maroon); color: var(--cream); }
.modal-btn.ghost { background: var(--cream); color: var(--ink); }
.modal-btn.danger { background: #fbeadd; color: var(--warn); }
.modal-btn:active { transform: scale(.97); }

/* Leaflet control tweaks */
.leaflet-control-zoom a {
  color: var(--maroon) !important;
  border-radius: 10px !important;
}
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow-sm) !important; }
.leaflet-container { font-family: var(--sans); }

/* ---------- accessibility & motion ---------- */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .trip { animation: none; }
  .user-pulse { animation: none; display: none; }
  .user-heading { transition: none; }
  .toast { transition: none; }
}

/* small screens: tighten */
@media (max-width: 380px) {
  .brand-text { font-size: 13px; }
  .stat-val { font-size: 19px; }
}
