/* ==========================================================================
   Maru B2B — public business directory design system
   Loaded only by templates/directory/directory_list.html
             and templates/directory/listing_detail.html
   Brand tokens: dark #0a0909 · Maru red #dc2626 · light bg #f8fafc
                 border #e2e8f0 · green #16a34a · amber #d97706 · blue #2563eb
   Mobile-first: 1-col grid, 2-col @768px, 3-col @1100px. Touch targets >=44px.
   ========================================================================== */

:root {
  --navy: #0a0909;
  --red: #dc2626;
  --red-dark: #b91c1c;
  --red-soft: #fef2f2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-dark: #15803d;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --amber-ink: #92400e;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --blue-ink: #1e40af;
  --muted: #64748b;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --tap: 44px;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--navy);
  background: var(--bg);
}

.dir-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.dir-page h1,
.dir-page h2,
.dir-page h3 { color: var(--navy); letter-spacing: -0.01em; }
.dir-page h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.2; margin: 0; }
.dir-page h2 { font-weight: 700; font-size: clamp(1.25rem, 3vw, 1.6rem); }
.dir-page h3 { font-weight: 600; }
.dir-page a { color: var(--red); }
.dir-page :focus-visible { outline: 3px solid rgba(220, 38, 38, 0.45); outline-offset: 2px; border-radius: 6px; }

.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── List hero ──────────────────────────────────────────────────────────── */
.dir-hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 40px 0 28px;
}
.dir-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--red);
}
.dir-hero p.dir-hero__sub {
  color: var(--muted); margin: 8px 0 0; max-width: 560px; font-size: 1rem;
}

