/* JAGRITI 2K27 – route map styles (works with Leaflet 1.9 + tokens.css) */
.rm {
  position: relative;
  width: 100%;
  height: clamp(520px, 78vh, 800px);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-alt);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  font-family: var(--font-body);
  isolation: isolate;
}
.rm__canvas { position: absolute; inset: 0; }
.rm .leaflet-container {
  width: 100%; height: 100%;
  font-family: var(--font-body);
  background-color: #e9eef6;
  background-image:
    linear-gradient(rgba(11, 31, 68, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 31, 68, .05) 1px, transparent 1px);
  background-size: 48px 48px;
  outline: none;
}
.rm.rm--sat .leaflet-container { background-color: #1b2a36; background-image: none; }
.rm .leaflet-container:focus-visible { outline: 3px solid var(--saffron); outline-offset: -3px; }
.rm-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
  .rm { height: clamp(500px, 80vh, 720px); border-radius: var(--radius-sm); }
}

/* ---- controls ---- */
.rm .leaflet-bar { border: 0; border-radius: 12px; box-shadow: var(--shadow-sm), 0 0 0 1px rgba(11, 31, 68, .08); overflow: hidden; background: #fff; }
.rm .leaflet-bar a, .rm .leaflet-bar button {
  width: 36px; height: 36px; line-height: 36px; display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--navy-900); border: 0; border-bottom: 1px solid var(--line);
  font-family: var(--font-body); font-size: 20px; font-weight: 600; cursor: pointer; padding: 0; text-decoration: none;
}
.rm .leaflet-bar a:last-child, .rm .leaflet-bar button:last-child { border-bottom: 0; }
.rm .leaflet-bar a:hover, .rm .leaflet-bar button:hover { background: var(--surface-alt); }
.rm .leaflet-bar a:focus-visible, .rm .leaflet-bar button:focus-visible,
.rm-legend__head:focus-visible, .rm-seg__btn:focus-visible, .rm-notice__link:focus-visible, .rm-fallback__open:focus-visible {
  outline: 3px solid var(--saffron); outline-offset: -3px; position: relative; z-index: 2;
}
.rm .leaflet-touch .leaflet-bar a { width: 38px; height: 38px; line-height: 38px; }
.rm .leaflet-control-zoom a { font-size: 22px; }
.rm .leaflet-top, .rm .leaflet-bottom { z-index: 800; }
.rm .leaflet-control { margin: 12px; }
.rm .leaflet-left .leaflet-control { margin-left: 12px; }

.rm-fit__btn svg { display: block; }

