/* StipCoach: Termite, well & repairs map (#/termite). Scoped to .tm. Uses tokens from styles.css. */
.tm {
  --tm-req: #F2AE3A;
  --tm-some: #FBE1A6;
  --tm-no: #D9E3F2;
  --tm-unc: #E3E6EB;
  --tm-sel: #0B1F3A;
  --tm-rep: #DCE3EE;
  --tm-rep-on: #C3D3F3;
  --tm-rep-co: #CBD8F2;
  --tm-rep-sel: #5B86F0;
}
.tm-head { margin-bottom: 20px; }

/* toolbar */
.tm-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.tm-seg { display: inline-grid; grid-auto-columns: 112px; }
.tm-search { position: relative; flex: 0 1 380px; min-width: 0; }
.tm-search > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.tm-search input { width: 100%; height: 48px; padding: 0 14px 0 40px; border-radius: 12px; border: 1px solid var(--line-2); background: #fff; box-shadow: var(--sh-xs); font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s; }
.tm-search input:focus { border-color: var(--blue); box-shadow: var(--ring); }
.tm-search input::-webkit-search-cancel-button { cursor: pointer; }
.tm-res { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-lg); padding: 6px; max-height: 360px; overflow: auto; }
.tm-res button { display: flex; width: 100%; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 9px 12px; border-radius: 10px; }
.tm-res button b { font-weight: 600; color: var(--navy); font-size: 14.5px; }
.tm-res button span { font-size: 12.5px; color: var(--muted); }
.tm-res button.on, .tm-res button:hover { background: var(--blue-25); }
.tm-nores { padding: 10px 12px; font-size: 14px; color: var(--muted); }

/* layout */
.tm-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.tm-mapcard { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px 18px; box-shadow: var(--sh-xs); }
.tm-maptop { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.tm-back[hidden] { display: none; }
.tm-back { height: 36px; padding: 0 14px; font-size: 14px; }
.tm-where { font: 700 17px "Inter Tight", Inter, sans-serif; color: var(--navy); letter-spacing: -0.015em; }
.tm-note { margin-top: 8px; }
.tm-pill { display: inline-flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--body); background: var(--bg); border-radius: 10px; padding: 7px 11px; }
.tm-pill svg { color: var(--blue); margin-top: 1px; }