/* Search */
.dir-search { margin-top: 20px; }
.dir-search__row { display: flex; flex-direction: column; gap: 10px; }
.dir-search__field { position: relative; flex: 1 1 auto; }
.dir-search__field .bi {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 1.05rem; pointer-events: none;
}
.dir-search input[type="search"],
.dir-search input[type="text"] {
  width: 100%; min-height: 48px; padding: 12px 16px 12px 46px;
  font-size: 1rem; color: var(--navy); background: var(--bg);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  -webkit-appearance: none; appearance: none;
}
.dir-search input::placeholder { color: var(--muted); }
.dir-search input:focus {
  border-color: var(--red); background: var(--surface); outline: none;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.10);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.dir-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  font-size: 0.95rem; font-weight: 600; line-height: 1.2;
  text-decoration: none; border: 1.5px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.dir-btn--primary { background: var(--red); color: #fff; }
.dir-btn--primary:hover { background: var(--red-dark); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.dir-btn--ghost { background: var(--surface); color: var(--navy); border-color: var(--border); }
.dir-btn--ghost:hover { border-color: var(--navy); color: var(--navy); }
.dir-btn--wa { background: var(--green); color: #fff; }
.dir-btn--wa:hover { background: var(--green-dark); color: #fff; transform: translateY(-1px); }
.dir-btn--site { background: var(--navy); color: #fff; }
.dir-btn--site:hover { background: #1a1a2e; color: #fff; }
.dir-btn--block { width: 100%; }

/* ── Filter pills ───────────────────────────────────────────────────────── */
.dir-filters { padding: 20px 0 8px; }
.pill-row {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  min-height: var(--tap); padding: 10px 16px;
  font-size: 0.875rem; font-weight: 600; text-decoration: none;
  color: var(--navy); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-pill);
  white-space: nowrap; transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.pill:hover { border-color: var(--red); color: var(--red); }
.pill.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill--clear { color: var(--red); border-color: rgba(220, 38, 38, 0.35); background: var(--red-soft); }

.dir-toolbar {
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 0 16px; border-bottom: 1px solid var(--border);
}
.dir-toolbar__count { font-size: 0.9rem; color: var(--muted); }
.dir-toolbar__count strong { color: var(--navy); font-weight: 700; }
.dir-toolbar select {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  font-size: 0.9rem; font-family: inherit; color: var(--navy); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.dir-toolbar select:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.10); }

/* ── Listing grid + cards ───────────────────────────────────────────────── */
.dir-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
  padding: 20px 0 56px; align-items: stretch;
}

.dir-card {
  position: relative; display: flex; flex-direction: column; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.dir-card:hover { transform: translateY(-3px); border-color: #cbd5e1; box-shadow: var(--shadow-md); }
.dir-card__link { text-decoration: none; color: inherit; display: block; height: 100%; }

.dir-card__head { display: flex; gap: 16px; align-items: flex-start; }

.dir-logo {
  width: 88px; height: 88px; flex: 0 0 88px;
  object-fit: contain; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px;
}
.dir-avatar {
  width: 88px; height: 88px; flex: 0 0 88px;
  display: grid; place-items: center;
  font-size: 1.75rem; font-weight: 800; letter-spacing: 0.02em;
  border-radius: var(--radius-sm); background: var(--bg); color: var(--navy);
}
/* Category-tinted initials avatar fallback */
.av-construction { background: #fef3c7; color: #92400e; }
.av-manufacturing { background: #ffe4e6; color: #9f1239; }
.av-retail { background: #e0f2fe; color: #075985; }
.av-logistics { background: #ede9fe; color: #5b21b6; }
.av-tech { background: #dbeafe; color: #1e40af; }
.av-healthcare { background: #dcfce7; color: #166534; }
.av-education { background: #fef9c3; color: #854d0e; }
.av-hospitality { background: #ffedd5; color: #9a3412; }
.av-agriculture { background: #d1fae5; color: #065f46; }
.av-finance { background: #e2e8f0; color: #334155; }
.av-professional { background: #f1f5f9; color: #334155; }
.av-other { background: #f1f5f9; color: #475569; }

.dir-card__info { flex: 1 1 auto; min-width: 0; }
.dir-name {
  margin: 0;
  font-size: 1.0625rem; font-weight: 600; line-height: 1.35; color: var(--navy);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dir-loc { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: 0.875rem; color: var(--muted); }

.dir-cat {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 5px 12px; font-size: 0.75rem; font-weight: 600;
  color: var(--navy); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
}

.dir-desc {
  margin: 16px 0 0; font-size: 0.9375rem; color: var(--muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* Tier badges — in-flow below the head row; Featured = amber, Verified = blue */
.tier-badge {
  position: static;
  align-self: flex-start;
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px; font-size: 0.6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: var(--radius-pill); white-space: nowrap;
  z-index: 1;
}
.tier-featured { background: var(--amber-soft); color: var(--amber-ink); border: 1px solid rgba(217, 119, 6, 0.35); }
.tier-verified { background: var(--blue-soft); color: var(--blue-ink); border: 1px solid rgba(37, 99, 235, 0.35); }
.tier-free { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

.dir-card__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 0.8125rem; color: #475569;
}
.dir-card__view {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 4px 0;
  font-size: 0.9375rem; font-weight: 700; color: var(--red); text-decoration: none;
}
.dir-card__view:hover { color: var(--red-dark); text-decoration: underline; }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 64px 20px 72px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  margin: 24px 0 56px;
}
.empty-state .bi { font-size: 2.75rem; color: var(--muted); opacity: 0.5; }
.empty-state h2 { margin: 16px 0 8px; font-size: clamp(1.2rem, 4vw, 1.5rem); font-weight: 700; }
.empty-state p { color: var(--muted); max-width: 420px; margin: 0 auto 20px; }
.empty-state__actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ── Detail hero (navy band) ────────────────────────────────────────────── */
.detail-hero { background: var(--navy); color: #fff; padding: 24px 0 32px; }
.detail-hero .back-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap);
  color: rgba(255, 255, 255, 0.75); font-size: 0.875rem; font-weight: 600; text-decoration: none;
}
.detail-hero .back-link:hover { color: #fff; text-decoration: underline; }
.detail-hero__row { display: flex; flex-direction: column; gap: 20px; margin-top: 8px; }
.detail-hero__logo-card {
  width: 112px; height: 112px; flex: 0 0 112px; padding: 8px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.detail-hero__logo-card img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; background: #fff; }
.detail-hero__logo-card .dir-avatar { width: 100%; height: 100%; flex: none; font-size: 2.25rem; }
.detail-hero h1 { color: #fff; }
.detail-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verified-tick {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 0.9rem; flex: 0 0 auto;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 0.8125rem; font-weight: 600;
  color: #e2e8f0; background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: var(--radius-pill);
}
.detail-hero .tier-badge { position: static; margin-top: 14px; }
.tier-badge--onDark { background: #fff; color: var(--navy); border: 1px solid rgba(255, 255, 255, 0.4); }

/* ── Detail layout ──────────────────────────────────────────────────────── */
.detail-body { padding: 24px 0 64px; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.detail-main, .detail-aside { display: flex; flex-direction: column; gap: 20px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.panel__title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 14px;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.panel__title .count {
  background: var(--red); color: #fff; font-size: 0.6875rem;
  padding: 2px 8px; border-radius: var(--radius-pill); letter-spacing: 0;
}
.about-text { margin: 0; color: #334155; font-size: 1rem; line-height: 1.75; white-space: pre-line; }

/* Services: 2-col grid from 768px */
.svc-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; padding: 0; list-style: none; }
.svc-item {
  display: flex; align-items: flex-start; gap: 10px;
  min-height: var(--tap); padding: 12px 14px;
  font-size: 0.9375rem; color: var(--navy); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.svc-item .bi { color: var(--green); margin-top: 2px; }

/* Detail info list */
.info-list { display: grid; grid-template-columns: 1fr; gap: 14px; margin: 0; }
.info-list dt { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.info-list dd { margin: 2px 0 0; font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.hours { white-space: pre-line; margin: 0; color: var(--navy); font-size: 0.9375rem; }

/* ── Contact buttons ────────────────────────────────────────────────────── */
.contact-actions { display: flex; flex-direction: column; gap: 10px; }
.contact-rows { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.contact-row {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap);
  font-size: 0.9375rem; color: var(--navy); text-decoration: none;
}
.contact-row .bi { width: 20px; text-align: center; color: var(--red); }
.contact-row span, .contact-row a { color: var(--navy); text-decoration: none; overflow-wrap: anywhere; }
.contact-row a:hover { color: var(--red); text-decoration: underline; }

/* ── Stats + reviews ────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; text-align: center; }
.stat__num { display: block; font-size: 1.125rem; font-weight: 700; color: var(--navy); }
.stat__lbl { display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.reviews-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.reviews-summary .rating-num { font-size: 1.75rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stars { display: inline-flex; gap: 2px; color: var(--amber); font-size: 0.9rem; }
.stars .bi-star { color: var(--border); }
.review-item { padding: 16px 0; border-top: 1px solid var(--border); }
.review-item:first-of-type { border-top: none; padding-top: 0; }
.review-item__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.review-item__name { font-weight: 600; font-size: 0.9375rem; color: var(--navy); }
.review-item__date { font-size: 0.75rem; color: var(--muted); }
.review-item p { margin: 8px 0 0; color: #475569; font-size: 0.9375rem; }

/* ── Responsive: 2-col @768px, 3-col @1100px ────────────────────────────── */
@media (min-width: 768px) {
  .dir-hero { padding: 56px 0 36px; }
  .dir-search__row { flex-direction: row; align-items: stretch; }
  .dir-search__row .dir-btn { flex: 0 0 auto; }
  .dir-toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .dir-toolbar select { width: 260px; }
  .dir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .info-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .empty-state__actions { flex-direction: row; justify-content: center; }
  .detail-hero__row { flex-direction: row; align-items: center; gap: 24px; }
}

@media (min-width: 1100px) {
  .dir-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
  .detail-aside { position: sticky; top: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  .dir-card, .dir-btn, .pill { transition: none; }
  .dir-card:hover { transform: none; }
}

/* ── Contact button color fix: beat the global .dir-page a { color: var(--red) } ── */
.dir-page .dir-btn--primary, .dir-page .dir-btn--wa, .dir-page .dir-btn--site { color: #fff; }
.dir-page .dir-btn--ghost { color: var(--navy); }
.dir-page .dir-btn--ghost:hover { color: var(--navy); }