/* basemap toggle */
.rm-seg { display: flex; padding: 3px; gap: 2px; border-radius: 999px !important; background: #fff; }
.rm .rm-seg .rm-seg__btn {
  width: auto; height: 34px; padding: 0 13px 0 11px; gap: 6px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.rm .rm-seg .rm-seg__btn:hover { background: var(--surface-alt); }
.rm .rm-seg .rm-seg__btn.is-on { background: var(--navy-900); color: #fff; }
.rm .rm-seg .rm-seg__btn:focus-visible { outline-offset: 1px; }
.rm .rm-seg .rm-seg__btn svg { flex: none; }

/* legend */
.rm-legend {
  background: rgba(255, 255, 255, .96); border-radius: 14px; box-shadow: var(--shadow-sm), 0 0 0 1px rgba(11, 31, 68, .08);
  min-width: 214px; max-width: 250px; color: var(--ink); overflow: hidden; backdrop-filter: blur(6px);
}
.rm-legend__head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: transparent; border: 0; cursor: pointer; text-align: left;
  font: 400 17px/1 var(--font-display); letter-spacing: .08em; color: var(--navy-900);
}
.rm-legend__head svg { transition: transform .2s var(--ease); }
.rm-legend:not(.is-open) .rm-legend__head svg { transform: rotate(-90deg); }
.rm-legend__body { padding: 0 12px 11px; }
.rm-legend__body[hidden] { display: none; }
.rm-legend__total { margin: 0 0 7px; font-size: 12px; line-height: 1.35; color: var(--ink-soft); }
.rm-legend__total strong { color: var(--navy-900); font-size: 14px; }
.rm-legend__total small { font-size: 12px; }
.rm-legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rm-legend li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 500; line-height: 1.2; }
.rm-legend li > svg { flex: none; width: 28px; }
.rm-key { flex: none; width: 28px; height: 18px; display: inline-flex; align-items: center; justify-content: center; position: relative; font-style: normal; }
.rm-key::before { content: ''; width: 14px; height: 14px; border-radius: 50%; }
.rm-key--start::before { background: var(--green); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--green); }
.rm-key--turn::before { background: var(--danger); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--danger); }
.rm-key--water::before { background: #0288d1; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #0288d1; }
.rm-key--km { font: 700 10px/1 var(--font-body); color: var(--navy-900); }
.rm-key--km { z-index: 0; }
.rm-key--km::before { position: absolute; z-index: -1; width: 17px; height: 17px; background: #fff; border: 2px solid var(--navy-900); box-sizing: border-box; }

/* hint + notice */
.rm-hint {
  position: absolute; left: 50%; bottom: 18px; z-index: 900; transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 32px);
  padding: 8px 15px; border-radius: 999px; background: rgba(6, 15, 38, .82); color: #fff;
  font-size: 12.5px; font-weight: 500; line-height: 1.3; pointer-events: none; opacity: 0;
  transition: opacity .35s var(--ease), transform .35s var(--ease); backdrop-filter: blur(4px); text-align: center;
}
.rm-hint svg { flex: none; }
.rm-hint.is-on { opacity: 1; transform: translate(-50%, 0); }
.rm-notice {
  position: absolute; left: 50%; top: 14px; z-index: 900; transform: translateX(-50%); display: flex; flex-wrap: wrap; gap: 6px 12px;
  align-items: center; justify-content: center; max-width: calc(100% - 140px); width: max-content;
  padding: 8px 14px; border-radius: 12px; background: #fff7e8; color: #7a4a00; border: 1px solid #ffd79a;
  font-size: 12.5px; font-weight: 500; text-align: center; box-shadow: var(--shadow-sm);
}
.rm-notice__link { color: var(--navy-800); font-weight: 700; }

/* ---- lanes & icons ---- */
.rm .leaflet-overlay-pane path.rm-lane { cursor: pointer; }
.rm-chev { background: none; border: 0; }
.rm-chev span { display: block; width: 14px; height: 14px; }
.rm-chev span svg { width: 14px; height: 14px; filter: drop-shadow(0 0 .5px rgba(0, 0, 0, .5)); }

.rm-pinwrap, .rm-water, .rm-km, .rm-lm { background: none; border: 0; }
.rm-pin { overflow: visible; filter: drop-shadow(0 3px 3px rgba(6, 15, 38, .25)); }
.rm-pin--start .rm-pin__body { fill: var(--green); stroke: #fff; stroke-width: 2; }
.rm-pin--turn .rm-pin__body { fill: var(--danger); stroke: #fff; stroke-width: 2; }
.rm-drop { filter: drop-shadow(0 2px 3px rgba(6, 15, 38, .3)); }
.rm-drop__bg { fill: #0288d1; stroke: #fff; stroke-width: 2; }
.rm-km span {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: var(--navy-900); border: 2.5px solid var(--navy-900); font: 700 12px/1 var(--font-body); letter-spacing: -.02em;
  box-shadow: 0 2px 5px rgba(6, 15, 38, .3);
}
.rm-lm span { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--navy-900); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(6, 15, 38, .4); }
.rm .leaflet-marker-icon:focus-visible { outline: 3px solid var(--saffron); outline-offset: 3px; border-radius: 12px; }

/* ---- tooltips (labels) ---- */
.rm .leaflet-tooltip.rm-tip { background: var(--navy-900); color: #fff; border: 0; border-radius: 8px; padding: 5px 10px; font: 500 12px/1.3 var(--font-body); box-shadow: var(--shadow-sm); }
.rm .leaflet-tooltip.rm-tip::before { display: none; }
.rm .leaflet-tooltip.rm-label {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 10px 6px; border: 0; border-radius: 10px;
  background: #fff; color: var(--navy-900); box-shadow: 0 3px 10px rgba(6, 15, 38, .28); white-space: nowrap; text-align: center;
  font: 600 12px/1.15 var(--font-body); pointer-events: none;
}
.rm .leaflet-tooltip.rm-label::before { display: none; }
.rm-label b { font: 400 17px/1 var(--font-display); letter-spacing: .06em; }
.rm-label span { font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.rm-label--start { border-top: 3px solid var(--green); }
.rm-label--start b { color: var(--green); }
.rm-label--turn { border-top: 3px solid var(--danger); }
.rm-label--turn b { color: var(--danger); }
.rm .leaflet-tooltip.rm-label--lm { flex-direction: row; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, .95); }

/* ---- popups ---- */
.rm .rm-popup .leaflet-popup-content-wrapper { border-radius: 14px; padding: 0; box-shadow: var(--shadow); color: var(--ink); overflow: hidden; }
.rm .rm-popup .leaflet-popup-content { margin: 0; font-family: var(--font-body); width: auto !important; min-width: 236px; max-width: 280px; }
.rm .rm-popup .leaflet-popup-tip { box-shadow: 0 3px 8px rgba(6, 15, 38, .15); }
.rm .rm-popup a.leaflet-popup-close-button { top: 6px; right: 6px; width: 26px; height: 26px; font: 400 20px/26px var(--font-body); color: var(--ink-soft); border-radius: 50%; padding: 0; text-align: center; }
.rm .rm-popup a.leaflet-popup-close-button:hover { background: var(--surface-alt); color: var(--ink); }
.rm-pop { display: flex; align-items: stretch; }
.rm-pop__bar { flex: none; width: 6px; }
.rm-pop > div { padding: 11px 32px 12px 12px; }
.rm-pop strong { display: block; font: 400 18px/1.1 var(--font-display); letter-spacing: .05em; color: var(--navy-900); }
.rm-pop p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); }

/* ---- attribution & scale ---- */
.rm .leaflet-control-attribution { font-size: 10.5px; background: rgba(255, 255, 255, .85); border-radius: 8px 0 0 0; margin: 0; padding: 1px 7px; }
.rm .leaflet-bottom.leaflet-right .leaflet-control { margin: 0; }

/* ---- fallback / error state ---- */
.rm--error { height: auto; min-height: 0; background: var(--surface-alt); }
.rm-fallback { padding: 16px; text-align: center; }
.rm-fallback__msg { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }
.rm-fallback__fig { margin: 0; }
.rm-fallback__img { width: 100%; max-height: 640px; object-fit: contain; border-radius: var(--radius-sm); background: #fff; }
.rm-fallback__open { display: inline-block; margin-top: 10px; padding: 8px 16px; border-radius: 999px; background: var(--navy-900); color: #fff; font-weight: 600; font-size: 13px; text-decoration: none; }

/* narrow screens */
@media (max-width: 560px) {
  .rm .leaflet-control { margin: 8px; }
  .rm .rm-seg .rm-seg__btn { padding: 0 10px 0 8px; font-size: 12px; height: 32px; }
  .rm-legend { min-width: 0; max-width: 200px; }
  .rm-legend li { font-size: 12px; }
  .rm-label span { display: none; }
  .rm-label--turn span { display: block; }
  .rm .leaflet-tooltip.rm-label { padding: 4px 8px 5px; }
  .rm-notice { max-width: calc(100% - 24px); top: 56px; }
  .rm-hint { bottom: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .rm-hint, .rm-legend__head svg, .rm-seg__btn { transition: none; }
}

/* ---------- Phone & touch polish: 44px map controls ---------- */
@media (max-width: 1020px), (pointer: coarse) {
  .rm .leaflet-bar a, .rm .leaflet-bar button, .rm .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .rm .rm-seg .rm-seg__btn { height: 44px; }
  .rm-legend__head { min-height: 44px; }
  .rm-fallback__open { min-height: 44px; display: inline-flex; align-items: center; padding: 10px 18px; }
}
