/* ======================================================================
   Greenway — playful "bubbly" trail-map UI
   Rounded, chunky, sticker-like. Fredoka display + Nunito body, vibrant
   greens with sunny/coral/sky accents.
   ====================================================================== */
:root {
  --bg: #ecf8ef;
  --card: #ffffff;
  --ink: #234034;
  --ink-soft: #5f7a68;
  --green: #16a34a;
  --green-2: #22c55e;
  --green-soft: #d6f5e0;
  --sun: #fbbf24;
  --coral: #fb7185;
  --sky: #38bdf8;
  --blaze: #fb7a3c;
  --amber: #f59e0b;
  --red: #ef4444;
  --line: #d2ecd9;
  --line-2: #bce4c8;
  --r: 18px;
  --shadow: 0 3px 0 var(--line-2), 0 12px 22px -12px rgba(43, 58, 46, 0.3);
  --shadow-sm: 0 2px 0 var(--line-2), 0 6px 14px -8px rgba(43, 58, 46, 0.28);
  --font-d: "Fredoka", system-ui, sans-serif;
  --font-b: "Nunito", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font-b); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
.num { font-family: var(--font-d); font-weight: 600; }

#app { display: flex; height: 100%; }

/* ---- Panel ------------------------------------------------------------ */
#panel { position: relative; width: 392px; min-width: 392px; height: 100%; background: var(--bg); border-right: 2px solid var(--line-2); overflow: hidden; }
.topo-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.7;
  background:
    radial-gradient(440px 320px at 88% -6%, rgba(34, 197, 94, 0.14), transparent 70%),
    radial-gradient(360px 300px at -8% 26%, rgba(56, 189, 248, 0.12), transparent 70%),
    radial-gradient(420px 360px at 108% 92%, rgba(251, 122, 60, 0.12), transparent 70%);
}
.panel-scroll { position: relative; z-index: 1; height: 100%; overflow-y: auto; padding: 24px 22px 18px; display: flex; flex-direction: column; gap: 18px; }
#map { flex: 1; height: 100%; position: relative; background: #f8faf6; }

