/*
 * Core Listing search: the [corelisting_search] shortcode.
 *
 * Everything is scoped under .core-app so the search can sit inside any theme
 * without its styles leaking out, or the theme's class names leaking in.
 * Per-shortcode values (accent, pin colour, panel width, height) arrive as CSS
 * variables on the .core-app element itself; the mobile rules, which depend on
 * each shortcode's breakpoint, are printed next to it.
 */
.core-app, .core-app *, .core-app *::before, .core-app *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Site themes style bare form controls (WordPress's Hello Elementor makes every
   select and input 100% wide with pink button borders). Start ours from neutral.
   :where() keeps this weak enough that the core- classes below still win, and
   the map is left out because Google styles its own zoom and fullscreen buttons. */
.core-app :where(.core-header, .core-filters, .core-panel) button,
.core-app :where(.core-header, .core-filters, .core-panel) input,
.core-app :where(.core-header, .core-filters, .core-panel) select,
.core-app :where(.core-header, .core-filters, .core-panel) summary,
.core-app select.core-map-style-pick {
  width: auto; padding: 0; font-family: inherit; line-height: normal; letter-spacing: normal;
  text-transform: none; text-decoration: none; box-shadow: none; transition: none;
}

.core-app {
  --core-bg:       #f5f6f8;
  --core-surface:  #ffffff;
  --core-border:   #e3e6eb;
  --core-border-2: #d3d8df;

  --core-text:     #1a1f2b;
  --core-muted:    #6b7280;
  --core-faint:    #9aa1ad;
  --core-sold:     #16a34a;
  --core-escrow:   #d97706;
  --core-active:   #2563eb;
  --core-hdr-h:    58px;
}

.core-app {
  height: var(--core-app-h, 100vh);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--core-bg);
  color: var(--core-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.core-app .core-header {
  min-height: var(--core-hdr-h);
  background: var(--core-surface);
  border-bottom: 1px solid var(--core-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  flex-shrink: 0;
  z-index: 10;
}
.core-app .core-header-spacer { flex: 1; }

.core-app .core-seg {
  display: flex;
  border: 1px solid var(--core-border-2);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.core-app .core-seg button {
  background: var(--core-surface);
  border: none;
  border-right: 1px solid var(--core-border);
  padding: 6px 12px;
  color: var(--core-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
}
.core-app .core-seg button:last-child { border-right: none; }
.core-app .core-seg button:hover:not(.core-is-active) { color: var(--core-text); background: var(--core-bg); }
.core-app .core-seg button.core-is-active { background: var(--core-accent); color: #fff; }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.core-app .core-filters {
  background: var(--core-surface);
  border-bottom: 1px solid var(--core-border);
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
  flex-shrink: 0;
  z-index: 9;
}
.core-app .core-f-group { display: flex; flex-direction: column; gap: 4px; }
.core-app .core-f-group.core-grow { flex: 1; min-width: 200px; max-width: 340px; }
.core-app .core-f-label { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--core-faint); }

.core-app .core-field {
  height: 34px;
  background: var(--core-surface);
  border: 1px solid var(--core-border-2);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--core-text);
  font-size: 0.83rem;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.core-app .core-field:focus { border-color: var(--core-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--core-accent) 15%, transparent); }
.core-app select.core-field { padding-right: 6px; cursor: pointer; }

.core-app .core-kw-wrap { position: relative; }
.core-app .core-kw-wrap .core-field { width: 100%; padding-left: 32px; padding-right: 30px; }
.core-app .core-kw-wrap svg { position: absolute; left: 10px; top: 10px; color: var(--core-faint); pointer-events: none; }
.core-app .core-kw-clear {
  position: absolute; right: 6px; top: 6px;
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: transparent; color: var(--core-faint); cursor: pointer; font-size: 13px; display: none;
}
.core-app .core-kw-clear:hover { background: var(--core-bg); color: var(--core-text); }

.core-app .core-range { display: flex; align-items: center; gap: 4px; }
.core-app .core-range .core-field { width: 76px; }
.core-app .core-range span { color: var(--core-faint); font-size: 0.8rem; }

.core-app .core-chips-row { display: flex; gap: 4px; }
.core-app .core-pill {
  height: 34px;
  background: var(--core-surface);
  border: 1px solid var(--core-border-2);
  border-radius: 7px;
  padding: 0 11px;
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--core-muted);
  cursor: pointer;
  white-space: nowrap;
}
.core-app .core-pill:hover { border-color: var(--core-accent); color: var(--core-text); }
.core-app .core-pill.core-is-active { background: var(--core-accent); border-color: var(--core-accent); color: #fff; }

/* Property type multi-select */
.core-app .core-dd { position: relative; }
.core-app .core-dd > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 150px; cursor: pointer; line-height: 32px; }
.core-app .core-dd > summary::-webkit-details-marker { display: none; }
.core-app .core-dd > summary::after { content: '▾'; color: var(--core-faint); font-size: 0.75rem; }
.core-app .core-dd.core-has-value > summary { border-color: var(--core-accent); color: var(--core-accent); }
.core-app .core-dd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  background: var(--core-surface); border: 1px solid var(--core-border-2); border-radius: 9px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  padding: 6px; min-width: 230px; max-height: 320px; overflow-y: auto;
}
.core-app .core-dd-menu label {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 0.82rem; cursor: pointer;
}
.core-app .core-dd-menu label:hover { background: var(--core-bg); }
.core-app .core-dd-menu label .core-cnt { margin-left: auto; color: var(--core-faint); font-size: 0.75rem; }
.core-app .core-dd-menu label.core-is-empty { opacity: 0.45; }
.core-app .core-dd-menu input { accent-color: var(--core-accent); }
.core-app .core-dd-clear { width: 100%; text-align: left; border: none; background: none; color: var(--core-accent); font-size: 0.78rem; padding: 6px 8px; cursor: pointer; }

