/* ─────────────────────────────────────────────────────────────────────────
 * parcel-drawer.css — Phase A Land Parcel Detail Drawer
 *
 * Right-side overlay drawer (520px desktop, 100% mobile). Built on the
 * Montana Editorial palette in styles/base.css — only token references,
 * no new color values.
 *
 * Sections render as `createWidget`-style cards stacked in a single
 * scroll column with a sticky 36px icon-rail nav at the left edge.
 * ────────────────────────────────────────────────────────────────────── */

#guide-parcel-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 100vw;
  /* A raised sheet floating over the map + left panel: solid, a 1px rule on
     its open edge, the elevation shadow. */
  background: var(--guide-color-raised);
  border-left: 1px solid var(--guide-color-line);
  box-shadow: var(--guide-shadow-overlay);
  z-index: var(--guide-z-max, 9000);
  transform: translateX(100%);
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  font-family: inherit;
  color: var(--text-primary, #1A1A1F);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #guide-parcel-drawer { background: var(--bg-1, #F2EFE8); }
}

#guide-parcel-drawer.pd-open {
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  #guide-parcel-drawer { transition: none; }
}

@media (max-width: 768px) {
  #guide-parcel-drawer { width: 100vw; }
}

/* ─── Header ──────────────────────────────────────────────────────────── */
.pd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-2, #FFFFFF);
  border-bottom: 1px solid var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
  flex-shrink: 0;
}

.pd-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: var(--guide-fs-base);
}

.pd-head-icon {
  width: 18px;
  height: 18px;
  color: var(--guide-color-ink);
}

.pd-head-text {
  color: var(--text-primary);
}

