/* NY Property Records — the map application
   ---------------------------------------------------------------------------
   Survey-sheet identity carried over from the isitfrum map it is modeled on:
   cool slate chrome, slate ink, teal accent. The map fills the screen; the
   search bar and the record card float over it as small "survey readouts". */

:root {
  --paper:  #f7f8fa;   /* app chrome (cool slate) */
  --card:   #ffffff;   /* readouts sit on white for crisp text */
  --ink:    #1b2530;
  --ink-2:  #3f4a57;
  --muted:  #5f6b78;
  --line:   #e2e6ec;
  --line-2: #d3d9e1;

  --accent:      #0e7c6b;   /* teal */
  --accent-ink:  #0b5f52;   /* teal as readable text */
  --accent-soft: #dcede9;   /* teal wash */

  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(27,37,48,.06), 0 2px 6px rgba(27,37,48,.08);
  --shadow-lg: 0 18px 44px -14px rgba(27,37,48,.34);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* [hidden] must beat any display rule below. */
[hidden] { display: none !important; }

/* The map is the page at every size: it fills the window, and the search
   bar, brand and record card float over it. Phones get the same treatment
   as desktop - the card just docks to the bottom instead of the right. */
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 15px/1.5 var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ header */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000;
  /* The bar spans the window, but only its controls should swallow clicks -
     everything else falls through to the map behind it. */
  pointer-events: none;
}
.bar {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
}
.bar > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 15px 7px 9px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-family: var(--font-display); font-size: 18px; font-weight: 600;
  letter-spacing: -.01em; color: var(--ink); text-decoration: none;
}
.brand:hover { color: var(--accent-ink); }
.brandmark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--accent);
}

/* ------------------------------------------------------------------ search */
.search {
  position: relative;
  width: 100%;
  max-width: 620px;
}
.search .icon {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 19px; height: 19px; pointer-events: none;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
#addr {
  width: 100%;
  height: 54px;
  padding: 0 44px 0 48px;
  font-family: var(--font-body); font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 27px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
#addr::placeholder { color: #9aa4b0; }
#addr:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14,124,107,.2), var(--shadow-sm);
}
.search.open #addr { border-radius: 27px 27px 0 0; box-shadow: none; border-color: var(--line-2); }

#clear {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--paper); color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s;
}
#clear:hover { background: var(--accent-soft); color: var(--accent-ink); }

#suggest {
  position: absolute; left: 0; right: 0; top: 100%;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 336px; overflow-y: auto;
  z-index: 1200;
}
#suggest li {
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
}
#suggest li .a { font-size: 14.5px; font-weight: 550; }
#suggest li .t { font-size: 12.5px; color: var(--muted); }
#suggest li[aria-selected="true"], #suggest li:hover { background: var(--accent-soft); }
#suggest li.empty { color: var(--muted); cursor: default; font-size: 14px; }
#suggest li.empty:hover { background: none; }

/* ------------------------------------------------------- the record card */
#result {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#result > * { flex-shrink: 0; }

/* Which address the card is about, and the button that dismisses it - the
   card floats over the map at every size now, so both are always wanted. */
.r-address {
  display: block;
  margin: -10px 0 2px;
  padding-right: 26px;
  font-family: var(--font-display);
  font-size: 15px; font-weight: 600; line-height: 1.35;
  letter-spacing: -.01em; color: var(--ink);
}
.r-close {
  position: sticky; top: -14px;
  align-self: flex-end;
  z-index: 2;
  width: 26px; height: 26px; margin: -4px -4px -6px 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--card); color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.r-close:hover { background: var(--accent-soft); color: var(--accent-ink);
                 border-color: var(--accent); }

/* The one number every record leads with. */
.d-market {
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
}
.d-market .v {
  font-family: var(--font-display); font-size: 24px; font-weight: 600;
  letter-spacing: -.01em;
}
.d-market .k {
  font: 500 10.5px/1.6 var(--font-mono); letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.d-class {
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font: 600 10.5px/1.6 var(--font-mono); letter-spacing: .04em;
  text-transform: uppercase;
}
/* Same chip language as .d-class, but it goes somewhere: the deed. */
.d-sold {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font: 600 10.5px/1.6 var(--font-mono); letter-spacing: .04em;
  text-transform: uppercase; text-decoration: none; white-space: nowrap;
  transition: background .15s, color .15s;
}
.d-sold:hover { background: var(--accent); color: #fff; }

/* OpenValue: the one solid-teal chip on the card - it is the product. */
.d-value {
  padding: 2px 10px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; cursor: pointer;
  font: 600 10.5px/1.6 var(--font-mono); letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
  transition: background .15s;
}
.d-value:hover { background: var(--accent-ink); }

#value-panel {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px 8px; background: var(--card);
}
.value-chart {
  width: 100%; height: auto; display: block;
  cursor: crosshair;
  /* Horizontal scrubbing belongs to the chart; vertical drags still
     scroll the card. */
  touch-action: pan-y;
}
.vc-tick { font: 500 10px var(--font-mono); fill: var(--muted); }
.vc-guide { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }
.vc-readout {
  font: 600 15px var(--font-body); color: var(--ink);
  margin-bottom: 2px;
}
.vc-readout .k {
  font: 600 10.5px/1.6 var(--font-mono); letter-spacing: .05em;
  text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: 999px; padding: 1px 8px;
  margin-right: 6px; vertical-align: 2px;
}
.value-note {
  margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--muted);
  border-top: 1px dashed var(--line-2); padding-top: 7px;
}
.value-note a { color: var(--accent-ink); }

