/* ==========================================================================
   CleanWhale Buildings UK — New-Build Developments, Site Reality Check,
   LEGRE Studio Concept & 6-Service Move-In Budget Calculator
   Modern Web Guidance compliant: container queries, responsive stacked tables,
   invoker-ready sort headers, content-visibility: auto (strictly below fold),
   accessible 48px+ form controls, accent-color + @supports fallback.
   ========================================================================== */

:root {
  --nd-blue: #1d4ed8;
  --nd-blue-dark: #1e40af;
  --nd-blue-soft: #eff6ff;
  --nd-ink: #0f172a;
  --nd-muted: #475569;
  --nd-border: #cbd5e1;
  --nd-border-strong: #64748b;
  --nd-surface: #ffffff;
  --nd-surface-alt: #f8fafc;
  --nd-green: #047857;
  --nd-green-soft: #ecfdf5;
  --nd-amber: #b45309;
  --nd-amber-soft: #fffbeb;
  --target-size: 24px;
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

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

/* Strictly applied ONLY to below-the-fold sections */
.nd-defer-fold {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 400px;
}

.nd-wrap {
  max-inline-size: 1180px;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.nd-hero {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border-block-end: 1px solid #e2e8f0;
  padding-block: 2rem 2.25rem;
}

.nd-hero h1,
.nd-sec-head h2,
.nd-card h3 {
  text-wrap: balance;
}

.nd-hero p,
.nd-prose p,
.nd-prose li {
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.nd-hero-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
  align-items: start;
}

@media (width < 860px) {
  .nd-hero-grid {
    grid-template-columns: 1fr;
  }
}

/* Stage badges */
.nd-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.nd-badge--active {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.nd-badge--plan {
  background: var(--nd-amber-soft);
  color: var(--nd-amber);
  border: 1px solid #fcd34d;
}

.nd-badge--complete {
  background: var(--nd-green-soft);
  color: var(--nd-green);
  border: 1px solid #6ee7b7;
}

.nd-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* KPI stat strip */
.nd-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-block-start: 1.25rem;
}

.nd-kpi {
  background: var(--nd-surface);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.nd-kpi dt {
  font-size: 0.78rem;
  color: var(--nd-muted);
  font-weight: 600;
  margin-block-end: 0.25rem;
}

.nd-kpi dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--nd-ink);
}

.nd-kpi dd.nd-kpi-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--nd-muted);
  margin-block-start: 0.2rem;
}

/* Search & Filter Form (<search><form method="GET">) */
.nd-filter-bar {
  background: var(--nd-surface);
  border: 1px solid var(--nd-border);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  margin-block: 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.nd-filter-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) repeat(auto-fit, minmax(160px, 1fr)) auto;
  gap: 0.85rem;
  align-items: end;
}

@media (width < 760px) {
  .nd-filter-grid {
    grid-template-columns: 1fr;
  }
}

.nd-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.nd-field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--nd-ink);
}

.nd-field input,
.nd-field select,
.nd-calc-form input:not([type="checkbox"]):not([type="radio"]),
.nd-calc-form select {
  font: inherit;
  font-size: max(1rem, 1em);
  min-block-size: 48px;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid #64748b;
  border-radius: 10px;
  background: #ffffff;
  color: var(--nd-ink);
  box-sizing: border-box;
  inline-size: 100%;
}

@media (pointer: coarse) {
  .nd-field input,
  .nd-field select,
  .nd-calc-form input:not([type="checkbox"]):not([type="radio"]),
  .nd-calc-form select {
    min-block-size: 52px;
  }
}

.nd-field input:focus-visible,
.nd-field select:focus-visible,
.nd-btn:focus-visible,
.nd-legre-tab:focus-visible,
.nd-calc-form input:focus-visible,
.nd-calc-form select:focus-visible,
.nd-sort-table th button:focus-visible {
  outline: 3px solid var(--nd-blue);
  outline-offset: 2px;
}

.nd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-block-size: 48px;
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  font: inherit;
  font-size: max(0.95rem, 1em);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.nd-btn--primary {
  background: var(--nd-blue);
  color: #ffffff;
}

.nd-btn--primary:hover {
  background: var(--nd-blue-dark);
  color: #ffffff;
}

.nd-btn--outline {
  background: #ffffff;
  color: var(--nd-blue);
  border-color: var(--nd-blue);
}

.nd-btn--outline:hover {
  background: var(--nd-blue-soft);
}

.nd-btn--green {
  background: #047857;
  color: #ffffff;
}

