/* ============================================================
   Town directory — local styles, built on Vina foundations.
   Toned-down "town foreground, Vina background" treatment.
   One responsive layout (desktop sidebar-free list + map),
   collapsing to the mobile treatment below the md breakpoint.
   ============================================================ */

.td {
  background: var(--bg-page);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  box-sizing: border-box;
  width: 100%;
}
.td *, .td *::before, .td *::after { box-sizing: border-box; }

/* Centered page column */
.td-inner { max-width: var(--container-max); margin: 0 auto; }

.td-wrap { padding: 0 var(--sp-8); }
.td-wrap-mobile { padding: 0 var(--sp-5); }

/* Quiet links inside the directory */
.td a { color: inherit; text-decoration: none; }
.td a:hover { color: var(--brand-hover); }

/* ---------- Masthead (town foreground) ---------- */
.td-masthead { padding: var(--sp-10) var(--sp-8) var(--sp-6); }
.td-town {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--fg-strong);
  margin: 0;
}
.td-tagline {
  font-size: var(--fs-18); color: var(--fg-secondary);
  margin: 8px 0 0; line-height: 1.5; max-width: 640px;
}
.td-accent-rule {
  width: 56px; height: 3px; background: var(--brand);
  border-radius: 2px; margin-bottom: var(--sp-5);
}
.td-count-line {
  font-size: var(--fs-14); color: var(--fg-muted);
  margin-top: var(--sp-4); display: flex; align-items: center; gap: 8px;
}
.td-count-line strong { color: var(--fg-strong); font-weight: 600; }

/* ---------- Search + controls ---------- */
.td-controlbar { display: flex; gap: 10px; margin-bottom: var(--sp-4); }
.td-search {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 11px 14px;
  flex: 1; min-width: 0;
}
.td-search:focus-within { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.td-search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: var(--fs-16); color: var(--fg-primary);
}
.td-search input::placeholder { color: var(--fg-muted); }

.td-controls { display: flex; gap: 10px; align-items: center; }

.td-toggle {
  display: inline-flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 11px 15px;
  font-size: var(--fs-14); font-weight: 600; color: var(--fg-strong);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.td-toggle .sw {
  width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background var(--dur-fast); flex-shrink: 0;
}
.td-toggle .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  transition: transform var(--dur-fast);
}
.td-toggle.on { border-color: var(--brand-soft); color: var(--brand-press); }
.td-toggle.on .sw { background: var(--accent-green); }
.td-toggle.on .sw::after { transform: translateX(14px); }

.td-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-14); font-weight: 600;
  border-radius: var(--r-sm); padding: 11px 15px; cursor: pointer;
  border: 1px solid var(--border-strong); background: #fff; color: var(--fg-strong);
  white-space: nowrap;
}
.td-btn:hover { background: var(--bg-tint-blue); }
.td-btn.on { border-color: var(--brand-soft); color: var(--brand-press); background: var(--bg-tint-blue); }
.td-btn .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--brand); color: var(--fg-on-blue); font-size: 11px; font-weight: 700;
}

/* Category chips */
.td-chiprow {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5);
}
.td-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.td-chips-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.td-chip {
  font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  background: var(--vina-blue-050); color: var(--fg-strong);
  border: 1px solid transparent; border-radius: var(--r-pill);
  padding: 6px 12px; white-space: nowrap; user-select: none;
}
.td-chip.on { background: var(--brand); color: var(--fg-on-blue); }

/* Segmented control (List / Map) */
.td-seg {
  display: inline-flex; background: var(--bg-sunken); border-radius: var(--r-sm);
  padding: 3px; gap: 2px; flex-shrink: 0;
}
.td-seg button {
  font: inherit; font-size: var(--fs-14); font-weight: 600;
  border: 0; background: transparent; color: var(--fg-secondary);
  padding: 7px 16px; border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.td-seg button.on { background: #fff; color: var(--fg-strong); box-shadow: var(--shadow-1); }

/* Sort select */
.td-select {
  font: inherit; font-size: var(--fs-14); font-weight: 500; color: var(--fg-strong);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 9px 12px; background: #fff; cursor: pointer; flex-shrink: 0;
}

/* ---------- Advanced filters (collapsed behind "Filters") ---------- */
.td-advanced {
  border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  background: var(--bg-surface); padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.td-advanced[hidden] { display: none; }
.td-advanced h5 {
  font-size: var(--fs-12); letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase; color: var(--fg-muted); font-weight: 600;
  margin: 0 0 var(--sp-3);
}
.td-daygrid { display: flex; flex-wrap: wrap; gap: 8px; }
.td-day input { position: absolute; opacity: 0; pointer-events: none; }
.td-day label {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; padding: 8px 12px; cursor: pointer;
  font-size: var(--fs-14); font-weight: 600; color: var(--fg-strong);
  background: var(--vina-blue-050); border: 1px solid transparent;
  border-radius: var(--r-pill); white-space: nowrap; user-select: none;
}
.td-day input:checked + label { background: var(--brand); color: var(--fg-on-blue); }
.td-day input:focus-visible + label { box-shadow: var(--shadow-focus); }
.td-advanced-foot { margin-top: var(--sp-4); display: flex; justify-content: flex-end; }
.td-link-btn {
  font: inherit; font-size: var(--fs-14); font-weight: 600; cursor: pointer;
  border: 0; background: transparent; color: var(--brand); padding: 4px 2px;
}
.td-link-btn:hover { color: var(--brand-hover); text-decoration: underline; }

/* ---------- Toolbar ---------- */
.td-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) 0 var(--sp-4); gap: var(--sp-4);
}
.td-resultcount { font-size: var(--fs-14); color: var(--fg-secondary); }
.td-resultcount strong { color: var(--fg-strong); font-weight: 600; }

/* ---------- Listing row ---------- */
.td-list { display: flex; flex-direction: column; }
.td-empty {
  padding: var(--sp-10) var(--sp-4); text-align: center;
  color: var(--fg-secondary); font-size: var(--fs-16);
}
.td-row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-2);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer; transition: background var(--dur-fast);
  color: inherit;
}
.td-row:hover { background: var(--bg-tint-blue); }
.td-row:last-child { border-bottom: 0; }
.td-avatar {
  width: 44px; height: 44px; border-radius: 9px; flex-shrink: 0;
  background: var(--vina-blue-100); color: var(--fg-strong);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; overflow: hidden;
}
.td-avatar img { width: 100%; height: 100%; object-fit: cover; }
.td-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.td-name {
  font-size: var(--fs-18); font-weight: 600; color: var(--fg-strong);
  margin: 0 0 3px;
}
.td-meta { font-size: var(--fs-14); color: var(--fg-secondary); }
.td-meta .cat { color: var(--fg-strong); font-weight: 500; }
.td-row-end { display: flex; align-items: center; gap: var(--sp-4); flex-shrink: 0; }
.td-chev { color: var(--fg-muted); display: flex; }

