/* U.S. New Developments & Active Foundation Permits Stylesheet (cleanwhale.us/buildings/)
   Follows modern-web-guidance: responsive-table (@container), sortable-table,
   search-hidden-content, forms, brand-consistent-forms (@supports not accent-color),
   and defer-rendering-heavy-content (content-visibility: auto strictly below the fold). */

:root {
  --nd-brand: #1d4ed8;
  --nd-brand-dark: #1e40af;
  --nd-brand-soft: #eff6ff;
  --nd-ink: #0f172a;
  --nd-muted: #475569;
  --nd-border: #cbd5e1;
  --nd-border-light: #e2e8f0;
  --nd-bg-subtle: #f8fafc;
}

/*Canonical screen-reader-only helper (never display: none) */
.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

/* Strictly below-the-fold deferred rendering */
.nd-below-fold {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 400px;
}

/* Stage Badges */
.nd-stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.nd-stage-badge--blue {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.nd-stage-badge--amber {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.nd-stage-badge--green {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Search & Filter Bar (<search><form method="GET">) */
.nd-filter-box {
  background: var(--nd-bg-subtle);
  border: 1px solid var(--nd-border-light);
  border-radius: 12px;
  padding: 1.125rem;
  margin-block: 1.25rem 1.75rem;
}
.nd-filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(auto-fit, minmax(170px, 1fr)) auto;
  gap: 0.875rem;
  align-items: end;
}
@media (max-width: 780px) {
  .nd-filter-grid {
    grid-template-columns: 1fr;
  }
}
.nd-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.nd-field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--nd-ink);
}
.nd-field input,
.nd-field select,
.nd-calc-input {
  font: inherit;
  font-size: max(1rem, 1em);
  padding: 0.65rem 0.8rem;
  min-height: 48px;
  border: 1px solid #64748b;
  border-radius: 8px;
  background: #fff;
  color: var(--nd-ink);
  box-sizing: border-box;
  width: 100%;
}
@media (pointer: coarse) {
  .nd-field input,
  .nd-field select,
  .nd-calc-input {
    min-height: 52px;
  }
}
.nd-field input:focus-visible,
.nd-field select:focus-visible,
.nd-calc-input:focus-visible,
.nd-btn:focus-visible,
.nd-legre-tab:focus-visible {
  outline: 3px solid var(--nd-brand);
  outline-offset: 2px;
}

.nd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-size: max(1rem, 1em);
  font-weight: 700;
  min-height: 48px;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--nd-brand);
  background: var(--nd-brand);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}
.nd-btn:hover {
  background: var(--nd-brand-dark);
  border-color: var(--nd-brand-dark);
  color: #fff;
}
.nd-btn--ghost {
  background: #fff;
  color: var(--nd-brand);
}
.nd-btn--ghost:hover {
  background: var(--nd-brand-soft);
  color: var(--nd-brand-dark);
}

/* Development Cards Grid */
.nd-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.nd-card {
  background: #fff;
  border: 1px solid var(--nd-border-light);
  border-radius: 12px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}
.nd-card:hover {
  border-color: #93c5fd;
}
.nd-card-title {
  margin: 0.35rem 0 0.2rem;
  font-size: 1.05rem;
  line-height: 1.35;
}
.nd-card-title a {
  color: var(--nd-ink);
  text-decoration: none;
  font-weight: 700;
}
.nd-card-title a:hover {
  color: var(--nd-brand);
  text-decoration: underline;
}
.nd-card-meta {
  font-size: 0.85rem;
  color: var(--nd-muted);
  margin: 0;
}
.nd-card-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  font-size: 0.85rem;
  color: var(--nd-ink);
  padding-top: 0.5rem;
  border-top: 1px solid #f1f5f9;
}
.nd-card-kpis span strong {
  font-weight: 700;
}

/* Hero + Site SVG Split on Development Page */
.nd-hero-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
  margin-block: 1rem 1.5rem;
}
@media (max-width: 860px) {
  .nd-hero-grid {
    grid-template-columns: 1fr;
  }
}
.nd-svg-card {
  background: #fff;
  border: 1px solid var(--nd-border-light);
  border-radius: 12px;
  padding: 0.85rem;
  text-align: center;
}
.nd-svg-card svg {
  max-inline-size: 100%;
  height: auto;
  display: block;
  margin-inline: auto;
}
.nd-svg-caption {
  font-size: 0.78rem;
  color: var(--nd-muted);
  margin: 0.5rem 0 0;
}