.nd-btn--green:hover {
  background: #065f46;
  color: #ffffff;
}

/* Development Cards & City Hub Grid (Container Queries) */
.nd-cards-container {
  container: ndcards / inline-size;
}

.nd-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1rem;
}

.nd-card {
  background: var(--nd-surface);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nd-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.07);
}

.nd-card-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
}

.nd-card h3 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.06rem;
  line-height: 1.32;
}

.nd-card h3 a {
  color: var(--nd-ink);
  text-decoration: none;
}

.nd-card h3 a:hover {
  color: var(--nd-blue);
  text-decoration: underline;
}

.nd-card-meta {
  font-size: 0.85rem;
  color: var(--nd-muted);
  margin: 0;
}

.nd-spec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block-start: 0.35rem;
}

.nd-spec-pill {
  font-size: 0.78rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #1e293b;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
}

.nd-dev-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: 0.75rem 1.25rem;
}

.nd-dev-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-block-size: 38px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--nd-border);
  background: #ffffff;
  color: var(--nd-ink);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}

.nd-dev-chip:hover,
.nd-dev-chip[aria-current="true"] {
  border-color: var(--nd-blue);
  background: var(--nd-blue-soft);
  color: var(--nd-blue-dark);
}

/* Footprint card */
.nd-footprint-box {
  background: var(--nd-surface);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem;
}

.nd-footprint-svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
  border-radius: 10px;
}

/* Reality Check vs Developer Brochure Grid */
.nd-reality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
  gap: 1rem;
  margin-block-start: 1rem;
}

.nd-reality-card {
  background: var(--nd-surface);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
}

.nd-reality-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.98rem;
  color: var(--nd-ink);
}

.nd-reality-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--nd-ink);
  margin: 0.15rem 0 0.4rem;
}

.nd-reality-vs {
  font-size: 0.83rem;
  color: var(--nd-muted);
  margin: 0;
  line-height: 1.45;
}

/* ==========================================================================
   Responsive & Sortable Data Table (modern-web-guidance: responsive-table + sortable-table)
   ========================================================================== */

.nd-table-wrap {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(560px, 80vh);
  container-type: inline-size;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.nd-sort-table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}

.nd-sort-table caption {
  text-align: start;
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--nd-ink);
  background: #f8fafc;
  border-block-end: 1px solid #e2e8f0;
}

.nd-sort-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #f1f5f9;
}

.nd-sort-table th,
.nd-sort-table td {
  padding: 0.72rem 0.9rem;
  border-block-end: 1px solid #e2e8f0;
  text-align: start;
  vertical-align: middle;
}

.nd-sort-table th[data-type="number"],
.nd-sort-table td[data-num] {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

/* Drop cell padding only when th contains sort button */
.nd-sort-table thead th:has(> button) {
  padding: 0;
}

.nd-sort-table thead th > button {
  appearance: none;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 700;
  color: var(--nd-ink);
  inline-size: 100%;
  min-block-size: 44px;
  padding: 0.72rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  cursor: pointer;
  text-align: inherit;
}

.nd-sort-table thead th[data-type="number"] > button {
  justify-content: flex-end;
}

.nd-sort-table thead th > button:hover {
  background: #e2e8f0;
}

.nd-sort-ico {
  display: inline-block;
  inline-size: 0.75em;
  font-size: 0.8rem;
  color: #64748b;
}

.nd-sort-ico::before {
  content: "↕";
}

.nd-sort-table thead th[aria-sort="ascending"] .nd-sort-ico::before {
  content: "↑";
  color: var(--nd-blue);
}

.nd-sort-table thead th[aria-sort="descending"] .nd-sort-ico::before {
  content: "↓";
  color: var(--nd-blue);
}

.nd-sort-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: #ffffff;
  font-weight: 700;
  color: var(--nd-ink);
}

.nd-sort-table tbody tr {
  view-transition-name: match-element;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none;
  }
}

@container (width < 600px) {
  .nd-sort-table,
  .nd-sort-table thead,
  .nd-sort-table tbody,
  .nd-sort-table tr,
  .nd-sort-table th,
  .nd-sort-table td {
    display: block;
    text-align: start !important;
  }

  .nd-sort-table thead {
    display: none;
  }

  .nd-sort-table tbody tr {
    margin: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    overflow: hidden;
  }

  .nd-sort-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #f1f5f9;
  }

  .nd-sort-table td:nth-child(2)::before {
    content: var(--label-2) ": ";
    font-weight: 700;
    color: #475569;
  }
  .nd-sort-table td:nth-child(3)::before {
    content: var(--label-3) ": ";
    font-weight: 700;
    color: #475569;
  }
  .nd-sort-table td:nth-child(4)::before {
    content: var(--label-4) ": ";
    font-weight: 700;
    color: #475569;
  }
  .nd-sort-table td:nth-child(5)::before {
    content: var(--label-5) ": ";
    font-weight: 700;
    color: #475569;
  }
}