/* status pill */
.td-status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-14); white-space: nowrap; }
.td-status .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.td-status.open { color: var(--vina-green-ink); font-weight: 600; }
.td-status.open .dot { background: var(--accent-green); }
.td-status.closed { color: var(--fg-muted); }
.td-status.closed .dot { background: var(--vina-stone-300); }
/* Unknown — no hours data on file; quiet, no signal dot */
.td-status.unknown { color: var(--fg-muted); font-style: italic; }
.td-status.unknown .dot { display: none; }

/* status shown beneath the name — mobile only */
.td-status-mobile { display: none; margin-top: 5px; }

/* ---------- Map view ---------- */
.td-mapsplit { display: grid; grid-template-columns: 360px 1fr; gap: var(--sp-5); }
.td-rail { display: flex; flex-direction: column; }
.td-rail-head {
  font-size: var(--fs-14); color: var(--fg-secondary);
  padding: 0 var(--sp-2) var(--sp-3); display: flex; align-items: center; justify-content: space-between;
}
.td-rail-head strong { color: var(--fg-strong); font-weight: 600; }
.td-rail-list { display: flex; flex-direction: column; overflow: auto; max-height: 560px; }
.td-rail-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px var(--sp-2); border-bottom: 1px solid var(--border-subtle); cursor: pointer;
  color: inherit;
}
.td-rail-row:hover { background: var(--bg-tint-blue); }
.td-rail-row.on { background: var(--vina-blue-050); }
.td-rail-pin {
  width: 26px; height: 26px; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
}
.td-rail-body { display: flex; flex-direction: column; min-width: 0; }
.td-rail-row .nm { font-size: var(--fs-16); font-weight: 600; color: var(--fg-strong); margin: 0 0 2px; }
.td-rail-row .ad { font-size: var(--fs-12); color: var(--fg-secondary); }
.td-rail-row .st { margin-top: 5px; }

/* map surface — wraps the [community_map] shortcode */
.td-map {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border-strong); background: #eef0e8;
  min-height: 520px;
}
.td-map > * { width: 100%; }
.td-map iframe, .td-map .leaflet-container, .td-map .map { min-height: 520px; width: 100%; }

/* The [community_map] shortcode renders its own search/category controls and
   its own business list alongside the Leaflet map. The page's control bar and
   the .td-rail already provide both, so hide the shortcode's duplicates and
   keep only the map itself. */
.td-map .community-map-controls,
.td-map .business-list { display: none !important; }

/* ---------- Mobile treatment (single responsive markup) ---------- */
@media (max-width: 767.98px) {
  /* #2 trim the chrome: smaller masthead, drop the tagline here */
  .td-masthead { padding: var(--sp-5) var(--sp-5) var(--sp-4); }
  .td-town { font-size: 26px; }
  .td-tagline { display: none; }
  .td-wrap { padding: 0 var(--sp-5); }

  /* search drops to its own full-width row; controls beneath */
  .td-controlbar { flex-wrap: wrap; }
  .td-search { flex-basis: 100%; }
  .td-controls { width: 100%; justify-content: space-between; }

  /* chips scroll horizontally, sort tucks under */
  .td-chiprow { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
  .td-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .td-select { align-self: flex-start; }

  /* tighten the result count line */
  .td-resultcount { padding: 0 var(--sp-1) var(--sp-2) !important; }

  /* rows: smaller avatar, status under the name */
  .td-avatar { width: 40px; height: 40px; font-size: 15px; }
  .td-name { font-size: var(--fs-16); }
  .td-meta { font-size: var(--fs-12); }
  .td-row-end .td-status { display: none; }
  .td-status-mobile { display: inline-flex; }

  /* #1 map-first: in Map view the map leads, results list sits below it */
  .td-mapsplit { display: flex; flex-direction: column; }
  .td-map { order: -1; min-height: 56vh; }
  .td-rail-head { padding-top: var(--sp-3); }
  .td-rail-list { max-height: none; }
}