/* map */
.tm-mapwrap { position: relative; margin-top: 8px; }
.tm-svg { display: block; width: 100%; height: auto; overflow: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tm-svg path { vector-effect: non-scaling-stroke; }
.tm-svg .st { stroke: #fff; stroke-width: 1; cursor: pointer; transition: fill .3s var(--ease), opacity .4s var(--ease); outline: none; }
.tm-svg .st:hover, .tm-svg .st:focus-visible { filter: brightness(.94); }
.tm-svg .st:focus-visible { stroke: var(--blue); stroke-width: 2; }
.tm-svg .st.dim { opacity: .34; }
.tm-svg .st.far { opacity: 0; pointer-events: none; }
.tm-svg .st.sel { stroke: var(--tm-sel); stroke-width: 1.5; }
.tm-svg .nat { fill: none; stroke: #C9D2DF; stroke-width: .75; pointer-events: none; }
.tm.zoomed .tm-svg .nat { opacity: 0; }
.s-statewide { fill: var(--tm-req); }
.s-counties { fill: var(--tm-some); }
.s-notreq { fill: var(--tm-no); }
.s-unconfirmed { fill: var(--tm-unc); }
.tm-svg .co { stroke: #fff; stroke-width: .6; cursor: pointer; transition: fill .3s var(--ease); }
.tm-svg .co:hover { filter: brightness(.93); }
.tm-svg .co.sel { stroke: var(--tm-sel); stroke-width: 2; }
.c-req { fill: var(--tm-req); }
.c-no { fill: var(--tm-no); }
.c-unc { fill: var(--tm-unc); }
.s-rep { fill: var(--tm-rep); }
.tm-svg .st.s-rep.sel { fill: var(--tm-rep-on); }
.c-rep { fill: var(--tm-rep-co); }
.tm-svg .co.c-rep.sel { fill: var(--tm-rep-sel); stroke: #fff; stroke-width: 1.5; }
#tmcounties { opacity: 0; }
#tmcounties.in { opacity: 1; transition: opacity .45s var(--ease) .15s; }
.tm-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; color: var(--muted); text-align: center; padding: 24px; }
.tm-loading span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--blue); animation: tmspin .8s linear infinite; }
.tm-loading.err span { display: none; }
@keyframes tmspin { to { transform: rotate(360deg); } }
.tm-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 500; padding: 5px 9px; border-radius: 8px; white-space: nowrap; box-shadow: var(--sh-md); }

/* legend */
.tm-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; color: var(--body); }
.tm-legend span { display: inline-flex; align-items: center; gap: 7px; }
.tm i[class^="s-"], .tm i[class^="c-"] { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 4px; }
.tm i.s-statewide, .tm i.c-req { background: var(--tm-req); }
.tm i.s-counties { background: var(--tm-some); box-shadow: inset 0 0 0 1px rgba(147, 96, 10, .18); }
.tm i.s-notreq, .tm i.c-no { background: var(--tm-no); }
.tm i.s-unconfirmed, .tm i.c-unc { background: var(--tm-unc); box-shadow: inset 0 0 0 1px rgba(11, 31, 58, .08); }
.tm i.c-rep { background: var(--tm-rep-co); }
.tm-hint { color: var(--muted); }
.tm-hint svg { color: var(--subtle); }
.tm-terr { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.tm-terr:empty { display: none; }

/* panel */
.tm-panel { position: sticky; top: 92px; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 20px 18px; box-shadow: var(--sh-xs); max-height: calc(100vh - 112px); overflow: auto; overscroll-behavior: contain; }
.tm-pin h2 { font: 700 22px/1.2 "Inter Tight", Inter, sans-serif; letter-spacing: -0.02em; color: var(--navy); }
.tm-lead { font-size: 14px; color: var(--muted); margin-top: 4px; }
.tm-x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.tm-x:hover { background: var(--bg); color: var(--navy); }
.tm-panel:has(.tm-x) .tm-pin h2 { padding-right: 36px; }
.tm-grab { display: none; }
.tm-badge { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; line-height: 1.35; }
.b-statewide, .b-req { background: #FDEBC8; color: #7A4F06; }
.b-counties { background: #FEF4DD; color: #7A4F06; box-shadow: inset 0 0 0 1px #F6DDA6; }
.b-notreq, .b-no { background: #E6EDF8; color: #2B4A75; }
.b-unconfirmed, .b-unc { background: #EEF0F3; color: #475569; }
.tm-why { font-size: 14.5px; color: var(--body); margin-top: 12px; line-height: 1.55; }
.tm-state-rule { font-size: 14px; color: var(--body); margin-top: 12px; line-height: 1.55; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.tm-state-rule.unc { background: #F4F5F7; color: var(--muted); }
.tm-rules { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px 10px; margin-top: 14px; font-size: 13.5px; line-height: 1.5; }
.tm-rules dt { font-size: 11.5px; font-weight: 700; letter-spacing: .03em; color: var(--blue-600); background: var(--blue-50); border-radius: 6px; text-align: center; padding: 2px 0; height: fit-content; margin-top: 1px; }
.tm-rules dd { color: var(--body); }
.tm-small { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.tm-find { margin-top: 16px; height: auto; min-height: 46px; padding: 10px 14px; white-space: normal; text-align: center; line-height: 1.3; }
.tm-find svg:last-child { opacity: .8; }
.tm-findnote { margin-top: 6px; text-align: center; }
.tm-counts { list-style: none; display: grid; gap: 2px; margin-top: 14px; }
.tm-counts li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--body); padding: 6px 0; border-bottom: 1px solid var(--line); }
.tm-counts li:last-child { border-bottom: 0; }
.tm-counts span { flex: 1; }
.tm-counts b { color: var(--navy); font-variant-numeric: tabular-nums; }
.tm-crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--blue); margin-bottom: 8px; }
.tm-more { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.tm-more summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--navy); list-style: none; display: flex; align-items: center; justify-content: space-between; }
.tm-more summary::-webkit-details-marker { display: none; }
.tm-more summary::after { content: "+"; color: var(--subtle); font-weight: 500; font-size: 18px; line-height: 1; }
.tm-more[open] summary::after { content: "–"; }

/* repairs */
.tm-lbl { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-top: 18px; }
.tm-lbl label { cursor: pointer; }
.tm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tm-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 10px 5px 8px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.2; text-align: left; transition: border-color .15s, background .15s, color .15s; }
.tm-chip svg { color: var(--subtle); flex: none; transition: color .15s; }
.tm-chip:hover { border-color: #C3CEDE; color: var(--navy); }
.tm-chip:hover svg { color: var(--blue); }
.tm-chip.on { background: var(--blue-50); border-color: rgba(30, 94, 255, .45); color: var(--blue-600); font-weight: 600; }
.tm-chip.on svg { color: var(--blue); }
.tm-chip:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--blue); }
.tm-field { position: relative; display: block; margin-top: 10px; }
.tm-field > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.tm-field input { width: 100%; height: 42px; padding: 0 12px 0 36px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-size: 14.5px; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.tm-field input:focus { border-color: var(--blue); box-shadow: var(--ring); }
.tm-field input::placeholder { color: var(--subtle); }
.tm-otherf { margin-top: 8px; }
.tm-rgo { position: sticky; bottom: -18px; z-index: 2; margin-top: 4px; padding: 12px 0 18px; background: linear-gradient(rgba(255, 255, 255, 0), #fff 12px); }
.tm-rgo .tm-find { margin-top: 0; }
.tm-rfind.off { opacity: .45; pointer-events: none; box-shadow: none; }
.tm-rep .tm-cl button.on { background: var(--blue-50); color: var(--blue-600); font-weight: 600; }
.tm-rep .tm-cl button.on i { background: var(--tm-rep-sel); }
.tm-rmore { margin-top: 18px; }
.tm-rh { display: flex; align-items: baseline; gap: 8px; margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--navy); }
.tm-rh span { font-size: 12px; font-weight: 500; color: var(--muted); }
.tm-ri { list-style: none; display: grid; gap: 0; margin-top: 6px; }
.tm-ri li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.tm-ri li:last-child { border-bottom: 0; }
.tm-ri b { font-weight: 600; color: var(--navy); }
.tm-ri span { color: var(--body); }
.tm-ri em { font-style: normal; font-size: 12px; color: var(--subtle); }

/* county list */
.tm-clist { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.tm-clh h4, .tm-srcs h4 { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tm-cq { width: 100%; height: 40px; margin-top: 10px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); font-size: 14px; outline: none; }
.tm-cq:focus { border-color: var(--blue); box-shadow: var(--ring); }
.tm-cl { list-style: none; margin-top: 8px; max-height: 260px; overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 6px; overscroll-behavior: contain; }
.tm-cl button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font-size: 13.5px; color: var(--text); padding: 6px 8px; border-radius: 8px; min-height: 34px; }
.tm-cl button:hover { background: var(--bg); color: var(--navy); }
.tm-cl li[hidden] { display: none; }

/* sources */
.tm-srcs { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 8px; }
.tm-src { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 12px; background: var(--bg); transition: background .15s; }
.tm-src:hover { background: var(--blue-25); }
.tm-src svg { color: var(--blue); margin-top: 2px; }
.tm-src span { display: grid; gap: 2px; min-width: 0; }
.tm-src b { font-size: 13px; font-weight: 600; color: var(--navy); line-height: 1.35; }
.tm-src em { font-style: normal; font-size: 12px; color: var(--muted); }

.tm-disc { display: flex; gap: 8px; align-items: center; justify-content: center; text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted); }
.tm-disc svg { color: var(--subtle); }

@media (max-width: 1100px) {
  .tm-grid { grid-template-columns: minmax(0, 1fr) 340px; }
}

/* phone + small tablet: panel becomes a bottom sheet once a state is picked */
@media (max-width: 860px) {
  .tm-head { margin-bottom: 14px; }
  .tm-bar { gap: 10px; }
  .tm-seg { width: 100%; grid-auto-columns: 1fr; }
  .tm-search { flex: 1 1 100%; }
  .tm-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tm-mapcard { padding: 12px 12px 14px; border-radius: 18px; }
  .tm-maptop { min-height: 36px; }
  .tm-where { font-size: 16px; }
  .tm-legend { font-size: 12.5px; gap: 6px 14px; }
  .tm-panel { position: static; max-height: none; border-radius: 18px; padding: 18px 16px; }
  .tm.has-sel .tm-panel {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; top: auto;
    max-height: 50vh; max-height: 50dvh; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px -8px rgba(11, 31, 58, .25);
    animation: tmsheet .32s var(--ease);
  }
  .tm.has-sel .tm-grab { display: block; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line-2); }
  .tm.has-sel .tm-x { top: 12px; right: 10px; }
  .tm-cl { max-height: 220px; }
  .tm.zoomed .tm-note { display: none; }
  .tm.has-sel .tm-panel { max-height: 50vh; max-height: 50dvh; }
  .tm.has-sel { padding-bottom: 50vh; }
  .tm-find { margin-top: 14px; }
  .tm-cl button { min-height: 40px; }
  .tm-chip { min-height: 36px; font-size: 13.5px; }
  .tm.has-sel .tm-rgo { bottom: calc(-18px - env(safe-area-inset-bottom)); padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .tm-field input { height: 46px; font-size: 16px; }
  .tm-disc { align-items: flex-start; text-align: left; justify-content: flex-start; }
}
@keyframes tmsheet { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .tm-svg .st, .tm-svg .co, #tmcounties.in { transition: none; }
  .tm.has-sel .tm-panel { animation: none; }
}