/* ---- Brand ------------------------------------------------------------ */
.brand { display: flex; gap: 13px; align-items: center; }
.mark {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  background: linear-gradient(150deg, var(--green-2), var(--green));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 #0f7a37, 0 10px 18px -8px rgba(22, 163, 74, 0.6);
}
.blaze { width: 12px; height: 24px; border-radius: 6px; background: var(--sun); box-shadow: 0 2px 0 #d99a14; }
.brand h1 { font-family: var(--font-d); font-weight: 700; font-size: 32px; line-height: 1; margin: 0; letter-spacing: -0.01em; color: var(--ink); }
.tag { margin: 5px 0 0; color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1.35; }
.brand h1 a { color: inherit; text-decoration: none; }
a.mark { text-decoration: none; cursor: pointer; }
.tag-link { color: var(--green); font-weight: 800; text-decoration: none; white-space: nowrap; }
.tag-link:hover { text-decoration: underline; }

/* ---- Tabs (pill) ------------------------------------------------------ */
.tabs { display: flex; gap: 6px; background: #e2f3e7; padding: 5px; border-radius: 999px; box-shadow: inset 0 2px 4px rgba(43,58,46,.06); }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--ink-soft); padding: 9px 6px; border-radius: 999px; font: 700 14px var(--font-b); cursor: pointer; transition: all .18s; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--green); color: #fff; box-shadow: 0 3px 0 #0f7a37, 0 6px 12px -4px rgba(22,163,74,.5); }

/* ---- Endpoints -------------------------------------------------------- */
.endpoints { position: relative; display: flex; flex-direction: column; gap: 9px; }
.field { position: relative; display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 12px 13px; box-shadow: var(--shadow-sm); }
.field:focus-within { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16); }
.field input { border: 0; outline: 0; flex: 1; font-size: 14.5px; background: transparent; color: var(--ink); font-family: inherit; font-weight: 600; }
.field input::placeholder { color: #b3a888; font-weight: 600; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px #fff, 0 1px 3px rgba(0,0,0,.2); }
.dot-from { background: var(--green); } .dot-to { background: var(--coral); }
.locate { border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--ink-soft); }
.locate:hover { color: var(--blaze); }
.swap { align-self: flex-end; margin: -6px 10px; width: 34px; height: 30px; border: 2px solid var(--line); background: var(--card); border-radius: 12px; cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.swap:hover { color: var(--green); border-color: var(--green-2); transform: rotate(180deg); transition: transform .25s; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; list-style: none; margin: 0; padding: 6px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 16px 36px -12px rgba(43,58,46,.4); max-height: 250px; overflow-y: auto; }
.suggest li { padding: 9px 11px; border-radius: 11px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.suggest li:hover, .suggest li.active { background: var(--green-soft); }
.suggest .sub { color: var(--ink-soft); font-size: 12px; }

/* ---- Modes ------------------------------------------------------------ */
.controls { display: flex; flex-direction: column; gap: 12px; }
.modes { display: flex; background: #e2f3e7; border-radius: 14px; padding: 5px; gap: 4px; }
.modes button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 11px; font: 700 13px var(--font-b); cursor: pointer; color: var(--ink-soft); transition: all .15s; }
.modes button:hover { color: var(--ink); }
.modes button.active { background: var(--green); color: #fff; box-shadow: 0 3px 0 #0f7a37; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.check input { accent-color: var(--green); width: 17px; height: 17px; }
.hint { color: #b3a888; }

/* ---- Result ----------------------------------------------------------- */
.result { display: flex; flex-direction: column; gap: 15px; }
.fallback-note { background: #fff3d6; border: 2px solid var(--sun); color: #92600c; padding: 10px 13px; border-radius: 14px; font-size: 13px; font-weight: 600; line-height: 1.4; }
.headline { display: flex; align-items: baseline; gap: 11px; }
.headline .big { font-family: var(--font-d); font-weight: 700; font-size: 50px; line-height: 0.8; letter-spacing: -0.02em; color: var(--green); }
.headline .unit { font-size: 16px; color: var(--ink-soft); font-weight: 700; }
.headline .climb { font-size: 14.5px; color: var(--ink-soft); font-weight: 700; }
.headline .time { margin-left: auto; font-size: 14.5px; color: var(--ink-soft); font-weight: 700; }
.protbar { height: 13px; border-radius: 999px; background: var(--red); overflow: hidden; display: flex; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
.protbar > i { display: block; height: 100%; }
.protbar .p { background: var(--green-2); } .protbar .c { background: var(--amber); }
.protline { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); display: flex; justify-content: space-between; margin-top: 7px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 2px solid var(--line); border-radius: 15px; padding: 11px 13px; box-shadow: var(--shadow-sm); }
.stat .v { font-family: var(--font-d); font-size: 22px; font-weight: 600; color: var(--ink); }
.stat .k { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin-top: 1px; }
.stat.warn .v { color: var(--red); }
.compromise { font-size: 13px; }
.compromise h4 { margin: 0 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 800; }
.compromise ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.compromise li { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.compromise li .seg-k { color: var(--ink-soft); }
.compromise li.road .seg-name::before { content: "⚠ "; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.btn { flex: 1 1 calc(50% - 5px); border: 2px solid var(--line); background: var(--card); padding: 11px; border-radius: 14px; cursor: pointer; font: 700 13.5px var(--font-b); color: var(--ink); white-space: nowrap; box-shadow: var(--shadow-sm); transition: transform .12s; }
.btn.primary { background: var(--green); color: #fff; border-color: #0f7a37; box-shadow: 0 3px 0 #0f7a37, 0 8px 16px -6px rgba(22,163,74,.5); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
details.cues { font-size: 13px; }
details.cues summary { cursor: pointer; color: var(--ink-soft); font-weight: 700; }
details.cues ol { margin: 9px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.cue-prot { color: var(--green); } .cue-conn { color: var(--amber); } .cue-road { color: var(--red); }
.noroute { background: #ffe4e0; border: 2px solid #f7b4ab; color: #b3372a; padding: 12px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; }

/* ---- Rides ------------------------------------------------------------ */
.rides-intro { color: var(--ink-soft); font-size: 13px; font-weight: 600; margin: 0 0 13px; line-height: 1.45; }
.rides-list { display: flex; flex-direction: column; gap: 12px; }
.ride-card { text-align: left; width: 100%; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px 15px; cursor: pointer; display: flex; flex-direction: column; gap: 7px; box-shadow: var(--shadow); transition: transform .15s; }
.ride-card:hover { transform: translateY(-3px) rotate(-0.4deg); border-color: var(--green-2); }
.ride-card .rc-top { display: flex; align-items: center; gap: 10px; }
.ride-card .rc-name { font-weight: 700; font-size: 15.5px; flex: 1; font-family: var(--font-d); }
.ride-card .rc-cat { font-size: 10px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.ride-card .rc-desc { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; line-height: 1.4; }
.ride-card .rc-stats { display: flex; gap: 13px; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; flex-wrap: wrap; align-items: center; }
.ride-card .rc-stats b { color: var(--ink); font-family: var(--font-d); font-weight: 600; }
.ride-card .rc-shape { font-size: 11px; font-weight: 800; color: var(--blaze); background: #fff3e6; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; }
.ride-detail .headline .shape { font-size: 13px; font-weight: 800; color: var(--blaze); }
.grade { width: 30px; height: 30px; border-radius: 11px; color: #fff; font-weight: 600; font-size: 15px; font-family: var(--font-d); display: flex; align-items: center; justify-content: center; flex: none; box-shadow: var(--shadow-sm); }
.kidpill { font-size: 10px; font-weight: 800; color: #0f7a37; background: var(--green-soft); padding: 3px 9px; border-radius: 999px; letter-spacing: .03em; text-transform: uppercase; }
.ride-detail .back { background: 0; border: 0; color: var(--blaze); cursor: pointer; font-size: 13px; padding: 0; font-weight: 800; }
.ride-detail h3 { margin: 11px 0 3px; font-size: 22px; font-family: var(--font-d); font-weight: 700; }
.ride-detail .rd-desc { font-size: 13px; color: var(--ink-soft); font-weight: 600; margin: 0 0 8px; line-height: 1.45; }

/* ---- Reach ------------------------------------------------------------ */
.reach-hint { color: var(--ink-soft); font-size: 12.5px; font-weight: 600; margin: 9px 0 0; }
#reach-result { margin-top: 16px; }
.reach-legend { display: flex; flex-direction: column; gap: 9px; margin: 12px 0 14px; }
.reach-legend .row { display: flex; align-items: center; gap: 11px; font-size: 13px; font-weight: 600; }
.reach-legend .sw { width: 15px; height: 15px; border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--line); flex: none; }
.reach-legend .ct { margin-left: auto; font-family: var(--font-d); font-weight: 600; color: var(--ink-soft); }
.reach-headline { font-size: 13px; color: var(--ink-soft); font-weight: 600; margin: 0 0 8px; line-height: 1.4; }
.reach-headline b { color: var(--green); font-size: 30px; font-family: var(--font-d); font-weight: 700; }

/* ---- Layers / footer -------------------------------------------------- */
.layers { border-top: 2px dashed var(--line-2); padding-top: 15px; display: flex; flex-direction: column; gap: 10px; }
.layers-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-weight: 800; }
.foot { margin-top: auto; color: #a99c7c; font-size: 11px; font-weight: 600; border-top: 2px solid var(--line); padding-top: 11px; line-height: 1.4; }

/* ---- Map chrome ------------------------------------------------------- */
.map-hint { position: absolute; left: 408px; top: 16px; z-index: 5; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--ink-soft); pointer-events: none; box-shadow: var(--shadow-sm); }
.map-hint.hidden { display: none; }
.mk { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 4px 9px rgba(0,0,0,.32); cursor: grab; }
.mk-from { background: var(--green); } .mk-to { background: var(--coral); } .mk-reach { background: var(--blaze); width: 24px; height: 24px; }
.mapboxgl-popup-content { font-family: var(--font-b); border-radius: 15px; background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 12px 28px -12px rgba(43,58,46,.4); padding: 11px 13px; }
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip { border-top-color: var(--card); }
.poi-popup b { display: block; margin-bottom: 7px; font-family: var(--font-d); font-weight: 600; font-size: 14px; }
.poi-popup button { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 5px 10px; cursor: pointer; font-size: 12px; margin-right: 5px; font-weight: 700; font-family: var(--font-b); }
.poi-popup button:hover { background: var(--green); color: #fff; border-color: var(--green); }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 700; opacity: 0; transition: all .22s; pointer-events: none; z-index: 50; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* drag handle for the mobile bottom sheet (hidden on desktop) */
.sheet-handle { display: none; }

@media (max-width: 720px) {
  /* Google/Apple-Maps-style: full-screen map with a draggable bottom sheet. */
  #app { display: block; height: 100%; }
  #map { position: fixed; inset: 0; width: 100%; height: 100%; }

  /* keep Mapbox logo + attribution clear of the sheet's peek */
  .mapboxgl-ctrl-bottom-left, .mapboxgl-ctrl-bottom-right { bottom: 2px; z-index: 4; }

  #panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; min-width: 0; height: 90vh; max-height: 90vh;
    display: flex; flex-direction: column;
    border-right: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 34px -8px rgba(31, 58, 46, 0.34);
    transform: translateY(calc(90vh - 198px)); /* peek by default (pre-JS) */
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    z-index: 6; overflow: visible;
  }
  #panel.sheet-dragging { transition: none; }

  .sheet-handle {
    display: flex; align-items: center; justify-content: center;
    flex: none; height: 30px; width: 100%; border: 0; background: transparent;
    cursor: grab; touch-action: none; padding: 0; position: relative; z-index: 2;
  }
  .sheet-handle:active, .brand:active { cursor: grabbing; }
  .sheet-handle span { width: 48px; height: 5px; border-radius: 3px; background: var(--line); }

  /* the brand header is also a drag grip (logo links still tap through) */
  .brand { touch-action: none; cursor: grab; padding-bottom: 2px; }

  .panel-scroll { flex: 1; min-height: 0; height: auto; padding: 2px 18px 26px; gap: 16px; }
  .brand .tag { display: none; }
  .map-hint { display: none; }
}
