/*
 * Agents directory cards — /agents, /fa/agents, /ar/agents only (js/dn-agents-listing.js renders them).
 *
 * 2026-09-22 (UI/UX audit #5). The base card look (white card, portrait column, gold badge) stays in
 * dn-ui-audit.css; this file only fixes what the audit found, scoped under #agentsGrid so it wins over
 * that file's !important rules without touching them:
 *   - the action row: four buttons squeezed into the text column ("View profil e", "C a ll" at 390px)
 *     now sit in their own grid area — 2x2 under the text on desktop, full card width on phones;
 *   - the bio is clamped to three WHOLE lines by the script, with a "Read more" toggle;
 *   - the portrait box is never an empty beige block: the agent's monogram sits behind the photo.
 * Colours are the site's ink/gold/ivory.
 */

#agentsGrid .card.dn-agent-card {
  grid-template-columns: 178px minmax(0, 1fr) !important;
  grid-template-rows: 1fr auto;
  grid-template-areas: "photo body" "photo actions";
}

/* ── Portrait: monogram behind, photo on top ───────────────────────────────────────────── */
#agentsGrid .dn-agent-photo {
  grid-area: photo;
  position: relative;
  display: block;
  min-height: 250px !important;
  max-height: none !important;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-surface-tertiary, #d7e1eb) 92%, var(--color-text, #171717) 8%);
}
#agentsGrid .dn-agent-monogram {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3194ff;
  font: 700 40px/1 Georgia, "Times New Roman", serif;
  letter-spacing: .06em;
}
#agentsGrid .dn-agent-photo .photo {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: 50% 28% !important;
  background: transparent !important;   /* the page's .photo rule paints the img itself beige */
  opacity: 0;
  transition: opacity .25s ease;
}
#agentsGrid .dn-agent-photo .photo.is-in { opacity: 1; }

/* ── Text column ─────────────────────────────────────────────────────────────────────────── */
#agentsGrid .dn-agent-body {
  grid-area: body;
  padding-block: 16px 4px;
  padding-inline: 16px 18px;
}
/* !important: the FA/AR pages set every <p> to 16.5px / 1.95 !important (dn-ui-audit.css), which
   made a card bio twice the height of its neighbours. */
#agentsGrid .dn-agent-bio,
#agentsGrid .dn-agent-facts {
  margin: 10px 0 0;
  color: #5b5346;
  font-size: 14px !important;
  line-height: 1.6 !important;
  overflow-wrap: anywhere;
  text-align: start;
}
html[lang^="fa"] #agentsGrid :is(.dn-agent-bio, .dn-agent-facts),
html[lang^="ar"] #agentsGrid :is(.dn-agent-bio, .dn-agent-facts) {
  font-size: 14px !important;
  line-height: 1.8 !important;
}
/* Three lines. The script cuts the text at a word so it fits them exactly and pins the height in
   px; this em value is only the no-script safety net. */
#agentsGrid .dn-agent-bio:not(.is-open) {
  max-height: 4.8em;
  overflow: hidden;
}
#agentsGrid .dn-agent-more {
  align-self: flex-start;
  margin: 2px 0 0;
  padding: 6px 0;
  border: 0;
  background: none;
  color: #0054af;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
#agentsGrid .dn-agent-more[hidden] { display: none; }
#agentsGrid .dn-agent-more:focus-visible { outline: 2px solid #1686ff; outline-offset: 2px; border-radius: 4px; }

/* ── Actions: their own grid area, two per row ─────────────────────────────────────────────── */
#agentsGrid .dn-agent-card > .actions {
  grid-area: actions;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  margin: 0 !important;
  padding-block: 10px 16px !important;
  padding-inline: 16px 18px !important;
}
#agentsGrid .dn-agent-card > .actions .btn {
  width: auto;
  min-width: 0;
  height: auto;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* No WhatsApp number -> three buttons: the enquiry button takes the full last row. */
#agentsGrid .dn-agent-card > .actions > :last-child:nth-child(odd) { grid-column: 1 / -1; }
#agentsGrid .dn-agent-card > .actions .btn-profile {
  background: #fffdf8;
  color: #171717;
  border: 1px solid rgba(22, 134, 255, .55);
}
#agentsGrid .dn-agent-card > .actions .btn-profile:hover { border-color: #0054af; }

/* ── Loading skeleton: the first screen keeps its shape, nothing reads as broken ──────────── */
#agentsGrid .dn-agent-skel {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  min-height: 300px;
  overflow: hidden;
  border: 1px solid rgba(23, 23, 23, .08);
  border-radius: 16px;
  background: #fff;
}
#agentsGrid .dn-agent-skel span,
#agentsGrid .dn-agent-skel i {
  background: linear-gradient(100deg, #deebf8 30%, #fbf7ef 50%, #deebf8 70%) 0 0 / 300% 100%;
  animation: dnAgentSkel 1.4s ease-in-out infinite;
}
#agentsGrid .dn-agent-skel i {
  margin: 20px 18px;
  border-radius: 8px;
  -webkit-mask: linear-gradient(#000 0 0) 0 0 / 70% 22px no-repeat, linear-gradient(#000 0 0) 0 34px / 45% 14px no-repeat,
    linear-gradient(#000 0 0) 0 70px / 100% 12px no-repeat, linear-gradient(#000 0 0) 0 92px / 90% 12px no-repeat,
    linear-gradient(#000 0 0) 0 100% / 100% 44px no-repeat;
          mask: linear-gradient(#000 0 0) 0 0 / 70% 22px no-repeat, linear-gradient(#000 0 0) 0 34px / 45% 14px no-repeat,
    linear-gradient(#000 0 0) 0 70px / 100% 12px no-repeat, linear-gradient(#000 0 0) 0 92px / 90% 12px no-repeat,
    linear-gradient(#000 0 0) 0 100% / 100% 44px no-repeat;
}
@keyframes dnAgentSkel { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  #agentsGrid .dn-agent-skel span, #agentsGrid .dn-agent-skel i { animation: none; }
}
.dn-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── RTL: the page's own `.wrap{direction:ltr}` wins over dir="rtl". /fa/agents overrides it inline;
   /ar/agents never did, so the Arabic grid ran left-to-right (photo left, labels before values). ── */
.wrap[dir="rtl"] { direction: rtl !important; text-align: right !important; }

/* ── Phones: portrait + text side by side, the buttons across the whole card below ─────────── */
@media (max-width: 640px) {
  #agentsGrid .card.dn-agent-card {
    grid-template-columns: 112px minmax(0, 1fr) !important;
    grid-template-rows: auto auto;
    grid-template-areas: "photo body" "actions actions";
  }
  #agentsGrid .dn-agent-photo { min-height: 200px !important; }
  #agentsGrid .dn-agent-monogram { font-size: 28px; }
  #agentsGrid .dn-agent-body { padding-block: 14px 10px; padding-inline: 14px; }
  #agentsGrid .dn-agent-card > .actions {
    padding-block: 12px !important;
    padding-inline: 12px !important;
    border-top: 1px solid rgba(23, 23, 23, .06);
  }
  #agentsGrid .dn-agent-skel { grid-template-columns: 112px minmax(0, 1fr); min-height: 260px; }
}
