/* ============================================================
   FIND A TRADIE TAS — Public Listing Card Styles
   css/listings.css

   Feature Pack 1 — Browse & Directory UI
   Two-section layout:
     Section 1 — Featured (Premium):  2 cards per row at 50% width
     Section 2 — Standard (all other): 3 cards per row
   ============================================================ */

:root {
  --fat-bg-card:    #181c27;
  --fat-bg-section: #13161f;
  --fat-gold:       #f5c842;
  --fat-red:        #e02020;
  --fat-border:     #2a2f3d;
  --fat-text-mid:   #c8cdd8;
  --fat-text-muted: #888ea0;
  --fat-radius:     6px;
}

/* ── Section wrappers ───────────────────────────────────── */
.listings-section-featured {
  margin-bottom: 32px;
}
.listings-section-standard {
  /* sits directly below featured section */
}

/* ── Grid — Premium (2 equal columns, each 50%) ────────── */
/*
  align-items: stretch so both cards in a row share the same
  height, driven by whichever card has more content.
*/
.listings-grid--premium {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  align-items: stretch;
}

/* ── Grid — Standard (3 equal columns) ─────────────────── */
/*
  Cards WITH a cover photo share one consistent row height.
  Cards WITHOUT a cover photo share a different consistent
  compact row height.
  Both are achieved by align-items: stretch — grid makes all
  cards in the same row equal height automatically.
*/
.listings-grid--standard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;
}

/* ── Legacy listings-grid (loading / empty state host) ─── */
.listings-grid {
  /* container written into by setLoading and empty state */
}

/* ── Card base ─────────────────────────────────────────── */
.tradie-card {
  background: var(--bg-card, var(--fat-bg-card));
  border: 1px solid var(--border, var(--fat-border));
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  /* Height stretches to match tallest card in row (via grid stretch) */
}
.tradie-card:hover {
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
  transform: translateY(-3px);
}

/* card-body fills available vertical space so footer always
   sits at the bottom regardless of content length */
.card-body {
  padding: 12px 14px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Premium card (Get Jobs tier) ───────────────────────────
   ~15–20% larger than standard. Gold border, gradient top.
   No label, ribbon, crown or star — visual hierarchy only. */
.tradie-card.tier-get-jobs {
  border: 2px solid var(--gold, var(--fat-gold));
  border-radius: 14px;
  background: linear-gradient(
    180deg,
    rgba(245, 200, 66, 0.08) 0%,
    var(--bg-card, var(--fat-bg-card)) 20%,
    var(--bg-card, var(--fat-bg-card)) 100%
  );
  box-shadow:
    0 0 0 1px rgba(245, 200, 66, 0.15),
    0 20px 48px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
}
.tradie-card.tier-get-jobs:hover {
  transform: translateY(-5px);
  box-shadow:
    0 0 0 2px rgba(245, 200, 66, 0.32),
    0 28px 64px rgba(0, 0, 0, 0.6);
}

/* ── Tier accent bar (standard cards) ──────────────────── */
.card-tier-bar {
  height: 3px;
  background: var(--border, var(--fat-border));
  flex-shrink: 0;
}
.tradie-card.tier-get-jobs .card-tier-bar {
  height: 0;
}

/* ── Photo ──────────────────────────────────────────────── */
/* Only rendered when photo_url exists — no empty placeholder */
.card-photo {
  flex-shrink: 0;
  overflow: hidden;
}
.card-photo img {
  width: 100%;
  height: 160px;    /* standard */
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}
.tradie-card:hover .card-photo img {
  transform: scale(1.03);
}
.tradie-card.tier-get-jobs .card-photo img {
  height: 180px;    /* premium */
}

/* ── Premium body padding — slightly reduced ────────────── */
.tradie-card.tier-get-jobs .card-body {
  padding: 12px 16px 10px;
  gap: 8px;
}

/* ── Header row: logo + name stack ─────────────────────── */
.card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.card-logo { flex-shrink: 0; }
.card-logo-img {
  width: 48px;      /* standard */
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border, var(--fat-border));
  background: var(--bg-card, var(--fat-bg-card));
}
.tradie-card.tier-get-jobs .card-logo-img {
  width: 64px;      /* premium */
  height: 64px;
  border-radius: 10px;
}
.card-header-info {
  flex: 1;
  min-width: 0;
}