.core-app .core-check { display: flex; align-items: center; gap: 6px; height: 34px; font-size: 0.82rem; color: var(--core-muted); cursor: pointer; white-space: nowrap; }
.core-app .core-check input { accent-color: var(--core-accent); width: 15px; height: 15px; }

.core-app .core-reset-btn { height: 34px; border: none; background: none; color: var(--core-accent); font-size: 0.8rem; font-weight: 600; cursor: pointer; padding: 0 6px; margin-left: auto; }
.core-app .core-reset-btn:hover { text-decoration: underline; }

/* ── App body ──────────────────────────────────────────────────────────────── */
.core-app .core-app-body { display: flex; flex: 1; min-height: 0; }

.core-app .core-panel {
  width: var(--core-panel-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--core-bg);
  border-right: 1px solid var(--core-border);
  min-height: 0;
}
.core-app .core-map-wrap { flex: 1; position: relative; min-width: 0; }
.core-app .core-map-canvas { width: 100%; height: 100%; }

.core-app.core-view-list .core-map-wrap { display: none; }
.core-app.core-view-list .core-panel { width: 100%; border-right: none; }
.core-app.core-view-list .core-cards-list { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

/* Card layouts beside the map (split_cards). List view keeps its grid. */
.core-app.core-cards-stack.core-view-split .core-cards-list,
.core-app.core-cards-row.core-view-split .core-cards-list { grid-template-columns: 1fr; }
.core-app.core-cards-row.core-view-split .core-card { flex-direction: row; }
.core-app.core-cards-row.core-view-split .core-card-thumb { width: 42%; aspect-ratio: auto; min-height: 160px; }
.core-app.core-cards-row.core-view-split .core-card-info { flex-shrink: 1; min-width: 0; }
.core-app.core-view-map  .core-panel { display: none; }

/* No Google Maps key saved yet: list only, nothing to switch to. */
.core-app.core-no-map .core-map-wrap,
.core-app.core-no-map .core-seg,
.core-app.core-no-map .core-follow { display: none; }

.core-app .core-panel-meta {
  padding: 9px 14px;
  border-bottom: 1px solid var(--core-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  flex-shrink: 0;
  background: var(--core-surface);
}
.core-app .core-count-label { font-size: 0.8rem; color: var(--core-muted); }
.core-app .core-count-label strong { color: var(--core-text); }
.core-app .core-panel-meta .core-check { height: auto; font-size: 0.76rem; }
.core-app .core-panel-meta .core-sort-pick { height: 30px; font-size: 0.78rem; margin-left: auto; }
.core-app .core-panel-meta .core-count-label { flex: 1 1 auto; }

.core-app .core-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: max-content;   /* rows size to the card, never squeezed to fit the panel */
  gap: 12px;
  align-content: start;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.core-app .core-card {
  display: flex;
  flex-direction: column;
  background: var(--core-surface);
  border: 1px solid var(--core-border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.13s, box-shadow 0.13s, transform 0.13s;
}
.core-app .core-card:hover { border-color: var(--core-border-2); box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
.core-app .core-card.core-is-active { border-color: var(--core-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--core-accent) 25%, transparent); }

.core-app .core-card-thumb { flex-shrink: 0; width: 100%; aspect-ratio: 4/3; position: relative; background: #eceef2; overflow: hidden; }
.core-app .core-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.core-app .core-no-img { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 0.64rem; color: var(--core-faint); text-transform: uppercase; letter-spacing: 0.05em; }

.core-app .core-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: #fff;   /* background comes from statusPill() */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.core-app .core-star { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, 0.92); color: #d97706; border-radius: 999px; padding: 2px 7px; font-size: 0.7rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.core-app .core-card-info { flex-shrink: 0; padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.core-app .core-card-price { font-size: 1rem; font-weight: 700; color: var(--core-text); }
.core-app .core-card-name { font-size: 0.83rem; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.core-app .core-card-type { font-size: 0.72rem; color: var(--core-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.core-app .core-card-addr { font-size: 0.72rem; color: var(--core-muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.core-app .core-card-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.core-app .core-chip { background: var(--core-bg); border: 1px solid var(--core-border); border-radius: 4px; padding: 2px 7px; font-size: 0.67rem; color: var(--core-muted); white-space: nowrap; }
.core-app .core-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--core-border); }
.core-app .core-card-view-link { font-size: 0.72rem; color: var(--core-accent); text-decoration: none; font-weight: 600; }
.core-app .core-card-view-link:hover { text-decoration: underline; }
.core-app .core-card-addr-count { font-size: 0.68rem; color: var(--core-faint); }

/* ── List states ───────────────────────────────────────────────────────────── */
.core-app .core-loader-row, .core-app .core-sentinel, .core-app .core-end-msg, .core-app .core-empty-state { grid-column: 1 / -1; }
.core-app .core-sentinel { height: 1px; }
.core-app .core-end-msg { text-align: center; padding: 12px; font-size: 0.74rem; color: var(--core-faint); }
.core-app .core-empty-state { text-align: center; padding: 56px 20px; color: var(--core-muted); font-size: 0.86rem; }
.core-app .core-empty-state .core-icon { font-size: 2rem; margin-bottom: 10px; }
.core-app .core-empty-state button { margin-top: 12px; }
.core-app .core-error-state { color: #dc2626; }

/* ── Map extras ────────────────────────────────────────────────────────────── */
.core-app .core-map-style-pick {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.core-app .core-popup { padding: 2px 4px 4px; min-width: 210px; max-width: 250px; font-family: inherit; }
.core-app .core-popup img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; margin-bottom: 8px; display: block; }
.core-app .core-popup-price { font-size: 0.95rem; font-weight: 700; color: var(--core-text); margin-bottom: 2px; }
.core-app .core-popup-name { font-size: 0.8rem; font-weight: 600; color: var(--core-text); margin-bottom: 2px; }

/* ── Card Display fields (card_fields="display") ───────────────────────────────
   The heading, line under it and label / value rows chosen in Core Listing
   under Account Settings → Listing Display. Each row also carries
   .core-row-{field}, e.g. .core-row-price, to style one field on its own. */
.core-app .core-card-headline { font-size: 0.95rem; font-weight: 700; -webkit-line-clamp: 2; }
.core-app .core-card-subhead,
.core-app .core-popup-subhead { font-size: 0.72rem; color: var(--core-muted); line-height: 1.35; }
.core-app .core-rows { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.core-app .core-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.74rem; line-height: 1.35; }
.core-app .core-row-label { color: var(--core-muted); white-space: nowrap; }
.core-app .core-row-value { color: var(--core-text); font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.core-app .core-row-nolabel { justify-content: flex-start; }
.core-app .core-row-nolabel .core-row-value { text-align: left; }
.core-app .core-popup .core-rows { margin: 4px 0 8px; }
.core-app .core-popup-name.core-card-headline { font-size: 0.9rem; }
.core-app .core-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.core-app .core-popup-addr { font-size: 0.73rem; color: var(--core-muted); margin-bottom: 8px; line-height: 1.4; }
.core-app .core-popup-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.core-app .core-popup-link { font-size: 0.75rem; font-weight: 600; color: var(--core-accent); text-decoration: none; }
.core-app .core-popup-link:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .core-app .core-cards-list { grid-template-columns: 1fr; }
  .core-app .core-f-group.core-grow { max-width: none; }
}

/* ── width="wide" / width="full" ─────────────────────────────────────────────
   Block themes hold post content to a narrow reading column with !important
   margins, which leaves a map no room beside the list. "wide" uses the
   theme's own wide width; "full" spans the window. --core-sbw is the
   scrollbar width, set by search.js, so 100vw does not cause a sideways
   scroll on systems with classic scrollbars. */
.core-app.core-width-wide {
  max-width: var(--wp--style--global--wide-size, 1280px) !important;
  width: 100%;
  margin-left: auto !important;
  margin-right: auto !important;
}
.core-app.core-width-full {
  --core-vw: calc(100vw - var(--core-sbw, 0px));
  width: var(--core-vw) !important;
  max-width: none !important;
  margin-left: calc(50% - var(--core-vw) / 2) !important;
  margin-right: calc(50% - var(--core-vw) / 2) !important;
}
