/* parcels/style.css — full-page map app.
   Design tokens (--background, --text, --accent, --surface, --muted,
   --border, --shadow) are defined inline below so this page is
   self-contained and doesn't inherit the site-wide layout CSS. */

:root {
  --background: #f5f5f5;
  --surface:    #ffffff;
  --text:       #1a1a1a;
  --muted:      #6b7280;
  --accent:     #2563eb;
  --border:     #e5e7eb;
  --shadow:     rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111827;
    --surface:    #1f2937;
    --text:       #f9fafb;
    --muted:      #9ca3af;
    --accent:     #60a5fa;
    --border:     #374151;
    --shadow:     rgba(0,0,0,0.35);
  }
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
}

/* ── Full-viewport map ──────────────────────────────────────────────── */
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Zoom hint — top-center floating pill ───────────────────────────── */
.zoom-hint {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Floating brand chip — top-left ────────────────────────────────── */
.map-brand {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px var(--shadow);
  transition: opacity 0.15s ease;
}
.map-brand:hover { opacity: 0.8; }

/* ── Filter panel — floating card, top-left ────────────────────────── */
.filter-panel {
  position: fixed;
  top: 52px;
  left: 12px;
  width: 290px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 130px);
  z-index: 90;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-panel.is-collapsed {
  transform: translateX(-100%);
}

/* Toggle handle — sticks out of the card's right edge, always visible. */
.filter-toggle {
  position: absolute;
  right: -28px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 56px;
  appearance: none;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  box-shadow: 3px 0 8px var(--shadow);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease;
}
.filter-toggle:hover { color: var(--text); }

.filter-toggle-chevron {
  display: block;
  transition: transform 0.2s ease;
}
.filter-panel.is-collapsed .filter-toggle-chevron { transform: rotate(180deg); }

.filter-inner {
  padding: 0.9rem 1rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.filter-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.filter-clear {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
}
.filter-clear:hover { text-decoration: underline; }

.filter-group { margin-top: 0.85rem; }

.filter-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.chip { cursor: pointer; }

.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.chip span {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--background);
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.range-row { display: flex; align-items: center; gap: 8px; }
.range-sep { flex-shrink: 0; font-size: 0.8rem; color: var(--muted); }

.filter-num,
.filter-select {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.filter-num:focus,
.filter-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.filter-hint {
  margin: 0.4rem 0 0;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
  font-style: italic;
}

.filter-search {
  width: 100%;
  margin-top: 1.1rem;
  padding: 9px 12px;
  appearance: none;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.filter-search:hover { opacity: 0.9; }
.filter-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.filter-result {
  margin: 0.8rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}
.filter-result[data-state="done"]    { color: var(--text); font-weight: 600; }
.filter-result[data-state="loading"] { font-style: italic; }
.filter-result[data-state="error"]   { color: #b00020; }

@media (prefers-color-scheme: dark) {
  .filter-result[data-state="error"] { color: #ff8080; }
}

@media (max-width: 600px) {
  .filter-panel { top: 48px; max-height: calc(100vh - 160px); }
}

/* ── Drawer — fixed right overlay ──────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 380px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 32px var(--shadow);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* closed: translated off the right edge */
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer.is-open {
  transform: translateX(0);
}

/* ── Drag handle — left edge of drawer ─────────────────────────────── */
.drawer-handle {
  position: absolute;
  left: -28px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  box-shadow: -3px 0 8px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.drawer-handle:active { cursor: grabbing; }

.drawer-handle-grip {
  display: block;
  width: 3px;
  height: 24px;
  border-left: 2px solid var(--border);
  border-right: 2px solid var(--border);
}

/* ── Mobile: full-width drawer, no handle ──────────────────────────── */
@media (max-width: 600px) {
  .drawer       { width: 100vw; }
  .drawer-handle { display: none; }
}

/* ── Drawer header ──────────────────────────────────────────────────── */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, var(--accent) 5%);
  flex-shrink: 0;
}

.drawer-title { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.drawer-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

#drawer-parcel-id {
  margin: 0;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 1rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.drawer-close {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.drawer-close:hover {
  background: color-mix(in srgb, var(--surface) 70%, var(--accent) 10%);
  color: var(--text);
  border-color: var(--border);
}

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover { color: var(--text); }

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Tab panels — scrollable content area ──────────────────────────── */
.tab-panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-panel {
  padding: 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.tab-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.panel-loading {
  color: var(--muted);
  font-style: italic;
}

.panel-error {
  color: #b00020;
  background: color-mix(in srgb, #b00020 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #b00020 25%, var(--border));
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
}

@media (prefers-color-scheme: dark) {
  .panel-error { color: #ff8080; }
}

/* ── Constraint content ─────────────────────────────────────────────── */
.constraints-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.4;
}

.constraints-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.constraints-grid dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.constraints-grid .muted { color: var(--muted); font-weight: 400; }

.panel-section-title {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.panel-source {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.panel-note {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.7rem;
  background: color-mix(in srgb, var(--surface) 82%, var(--accent) 12%);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.panel-warning {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-warnings {
  list-style: disc inside;
  margin: 0.6rem 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── MapLibre controls — slide left when drawer is open ─────────────── */
.maplibregl-ctrl-top-right {
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
body.drawer-open .maplibregl-ctrl-top-right {
  right: 388px; /* 380px drawer + 8px gap */
}
/* On mobile the drawer is full-width; don't shift controls (they're hidden anyway) */
@media (max-width: 600px) {
  body.drawer-open .maplibregl-ctrl-top-right { right: 8px; }
}

/* ── MapLibre controls readability ──────────────────────────────────── */
.maplibregl-ctrl-attrib {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--text);
}

.maplibregl-ctrl-attrib a { color: var(--accent); }

/* ── Embed popup (used on /parcels/embed.html) ───────────────────────── */
.maplibregl-popup-content {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px var(--shadow);
  font-family: inherit;
}

.maplibregl-popup-tip { border-top-color: var(--border); }

.parcel-popup dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 10px;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.parcel-popup dt { color: var(--muted); font-weight: 600; text-transform: capitalize; }
.parcel-popup dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.parcel-popup .err {
  margin: 0.35rem 0 0;
  color: #b00020;
  font-size: 0.85rem;
}

@media (prefers-color-scheme: dark) {
  .parcel-popup .err { color: #ff8080; }
}
