/* Business Directory view (Phase C of the directory redesign, 2026-10-10). Colour tokens come from map.css's
   :root, like calendar.css. Scoped to html[data-view="directory"] where it touches html/body, for the same reason
   as calendar.css: the map needs a fixed, non-scrolling viewport, this view is ordinary scrolling content. */
html[data-view="directory"], html[data-view="directory"] body {
  margin: 0; min-height: 100%; height: auto;
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg-dark); color: var(--text-light);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
html.dir-detail-open, html.dir-detail-open body { overflow: hidden; }
/* Same corner as the calendar: no map sidebar or announcement bubble to dodge here. */
html[data-view="directory"] #cehub-sponsor-bubble { right: 18px; bottom: 18px; top: auto; left: auto; }

#dir-app { min-height: 100vh; display: flex; flex-direction: column; }
#dir-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; padding-top: 64px; /* clears the fixed view toggle, same number as #cal-header */
  border-bottom: 1px solid var(--border);
}
#dir-logo { height: 34px; width: auto; }
#dir-heading { font-size: 18px; margin: 0; }
#dir-subheading { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
#dir-body { flex: 1; padding: 18px 20px 90px; }
.dir-loading { color: var(--text-muted); font-size: 14px; }

/* ---- Locked panel (free sample) ---- */
.dir-locked {
  max-width: 520px; margin: 40px auto; padding: 36px 28px; text-align: center;
  border: 1px solid var(--border); border-radius: 18px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(241, 174, 41, 0.14), transparent 60%), var(--bg-dark-2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.dir-locked-icon {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px;
  background: rgba(241, 174, 41, 0.16); border: 1px solid rgba(241, 174, 41, 0.45);
}
.dir-locked h2 { margin: 0 0 10px; font-size: 22px; }
.dir-locked p { margin: 0 0 22px; color: var(--text-muted); line-height: 1.55; font-size: 15px; }
.dir-locked-btn {
  display: inline-block; padding: 12px 26px; border-radius: 999px;
  background: var(--accent); color: #1a1a2e; font-weight: 700; text-decoration: none; font-size: 15px;
  box-shadow: 0 6px 18px rgba(241, 174, 41, 0.35);
}
.dir-locked-btn:hover { filter: brightness(1.07); }

/* ---- Controls ---- */
.dir-layout { max-width: 1240px; margin: 0 auto; }
.dir-controls {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-dark-2);
}
.dir-search-row { display: flex; align-items: center; gap: 12px; }
.dir-search {
  flex: 1; min-width: 0; padding: 11px 14px 11px 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-dark) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a9a6c0' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center;
  color: var(--text-light); font-size: 15px; font-family: inherit;
}
.dir-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(241, 174, 41, 0.18); }
.dir-count { color: var(--text-muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dir-filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.dir-control-label { display: block; font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; letter-spacing: 0.02em; }
.dir-seg-btns { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--bg-dark); border: 1px solid var(--border); }
.dir-seg-btn {
  border: none; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.dir-seg-btn.is-active { background: var(--accent); color: #1a1a2e; }
.dir-seg-btn:not(.is-active):hover { color: var(--text-light); }
.dir-select { display: flex; flex-direction: column; min-width: 190px; flex: 1 1 190px; max-width: 320px; }
.dir-select select {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-dark);
  color: var(--text-light); font: inherit; font-size: 14px;
}
.dir-tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dir-tag {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px;
  background: #34345a; color: var(--text-light); border: 1px solid transparent; white-space: nowrap;
}
.dir-tag.has-color { background: var(--tag-bg); color: var(--tag-fg); }
button.dir-tag { cursor: pointer; font-family: inherit; background: transparent; border-color: var(--border); color: var(--text-muted); }
button.dir-tag:hover { border-color: var(--accent); color: var(--text-light); }
button.dir-tag.is-active { background: var(--accent); border-color: var(--accent); color: #1a1a2e; }
.dir-tag-count { font-size: 10.5px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.dir-tag-more { background: transparent; border-color: var(--border); color: var(--text-muted); }
.dir-more { border: none; background: none; color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 3px 6px; }

/* ---- Results ---- */
.dir-results { margin-top: 18px; }
.dir-active-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--text-muted); font-size: 13px; }
.dir-clear { border: 1px solid var(--border); background: transparent; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.dir-clear:hover { border-color: var(--accent); }
.dir-empty { text-align: center; padding: 50px 10px; color: var(--text-muted); }
.dir-group { margin-top: 22px; }
.dir-group-title {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 16px;
  position: sticky; top: 0; z-index: 2; padding: 8px 0; background: var(--bg-dark);
}
.dir-group-count {
  font-size: 11.5px; font-weight: 700; color: #1a1a2e; background: var(--accent);
  padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.dir-card {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg-dark-2);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.dir-card:hover { border-color: rgba(241, 174, 41, 0.7); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25); }
.dir-card-open { all: unset; display: flex; flex-direction: column; gap: 5px; cursor: pointer; }
.dir-card-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.dir-card-title { margin: 0; font-size: 15.5px; line-height: 1.3; }
.dir-card-meta { margin: 0; font-size: 12px; color: var(--accent); font-weight: 600; }
.dir-card-meta:empty { display: none; }
.dir-card-inside { margin: 0 0 2px; font-size: 12px; font-weight: 600; color: var(--accent); }
.dir-card-address { margin: 0; font-size: 12.5px; color: var(--text-light); opacity: 0.9; }
.dir-card-summary {
  margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.dir-card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.dir-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.dir-act {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text-light);
  font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.dir-act:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Detail window ---- */
.dir-detail-overlay {
  position: fixed; inset: 0; z-index: 6000; display: grid; place-items: center; padding: 20px;
  background: rgba(8, 8, 20, 0.66); backdrop-filter: blur(3px);
}
.dir-detail-overlay.hidden { display: none; }
.dir-detail {
  position: relative; width: min(600px, 100%); max-height: min(86vh, 900px); overflow-y: auto;
  padding: 22px; border-radius: 16px; background: var(--bg-dark-2); border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.dir-detail-close {
  position: sticky; float: right; top: 0; z-index: 1; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-dark); color: var(--text-light); cursor: pointer; font-size: 15px;
}
.dir-detail-image { display: block; width: 100%; max-height: 280px; object-fit: cover; border-radius: 12px; margin: 0 0 14px; }
.dir-detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.dir-badge {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: rgba(241, 174, 41, 0.15); color: var(--accent); border: 1px solid rgba(241, 174, 41, 0.4);
}
.dir-badge.is-hood { background: transparent; color: var(--text-muted); border-color: var(--border); }
.dir-detail-title { margin: 10px 0 10px; font-size: 21px; line-height: 1.25; }
.dir-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 16px 0; font-size: 14px; }
.dir-info dt { color: var(--text-muted); font-size: 12.5px; padding-top: 1px; }
.dir-info dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.dir-info a { color: var(--accent); }
.dir-detail-desc { font-size: 14px; line-height: 1.6; color: var(--text-light); }
.dir-detail-desc a { color: var(--accent); }
.dir-detail-desc img { max-width: 100%; border-radius: 8px; }
.dir-detail-desc table { border-collapse: collapse; font-size: 13px; }
.dir-detail-desc td, .dir-detail-desc th { border: 1px solid var(--border); padding: 4px 8px; }
.dir-detail-map-btn {
  margin-top: 16px; width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--accent); color: #1a1a2e; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}

@media (max-width: 767px) {
  /* The toggle sits at top:58px on mobile (map.css), so the header clears 108px -- same as #cal-header. */
  #dir-header { padding: 14px 16px; padding-top: 108px; }
  #dir-heading { font-size: 16px; }
  #dir-body { padding: 14px 16px 90px; }
  html[data-view="directory"] #cehub-sponsor-bubble { right: 14px; bottom: 14px; }
  .dir-controls { padding: 12px; }
  .dir-filter-row { flex-direction: column; align-items: stretch; }
  .dir-seg-btns { display: flex; }
  .dir-seg-btn { flex: 1; }
  .dir-select { max-width: none; min-width: 0; flex: 1 1 auto; }
  .dir-grid { grid-template-columns: 1fr; }
  .dir-detail-overlay { padding: 0; align-items: end; }
  .dir-detail { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .dir-locked { margin: 16px 0; padding: 28px 20px; }
}

/* ---- Launch veil: "coming soon" countdown for subscribers (2026-10-11) ---- */
.dir-veil {
  max-width: 640px; margin: 36px auto; padding: 38px 28px 30px; text-align: center;
  border: 1px solid rgba(241, 174, 41, 0.35); border-radius: 20px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(241, 174, 41, 0.18), transparent 62%), var(--bg-dark-2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.dir-veil-badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px; margin-bottom: 14px;
  background: rgba(241, 174, 41, 0.15); border: 1px solid rgba(241, 174, 41, 0.5); color: var(--accent);
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.dir-veil h2 { margin: 0 0 10px; font-size: 25px; line-height: 1.25; text-wrap: balance; }
.dir-veil-msg { text-wrap: balance; margin: 0 auto 22px; max-width: 480px; color: var(--text-muted); line-height: 1.55; font-size: 15px; }
.dir-veil-clock { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 460px; margin: 0 auto 18px; }
.dir-veil-unit {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px 10px; border-radius: 14px;
  background: var(--bg-dark); border: 1px solid var(--border);
}
.dir-veil-num { font-size: 38px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.dir-veil-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.dir-veil-date { margin: 0 0 6px; font-weight: 600; color: var(--text-light); }
.dir-veil-note { margin: 0; font-size: 13px; color: var(--text-muted); }
.dir-veil .dir-locked-btn { margin: 14px 0 12px; }
.dir-preview-banner {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px;
  background: rgba(241, 174, 41, 0.12); border: 1px dashed rgba(241, 174, 41, 0.6); color: #ffd38a;
}
@media (max-width: 767px) {
  .dir-veil { margin: 14px 0; padding: 28px 16px 22px; }
  .dir-veil h2 { font-size: 21px; }
  .dir-veil-clock { gap: 6px; }
  .dir-veil-num { font-size: 28px; }
  .dir-veil-label { font-size: 9.5px; }
}
