/* Top Projects — builder project carousel (brand orange + blue) */

.top-projects-section {
  --tp-orange: #ff6b35;
  --tp-orange-dark: #ea580c;
  --tp-orange-soft: #fff7ed;
  --tp-blue: #0984e3;
  --tp-blue-soft: #e8f2ff;
  --tp-navy: #102a43;
  /* Portal-style project thumb (99acres / MagicBricks-like 16:9) */
  --tp-media-aspect: 16 / 9;
  background: #ffffff;
}

.top-projects-section .section-title::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tp-orange), #ff8c5a);
}

.top-projects-section__header {
  align-items: flex-start;
}

.top-projects-section__view-all {
  white-space: nowrap;
}

.top-projects-section__header-copy {
  min-width: 0;
}

.top-projects-section--insights .top-projects-section__header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.top-projects-section--insights .top-projects-section__header-copy {
  flex: 1 1 auto;
}

.top-projects-section__view-all--insights {
  align-items: center;
  color: #f97316;
  display: inline-flex;
  font-weight: 700;
  gap: 0.45rem;
  margin-left: auto;
  text-decoration: none;
}

.top-projects-section__view-all--insights:hover,
.top-projects-section__view-all--insights:focus-visible {
  color: #ea580c;
}

.top-projects-section--detail .top-projects-section__header {
  align-items: flex-start;
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  justify-content: space-between;
}

.top-projects-section--detail .top-projects-section__header-copy {
  flex: 1 1 auto;
}

.top-projects-section__view-all--detail {
  flex: 0 0 auto;
  margin-left: auto;
}

.top-projects-section__view-all-text--short {
  display: none;
}

.top-project-card {
  background: #ffffff;
  border: 1px solid #e8edf2;
  border-top: 4px solid var(--tp-orange);
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  color: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  position: relative;
  text-decoration: none;
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

.top-project-card:hover,
.top-project-card:focus-within {
  border-color: #fed7aa;
  border-top-color: var(--tp-orange);
  box-shadow: 0 16px 36px rgba(255, 107, 53, 0.12);
  transform: translateY(-4px);
}

.top-project-card__media-link {
  display: block;
  color: inherit;
}

.top-project-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: var(--tp-media-aspect);
  overflow: hidden;
  background: #e8edf2;
  isolation: isolate;
}

.top-project-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.4s ease;
}

.top-project-card:hover .top-project-card__image,
.top-project-card:focus-within .top-project-card__image {
  transform: scale(1.04);
}

.top-project-card__media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(16, 42, 67, 0.08) 0%,
    rgba(16, 42, 67, 0.02) 42%,
    rgba(16, 42, 67, 0.78) 100%
  );
  pointer-events: none;
}

/* Landing — same media ratio as portals; grid columns only below */
.top-projects-section--landing .top-project-card__media-overlay {
  background: linear-gradient(
    180deg,
    rgba(16, 42, 67, 0.06) 0%,
    rgba(16, 42, 67, 0) 45%,
    rgba(16, 42, 67, 0.78) 100%
  );
}

@media (min-width: 768px) and (max-width: 1199.98px) {
  .top-projects-section--landing .top-projects-track > .top-project-item {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    min-width: 0 !important;
  }
}

@media (min-width: 1200px) {
  .top-projects-section--landing .top-projects-track > .top-project-item {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 767.98px) {
  .top-projects-section--landing .top-projects-track > .top-project-item {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }
}

.top-project-card__status {
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  z-index: 1;
  max-width: 46%;
  padding: 0.3rem 0.58rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--tp-blue);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 14px rgba(9, 132, 227, 0.12);
}

.top-project-card__builder-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem 0.65rem;
}

.top-project-card__builder-avatar {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tp-orange) 0%, #ff8c5a 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.25);
}

.top-project-card__builder-name {
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-project-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.95rem 1rem 1.05rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.top-project-card__body-link {
  display: block;
  color: inherit;
}

.top-project-card__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.3rem;
}

