/* Simple Injection brand tokens (from simpleinjection.com, Nov 2026). */
:root {
  --si-green: #3ca749;          /* primary */
  --si-green-hover: #32913f;
  --si-green-text: #267a32;     /* green text and links on light backgrounds */
  --si-green-tint: #ddf2e0;     /* primary container */
  --on-green: #0b1713;          /* text on the green */
  --charcoal: #232326;          /* text, dark UI */
  --charcoal-2: #191d20;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-alt: #f1f2f0;
  --ink: #232326;
  --muted: #5f5e63;
  --line: #d2d2d5;
  --line-soft: #e8e8ea;
  --warning-tint: #fff0cc; --warning: #805000;
  --radius: 12px;
  --shadow: 0 4px 12px #00000014;
  --shadow-lg: 0 8px 24px #0000001f;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Condensed", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  display: grid; grid-template-rows: auto 1fr auto;
  font: 14px/1.5 var(--font-body);
  color: var(--ink); background: var(--bg);
}
a { color: var(--si-green-text); }

/* Header: white, like simpleinjection.com */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { height: 40px; width: auto; display: block; }
.brand.product {
  padding-left: 12px; border-left: 1px solid var(--line);
  font: 700 22px/1 var(--font-display); letter-spacing: .3px; color: var(--charcoal); text-transform: uppercase;
}

#search { display: flex; flex: 1; flex-wrap: wrap; gap: 8px; min-width: 0; }
.field.query {
  flex: 1 1 280px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: var(--surface); border-radius: 8px; border: 1px solid var(--line);
}
.field.query:focus-within { border-color: var(--si-green); box-shadow: 0 0 0 3px #3ca74933; }
.field.query svg { width: 18px; height: 18px; fill: var(--muted); flex: none; }
#q { flex: 1; min-width: 0; border: 0; outline: 0; padding: 9px 0; font: 15px var(--font-body); background: transparent; color: var(--ink); }
#search select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-alt); color: var(--ink); font: 14px var(--font-body); cursor: pointer;
}
#search select:focus-visible { outline: 2px solid var(--si-green); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 14px var(--font-body);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); }
.btn:focus-visible { outline: 2px solid var(--si-green); outline-offset: 1px; }
.btn.primary { background: var(--si-green); border-color: var(--si-green); color: var(--on-green); }
.btn.primary:hover { background: var(--si-green-hover); border-color: var(--si-green-hover); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* Layout */
main { display: grid; grid-template-columns: 360px 1fr; min-height: 0; }
#panel { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line-soft); }
.panel-head {
  position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line-soft);
}
#summary { color: var(--muted); font-weight: 500; }
#operator {
  flex: 1 1 100%; min-width: 0; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-alt); color: var(--ink); font: 13px var(--font-body); cursor: pointer;
}
#operator:focus-visible { outline: 2px solid var(--si-green); outline-offset: 1px; }

#intro { padding: 16px; color: var(--muted); }
#intro h2 { margin: 0 0 6px; font: 700 20px/1.1 var(--font-display); text-transform: uppercase; color: var(--charcoal); }
#intro p { margin: 0 0 10px; }
.examples-label { font-weight: 600; color: var(--ink); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button {
  padding: 5px 12px; border-radius: 9999px; border: 1px solid var(--line); background: var(--surface-alt);
  font: 13px var(--font-body); color: var(--ink); cursor: pointer;
}
.examples button:hover { border-color: var(--si-green); background: var(--si-green-tint); }

#results { list-style: none; margin: 0; padding: 6px 8px 16px; }
#export { align-self: flex-start; margin: 0 16px 16px; }
#results li {
  display: grid; grid-template-columns: 10px 1fr; gap: 2px 10px; align-items: baseline;
  padding: 10px; border-radius: 8px; cursor: pointer;
}
#results li + li { border-top: 1px solid var(--line-soft); }
#results li:hover, #results li:focus-visible { background: var(--surface-alt); outline: none; }
#results li.selected { background: var(--si-green-tint); }
#results .dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
/* Facility shapes, matching the map icons: square tank battery, triangle compressor, diamond pump station, hexagon other site. */
#results .dot.square { border-radius: 2px; }
#results .dot.triangle, #legend i.triangle, .layer-toggle i.triangle {
  border: 0; border-radius: 0; box-shadow: none; clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
#results .dot.diamond { border-radius: 1px; transform: rotate(45deg) scale(.85); }
#results .dot.hexagon, #legend i.hexagon, .layer-toggle i.hexagon {
  border: 0; border-radius: 0; box-shadow: none; clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
}
#results strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results .meta { grid-column: 2; color: var(--muted); font-size: 12.5px; }
.api { font-family: var(--font-mono); font-size: .92em; }