.d-section { display: flex; flex-direction: column; gap: 3px; }
.d-head {
  /* Tighter than the tagline's .09em: the violation/complaint heads carry
     three stats ("total 29 · open 0 · dismissed 29") and must fit the
     380px panel on one line. */
  font: 500 10px/1.8 var(--font-mono); letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px dashed var(--line-2);
  margin-bottom: 3px;
  /* Room for the panel's sticky close button when a section head is the
     first thing in the panel. */
  padding-right: 26px;
}

/* --------------------------------------------------------- Street View */
.sv-fold > summary.d-head {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 6px;
  color: var(--accent-ink);
}
.sv-fold > summary.d-head::-webkit-details-marker { display: none; }
.sv-fold > summary.d-head::after {
  content: "▾"; margin-left: auto; padding-right: 2px;
  font-size: 11px; color: var(--muted); transition: transform .15s;
}
.sv-fold[open] > summary.d-head::after { transform: rotate(180deg); }
.sv-fold > summary.d-head:hover { color: var(--accent); }
.sv-frame {
  position: relative; width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 220px;
  margin-top: 4px;
  border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--paper);
}
.sv-frame .sv-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border: 0;
  pointer-events: none;
  user-select: none;
  background: var(--paper);
}
.sv-open {
  display: inline-block; margin-top: 6px;
  font-size: 12px; font-weight: 600; color: var(--accent-ink);
  text-decoration: none;
}
.sv-open:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  .sv-fold > summary.d-head::after { transition: none; }
}
.d-row {
  display: flex; gap: 12px; align-items: baseline;
  font-size: 13.5px; line-height: 1.5;
}
.d-row .k { flex: 0 0 118px; color: var(--muted); font-size: 12.5px; }
.d-row .v { color: var(--ink); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.d-row .v.money { font-family: var(--font-mono); font-weight: 500; }

.r-dim { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------ recorded documents (NYC) */
.doc {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; margin: 2px 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card);
}
.doc-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.doc-type { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.doc-amt { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent-ink); font-weight: 500; }
.doc-date { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.doc-party { font-size: 12.5px; color: var(--ink-2); }
.doc-party .k {
  display: inline-block; min-width: 0;
  font: 500 10px/1.6 var(--font-mono); letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-right: 4px;
}
.doc-open {
  align-self: flex-start; margin-top: 4px;
  padding: 3px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12px; font-weight: 600; text-decoration: none;
  transition: background .15s, color .15s;
}
.doc-open:hover { background: var(--accent); color: #fff; }

/* --------------------------------------------------------- DOB violations */
.viol {
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 10px; margin: 2px 0;
  border: 1px solid var(--line); border-radius: 10px;
}
a.viol-link {
  color: inherit; text-decoration: none;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
a.viol-link:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.viol-go {
  align-self: flex-start; margin-top: 2px;
  font-size: 11px; font-weight: 600; color: var(--accent-ink);
}
a.viol-link:hover .viol-go { text-decoration: underline; }

.viol-status {
  padding: 1px 8px; border-radius: 999px;
  background: var(--paper); color: var(--muted);
  font: 600 10px/1.7 var(--font-mono); letter-spacing: .05em;
  text-transform: uppercase;
}
.viol-status.open { background: #f8e8e2; color: #a4431f; }
/* HPD hazard classes: C shouts, B warns, A murmurs. */
.viol-status.hpd-c { background: #f6dcd5; color: #8f2c0d; }
.viol-status.hpd-b { background: #f7ecd7; color: #8a6520; }
.viol-status.hpd-a { background: var(--paper); color: var(--muted); }
.viol-status.hpd-i { background: #f6dcd5; color: #8f2c0d; }
.viol-open-ct {
  margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: #f8e8e2; color: #a4431f;
  font: 600 10px/1.7 var(--font-mono); letter-spacing: .05em;
}
/* An open count that is not zero should catch the eye on a skim. */
.d-head .ct-open { color: #a4431f; font-weight: 600; }
.viol-more summary {
  cursor: pointer; font-size: 12.5px; color: var(--accent-ink);
  font-weight: 600; padding: 4px 0;
}
.viol-more summary:hover { text-decoration: underline; }
.r-empty { color: var(--muted); font-style: italic; font-size: 14px; }

.r-spin {
  display: inline-block; width: 12px; height: 12px; margin-top: 3px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: r-spin .7s linear infinite;
}
@keyframes r-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .r-spin { animation-duration: 2.4s; } }

.r-share { margin-top: 1px; }
.r-copy {
  padding: 5px 13px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--accent-ink);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.r-copy:hover { background: var(--accent-soft); border-color: var(--accent); }
.r-copy.ok { background: #e6f0e4; border-color: #b7d3ac; color: #3d6b2e; }

.towns {
  margin: 0;
  padding: 5px 14px;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.towns a { color: var(--accent-ink); text-decoration: none; }
.towns a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------- map */
#map { position: fixed; inset: 0; height: 100%; background: #e7e6df; }

/* The map page's visible footer: a small pill pinned bottom-left, clear of
   Leaflet's attribution (bottom-right) and the hint (bottom-centre). */
#sitefoot {
  position: fixed; left: 12px; bottom: 12px; z-index: 900;
  padding: 9px 16px;
  background: var(--card);
  border: 1px solid var(--line-2); border-radius: 999px;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
}
#sitefoot a {
  color: var(--accent-ink); text-decoration: none; font-weight: 600;
  padding: 2px 2px;
}
#sitefoot a:hover { color: var(--accent); text-decoration: underline; }

.hint {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(27,37,48, .9);
  color: var(--paper);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 900;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.pin-mark { background: none; border: 0; }
.pin-mark svg { display: block; filter: drop-shadow(0 3px 4px rgba(27,37,48,.35)); }

/* Owner labels on each parcel — kept high-contrast against the basemap */
.owner-label {
  background: rgba(255, 253, 248, .95);
  color: #17212e;
  border: 1px solid rgba(27,37,48, .16);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(27,37,48, .2);
}
.owner-label::before { display: none; }
.leaflet-tooltip.owner-label { margin: 0; }

/* Parcel popup */
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-lg);
  background: var(--card); }
.leaflet-popup-tip { background: var(--card); }
.leaflet-popup-content { margin: 14px 16px; max-height: 60vh; overflow-y: auto; }
.pp-owner { font-family: var(--font-display); font-size: 16px; font-weight: 600;
  letter-spacing: -.01em; margin-bottom: 3px; }
.pp-addr { font-size: 13px; color: var(--muted); }
.pp-meta { font-family: var(--font-mono); font-size: 11px; letter-spacing: .03em;
  color: var(--muted); margin-top: 7px; }

.leaflet-control-attribution { font-size: 10px; }

@media (max-width: 640px) {
  .bar { padding: 15px 14px 17px; gap: 11px; }
  #addr { height: 50px; font-size: 16px; }
  .towns { font-size: 10.5px; letter-spacing: .04em; }
  .leaflet-popup-content { min-width: 0 !important; }
  .d-row .k { flex-basis: 104px; }
}

/* ===========================================================================
   Desktop: the map is the page. Search centred on top, the record card as a
   panel down the right that scrolls inside itself.
   =========================================================================== */
@media (min-width: 1000px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: block; min-height: 0; }

  #map { position: fixed; inset: 0; height: 100%; min-height: 0; }

  #topbar {
    position: fixed; top: 0; left: 0; right: 0;
    background: none; background-image: none; border-bottom: 0;
    pointer-events: none;    /* only the controls swallow clicks */
  }
  .bar { padding: 18px 20px 0; gap: 11px; }
  .bar > * { pointer-events: auto; }

  .brand {
    padding: 7px 15px 7px 9px;
    background: var(--card);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
  }
  .towns {
    padding: 5px 14px;
    background: rgba(255,255,255,.9);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    backdrop-filter: blur(4px);
  }

  #result {
    position: fixed;
    top: 18px; right: 18px; bottom: auto; left: auto;
    width: 380px; max-width: calc(100vw - 36px);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
  }

  .r-address {
    display: block;
    margin: -10px 0 2px;
    padding-right: 26px;
    font-family: var(--font-display);
    font-size: 15px; font-weight: 600; line-height: 1.35;
    letter-spacing: -.01em; color: var(--ink);
  }

  .r-close {
    position: sticky; top: -14px;
    align-self: flex-end;
    z-index: 2;
    width: 26px; height: 26px; margin: -4px -4px -6px 0; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-2); border-radius: 50%;
    background: var(--card); color: var(--muted);
    font-size: 17px; line-height: 1; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
  }
  .r-close:hover { background: var(--accent-soft); color: var(--accent-ink);
                   border-color: var(--accent); }
}

/* Below the desktop breakpoint the record card docks as a bottom sheet:
   full width, its own scroll, map still visible above it. */
@media (max-width: 999px) {
  /* The footer pill owns the bottom edge on a phone - and can wrap to two
     lines on narrow screens - so the hint toast clears it with room. */
  .hint { bottom: 92px; }
  #sitefoot {
    font-size: 11px; padding: 6px 12px;
    max-width: calc(100vw - 24px);
  }

  #result {
    position: fixed;
    left: 8px; right: 8px; bottom: 8px;
    width: auto; max-width: none;
    max-height: 55vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
  }
}

/* Between these widths an open panel would sit under a centred search box. */
@media (min-width: 1000px) and (max-width: 1399px) {
  body:has(#result:not([hidden])) .bar { padding-right: 416px; }
}
