/* ============================================================
   KPDD Base Styles
   Reset, typography, layout primitives, forms, buttons
   ============================================================ */

/* ---- Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Reserve the scrollbar gutter up-front. Without this, a vertical
     scrollbar appearing or disappearing during page render shifts the
     effective viewport width by ~15px — enough to flip media queries
     near the 991px / 768px breakpoints, which briefly toggles
     `.header-top { display: none }` and bumps the sticky site-header
     down a row. `stable` reserves the space at all times, so the
     viewport width is constant regardless of overflow state and the
     header never flickers between its compact and full-height forms.
     Chrome 94+ / Firefox 97+ / Safari 18.2+; older browsers ignore. */
  scrollbar-gutter: stable;
  /* Defensive — kills horizontal overflow at the page edge without
     creating a scroll context (so position:sticky inside still works,
     unlike `overflow: hidden`). Stops stray full-bleed children with a
     `100vw` width or a slightly-too-wide rail from leaking a white
     sliver past the right edge on mobile. */
  overflow-x: clip;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  color: var(--color-body);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--color-primary-dark);
}

ul, ol {
  list-style: none;
}

/* CMS-rendered content — restores list styling for HTML produced by
   the kpdd-editor (page bodies, blog posts, job descriptions, etc.).
   Mirrors the .kpdd-editor-content rules in components/editor.css so
   what authors see while editing matches what visitors see. */
.cms-content ul,
.cms-content ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}
.cms-content ul { list-style: disc outside; }
.cms-content ol { list-style: decimal outside; }
.cms-content li { margin: 0.25em 0; }

dl, dd {
  margin: 0;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-heading);
  margin-bottom: var(--space-sm);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }
h6 { font-size: var(--font-size-base); }

p {
  margin-bottom: var(--space-md);
}
p:last-child {
  margin-bottom: 0;
}