/* Parcel Reality Check Grid */
.nd-reality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.nd-reality-card {
  background: var(--nd-bg-subtle);
  border: 1px solid var(--nd-border-light);
  border-radius: 10px;
  padding: 1rem;
}
.nd-reality-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--nd-muted);
  margin: 0 0 0.35rem;
}
.nd-reality-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--nd-ink);
  margin: 0 0 0.3rem;
}
.nd-reality-note {
  font-size: 0.84rem;
  color: var(--nd-muted);
  margin: 0;
  line-height: 1.45;
}

/* Responsive + Sortable Table (modern-web-guidance: responsive-table + sortable-table) */
.nd-table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(560px, 80vh);
  container-type: inline-size;
  border: 1px solid var(--nd-border-light);
  border-radius: 10px;
  background: #fff;
}
.nd-table-wrapper:focus-visible {
  outline: 3px solid var(--nd-brand);
  outline-offset: 2px;
}
.nd-sortable-table {
  width: 100%;
  min-inline-size: 640px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}
.nd-sortable-table caption {
  text-align: start;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--nd-ink);
  background: var(--nd-bg-subtle);
  border-bottom: 1px solid var(--nd-border-light);
}
.nd-sortable-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #f1f5f9;
}
.nd-sortable-table th,
.nd-sortable-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--nd-border-light);
  text-align: start;
  vertical-align: middle;
}
.nd-sortable-table th.nd-num,
.nd-sortable-table td.nd-num {
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.nd-sortable-table thead th:has(> button) {
  padding: 0;
}
.nd-sortable-table thead th > button {
  appearance: none;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 700;
  color: var(--nd-ink);
  width: 100%;
  min-height: 40px;
  min-width: 24px;
  padding: 0.65rem 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  cursor: pointer;
  text-align: inherit;
}
.nd-sortable-table thead th.nd-num > button {
  justify-content: flex-end;
}
.nd-sortable-table thead th > button:hover {
  background: #e2e8f0;
}
.nd-sortable-table thead th > button:focus-visible {
  outline: 2px solid var(--nd-brand);
  outline-offset: -2px;
}
.nd-sort-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.38;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.nd-sortable-table thead th[aria-sort] .nd-sort-icon {
  opacity: 1;
  color: var(--nd-brand);
}
.nd-sortable-table thead th[aria-sort="descending"] .nd-sort-icon {
  transform: rotate(180deg);
}
.nd-sortable-table tbody th[scope="row"] {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: #fff;
  font-weight: 600;
}

@container (width < 600px) {
  .nd-sortable-table {
    min-inline-size: 0;
    --label-2: "Stage / Type";
    --label-3: "Permit #";
    --label-4: "Stories";
    --label-5: "Units";
    --label-6: "Valuation ($)";
    --label-7: "Distance / Date";
  }
  .nd-sortable-table,
  .nd-sortable-table thead,
  .nd-sortable-table tbody,
  .nd-sortable-table tr,
  .nd-sortable-table th,
  .nd-sortable-table td {
    display: block;
  }
  .nd-sortable-table thead {
    display: none;
  }
  .nd-sortable-table tbody tr {
    margin: 0.75rem;
    border: 1px solid var(--nd-border);
    border-radius: 8px;
    overflow: hidden;
  }
  .nd-sortable-table tbody th[scope="row"] {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #f8fafc;
    border-bottom: 1px solid var(--nd-border-light);
  }
  .nd-sortable-table td,
  .nd-sortable-table td.nd-num {
    text-align: start;
    padding: 0.45rem 0.85rem;
  }
  .nd-sortable-table td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 600; color: var(--nd-muted); }
  .nd-sortable-table td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 600; color: var(--nd-muted); }
  .nd-sortable-table td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 600; color: var(--nd-muted); }
  .nd-sortable-table td:nth-child(5)::before { content: var(--label-5) ": "; font-weight: 600; color: var(--nd-muted); }
  .nd-sortable-table td:nth-child(6)::before { content: var(--label-6) ": "; font-weight: 600; color: var(--nd-muted); }
  .nd-sortable-table td:nth-child(7)::before { content: var(--label-7) ": "; font-weight: 600; color: var(--nd-muted); }
}

