/* kml.css -- the map page: full-screen map, the pull-out toolchest, panels and map marks.
   Created by LT Sean Egan, PhD <sean.d.egan3.mil@us.navy.mil>, 2026-10-22 */

:root {
  --bg: #ffffff; --panel: rgba(255, 255, 255, 0.97); --ink: #1d232b; --muted: #5d6773; --line: #d5dbe2;
  --chip: #f2f5f8; --chip-hover: #e5ecf3; --accent: #1c5d8a; --accent-ink: #ffffff; --danger: #b3261e;
  --sea: #cfe0ec; --land: #ece6d8; --coast: #8a8f96; --grid: rgba(30, 45, 60, 0.38); --gridlab: #2a3440;
  --halo: rgba(255, 255, 255, 0.9); --shadow: 0 6px 24px rgba(15, 25, 40, 0.22);
  --dw: min(360px, calc(100vw - 44px));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171d; --panel: rgba(20, 26, 33, 0.97); --ink: #e6ebf0; --muted: #9aa6b2; --line: #33404c;
    --chip: #1e2731; --chip-hover: #283441; --accent: #5fa8dc; --accent-ink: #0b1620; --danger: #ff8a80;
    --sea: #13212d; --land: #2c3138; --coast: #5c6670; --grid: rgba(200, 215, 230, 0.32); --gridlab: #c9d3dc;
    --halo: rgba(10, 14, 18, 0.85); --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #12171d; --panel: rgba(20, 26, 33, 0.97); --ink: #e6ebf0; --muted: #9aa6b2; --line: #33404c;
  --chip: #1e2731; --chip-hover: #283441; --accent: #5fa8dc; --accent-ink: #0b1620; --danger: #ff8a80;
  --sea: #13212d; --land: #2c3138; --coast: #5c6670; --grid: rgba(200, 215, 230, 0.32); --gridlab: #c9d3dc;
  --halo: rgba(10, 14, 18, 0.85); --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { font-size: 14px; line-height: 1.4; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.map { position: fixed; inset: 0; background: var(--sea); }
.map.drawing, .map.drawing .leaflet-interactive { cursor: crosshair; }
.tiles-light { filter: grayscale(1) brightness(1.07) contrast(0.9); }
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.55); }
.map[data-base="dark"] { background: #1b222a; }
.map[data-base="dark"], .map[data-base="satellite"] { --grid: rgba(225, 235, 245, 0.4); --gridlab: #e8eef3; --halo: rgba(0, 0, 0, 0.75); }

/* ---------------------------------------------------------------- buttons and fields */
.btn {
  border: 1px solid var(--line); background: var(--chip); border-radius: 8px; padding: 6px 12px; cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: var(--chip-hover); }
.btn:focus-visible, .chip:focus-visible, .d-tabs button:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.round { border-radius: 50%; width: 28px; height: 28px; padding: 0; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.fld { display: block; margin: 8px 0; }
.fld > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.fld input[type="text"], .fld input[type="number"], .fld select, .fld textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
.fld input[type="color"] { width: 64px; height: 30px; padding: 0 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.fld input[type="range"] { width: 100%; }
.chk { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.two { display: flex; gap: 14px; align-items: flex-end; }
.two .fld { flex: 1; }

/* ---------------------------------------------------------------- the toolchest */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--dw); z-index: 1100; display: flex; flex-direction: column;
  background: var(--panel); box-shadow: var(--shadow); transform: translateX(-102%); transition: transform 0.22s ease;
  border-right: 1px solid var(--line);
}
.drawer.open { transform: translateX(0); }
.tab {
  position: fixed; left: 0; top: 96px; z-index: 1101; width: 34px; height: 104px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0; background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow); transition: transform 0.22s ease; font-weight: 600; letter-spacing: 0.04em;
}
.tab span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); }
.chest-open .tab { transform: translateX(var(--dw)); }
.d-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 6px; flex-wrap: wrap; }
.d-head h1 { margin: 0; font-size: 17px; letter-spacing: 0.01em; }
.d-acts { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.d-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 12px 8px; border-bottom: 1px solid var(--line); }
.d-tabs button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 13px;
}
.d-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.d-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 12px 16px; }
.d-foot { border-top: 1px solid var(--line); padding: 6px 12px; }
.d-foot p { margin: 0; font-size: 12px; color: var(--muted); }
.d-foot p.warn { color: var(--danger); }