/* ── Badges row ─────────────────────────────────────────── */
.card-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.7;
}
.badge-abn      { background: rgba(26, 92, 42, 0.30); color: #4caf7d; }
.badge-founding { background: rgba(245, 200, 66, 0.15); color: var(--gold, var(--fat-gold)); }
.badge-premium  {
  background: rgba(245, 200, 66, 0.12);
  color: var(--gold, var(--fat-gold));
  border: 1px solid rgba(245, 200, 66, 0.30);
}

/* Internal tier badge — always hidden on public pages */
.badge-tier { display: none !important; }

/* ── Business name ──────────────────────────────────────── */
.card-business-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--gold, var(--fat-gold));
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}
.tradie-card.tier-get-jobs .card-business-name {
  font-size: 21px;
  letter-spacing: 0.02em;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted, var(--fat-text-muted));
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Review score ───────────────────────────────────────── */
.card-reviews {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}
.card-stars        { color: var(--gold, var(--fat-gold)); letter-spacing: 1px; }
.card-review-score { font-weight: 700; color: var(--text-mid, var(--fat-text-mid)); }
.card-review-count { color: var(--text-muted, var(--fat-text-muted)); }

/* ── Bio ────────────────────────────────────────────────── */
.card-bio {
  font-size: 13px;
  color: var(--text-mid, var(--fat-text-mid));
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tradie-card.tier-get-jobs .card-bio {
  font-size: 14px;
  -webkit-line-clamp: 3;
}

/* ── Attribute badges ───────────────────────────────────── */
.card-attributes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.badge-attr {
  background: rgba(245, 200, 66, 0.09);
  color: var(--gold, var(--fat-gold));
  border: 1px solid rgba(245, 200, 66, 0.22);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

/* ── Gallery strip (Premium / Get Jobs tier) ───────────────── */
.card-gallery-strip {
  display: flex;
  gap: 5px;
  overflow: hidden;
  border-radius: 5px;
}
.gallery-thumb {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  transition: transform 0.25s;
}
.gallery-thumb:hover {
  transform: scale(1.04);
}

/* ── Profile link (body) — compat stub ─────────────────── */
.card-profile-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold, var(--fat-gold));
  margin-top: auto;
  padding-top: 4px;
  display: inline-block;
}
.card-profile-link:hover { text-decoration: underline; }

/* ── Title row ──────────────────────────────────────────── */
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Footer ─────────────────────────────────────────────── */
/*
  Footer always sits at the bottom of the card because
  .card-body has flex:1 and the card is a flex column.
  margin-top:auto on the footer is not needed — flex column
  with flex:1 body handles it.
*/
.card-footer {
  padding: 9px 16px 11px;
  border-top: 1px solid var(--border, var(--fat-border));
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--bg-section, var(--fat-bg-section));
  flex-shrink: 0;
}
.tradie-card.tier-get-jobs .card-footer {
  padding: 9px 18px 11px;
  gap: 7px;
}

/* ── Footer rows ────────────────────────────────────────── */
/*
  Standard cards: one row, 4 equal columns.
  Ghost buttons fill empty slots so alignment never breaks.

  Premium cards: two rows.
    Row 1 (.card-footer-row--contact):
      If phone: 3 equal columns — Call | Email | Web
      If no phone: 2 equal columns — Email | Web
      (controlled by data-has-phone attribute on the row)
    Row 2 (.card-footer-row--actions):
      2 equal columns — Get Quote | View Profile
*/
.card-footer-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
}

/* Premium contact row — 3 cols (Call + Email + Web) */
.card-footer-row--contact-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Premium contact row — 2 cols (Email + Web, no phone) */
.card-footer-row--contact-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Premium actions row — always 2 equal cols */
.card-footer-row--actions {
  grid-template-columns: repeat(2, 1fr);
}