.nd-extra-details {
  margin-top: 0.85rem;
  border: 1px solid var(--nd-border-light);
  border-radius: 8px;
  background: var(--nd-bg-subtle);
}
.nd-extra-details summary {
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--nd-brand);
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* LEGRE Studio Interior Design Concept Section */
.nd-legre-wrap {
  background: #fff;
  border: 1px solid var(--nd-border-light);
  border-radius: 14px;
  padding: 1.35rem;
}
.nd-legre-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.nd-legre-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}
.nd-legre-tab {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--nd-border);
  background: var(--nd-bg-subtle);
  color: var(--nd-ink);
  cursor: pointer;
}
.nd-legre-tab[aria-expanded="true"] {
  background: var(--nd-brand);
  border-color: var(--nd-brand);
  color: #fff;
}
/* Nested wrapper inside [hidden="until-found"] panel per search-hidden-content */
.nd-legre-panel-inner {
  border-top: 1px solid var(--nd-border-light);
  padding-top: 1.1rem;
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 840px) {
  .nd-legre-panel-inner {
    grid-template-columns: 1fr;
  }
}
.nd-legre-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
.nd-legre-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--nd-border-light);
  background: #f1f5f9;
}
.nd-legre-price-box {
  background: var(--nd-brand-soft);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-block: 0.85rem;
}

/* 6-Service Buyer & Renter Move-In Calculator (brand-consistent-forms) */
.nd-calc-form {
  accent-color: var(--nd-brand);
  color-scheme: light;
  background: #fff;
  border: 1px solid var(--nd-border-light);
  border-radius: 14px;
  padding: 1.35rem;
}
.nd-calc-controls {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 2fr;
  gap: 1rem;
  align-items: end;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--nd-border-light);
  margin-bottom: 1.1rem;
}
@media (max-width: 780px) {
  .nd-calc-controls {
    grid-template-columns: 1fr;
  }
}
.nd-calc-services {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.9rem;
}
.nd-svc-card {
  border: 1px solid var(--nd-border-light);
  border-radius: 10px;
  padding: 0.95rem 1rem;
  background: var(--nd-bg-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.55rem;
}
.nd-svc-check-label {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--nd-ink);
  cursor: pointer;
  min-height: 48px;
  padding-block: 0.25rem;
}
.nd-svc-check-label input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}
.nd-svc-amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--nd-brand-dark);
}
.nd-calc-totals {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.nd-calc-totals output {
  font-size: 1.45rem;
  font-weight: 800;
  color: #93c5fd;
}

/* Fallback for browsers without accent-color support (modern-web-guidance: brand-consistent-forms) */
@supports not (accent-color: #1d4ed8) {
  .nd-calc-form input[type="checkbox"].nd-svc-check {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }
  .nd-svc-check-label {
    position: relative;
    padding-inline-start: 2rem;
  }
  .nd-calc-form input[type="checkbox"].nd-svc-check + span::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0.35rem;
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid #64748b;
    background: #fff;
    border-radius: 4px;
    box-sizing: border-box;
  }
  .nd-calc-form input[type="checkbox"].nd-svc-check:focus-visible + span::before {
    outline: 2px solid var(--nd-brand);
    outline-offset: 2px;
  }
  .nd-calc-form input[type="checkbox"].nd-svc-check:checked + span::before {
    background-color: var(--nd-brand);
    border-color: var(--nd-brand);
  }
  .nd-calc-form input[type="checkbox"].nd-svc-check:checked + span::after {
    content: "✓";
    position: absolute;
    inset-inline-start: 0.25rem;
    top: 0.28rem;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
  }
  .nd-calc-form input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
  }
  .nd-calc-form input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, var(--nd-brand) var(--progress, 25%), #cbd5e1 var(--progress, 25%));
    border-radius: 4px;
  }
  .nd-calc-form input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--nd-brand);
    margin-top: -5px;
    cursor: pointer;
  }
}

.nd-btn, a.nd-btn, a.nd-btn:visited, a.nd-btn:hover, button.nd-btn {
  color: #ffffff !important;
  text-decoration: none !important;
}
.bw-facts-5col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.65rem;
  margin: 0 0 1rem 0;
  padding: 0;
}
.bw-facts-5col .bw-fact-cell {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.bw-facts-5col .bw-fact-cell dd {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}
.bw-facts-5col .bw-fact-cell dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