.pd-head-id {
  font-family: var(--guide-font-mono);
  font-size: var(--guide-fs-xs);
  color: var(--text-tertiary, #6B6B73);
  background: var(--bg-3, #F7F5F0);
  padding: 2px 8px;
  border-radius: 4px;
}

.pd-head-actions {
  display: flex;
  gap: 4px;
}

.pd-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 6px;
  color: var(--text-secondary, #4A4A52);
  transition: background 120ms ease;
}

.pd-icon-btn:hover { background: var(--bg-4, #EDEAE2); color: var(--text-primary); }
.pd-icon-btn:focus-visible {
  outline: 2px solid var(--mt-teal, #0F766E);
  outline-offset: 2px;
}
.pd-icon-btn-active {
  background: color-mix(in srgb, var(--guide-color-action) 10%, transparent);
  color: var(--guide-color-action);
}
.pd-icon-btn-active:hover {
  background: color-mix(in srgb, var(--guide-color-action) 18%, transparent);
  color: var(--guide-color-action);
}

.pd-icon-btn i { width: 16px; height: 16px; }

/* ─── Body: nav rail + scroll column ──────────────────────────────────── */
.pd-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.pd-nav {
  flex: 0 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  background: var(--bg-3, #F7F5F0);
  border-right: 1px solid rgba(var(--guide-wash-rgb, 0, 0, 0), 0.05);
}

.pd-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary, #6B6B73);
  transition: background 120ms, color 120ms;
}

.pd-nav-btn i { width: 14px; height: 14px; }

.pd-nav-btn:hover { background: var(--bg-2); color: var(--text-primary); }
.pd-nav-btn:focus-visible {
  outline: 2px solid var(--mt-teal);
  outline-offset: 1px;
}

.pd-nav-slate:hover { color: var(--mt-slate, #3B5A7A); }
.pd-nav-gold:hover  { color: var(--mt-gold, #C8932F); }
.pd-nav-teal:hover  { color: var(--mt-teal, #0F766E); }
.pd-nav-red:hover   { color: var(--guide-color-action); }
.pd-nav-sage:hover  { color: var(--ai-accent, #84A65A); }

.pd-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px 24px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .pd-scroll { scroll-behavior: auto; }
}

.pd-scroll:focus-visible {
  outline: 2px solid var(--mt-teal);
  outline-offset: -2px;
}

/* ─── Sections ────────────────────────────────────────────────────────── */
.pd-section {
  background: var(--bg-2, #FFFFFF);
  border: 1px solid var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.pd-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(var(--guide-wash-rgb, 0, 0, 0), 0.04);
}

.pd-section-icon {
  width: 16px;
  height: 16px;
  color: var(--mt-slate);
}

.pd-section-slate .pd-section-icon { color: var(--mt-slate); }
.pd-section-gold  .pd-section-icon { color: var(--mt-gold); }
.pd-section-teal  .pd-section-icon { color: var(--mt-teal); }
.pd-section-red   .pd-section-icon { color: var(--guide-color-ink); }
.pd-section-sage  .pd-section-icon { color: var(--ai-accent, #84A65A); }

.pd-section-title {
  margin: 0;
  font-size: var(--guide-fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-secondary);
}

.pd-section-body {
  padding: 12px 14px 14px;
  font-size: var(--guide-fs-sm);
  color: var(--text-primary);
}

/* ─── Loading / empty / error ─────────────────────────────────────────── */
.pd-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pd-skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--bg-3) 0%, var(--bg-4) 50%, var(--bg-3) 100%);
  background-size: 200% 100%;
  animation: pd-shimmer 1.2s ease-in-out infinite;
}

.pd-skeleton-bar--short { width: 60%; }


@media (prefers-reduced-motion: reduce) {
  .pd-skeleton-bar { animation: none; }
}

.pd-empty,
.pd-empty-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  color: var(--text-tertiary);
  font-size: var(--guide-fs-sm);
  text-align: center;
}

.pd-empty i, .pd-empty-mini i { width: 22px; height: 22px; opacity: 0.6; }

.pd-empty p { margin: 4px 0 0; }

.pd-empty-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  background: var(--bg-3);
  border-radius: 8px;
  font-size: var(--guide-fs-xs);
  color: var(--text-secondary);
}

.pd-empty-hint i { width: 14px; height: 14px; color: var(--mt-slate); }

.pd-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--guide-color-line);
  background: rgba(180, 83, 9, 0.06);
  border-radius: 6px;
  font-size: var(--guide-fs-sm);
  color: var(--text-primary);
}

.pd-error i { width: 16px; height: 16px; color: var(--severity-warn); }

/* ─── Chips (Identity) ───────────────────────────────────────────────── */
.pd-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.pd-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-3);
  border-radius: 8px;
  min-width: 0;
}

.pd-chip-icon {
  width: 16px; height: 16px;
  color: var(--mt-slate);
  flex-shrink: 0;
}

.pd-chip-meta { min-width: 0; }

.pd-chip-val {
  font-size: var(--guide-fs-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-chip-lab {
  font-size: var(--guide-fs-2xs);
  color: var(--text-tertiary);
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.pd-trs {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--guide-fs-xs);
  color: var(--text-tertiary);
  font-family: var(--guide-font-mono);
}

.pd-trs i { width: 12px; height: 12px; }

/* ─── Stat rows ──────────────────────────────────────────────────────── */
.pd-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.pd-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg-3);
  border-radius: 6px;
}

.pd-stat-val {
  font-size: var(--guide-fs-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.pd-stat-lab {
  font-size: var(--guide-fs-2xs);
  color: var(--text-tertiary);
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ─── Cards ──────────────────────────────────────────────────────────── */
.pd-card {
  border: 1px solid var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--bg-2);
}

.pd-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--guide-fs-xs);
  font-weight: 600;
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pd-card-head i { width: 14px; height: 14px; }

.pd-card-warn  { border: 1px solid var(--guide-color-line); background: rgba(180, 83, 9, 0.04); }

.pd-soil-mu {
  padding: 6px 0;
  border-top: 1px dashed var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
  font-size: var(--guide-fs-xs);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pd-soil-mu strong { font-weight: 500; color: var(--text-primary); }

.pd-mono { font-family: var(--guide-font-mono); font-size: var(--guide-fs-xs); }
.pd-muted { color: var(--text-tertiary); }

.pd-hint {
  margin-top: 8px;
  font-size: var(--guide-fs-xs);
  color: var(--text-tertiary);
  font-style: italic;
}

/* ─── Water table ────────────────────────────────────────────────────── */
.pd-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
}

.pd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--guide-fs-xs);
}

.pd-table thead th {
  background: var(--bg-3);
  text-align: left;
  padding: 6px 8px;
  font-weight: 600;
  font-size: var(--guide-fs-2xs);
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--guide-color-border-subtle, rgba(0, 0, 0, 0.06));
}

.pd-table tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(var(--guide-wash-rgb, 0, 0, 0), 0.04);
}

.pd-table tbody tr:last-child td { border-bottom: none; }

.pd-water-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.pd-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: var(--guide-fs-2xs);
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
  font-weight: 600;
  background: var(--bg-3);
  color: var(--text-secondary);
}

.pd-badge-active, .pd-badge-actv {
  background: rgba(21, 115, 71, 0.12);
  color: var(--severity-success, #157347);
}
.pd-badge-inactive, .pd-badge-inac {
  background: var(--bg-4);
  color: var(--text-tertiary);
}

/* ─── Gauge rows ─────────────────────────────────────────────────────── */
.pd-gauge-row {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  font-size: var(--guide-fs-xs);
  border-top: 1px dashed rgba(var(--guide-wash-rgb, 0, 0, 0), 0.05);
}

/* ─── Recorded risk facts (no grades) ───────────────────────────────────────────────────────────────────────────── */
.pd-grade-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.pd-grade-factors {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--guide-fs-xs);
}

.pd-factor {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--bg-3);
}


.pd-factor-delta {
  font-family: var(--guide-font-mono);
  font-size: var(--guide-fs-xs);
  color: var(--text-secondary);
}

/* ─── AI Brief CTA ───────────────────────────────────────────────────── */
.pd-ai-brief { display: flex; flex-direction: column; gap: 10px; }

.pd-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--guide-color-action);
  color: var(--guide-color-text-on-accent, #fff);
  font-weight: 600;
  font-size: var(--guide-fs-sm);
  transition: background var(--guide-dur-fast);
}

