/*
 * Home page (§12, §15, §36.1 + approved final prototype) — Views/Home/Index.cshtml.
 * Entry band (title · search · category×city finder · main categories) → browse by city → call directly → add business.
 * Loaded from the view's @section styles (before the ds files), so selectors are scoped under .ds-home.
 * Tokens only, logical properties only. Breakpoints: 640px (tablet), 1024px (desktop).
 */

.ds-home {
  padding-block-end: var(--space-40);
  background-color: var(--color-background);
  text-align: start; /* the legacy site CSS sets body text-align:left */
}

/* ===================== Entry band ===================== */

.ds-home .ds-home__entry {
  border-block-end: var(--border-width) solid var(--color-border);
  background-color: var(--color-surface);
}

.ds-home .ds-home__entry-inner {
  padding-block: var(--space-20) var(--space-24);
}

.ds-home .ds-home__title {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-h1-mobile);
  font-weight: var(--font-weight-h1);
  line-height: var(--line-height-h1);
}

.ds-home .ds-home__lead {
  display: -webkit-box;
  max-width: var(--home-hero-text-max-width);
  margin: var(--space-4) 0 0;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
  line-height: var(--line-height-body);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* 1) Search — below 1024px the header's always-visible search row is this same search */
.ds-home .ds-home__search {
  display: none;
  max-width: var(--home-hero-search-max-width);
  margin-block-start: var(--space-24);
}

/* 2) Finder: "أو تصفّح [التصنيف] في [المدينة] [عرض النتائج]" */
.ds-home .ds-home__finder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-8);
  margin-block-start: var(--space-16);
}

.ds-home .ds-home__finder[hidden] {
  display: none;
}

.ds-home .ds-home__finder-label {
  grid-column: 1 / -1;
  color: var(--color-text-strong-secondary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
}

.ds-home .ds-home__finder-field {
  min-width: 0;
}

.ds-home .ds-home__finder .ds-select {
  min-height: var(--filter-height);
  font-size: var(--font-size-small);
}

.ds-home .ds-home__finder-in {
  display: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.ds-home .ds-home__finder-go {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .ds-home .ds-home__finder {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: var(--space-12);
  }

  .ds-home .ds-home__finder[hidden] {
    display: none;
  }

  .ds-home .ds-home__finder-label,
  .ds-home .ds-home__finder-in {
    display: inline;
  }

  .ds-home .ds-home__finder {
    flex-wrap: nowrap;
  }

  .ds-home .ds-home__finder-label,
  .ds-home .ds-home__finder-in,
  .ds-home .ds-home__finder-go {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .ds-home .ds-home__finder-field {
    flex: 1 1 0;
  }
}

@media (min-width: 1024px) {
  .ds-home .ds-home__finder-field {
    flex: 0 1 var(--results-dropdown-width);
  }
}

/* 3) Main categories: one row of quick links + the full index */
.ds-home .ds-home__cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8) var(--space-12);
  margin-block-start: var(--space-20);
  padding-block-start: var(--space-16);
  border-block-start: var(--border-width) solid var(--color-border);
}

.ds-home .ds-home__cats-title {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-h3);
}

.ds-home .ds-home__cats-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ds-home .ds-home__cat,
.ds-home .ds-home__cat:visited {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  min-height: var(--button-height-sm);
  padding-inline: var(--space-12);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-button);
  background-color: var(--color-surface);
  color: var(--color-text-strong-secondary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  white-space: nowrap;
}

.ds-home .ds-home__cat:hover {
  border-color: var(--filter-active-border);
  background-color: var(--filter-active-bg);
  color: var(--filter-active-text);
}

.ds-home .ds-home__cat--all,
.ds-home .ds-home__cat--all:visited {
  border-color: transparent;
  background-color: transparent;
  color: var(--color-primary);
}

.ds-home .ds-home__cat--all .fa-chevron-left {
  font-size: var(--font-size-caption);
}

[dir="ltr"] .ds-home .ds-home__cat--all .fa-chevron-left {
  transform: scaleX(-1);
}

@media (max-width: 639.98px) {
  /* Phones: the title sits on its own line above the links */
  .ds-home .ds-home__cats-title {
    flex-basis: 100%;
  }
}

@media (min-width: 1024px) {
  .ds-home .ds-home__entry-inner {
    padding-block: var(--space-40) var(--space-32);
  }

  .ds-home .ds-home__title {
    font-size: var(--font-size-h1);
  }

  .ds-home .ds-home__lead {
    font-size: var(--font-size-body);
  }

  .ds-home .ds-home__search {
    display: flex;
  }
}

/* ===================== Sections ===================== */

.ds-home .ds-home__section {
  padding-block-start: var(--space-32);
}

/* Level-2 sections: section titles one step below the page title (Results/Item use 16–20px section titles) */
.ds-home .ds-section-head .ds-section-head__title {
  font-size: var(--font-size-h3-mobile);
  line-height: var(--line-height-h3);
}

@media (min-width: 640px) {
  .ds-home .ds-section-head .ds-section-head__title {
    font-size: var(--font-size-h3);
  }
}

/* ---------- Browse by city: 2 columns <640px, 3 tablet, 4 desktop; the rest behind "كل المدن (N)" ---------- */

.ds-home .ds-home__cities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-16);
  margin: 0;
  padding: 0;
  border-block-start: var(--border-width) solid var(--color-border);
  list-style: none;
}

@media (min-width: 640px) {
  .ds-home .ds-home__cities {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--space-32);
  }
}

