/*
  TL_AD_CARDS_V3 (2026-01-17)
  Unified Property Ad Card across the site

  Trust variants (accent bar):
  - .tl-ad-card--verified  (trusted office/contractor)
  - .tl-ad-card--approved  (approved office / broker / contractor)
  - .tl-ad-card--owner     (property owner)

  Advertiser kind (badge/icon styling):
  - .tl-ad-card--k-owner
  - .tl-ad-card--k-broker
  - .tl-ad-card--k-office
  - .tl-ad-card--k-contractor

  Notes:
  - Keeps all existing class names to avoid breaking any current behavior.
  - Designed for: mobile = full-width cards, desktop = 4 cards per row on listing pages.
*/

:root{
  --tl-adc-radius: 20px;
  --tl-adc-shadow: 0 12px 26px rgba(2,6,23,.08);
  --tl-adc-shadow-hover: 0 18px 44px rgba(2,6,23,.12);

  /* Grid rhythm */
  --tl-adc-gap: 12px;
}

.tl-ad-card{
  position: relative;
  display: flex;
  flex-direction: row;
  gap: 12px;
  direction: rtl;
  align-items: stretch;
  height: 100%;

  background: var(--tl-surface, #fff);
  border: 1px solid rgba(148,163,184,.35);
  border-radius: var(--tl-adc-radius);
  overflow: hidden;

  /* Anchor defaults (component root is <a>) */
  text-decoration: none;
  color: inherit;

  padding: 12px;
  box-shadow: var(--tl-adc-shadow);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;

  /* Trust accent (overridden by variant classes) */
  --tl-adc-accent: var(--tl-aqua, #25BCCF);

  /* Advertiser kind tokens (overridden by kind classes) */
  --tl-adc-kind-solid: rgba(15,23,42,.75);
  --tl-adc-kind-soft: rgba(15,23,42,.06);
  --tl-adc-kind-border: rgba(15,23,42,.12);
}

.tl-ad-card:hover{
  transform: translateY(-1px);
  box-shadow: var(--tl-adc-shadow-hover);
}

.tl-ad-card:focus-visible{
  outline: 3px solid rgba(37,188,207,.35);
  outline-offset: 3px;
}

/* Trust accent bar (RTL: right side) */
.tl-ad-card::before{
  content:"";
  position:absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 5px;
  background: var(--tl-adc-accent);
  z-index: 2;
}

/* Trust variants */
.tl-ad-card--verified{ --tl-adc-accent: #16a34a; }
.tl-ad-card--approved{ --tl-adc-accent: var(--tl-aqua, #25BCCF); }
.tl-ad-card--owner{ --tl-adc-accent: var(--tl-gold, #E1BA41); }


.tl-ad-card--contractor{ --tl-adc-accent: #7c3aed; } /* purple */
/* Advertiser kinds */
.tl-ad-card--k-owner{
  --tl-adc-kind-solid: var(--tl-gold, #E1BA41);
  --tl-adc-kind-soft: rgba(225,186,65,.12);
  --tl-adc-kind-border: rgba(225,186,65,.24);
}
.tl-ad-card--k-broker{
  --tl-adc-kind-solid: var(--tl-aqua, #25BCCF);
  --tl-adc-kind-soft: rgba(37,188,207,.12);
  --tl-adc-kind-border: rgba(37,188,207,.24);
}
.tl-ad-card--k-office{
  --tl-adc-kind-solid: var(--tl-navy, #222F75);
  --tl-adc-kind-soft: rgba(34,47,117,.10);
  --tl-adc-kind-border: rgba(34,47,117,.20);
}
.tl-ad-card--k-contractor{
  --tl-adc-kind-solid: #7c3aed;
  --tl-adc-kind-soft: rgba(124,58,237,.12);
  --tl-adc-kind-border: rgba(124,58,237,.22);
}

/* No price state */
.tl-ad-card--no-price{
  border-color: rgba(148,163,184,.28);
}

.tl-ad-card__thumb{
  flex: 0 0 auto;
  width: 136px;
  height: 108px;
  border-radius: 16px;
  overflow: hidden;
  background: #0b1220;
  position: relative;
}

.tl-ad-card__thumb img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Side column: thumbnail + location under thumbnail */
.tl-ad-card__side{
  flex: 0 0 auto;
  width: 136px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: stretch;
}

/* Keep the location row aligned with the meta row by pushing it to the bottom */
.tl-ad-card__side .tl-ad-card__loc{
  margin-top: auto;
}

/* Icon only (top-right on image, RTL) */
.tl-ad-card__kindIcon{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--tl-adc-kind-border);
  box-shadow: 0 10px 22px rgba(2,6,23,.10);
  backdrop-filter: blur(10px);
}

.tl-ad-card__kindIconInner{
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tl-adc-kind-solid);
}

.tl-ad-card__kindIconInner svg{
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tl-ad-card__kindIconTick{
  position: absolute;
  bottom: -4px;
  left: -4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(22,163,74,.14);
  border: 1px solid rgba(22,163,74,.30);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #16a34a;
}

.tl-ad-card__kindIconTick svg{
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* =============================
   Top info row (badge + price) + tag
   Requirement: NO overlays on image
   ============================= */

.tl-ad-card__top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Tag (offer/type) under the image */
.tl-ad-card__tag{
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(15,23,42,.12);
  color: rgba(15,23,42,.85);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(8px);
}

/* Advertiser badge (icon + short label + optional verified tick) */
.tl-ad-card__badge{
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--tl-adc-kind-border);
  box-shadow: 0 8px 18px rgba(2,6,23,.10);
  color: rgba(15,23,42,.85);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
}

.tl-ad-card__badgeIc{
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tl-adc-kind-solid);
}

.tl-ad-card__badgeIc svg{
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tl-ad-card__badgeTxt{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 900;
}

.tl-ad-card__badgeCheck{
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(22,163,74,.12);
  border: 1px solid rgba(22,163,74,.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #16a34a;
}

.tl-ad-card__badgeCheck svg{
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Price tag (scan-first) */
.tl-ad-card__priceTag{
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(15,23,42,.12);
  box-shadow: 0 8px 18px rgba(2,6,23,.10);
  color: rgba(15,23,42,.92);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
}

.tl-ad-card__priceTag::before{
  content:"";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--tl-adc-accent);
  box-shadow: 0 0 0 4px rgba(2,6,23,.04);
}

/* Price under title */
.tl-ad-card__priceUnder{
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(15,23,42,.12);
  box-shadow: 0 8px 18px rgba(2,6,23,.08);
  color: rgba(15,23,42,.92);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
}

.tl-ad-card__priceUnder::before{
  content:"";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--tl-adc-accent);
  box-shadow: 0 0 0 4px rgba(2,6,23,.04);
}

/* Price row (main + USD report) */
.tl-ad-card__priceRow{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tl-ad-card__priceUsd{
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px dashed rgba(22,163,74,.32);
  box-shadow: 0 8px 18px rgba(2,6,23,.06);
  color: #16a34a;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
}

.tl-ad-card__priceUsd::before{
  content:"";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(2,6,23,.04);
}


.tl-ad-card--no-price .tl-ad-card__priceTag{
  background: rgba(241,245,249,.94);
  border-color: rgba(148,163,184,.32);
  color: rgba(15,23,42,.70);
}

/* Verified ads: subtle thumb ring */
.tl-ad-card--verified .tl-ad-card__thumb{
  box-shadow: 0 0 0 2px rgba(22,163,74,.22) inset;
}

.tl-ad-card__body{
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-inline-end: 4px; /* keep text away from the accent bar */
}

.tl-ad-card__title{
  color: var(--tl-ink, #0b1220);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 900;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tl-ad-card__org{
  font-size: 12px;
  color: rgba(15,23,42,.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-ad-card__orgPill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tl-adc-kind-border);
  background: var(--tl-adc-kind-soft);
  color: rgba(15,23,42,.86);
  font-weight: 900;
}

.tl-ad-card__loc{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(15,23,42,.62);
  min-width: 0;
}

.tl-ad-card__pin{
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  opacity: .9;
}

.tl-ad-card__pin svg{
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.tl-ad-card__locText{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-ad-card__meta{
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  font-size: 12px;
  color: rgba(15,23,42,.62);

  /* Always keep rooms + bathrooms + area in a single line on mobile */
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;

  /* Align meta with the location row under the thumbnail */
  margin-top: auto;
}

.tl-ad-card__meta::-webkit-scrollbar{
  display: none;
}

.tl-ad-card__metaItem{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,.28);
  background: rgba(255,255,255,.92);
}

.tl-ad-card__metaItem svg{
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .9;
}

/* Responsive tweaks */
@media (max-width: 480px){
  .tl-ad-card{ padding: 10px; gap: 10px; }
  .tl-ad-card__thumb{ width: 118px; height: 96px; border-radius: 14px; }
  .tl-ad-card__side{ width: 118px; }
  .tl-ad-card__title{ font-size: 14px; }
}

/* Ultra-narrow devices (e.g., Galaxy Fold cover screen): switch to vertical card
   to prevent cramped/"broken" horizontal layout. */
@media (max-width: 360px){
  .tl-ad-card{
    flex-direction: column;
    align-items: stretch;
  }

  .tl-ad-card__side{ width: 100%; }

  .tl-ad-card__thumb{
    width: 100%;
    height: 168px;
  }

  .tl-ad-card__title{ font-size: 15px; }
}

@media ((min-width: 1024px) and (hover: hover) and (pointer: fine)), (min-width: 1367px){
  /* Desktop: vertical card works better in multi-column grids */
  .tl-ad-card{
    flex-direction: column;
    padding: 10px;
  }

  /* Accent bar becomes top */
  .tl-ad-card::before{
    right: 0;
    top: 0;
    bottom: auto;
    width: 100%;
    height: 5px;
  }

  .tl-ad-card__thumb{
    width: 100%;
    height: 180px;
    border-radius: 18px;
  }

  .tl-ad-card__side{
    width: 100%;
  }

  .tl-ad-card__top{ gap: 10px; }

  .tl-ad-card__title{ font-size: 14px; }
  .tl-ad-card__metaItem{ padding: 6px 8px; }
}

/* =============================
   Grid helpers (used by listing pages)
   ============================= */

/*
  Requirement:
  - Mobile: 1 card per row (full width)
  - Desktop: 4 cards per row
*/
.tl-ads-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: var(--tl-adc-gap);
}

@media ((min-width: 1024px) and (hover: hover) and (pointer: fine)), (min-width: 1367px){
  .tl-ads-grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Keep the existing helper (used by home page) */
.tl-ads-grid-3{ display:grid; grid-template-columns: 1fr; gap: var(--tl-adc-gap); }
@media (min-width: 640px){ .tl-ads-grid-3{ grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px){ .tl-ads-grid-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Legend pills (keep old mapping: v=verified, a=approved, o=owner) */
.tl-ad-legend{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.tl-ad-legend .it{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(148,163,184,.35);
  box-shadow: 0 8px 18px rgba(2,6,23,.04);
  font-size: 12px;
  color: rgba(15,23,42,.75);
}
.tl-ad-legend .dot{ width:10px; height:10px; border-radius:999px; }
.tl-ad-legend .dot.v{ background:#16a34a; }
.tl-ad-legend .dot.a{ background: #7c3aed; }
.tl-ad-legend .dot.o{ background: var(--tl-gold, #E1BA41); }

/* Force contractor chip color when advertiser_type=contractor (even if kind differs due to legacy relations) */
.tl-ad-card[data-at="contractor"]{
  --tl-adc-kind-solid: #7c3aed;
  --tl-adc-kind-soft: rgba(124,58,237,.12);
  --tl-adc-kind-border: rgba(124,58,237,.22);
  --tl-adc-accent: #7c3aed;
}

/* Legend buttons reset */
.tl-ad-legend .it{
  appearance:none;
  -webkit-appearance:none;
  border:1px solid rgba(148,163,184,.35);
  background:#fff;
  cursor:pointer;
  font:inherit;
}
.tl-ad-legend .it:focus{ outline: none; }
.tl-ad-legend .it:focus-visible{ outline: 2px solid rgba(124,58,237,.35); outline-offset: 2px; }

/*
  Legend stacking:
  Keep it within the normal stacking context so it never overlays sticky
  toolbars/filters on listing pages.
*/
.tl-ad-legend{ position: relative; z-index: 1; }

/* Active state (used by listing-page quick filters) */
.tl-ad-legend .it.is-active{
  border-color: rgba(37,99,235,.45);
  background: rgba(37,99,235,.06);
}

/* Hide legend when map overlay is open */
.tl-map-overlay.is-open ~ .tl-ad-legend,
.tl-map-overlay.is-open .tl-ad-legend{
  display:none !important;
}

/* Hide legend while map is open */
html.tl-map-open .tl-ad-legend{ display:none !important; }

/* ===== Video badge on ad cards (ready/processing) ===== */
.tl-ad-card__thumb{ position: relative; }

.tl-ad-card__videoBadge{
  position: absolute;
  left: 10px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,.55);
  color: #fff;
  z-index: 4;
  box-shadow: 0 10px 20px rgba(2,6,23,.18);
  backdrop-filter: blur(6px);
}

.tl-ad-card__videoBadge svg{
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.tl-ad-card__videoBadge.is-processing::after{
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: rgba(255,255,255,1);
  animation: tlVideoBadgeSpin 1s linear infinite;
}

@keyframes tlVideoBadgeSpin{
  to { transform: rotate(360deg); }
}

/* ===== Video-highlighted cards (senior treatment) =====
   Goal: make video ads immediately recognizable without being noisy.
   - Subtle gradient glow + ring
   - No layout shifts
   - Accessible (keeps existing aria-label/title)
*/
.tl-ad-card--has-video{
  border-color: rgba(37,188,207,.50);
  box-shadow:
    var(--tl-adc-shadow),
    0 0 0 2px rgba(37,188,207,.14),
    0 22px 58px rgba(37,188,207,.10);
}

.tl-ad-card--has-video:hover{
  box-shadow:
    var(--tl-adc-shadow-hover),
    0 0 0 2px rgba(37,188,207,.18),
    0 28px 70px rgba(37,188,207,.12);
}

/* Soft corner glow (kept behind content) */
.tl-ad-card--has-video::after{
  content:"";
  position:absolute;
  inset: 0;
  border-radius: var(--tl-adc-radius);
  pointer-events:none;
  z-index: 0;
  opacity: .65;
  background:
    radial-gradient(420px 180px at 0% 0%, rgba(37,188,207,.22), transparent 58%),
    radial-gradient(360px 160px at 100% 100%, rgba(225,186,65,.12), transparent 60%);
}

.tl-ad-card--has-video > *{ position: relative; z-index: 1; }

/* Give the thumbnail a subtle ring so the "media" feel is obvious */
.tl-ad-card--has-video .tl-ad-card__thumb{
  outline: 2px solid rgba(37,188,207,.18);
  outline-offset: -2px;
}

/* Processing state: warn glow (keeps existing spinner on the badge) */
.tl-ad-card--video-processing{
  border-color: rgba(245,158,11,.52);
}

.tl-ad-card--video-processing::after{
  opacity: .62;
  background:
    radial-gradient(420px 180px at 0% 0%, rgba(245,158,11,.22), transparent 58%),
    radial-gradient(360px 160px at 100% 100%, rgba(225,186,65,.14), transparent 60%);
  animation: tlVideoProcessingGlow 2.2s ease-in-out infinite;
}

.tl-ad-card--video-processing .tl-ad-card__thumb{
  outline-color: rgba(245,158,11,.20);
}

@keyframes tlVideoProcessingGlow{
  0%, 100%{ opacity: .54; }
  50%{ opacity: .82; }
}

@media (prefers-reduced-motion: reduce){
  .tl-ad-card--video-processing::after{ animation: none; }
}

/* Optional: expand the badge to a pill when there is enough room (keeps mobile compact) */
@media (min-width: 520px){
  .tl-ad-card__videoBadge{
    width: auto;
    padding: 0 12px;
    gap: 8px;
  }
  .tl-ad-card__videoBadge::before{
    content: "\0641 \064a \062f \064a \0648 ";
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .2px;
    line-height: 1;
  }
  .tl-ad-card__videoBadge.is-processing::before{ content: "\0645 \0639 \0627 \0644 \062c \0629 "; }
}