.nd-more-details {
  margin-block-start: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.65rem 1rem;
}

.nd-more-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--nd-blue);
  min-block-size: var(--target-size);
}

/* ==========================================================================
   LEGRE Studio Instant Interior Concept Section
   ========================================================================== */

.nd-legre-box {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  border-radius: 18px;
  padding: 1.6rem;
  margin-block: 1.5rem;
}

.nd-legre-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-block-end: 1.15rem;
}

.nd-legre-wordmark {
  height: 26px;
  width: auto;
  filter: brightness(0) invert(1);
}

.nd-legre-price-badge {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
}

.nd-legre-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 1.25rem;
}

.nd-legre-tab {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  min-block-size: 46px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.nd-legre-tab[aria-expanded="true"] {
  background: #ffffff;
  color: #0f172a;
  border-color: #ffffff;
}

.nd-legre-panel-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
}

@media (width < 820px) {
  .nd-legre-panel-inner {
    grid-template-columns: 1fr;
  }
}

.nd-legre-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.nd-legre-gallery img {
  inline-size: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #334155;
}

.nd-legre-gallery img:first-child {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
}

.nd-legre-list {
  margin: 0.75rem 0 1.1rem;
  padding-inline-start: 1.2rem;
  color: #cbd5e1;
  font-size: 0.9rem;
  line-height: 1.55;
}

.nd-legre-quote {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-block-end: 1rem;
}

/* ==========================================================================
   6-Service New-Build Move-In & Completion Budget Calculator
   ========================================================================== */

.nd-calc-card {
  background: var(--nd-surface);
  border: 1.5px solid #cbd5e1;
  border-radius: 18px;
  padding: 1.5rem;
}

.nd-calc-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-block-end: 1.25rem;
}

.nd-calc-fieldset {
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 1rem 1.15rem;
  margin: 0 0 1.25rem;
}

.nd-calc-fieldset legend {
  font-weight: 800;
  padding-inline: 0.45rem;
  color: var(--nd-ink);
}

.nd-svc-list {
  display: grid;
  gap: 0.85rem;
}

.nd-svc-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: start;
  padding: 0.9rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

@media (width < 680px) {
  .nd-svc-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .nd-svc-price-col {
    grid-column: 2;
  }
}

.nd-svc-row input[type="checkbox"] {
  inline-size: 1.35rem;
  block-size: 1.35rem;
  margin-block-start: 0.15rem;
  accent-color: #1d4ed8;
  cursor: pointer;
}

@supports not (accent-color: #1d4ed8) {
  .nd-svc-row input[type="checkbox"] {
    appearance: none;
    border: 2px solid #475569;
    border-radius: 4px;
    background: #ffffff;
    position: relative;
  }
  .nd-svc-row input[type="checkbox"]:checked {
    background: #1d4ed8;
    border-color: #1d4ed8;
  }
  .nd-svc-row input[type="checkbox"]:checked::after {
    content: "✓";
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 800;
    position: absolute;
    inset-inline-start: 3px;
    inset-block-start: -1px;
  }
}

.nd-svc-label {
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--nd-ink);
  cursor: pointer;
  display: inline-block;
  padding-block: 6px;
  margin-block: -6px;
}

.nd-svc-desc {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--nd-muted);
  line-height: 1.45;
}

.nd-svc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.nd-svc-links a {
  color: var(--nd-blue);
  overflow-wrap: anywhere;
}

.nd-svc-price-col {
  text-align: end;
  font-variant-numeric: tabular-nums;
  min-inline-size: 120px;
}

.nd-svc-price-col output {
  display: block;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--nd-ink);
}

.nd-svc-price-col small {
  color: var(--nd-muted);
  font-size: 0.76rem;
}

.nd-calc-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
}

.nd-calc-total-box span {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e3a8a;
}

.nd-calc-total-box output {
  display: block;
  font-size: 1.65rem;
  font-weight: 900;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.nd-btn, a.nd-btn, a.nd-btn:visited, a.nd-btn:hover { color: #ffffff !important; text-decoration: none !important; }