#map { position: relative; min-height: 300px; }

/* Map overlays */
.map-card { background: #fffffff2; border-radius: var(--radius); box-shadow: var(--shadow); }
#legend {
  position: absolute; left: 10px; bottom: 34px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 7px 10px; font-size: 12px; max-width: calc(100% - 20px);
}
#legend span { display: inline-flex; align-items: center; gap: 5px; text-transform: capitalize; }
#legend i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #00000026; }
#legend i.square, .layer-toggle i.square { border-radius: 2px; }
#legend i.diamond { border-radius: 1px; transform: rotate(45deg) scale(.85); }
#legend i.square, #legend i.triangle, #legend i.diamond, #legend i.hexagon, .layer-toggle i { background: var(--muted); }
#legend i.triangle, .layer-toggle i.triangle { width: 11px; height: 10px; }
#legend .kind-key { text-transform: none; }

.map-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.map-controls .map-card { margin: 0; }
.layer-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; cursor: pointer;
  font: 600 12.5px var(--font-body); color: var(--muted);
}
.layer-toggle i { width: 9px; height: 9px; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #00000026; }
.layer-toggle[aria-pressed="true"] { color: var(--charcoal); }
.layer-toggle[aria-pressed="true"] i { background: var(--si-green); }
.layer-toggle[aria-pressed="false"] { opacity: .75; }
.basemap-toggle { display: flex; padding: 3px; gap: 2px; }
.basemap-toggle button {
  padding: 5px 10px; border: 0; border-radius: 8px; background: transparent;
  font: 600 12.5px var(--font-body); color: var(--muted); cursor: pointer;
}
.basemap-toggle button[aria-pressed="true"] { background: var(--charcoal); color: #fff; }

/* Popup (above the legend) */
.maplibregl-popup { z-index: 3; }
.maplibregl-popup-content { padding: 14px 16px 12px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-family: var(--font-body); }
.maplibregl-popup-close-button { font-size: 20px; padding: 2px 8px; color: var(--muted); }
.popup h3 { margin: 0 22px 4px 0; font: 700 18px/1.15 var(--font-display); text-transform: uppercase; letter-spacing: .2px; }
.popup .chip {
  display: inline-block; margin-bottom: 10px; padding: 2px 8px; border-radius: 9999px;
  font-size: 11.5px; font-weight: 600; text-transform: capitalize; color: #fff;
}
.popup dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 12px; font-size: 13px; }
.popup dt { color: var(--muted); }
.popup dd { margin: 0; overflow-wrap: anywhere; }
.popup .actions { display: flex; gap: 6px; flex-wrap: wrap; }

footer { padding: 6px 20px; font-size: 12px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line-soft); }
.foot-full { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.foot-toggle { display: none; }
footer .by { white-space: nowrap; }
footer .by a { color: var(--ink); font-weight: 600; text-decoration: none; }
footer .by a:hover { color: var(--si-green-text); }

@media (max-width: 720px) {
  /* iOS Safari zooms into any focused field with text under 16px. Keep form text at 16px on phones
     instead of disabling zoom (maximum-scale=1 would also block pinch-zoom). */
  input, select, textarea, #q, #search select, #operator { font-size: 16px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand img { height: 32px; }
  .brand.product { font-size: 19px; padding-left: 10px; }
  #search { flex-basis: 100%; }
  .field.query { flex-basis: 100%; }
  #search select { flex: 1; }
  main { grid-template-columns: 1fr; grid-template-rows: 50vh 1fr; }
  #panel { order: 2; border-right: 0; border-top: 1px solid var(--line-soft); }
  #map { order: 1; }
  #legend { bottom: 30px; font-size: 11px; gap: 3px 8px; }
  .maplibregl-popup-content { padding: 10px 12px 10px; }
  .popup h3 { font-size: 16px; }
  .popup .chip { margin-bottom: 6px; }
  .popup dl { gap: 1px 10px; margin-bottom: 8px; font-size: 12.5px; }
  footer { font-size: 12px; padding: 0 12px; }
  .foot-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
    padding: 8px 0; border: 0; background: none; font: 12px var(--font-body); color: var(--muted); cursor: pointer; text-align: left;
  }
  .foot-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .foot-toggle svg { width: 16px; height: 16px; flex: none; fill: currentColor; transition: transform .2s; }
  .foot-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .foot-full { display: none; flex-direction: column; padding-bottom: 8px; }
  footer.open .foot-full { display: flex; }
}