.top-project-card__title {
  color: var(--tp-navy);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.top-project-card__category {
  flex-shrink: 0;
  padding: 0.22rem 0.52rem;
  border-radius: 999px;
  background: var(--tp-blue-soft);
  color: var(--tp-blue);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-project-card__location {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.4;
}

.top-project-card__location i {
  color: var(--tp-orange);
  font-size: 0.74rem;
  margin-top: 0.12rem;
  flex-shrink: 0;
}

.top-project-card__location span {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.top-project-card__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.15rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #e2e8f0;
}

.top-project-card__stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.48rem 0.42rem;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e8edf2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.top-project-card__stat-label {
  color: var(--tp-orange-dark);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.top-project-card__stat-value {
  color: var(--tp-navy);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-word;
}

.top-project-card__stat-value--price {
  color: #16a34a;
}

@media (max-width: 991.98px) {
  .top-projects-section {
    --tp-media-aspect: 16 / 9;
  }

  .top-project-card__stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-projects-section--detail .top-projects-track--detail {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    margin-left: 0;
    margin-right: 0;
    overflow-x: auto;
    padding: 0.25rem 0 0.75rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .top-projects-section--detail .top-projects-track--detail::-webkit-scrollbar {
    display: none;
  }

  .top-projects-section--detail .top-project-item--detail {
    flex: 0 0 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
    scroll-snap-align: start;
  }

  .top-projects-section--detail .top-project-card {
    min-height: 100%;
  }
}

@media (max-width: 767.98px) {
  .top-projects-section__header,
  .top-projects-section--insights .top-projects-section__header,
  .top-projects-section--detail .top-projects-section__header {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 0.75rem;
  }

  .top-projects-section__header-copy {
    flex: 1 1 auto;
    min-width: 0;
  }

  .top-projects-section__view-all,
  .top-projects-section__view-all--insights,
  .top-projects-section__view-all--detail {
    flex: 0 0 auto;
    margin-left: auto;
    margin-top: 0.15rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    font-size: 0.92rem;
  }

  .top-projects-section__view-all-text--full {
    display: inline;
  }

  .top-projects-section__view-all-text--short {
    display: none;
  }

  .top-projects-section {
    --tp-media-aspect: 3 / 2;
  }

  .top-project-card__body {
    padding: 0.85rem 0.9rem 0.95rem 1rem;
  }

  .top-project-card__stats {
    grid-template-columns: 1fr 1fr;
  }

  .top-project-card__stat:last-child {
    grid-column: 1 / -1;
  }

  .top-projects-section__header {
    width: 100%;
  }
}

/* Landing / home — legacy portrait/landscape rules replaced by --landing block above */
@media (min-width: 768px) and (max-width: 1199.98px) and (orientation: portrait) {
  body:not(:has(#home-page)) .top-projects-section:not(.top-projects-section--detail):not(.top-projects-section--landing) .top-projects-track > .top-project-item {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    min-width: 0 !important;
  }
}

@media (min-width: 768px) and (max-width: 1199.98px) and (orientation: landscape) {
  body:not(:has(#home-page)) .top-projects-section:not(.top-projects-section--detail):not(.top-projects-section--landing) .top-projects-track > .top-project-item {
    flex: 0 0 33.333333% !important;
    max-width: 33.333333% !important;
    width: 33.333333% !important;
    min-width: 0 !important;
  }
}

/* Listing iPad portrait: filter ON => 1 card, filter OFF => 2 cards */
@media (min-width: 768px) and (max-width: 991.98px) {
  #propertyListRow .property-list .pd-list-insight-slot[data-insight-section="pd-section-top-projects"] .top-projects-track {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  #propertyListRow:not(.filters-closed) .property-list .pd-list-insight-slot[data-insight-section="pd-section-top-projects"] .top-projects-track > .top-project-item {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  #propertyListRow.filters-closed .property-list .pd-list-insight-slot[data-insight-section="pd-section-top-projects"] .top-projects-track > .top-project-item {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    min-width: 0 !important;
  }

  #propertyListRow.filters-closed .property-list .pd-list-insight-slot[data-insight-section="pd-section-top-projects"] .top-project-card__body {
    padding: 0.85rem 0.9rem 0.95rem !important;
  }
}

/* iPad portrait widths above 991.98px (e.g. 1024) */
@media (min-width: 992px) and (max-width: 1199.98px) and (orientation: portrait) {
  #propertyListRow.filters-closed .property-list .pd-list-insight-slot[data-insight-section="pd-section-top-projects"] .top-projects-track {
    display: flex !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  #propertyListRow.filters-closed .property-list .pd-list-insight-slot[data-insight-section="pd-section-top-projects"] .top-projects-track > .top-project-item {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    min-width: 0 !important;
  }
}

.top-projects-section__header-copy {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

.top-projects-section .section-subtitle {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  font-size: 0.82rem;
  line-height: 1.4;
}

.top-projects-section__view-all {
  font-size: 0.8rem;
}

/* Property detail page only — iPad portrait: 2 top-project cards per row */
@media (min-width: 768px) and (max-width: 991.98px) {
  .pd-detail-page .top-projects-section--detail .top-projects-track--detail {
    gap: 1rem;
    width: 100%;
  }

  .pd-detail-page .top-projects-section--detail .top-project-item--detail {
    flex: 0 0 calc(50% - 0.5rem) !important;
    max-width: calc(50% - 0.5rem) !important;
    width: calc(50% - 0.5rem) !important;
    min-width: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .pd-detail-page .top-projects-section--detail .top-project-card {
    width: 100%;
  }
}

@media (min-width: 992px) and (max-width: 1199.98px) and (orientation: portrait) {
  .pd-detail-page .top-projects-section--detail .top-project-item--detail {
    flex: 0 0 calc(50% - 0.5rem) !important;
    max-width: calc(50% - 0.5rem) !important;
    width: calc(50% - 0.5rem) !important;
    min-width: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}