/* ── Buttons ────────────────────────────────────────────── */
.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  padding: 0 6px;
  border-radius: var(--radius, var(--fat-radius));
  font-family: 'Barlow', sans-serif;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  cursor: pointer;
  border: none;
  box-sizing: border-box;
  transition: opacity 0.2s, transform 0.15s;
  line-height: 1;
  min-width: 0;
}
.card-btn:hover { opacity: 0.88; transform: translateY(-1px); }

.card-btn-call    { background: var(--red, var(--fat-red)); color: #fff; }
.card-btn-email   { background: var(--bg-card, var(--fat-bg-card)); border: 1px solid var(--border, var(--fat-border)); color: var(--text-mid, var(--fat-text-mid)); }
.card-btn-web     { background: var(--bg-card, var(--fat-bg-card)); border: 1px solid var(--border, var(--fat-border)); color: var(--text-mid, var(--fat-text-mid)); }
.card-btn-quote   { background: var(--gold, var(--fat-gold)); color: #000; font-weight: 700; }
.card-btn-profile { background: transparent; border: 1px solid var(--gold, var(--fat-gold)); color: var(--gold, var(--fat-gold)); font-weight: 700; }
.card-btn-profile:hover { background: rgba(245, 200, 66, 0.10); opacity: 1; }

/* Ghost — invisible placeholder that holds column width */
.card-btn-ghost {
  background: transparent;
  border: none;
  cursor: default;
  pointer-events: none;
}
.card-btn-ghost:hover { opacity: 1; transform: none; }

/* ── Listings container width ───────────────────────────── */
/*
  Slightly widen the listing sections to reduce the large
  right-hand margin visible at wide viewports.
  Overrides the max-width set on .listings-section in trades.html
  by targeting the grid wrappers directly.
*/
.listings-section-featured,
.listings-section-standard {
  max-width: 1260px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Loading / Empty ────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted, var(--fat-text-muted));
  font-size: 16px;
}
.empty-state {
  text-align: center;
  padding: 80px 24px;
}
.empty-icon  { font-size: 44px; margin-bottom: 12px; }
.empty-state h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-mid, var(--fat-text-mid));
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 15px;
  color: var(--text-muted, var(--fat-text-muted));
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.empty-cta {
  display: inline-block;
  background: var(--red, var(--fat-red));
  color: #fff;
  padding: 13px 26px;
  border-radius: var(--radius, var(--fat-radius));
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.empty-cta:hover { opacity: 0.88; }

/* ── Grouped region select ──────────────────────────────── */
.filter-group select optgroup {
  font-weight: 700;
  font-style: normal;
  color: var(--gold, var(--fat-gold));
  background: #0c044b;
}
.filter-group select optgroup option {
  font-weight: 400;
  color: #ffffff;
  background: #0c044b;
  padding-left: 8px;
}

/* ── Responsive — Tablet (≤900px) ──────────────────────── */
@media (max-width: 900px) {
  .listings-grid--premium {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .listings-grid--standard {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .listings-section-featured,
  .listings-section-standard {
    max-width: 100%;
  }
}

/* ── Responsive — Mobile (≤640px) ──────────────────────── */
@media (max-width: 640px) {
  .listings-grid--premium,
  .listings-grid--standard {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .listings-section-featured {
    margin-bottom: 20px;
  }

  /* Premium card — no lift on mobile */
  .tradie-card.tier-get-jobs {
    transform: none;
  }
  .tradie-card.tier-get-jobs:hover {
    transform: translateY(-3px);
  }

  /* Reduced image heights on mobile */
  .card-photo img {
    height: 140px;
  }
  .tradie-card.tier-get-jobs .card-photo img {
    height: 170px;
  }

  /* Standard footer: 2×2 on mobile so text isn't crushed */
  .card-footer-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  /* Premium contact rows keep their column count on mobile */
  .card-footer-row--contact-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .card-footer-row--contact-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .card-footer-row--actions {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Compact card body */
  .card-body {
    padding: 12px 14px 10px;
    gap: 8px;
  }
  .tradie-card.tier-get-jobs .card-body {
    padding: 12px 14px 10px;
    gap: 8px;
  }
  .card-footer {
    padding: 8px 14px 10px;
  }
  .tradie-card.tier-get-jobs .card-footer {
    padding: 8px 14px 10px;
  }
}