.chip-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 4px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--chip); font-size: 13px; max-width: 100%; text-align: left;
}
.chip:hover { background: var(--chip-hover); }
.chip.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.chip svg { flex: none; }
.chip.base { padding: 4px 10px 4px 5px; gap: 7px; }
.chip.base.on { background: var(--accent); color: var(--accent-ink); }
.sw { display: inline-block; width: 22px; height: 16px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.2); }
.sw-osm { background: linear-gradient(135deg, #f2efe9 50%, #aad3df 50%); }
.sw-light { background: linear-gradient(135deg, #f7f7f7 50%, #cfd3d6 50%); }
.sw-dark { background: linear-gradient(135deg, #2b2d30 50%, #191a1c 50%); }
.sw-terrain { background: linear-gradient(135deg, #c8dca5 40%, #e9d3a8 40%, #e9d3a8 70%, #fff 70%); }
.sw-ocean { background: linear-gradient(180deg, #a9d1ec, #2a5d9a); }
.sw-satellite { background: linear-gradient(135deg, #46613a 45%, #1c3b5a 45%); }
.sw-blank { background: repeating-linear-gradient(0deg, #f4f1ea 0 5px, #b9c2cc 5px 6px); }

/* files */
.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 12px; text-align: center; margin: 6px 0 4px; }
.drop p { margin: 8px 0 0; }
.layer { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.lrow { display: flex; align-items: center; gap: 6px; }
.lname { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 2px 0; cursor: text; font-weight: 600;
         overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrename { flex: 1; min-width: 0; padding: 3px 6px; border: 1px solid var(--accent); border-radius: 5px; background: var(--bg); }
.count { font-size: 12px; color: var(--muted); }
.icon { background: none; border: 0; cursor: pointer; font-size: 16px; padding: 0 3px; color: var(--muted); }
.icon:hover { color: var(--ink); }
.lfeats summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.lfeats ul { list-style: none; margin: 4px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.lfeats li { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 13px; }
.fname { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; flex: 1; min-width: 0; overflow: hidden;
         text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.fname:hover { text-decoration: underline; }
.ftype { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* inspect */
.ins-title { margin: 8px 0 0; font-size: 16px; word-break: break-word; }
.ins-form { margin: 6px 0 10px; }
.ins-form > .btn { margin: 4px 0; }
.ins-meas { background: var(--chip); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.kv { display: flex; gap: 10px; font-size: 13px; padding: 1px 0; }
.kv .k { flex: 0 0 92px; color: var(--muted); }
.kv .v { flex: 1; font-variant-numeric: tabular-nums; word-break: break-word; }
.ins-head { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.ins-head h4 { margin: 0; flex: 1; }
.pts { margin: 6px 0; padding-left: 30px; max-height: 280px; overflow-y: auto; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pts li { padding: 2px 0; position: relative; padding-right: 22px; }
.pts .dd { display: block; }
.pts .dm { display: block; color: var(--muted); }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 3px; }
.x:hover { color: var(--danger); }
.pts .x { position: absolute; right: 0; top: 2px; }
.props { margin: 4px 0; }
.prow { display: flex; gap: 4px; margin: 3px 0; align-items: center; }
.prow input { flex: 1; min-width: 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); font-size: 13px; }
.prow input:first-child { flex: 0 0 38%; font-weight: 600; }
h4 { margin: 14px 0 4px; font-size: 13.5px; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* export */
.exgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.btn.ex { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left; }
.btn.ex b { font-size: 15px; }
.btn.ex span { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- over the map */
.jump {
  position: fixed; top: 10px; right: 54px; z-index: 1000; display: flex; gap: 4px; background: var(--panel); padding: 4px;
  border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.jump input { width: 210px; max-width: 42vw; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: var(--bg); }
.hint {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 1050; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px;
  align-items: center; max-width: min(560px, calc(100vw - 24px)); flex-wrap: wrap; justify-content: center; font-size: 13.5px;
}
.selbar {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 1040; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 999px; padding: 4px 6px 4px 14px; display: flex;
  gap: 6px; align-items: center; max-width: calc(100vw - 24px);
}
#selname { font-weight: 600; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos {
  position: fixed; bottom: 6px; left: 50%; transform: translateX(-50%); z-index: 900; font-size: 12px; padding: 2px 8px;
  border-radius: 6px; background: var(--panel); color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums;
  max-width: calc(100vw - 260px); overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.pos:empty { display: none; }
.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 1300; background: #1d232b; color: #fff;
  padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: min(520px, calc(100vw - 24px)); font-size: 13.5px;
}
.info {
  position: fixed; right: 10px; bottom: 30px; z-index: 1001; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--panel); color: var(--accent); font: italic 700 16px Georgia, serif;
  cursor: pointer; box-shadow: var(--shadow); padding: 0;
}
.modal { position: fixed; inset: 0; z-index: 1400; background: rgba(10, 16, 24, 0.42); display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 22px; max-width: 440px; width: 100%;
        max-height: calc(100vh - 32px); overflow-y: auto; border: 1px solid var(--line); }
.card.wide { max-width: 620px; }
.card h2 { margin: 0 0 10px; font-size: 19px; }
.card p { margin: 0 0 10px; }
.card .btn.primary { margin-top: 6px; }
.key h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 0 4px; }
.keygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 10px; }
.keyrow { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.dropzone { display: none; position: fixed; inset: 0; z-index: 1500; background: rgba(28, 93, 138, 0.25); border: 4px dashed var(--accent);
            align-items: center; justify-content: center; pointer-events: none; }
.dropzone p { background: var(--panel); padding: 12px 20px; border-radius: 10px; font-size: 18px; font-weight: 600; }
.dropping .dropzone { display: flex; }

/* ---------------------------------------------------------------- marks on the map */
.kt-gicon, .kt-texticon { background: none; border: 0; }
.kt-glyph { display: block; overflow: visible; }
.kt-text { display: inline-block; transform: translate(-50%, -50%); font-weight: 700; white-space: nowrap; line-height: 1.1;
           text-shadow: 0 0 3px var(--halo), 0 0 3px var(--halo), 0 0 2px var(--halo); }
.kt-h { background: #ffffff; border: 2px solid #111; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.kt-hpt { border-radius: 50%; background: rgba(255, 255, 255, 0.6); }
.kt-hmid { background: rgba(255, 255, 255, 0.75); border: 1.5px solid #333; border-radius: 50%; transform-origin: center; }
.kt-hm { background: #ffd400; border: 2px solid #111; border-radius: 50%; cursor: move; }
.kt-hm::after { content: "\2725"; display: block; text-align: center; font-size: 13px; line-height: 18px; color: #111; }
.kt-grid { stroke: var(--grid); }
.kt-gridlab { background: none; border: 0; font-size: 10.5px; color: var(--gridlab); white-space: nowrap;
              text-shadow: 0 0 2px var(--halo), 0 0 2px var(--halo); font-variant-numeric: tabular-nums; }
.kt-land { fill: var(--land); stroke: var(--coast); }
.kt-jump { background: none; border: 3px solid #e4572e; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8); }
.kt-jumppop { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.kt-name { background: rgba(255, 255, 255, 0.85); border: 0; box-shadow: none; padding: 1px 5px; font-size: 12px; font-weight: 600; }
.kt-name::before { display: none; }
.kt-mtipwrap { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.kt-mtip { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.kt-mtip span { font-size: 11.5px; color: var(--muted); }
.leaflet-control-scale, .kt-scale { margin-left: 10px !important; margin-bottom: 8px !important; }
.kt-scale { display: flex; flex-direction: column; gap: 2px; }
.kt-scalebar { border: 2px solid #222; border-top: 0; background: rgba(255, 255, 255, 0.75); font-size: 11px; line-height: 1.1;
               padding: 1px 4px 0; color: #222; white-space: nowrap; }
.kt-scalebar + .kt-scalebar { border-top: 2px solid #222; border-bottom: 0; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10.5px; max-width: 60vw; }
.leaflet-top.leaflet-right { top: 0; }

@media (max-width: 760px) {
  .jump { right: 50px; left: 44px; top: 8px; }
  .jump input { width: 100%; max-width: none; flex: 1; min-width: 0; }
  .hint { top: 56px; }
  .pos { left: auto; right: 48px; transform: none; bottom: 50px; max-width: calc(100vw - 64px); font-size: 11px; }
  .selbar { bottom: 78px; }
  .toast { bottom: 128px; }
  .exgrid { grid-template-columns: 1fr; }
  .leaflet-control-attribution { max-width: 70vw; }
}
@media (min-width: 761px) {
  .leaflet-left { transition: transform 0.22s ease; }
  .chest-open .leaflet-left { transform: translateX(var(--dw)); }
  .chest-open .pos { left: calc(50% + var(--dw) / 2); }
}