small {
  font-size: var(--font-size-sm);
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.container-narrow {
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

/* ---- Grid ---- */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 991px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 575px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.625rem 1.5rem;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #fff;
}

.btn-outline {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover,
.btn-outline.active {
  background-color: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background-color: var(--color-danger);
  filter: brightness(0.9);
  color: #fff;
}

.btn-dark {
  background-color: var(--color-dark);
  color: #fff;
  border-color: var(--color-dark);
}
.btn-dark:hover {
  background-color: var(--color-nav);
  border-color: var(--color-nav);
  color: #fff;
}

.btn-sm {
  padding: 0.375rem 1rem;
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: var(--font-size-base);
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-heading);
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-body);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-control::placeholder {
  color: var(--color-muted);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23768ea7' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* ---- Tables ---- */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.table th {
  font-weight: var(--font-weight-semibold);
  color: var(--color-heading);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.badge-sale { background: var(--color-for-sale); color: #fff; }
.badge-rent { background: var(--color-for-rent); color: #fff; }
.badge-new  { background: var(--color-new); color: #fff; }
.badge-luxury { background: linear-gradient(135deg, #b8860b, #d4a017); color: #fff; }
.badge-luxury i { margin-right: 0.2em; font-size: 0.9em; }
.badge-exclusive { background: linear-gradient(135deg, #1e3a5f, #2563eb); color: #fff; letter-spacing: 0.06em; }

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--color-bg);
  /* Treat the header as a shared element across SPA nav. Without this,
     it gets captured inside the `root` view-transition snapshot and
     slides up 6px / fades along with the rest of the document — which
     reads as a visible header jump on every nav. With a named transition
     the browser morphs the header from its old box to its new (identical)
     box as a no-op while the page content cross-fades around it. */
  view-transition-name: site-header;
}

.header-top {
  background: var(--color-nav);
  color: #fff;
  font-size: var(--font-size-sm);
  padding: var(--space-xs) 0;
}

.header-top-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-contact {
  display: flex;
  gap: var(--space-lg);
}

.header-contact a {
  color: rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}
.header-contact a:hover {
  color: #fff;
}

.header-social a {
  color: rgba(255, 255, 255, 0.85);
  margin-left: var(--space-sm);
}
.header-social a:hover {
  color: #fff;
}

.header-nav {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-sm) 0;
}

.header-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo img {
  /* Fixed slot — different brand variants (residential / commercial /
     rental) have different intrinsic widths. Without a locked size,
     swapping between them on section-change reflows the header by a
     few px and the whole nav row jitters. `object-fit: contain` +
     `object-position: left center` lets each variant render at its
     natural aspect ratio within the slot, left-aligned. Adjust width
     here if a future logo variant is wider than this. */
  width: 200px;
  height: 50px;
  object-fit: contain;
  object-position: left center;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-heading);
  cursor: pointer;
}

.nav-menu {
  display: flex;
  gap: var(--space-xs);
}

.nav-item {
  list-style: none;
}

.nav-link {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-heading);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.nav-link:hover,
.nav-link.active {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

@media (max-width: 991px) {
  .nav-toggle {
    display: block;
  }
  .nav-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    z-index: var(--z-dropdown);
  }
  .header-nav.nav-open .nav-menu {
    display: flex;
  }
  .header-nav {
    position: relative;
  }
}

/* Hide the top contact strip on true mobile only. Kept on a separate
   breakpoint (768px, not 991px) so admins testing with devtools open
   at ~960px don't sit right on the boundary — a 15px viewport shift
   from a scrollbar appearing/disappearing used to flip this rule mid
   SPA navigation, bumping the sticky site-header down a row. */
@media (max-width: 768px) {
  .header-top {
    display: none;
  }
}

/* ---- Footer ---- */
/* ---- Content Visibility (skip rendering of below-fold sections) ---- */
.site-footer,
.smart-cta,
.agent-bookend,
.mls-disclaimer-bar {
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}

.site-footer {
  margin-top: var(--space-4xl);
}
/* Suppress the breathing-room margin when the last main-content
   section is a full-bleed colored band (e.g. the homepage CTA strip).
   Without this, the white body bg shows as a disconnected "sock"
   between the band and the dark footer. */
main:has(> .hp-cta-strip:last-child) + .site-footer,
main:has(> .hp-reviews:last-child) + .site-footer {
  margin-top: 0;
}

/* Nav-in-flight feedback. router.js sets aria-busy="true" on
   <main id="main-content"> the instant a SPA click fires and the
   attribute disappears naturally when the new <main> replaces the
   old one. A small opacity dip plus pointer-events:none signals
   "we heard you" and prevents accidental double-clicks during the
   in-flight fetch. The kpdd-route-progress laser bar handles the
   chrome-level loader; this just calms the content area. */
main[aria-busy="true"] {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 140ms ease;
}
@media (prefers-reduced-motion: reduce) {
  main[aria-busy="true"] { transition: none; }
}

.footer-main {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  padding: var(--space-3xl) 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-xl);
}

@media (max-width: 991px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 575px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

.footer-logo img {
  height: 40px;
  width: auto;
  margin-bottom: var(--space-md);
}

.footer-about {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-loose);
}

.footer-heading {
  color: #fff;
  font-size: var(--font-size-md);
  margin-bottom: var(--space-md);
}

.footer-links li {
  margin-bottom: var(--space-sm);
}
.footer-links a {
  color: var(--color-footer-text);
  font-size: var(--font-size-sm);
}
.footer-links a:hover {
  color: #fff;
}

.footer-address {
  font-style: normal;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-loose);
}
.footer-address i {
  margin-right: var(--space-xs);
  color: var(--color-primary);
}
.footer-address a {
  color: var(--color-footer-text);
}
.footer-address a:hover {
  color: #fff;
}
.footer-address p {
  margin-bottom: var(--space-sm);
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-footer-text);
  margin-right: var(--space-sm);
  margin-top: var(--space-md);
  transition: all var(--transition-fast);
}
.footer-social a:hover {
  background: var(--color-primary);
  color: #fff;
}

.footer-bottom {
  background: #0e2030;
  color: var(--color-muted);
  padding: var(--space-md) 0;
  font-size: var(--font-size-sm);
}

.footer-bottom-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.mls-attribution {
  font-size: var(--font-size-xs);
  color: var(--color-muted);
}

/* ---- Pagination ---- */
.pagination-nav {
  display: flex;
  justify-content: center;
  padding: var(--space-xl) 0;
}

.pagination {
  display: flex;
  gap: var(--space-xs);
}

.page-item {
  list-style: none;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-body);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.page-item.active .page-link {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.page-item:not(.disabled):not(.active) .page-link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.page-item.disabled .page-link {
  color: var(--color-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

/* ---- Inline Pagination (agent past sales) ---- */
.pagination-inline {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  text-decoration: none;
}

.pagination-link:hover {
  background: var(--color-bg-alt);
}

.pagination-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 var(--space-sm);
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 2rem;
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  user-select: none;
}

/* ---- Error page ---- */
.error-page {
  padding: var(--space-4xl) 0;
  text-align: center;
}

.error-code {
  font-size: 8rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-primary-light);
  line-height: 1;
}

.error-title {
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

.error-message {
  color: var(--color-muted);
  max-width: 400px;
  margin-inline: auto;
  margin-bottom: var(--space-xl);
}

.error-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

/* ---- DSD card hosts: pre-style before shadow DOM attaches ---- */
kpdd-agent-card,
kpdd-partner-card,
kpdd-vendor-card,
kpdd-listing-card,
kpdd-contact-card,
kpdd-review-card {
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Functional island hosts default to inline (custom-element default), which
   lets inner widgets mis-measure their width and overflow on mobile — the
   market chart in particular falls back to a fixed 600px when its inline host
   reports a 0 clientWidth. Force block so they fill (and are bounded by) their
   column like every other block on the page. */
kpdd-market-chart,
kpdd-drive-times,
kpdd-school-zones {
  display: block;
  max-width: 100%;
}

kpdd-agent-card > [slot="photo"],
kpdd-listing-card > [slot="photo"] {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

kpdd-partner-card > [slot="photo"],
kpdd-vendor-card > [slot="photo"] {
  display: block;
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}