@media (min-width: 1024px) {
  .ds-home .ds-home__cities {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.ds-home .ds-home__city {
  min-width: 0;
  padding-block: var(--space-12);
  border-block-end: var(--border-width) solid var(--color-border);
}

.ds-home .ds-home__city-name {
  display: block;
  margin-block-end: var(--space-4);
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}

.ds-home .ds-home__city ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-16);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ds-home .ds-home__city a,
.ds-home .ds-home__city a:visited {
  display: inline-flex;
  align-items: center;
  min-height: var(--space-32);
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
  text-decoration: none;
}

.ds-home .ds-home__city a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.ds-home .ds-home__more {
  margin-block-start: var(--space-8);
}

.ds-home .ds-home__more > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  min-height: var(--button-height-md);
  color: var(--link-action-color);
  font-size: var(--link-action-font-size);
  font-weight: var(--link-action-font-weight);
  list-style: none;
  cursor: pointer;
}

.ds-home .ds-home__more > summary::-webkit-details-marker {
  display: none;
}

.ds-home .ds-home__more > summary:hover {
  color: var(--link-action-color-hover);
}

.ds-home .ds-home__more-icon {
  font-size: var(--icon-size-sm);
  transition: transform var(--motion-duration-fast) var(--motion-easing);
}

.ds-home .ds-home__more[open] .ds-home__more-icon {
  transform: rotate(180deg);
}

.ds-home .ds-home__more .ds-home__cities {
  border-block-start: 0;
}

/* ---------- "اتصل مباشرة" (paid, labelled): scroller <1024px, 4-per-row grid ≥1024px ---------- */

.ds-home .ds-home__featured {
  display: grid;
  grid-auto-columns: var(--home-featured-card-width-mobile);
  grid-auto-flow: column;
  gap: var(--space-12);
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  list-style: none;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.ds-home .ds-home__featured::-webkit-scrollbar {
  display: none;
}

.ds-home .ds-home__featured > li {
  scroll-snap-align: start;
}

@media (min-width: 640px) {
  .ds-home .ds-home__featured {
    grid-auto-columns: var(--home-featured-card-width);
  }
}

@media (min-width: 1024px) {
  .ds-home .ds-home__featured {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-columns: auto;
    grid-auto-flow: row;
    gap: var(--space-16);
    overflow: visible;
    scroll-snap-type: none;
  }
}

.ds-home .ds-home__feat {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  box-sizing: border-box;
  height: 100%;
  padding: var(--card-padding);
  border: var(--border-width) solid var(--card-border-color);
  border-radius: var(--radius-card);
  background-color: var(--card-bg);
}

.ds-home .ds-home__feat-badge {
  order: -1;
  align-self: flex-start;
}

.ds-home .ds-home__feat-name,
.ds-home .ds-home__feat-name:visited {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

.ds-home .ds-home__feat-name:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.ds-home .ds-home__feat-address {
  display: -webkit-box;
  margin: var(--space-4) 0 0;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ds-home .ds-home__feat-call {
  gap: var(--space-8);
  justify-content: center;
  margin-block-start: auto;
  font-variant-numeric: tabular-nums;
}

.ds-home .ds-home__feat-call .fa-phone {
  color: var(--color-primary);
}

/* ---------- Browse by category: same divided grid as "by city", category first then its cities ---------- */

.ds-home .ds-home__type a.ds-home__type-name,
.ds-home .ds-home__type a.ds-home__type-name:visited {
  display: inline-block;
  margin-block-end: var(--space-4);
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

.ds-home .ds-home__type a.ds-home__type-name:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.ds-home .ds-home__type a.ds-home__type-name {
  min-height: 0;
  font-size: var(--font-size-body);
}

/* Tablet: exactly 4 categories read better as 2 × 2 than 3 + 1 */
@media (min-width: 640px) and (max-width: 1023.98px) {
  .ds-home .ds-home__types:has(> li:nth-child(4):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Desktop: 3 columns by default (3, 6 categories fill rows); 4 when there are exactly 4 or 8 */
@media (min-width: 1024px) {
  .ds-home .ds-home__types {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ds-home .ds-home__types:has(> li:nth-child(4):last-child),
  .ds-home .ds-home__types:has(> li:nth-child(8)) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.ds-home .ds-home__type ul {
  gap: 0 var(--space-12);
}

.ds-home .ds-home__type a.ds-home__type-all,
.ds-home .ds-home__type a.ds-home__type-all:visited {
  color: var(--link-action-color);
  font-weight: var(--link-action-font-weight);
}

/* ---------- For business owners: add for free + advertise ---------- */

.ds-home .ds-home__owners {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-16);
  margin-block-start: var(--space-40);
}

@media (min-width: 1024px) {
  .ds-home .ds-home__owners {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ds-home .ds-home__add {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-12);
  padding: var(--space-20);
  border: var(--border-width) solid var(--color-info-border);
  border-radius: var(--radius-card);
  background-color: var(--color-primary-soft);
}

.ds-home .ds-home__add-title {
  margin: 0 0 var(--space-4);
  color: var(--color-text);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-h4);
}

.ds-home .ds-home__add p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-small);
}

@media (min-width: 640px) {
  .ds-home .ds-home__add {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-20) var(--space-24);
  }

  .ds-home .ds-home__add > .ds-button {
    flex: 0 0 auto;
  }
}

/* Advertise: neutral surface so the free listing stays the lighter-weight first step */
.ds-home .ds-home__add--adv {
  border-color: var(--color-border);
  background-color: var(--color-surface);
}

@media (prefers-reduced-motion: reduce) {
  .ds-home .ds-home__more-icon {
    transition: none;
  }
}