.pd-cta:hover { background: var(--guide-color-action-hover); }
.pd-cta:focus-visible {
  outline: 2px solid var(--mt-teal);
  outline-offset: 2px;
}

.pd-cta i { width: 16px; height: 16px; }

.pd-ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(132, 166, 90, 0.15);
  color: #4d6235;
  font-size: var(--guide-fs-2xs);
  font-weight: 600;
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
  margin-left: auto;
}

.pd-cta .pd-ai-pill {
  background: rgba(255, 255, 255, 0.15);
  color: var(--guide-color-text-on-accent, #fff);
}

.pd-ai-pill i { width: 10px; height: 10px; }

.pd-brief-out {
  background: var(--bg-3);
  padding: 12px;
  border-radius: 8px;
  font-size: var(--guide-fs-sm);
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* ─── Body class while open: prevent host scroll ──────────────────────── */
body.guide-parcel-drawer-open {
  overflow: hidden;
}

/* ── Dark-theme overrides ── */
[data-theme="dark"] #guide-parcel-drawer {
  border-left-color: rgba(255,255,255,0.08);
  box-shadow: var(--guide-shadow-overlay);
}
[data-theme="dark"] .pd-head { border-bottom-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pd-nav { border-right-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .pd-section { border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pd-section-head { border-bottom-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .pd-card { border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pd-soil-mu { border-top-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pd-table-wrap { border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pd-table thead th { border-bottom-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .pd-table tbody td { border-bottom-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .pd-gauge-row { border-top-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .pd-ai-pill:not(.pd-cta .pd-ai-pill) { color: #4ADE80; }

@media (min-width: 1280px) {
  body.guide-parcel-drawer-open {
    overflow: auto; /* desktop keeps the page scrollable next to drawer */
  }
}

/* ── Provenance footer ─────────────────────────────────────────────────────
   What the cadastral record IS, sourced from the MSDI Cadastral Framework
   service description. Owner data is a copy of a tax database and boundaries
   are GCDB-aligned depictions, not a survey — both facts change how much
   weight a reader should put on the panel above. */
.pd-provenance {
  margin: var(--guide-sp-4, 16px) 0 0;
  padding: 12px 14px;
  border-top: 1px solid var(--guide-color-line, rgba(0,0,0,0.10));
  color: var(--guide-color-ink-3, rgba(0,0,0,0.55));
}
.pd-provenance h4 {
  margin: 0 0 6px;
  font-size: var(--guide-fs-xs);
  text-transform: var(--guide-label-case, uppercase);
  letter-spacing: 0.04em;
}
.pd-provenance p { margin: 0 0 6px; font-size: var(--guide-fs-xs); line-height: 1.45; max-width: 70ch; }
.pd-provenance strong { color: var(--guide-color-ink-2, rgba(0,0,0,0.70)); }
.pd-provenance-src { font-style: italic; }

/* Withheld by the owner gate (lib/parcel-privacy.js) — visibly different from
   an em dash, which would claim the record has no owner. */
.pd-locked {
  color: var(--guide-color-mt-blue, #3B5A7A);
  font-style: italic;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}
