/*
 * Halal landscape: ONLY what DataHub's components/dashboard.css does not already provide.
 *
 * Stat cards, sections, chart cards + chart stats, dt-table + pagination, catalogue search + pill tabs, dashboard
 * tabs, section tabs, barmeters, dropdowns and skeletons all come from dashboard.css unchanged. This file adds the
 * halal-only pieces (results table, facets, tile map, overlap matrix, drawer) and a few narrow overrides.
 *
 * Every selector starts with #halal-app (or is body.halal-drawer-open), so on DataHub nothing leaks into the shell
 * or other pages; jakim/datahub_bundle.py refuses to build otherwise. Uploaded unchanged as halal_landscape.css.
 */
#halal-app { color: #111827; font-family: "Inter", sans-serif; }
body.halal-drawer-open { overflow: hidden; }

#halal-app :is(.section-subtitle, .section-summary, .about-list, .dr-grid, .chart-note) a { color: #2563eb; }
#halal-app :is(.section-subtitle, .section-summary, .about-list, .dr-grid, .chart-note) a:hover { text-decoration: underline; }
#halal-app code { font-size: 0.8em; background: #f3f4f6; padding: 1px 5px; border-radius: 0.25rem; }
#halal-app kbd { font: 600 0.75rem "Inter", sans-serif; border: 1px solid #d1d5db; border-bottom-width: 2px; border-radius: 0.25rem; padding: 0 5px; background: #fff; color: #4b5563; }
#halal-app mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }
#halal-app .muted { color: #6b7280; }

/* ---- page frame */
#halal-app .halal-main { padding-top: 1.5rem; padding-bottom: 3rem; }
#halal-app a.tab-item { text-decoration: none; display: block; }
#halal-app .section, #halal-app .stats-section { scroll-margin-top: 64px; }
#halal-app .halal-engine { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: #6b7280; min-height: 1rem; }
#halal-app .halal-engine .dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; flex: none; animation: halal-pulse 1.2s infinite; }
#halal-app .halal-engine .dot.ok { background: #22c55e; }
#halal-app .halal-engine.ready .dot { animation: none; }
#halal-app .halal-engine .dot.err { background: #dc2626; animation: none; }
@keyframes halal-pulse { 50% { opacity: 0.35; } }

/* ---- narrative + layout additions */
#halal-app .section-summary { font-size: 0.9375rem; line-height: 1.6; color: #374151; margin: 0 0 2rem; max-width: 90ch; }
#halal-app .section-summary b { color: #111827; font-weight: 600; }
#halal-app .chart-note { font-size: 0.75rem; color: #6b7280; margin: 0.75rem 0 0; }
@media (min-width: 1024px) { #halal-app .chart-grid-pair.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }

/* ---- directory */
#halal-app .examples { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; font-size: 0.875rem; color: #6b7280; margin: 0.75rem 0 1.25rem; }
#halal-app .examples button { border: 1px solid #e5e7eb; background: #fff; border-radius: 9999px; padding: 0.125rem 0.625rem; font-size: 0.8125rem; color: #374151; cursor: pointer; }
#halal-app .examples button:hover { background: #f8fafc; border-color: #d1d5db; }
#halal-app .dir-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
#halal-app .dir-bar .catalogue-tabs { padding-bottom: 0; }
#halal-app .catalogue-tab .count { font-size: 0.75rem; opacity: 0.75; font-variant-numeric: tabular-nums; margin-left: 0.25rem; }
#halal-app .filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
#halal-app .dir-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
#halal-app .results-panel { min-width: 0; border: 1px solid #e5e7eb; border-radius: 0.75rem; overflow: hidden; }
#halal-app .results-info { padding: 0.75rem 1rem; border-bottom: 1px solid #e5e7eb; font-size: 0.875rem; color: #6b7280; display: flex; gap: 0.5rem; align-items: center; min-height: 2.875rem; }
#halal-app .results-info b { color: #111827; font-weight: 600; }
#halal-app .timing { margin-left: auto; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
#halal-app .timing b { color: #2563eb; font-weight: 600; }
#halal-app .results-panel .dt-pagination { margin: 0; padding: 0.75rem 1rem; border-top: 1px solid #e5e7eb; color: #4b5563; font-variant-numeric: tabular-nums; }
#halal-app .results-panel .dt-pagination:empty { display: none; }

/* dt-table is centred and fit-to-content in dashboard.css; these tables fill their panel and wrap long names */
#halal-app .dt-table.full { width: 100%; white-space: normal; margin: 0; }
#halal-app .dt-table.full th { cursor: default; white-space: nowrap; }
#halal-app .dt-table.full th:hover { background: none; }
#halal-app .dt-table.full td { vertical-align: middle; }
#halal-app .results-table tbody tr { cursor: pointer; }
#halal-app .results-table tbody tr:hover, #halal-app .results-table tbody tr.active { background: #f3f4f6; }
#halal-app .results-table td.name { font-weight: 500; min-width: 260px; }
#halal-app .results-table td.name small { font-weight: 400; color: #6b7280; font-size: 0.8125rem; margin-top: 0.125rem;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
#halal-app .results-table td.dim { color: #4b5563; }
#halal-app .dt-table td.nowrap { white-space: nowrap; }
#halal-app .results-table td.empty { padding: 3rem 1.5rem; text-align: center; color: #6b7280; cursor: default; white-space: normal; }
#halal-app .results-table tbody tr:has(td.empty) { cursor: default; background: #fff; }

/* chips (palette colour at 10%, as PALETTE.*_H) and status badges */
#halal-app .chip { display: inline-block; font-size: 0.75rem; font-weight: 500; padding: 0.0625rem 0.5rem; border-radius: 9999px; color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); white-space: nowrap; margin-right: 0.25rem; }
#halal-app .badge { display: inline-block; font-size: 0.75rem; font-weight: 500; padding: 0.125rem 0.5rem; border-radius: 0.375rem; white-space: nowrap; }
#halal-app .badge.ok { color: #15803d; background: #f0fdf4; }
#halal-app .badge.warn { color: #b45309; background: #fffbeb; }
#halal-app .badge.bad { color: #b91c1c; background: #fef2f2; }
#halal-app .badge.muted { color: #4b5563; background: #f3f4f6; }
#halal-app .pill { display: inline-block; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; padding: 0.125rem 0.625rem; background: #f3f4f6; color: #374151; }
#halal-app .pill.added { color: #15803d; background: #f0fdf4; }
#halal-app .pill.removed { color: #b91c1c; background: #fef2f2; }
#halal-app .pill.renewed, #halal-app .pill.modified { color: #1e40af; background: #dbeafe; }

/* facets: dashboard.css barmeters, made clickable */
#halal-app .facets { display: flex; flex-direction: column; gap: 2rem; min-width: 0; }
#halal-app .facet h4 { margin: 0 0 0.75rem; font-size: 0.875rem; font-weight: 500; color: #6b7280; text-transform: uppercase; }
#halal-app button.barmeter-item { border: 0; background: none; padding: 0; text-align: left; width: 100%; cursor: pointer; font: inherit; color: inherit; }
#halal-app button.barmeter-item:hover .barmeter-label { color: #2563eb; }
#halal-app .barmeter-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#halal-app .barmeter-sub { font-size: 0.75rem; color: #6b7280; }
#halal-app .barmeter-item.on .barmeter-fill { background-color: #2563eb; }
#halal-app .barmeter-item.on .barmeter-label { color: #2563eb; font-weight: 600; }
#halal-app .facets .barmeter-track { height: 0.5rem; }
#halal-app .toplist { margin: 0; padding: 0; list-style: none; font-size: 0.875rem; }
#halal-app .toplist li { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid #e5e7eb; cursor: pointer; }
#halal-app .toplist li:hover span { color: #2563eb; }
#halal-app .toplist span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#halal-app .toplist b { font-weight: 500; color: #6b7280; font-variant-numeric: tabular-nums; }
#halal-app .sugs { display: flex; flex-wrap: wrap; gap: 0.375rem; }
#halal-app .sugs button { border: 1px solid #e5e7eb; background: #fff; border-radius: 9999px; padding: 0.125rem 0.625rem; font-size: 0.8125rem; cursor: pointer; }
#halal-app .sugs button span { color: #9ca3af; font-size: 0.75rem; }
#halal-app .sugs button:hover { background: #f8fafc; }

/* ---- charts: tile map and co-certification matrix */
#halal-app .tilemap { position: relative; }
#halal-app .tilemap-svg { width: 100%; height: auto; max-height: 440px; display: block; }
#halal-app .tilemap .tile { cursor: pointer; outline: none; }
#halal-app .tilemap .tile:hover rect, #halal-app .tilemap .tile:focus rect { stroke: #111827; stroke-width: 2; }
#halal-app .tilemap .code { font: 600 13px "Inter", sans-serif; }
#halal-app .tilemap .val { font: 500 12px "Inter", sans-serif; }
#halal-app .tilemap .region { font: 600 11px "Inter", sans-serif; fill: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; }
#halal-app .tm-tip { position: absolute; pointer-events: none; background: rgba(0, 0, 0, 0.8); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; line-height: 1.5; z-index: 5; width: max-content; max-width: 220px; }
#halal-app .overlap { overflow-x: auto; }
#halal-app .matrix { border-collapse: separate; border-spacing: 2px; font-size: 0.8125rem; width: 100%; }
#halal-app .matrix th { font-weight: 500; color: #6b7280; padding: 0.375rem; text-align: center; font-size: 0.75rem; }
#halal-app .matrix tbody th { text-align: right; padding-right: 0.5rem; }
#halal-app .matrix td { text-align: center; padding: 0.5rem 0.25rem; border-radius: 0.25rem; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, #2563eb calc(var(--a, 0) * 100%), #f8fafc); color: #374151; }
#halal-app .matrix td.inv { color: #fff; }
#halal-app .matrix td.diag { background: #111827; color: #fff; font-weight: 600; }

#halal-app .about-list { list-style: disc; color: #4b5563; font-size: 0.875rem; max-width: 100ch; padding-left: 1.125rem; margin: 0; line-height: 1.6; }
#halal-app .about-list li { margin-bottom: 0.5rem; }
#halal-app .about-list b { color: #111827; font-weight: 600; }

/* ---- company drawer */
#halal-app .drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 60; }
#halal-app .drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 100vw); background: #fff; z-index: 61; border-left: 1px solid #d1d5db;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); overflow-y: auto; padding: 2rem 2rem 3rem; animation: halal-slide 0.18s ease-out; }
@keyframes halal-slide { from { transform: translateX(24px); opacity: 0.6; } }
#halal-app [hidden] { display: none !important; }
#halal-app .drawer-close { position: absolute; top: 1rem; right: 1rem; }
#halal-app .drawer-eyebrow { color: #3b82f6; text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; font-size: 0.8125rem; margin: 0 0 0.5rem; font-family: "Poppins", sans-serif; }
#halal-app .dr-head h2 { margin: 0 2.5rem 0.75rem 0; font: 700 1.25rem/1.4 "Poppins", sans-serif; }
#halal-app .dr-sub { margin-bottom: 1.5rem; }
#halal-app .dr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #e5e7eb; }
#halal-app .dr-grid span { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.025em; color: rgb(113, 113, 122); text-transform: uppercase; }
#halal-app .dr-grid p { margin: 0.25rem 0 0; font-size: 0.875rem; overflow-wrap: anywhere; }
#halal-app .drawer h3 { font-size: 1.125rem; font-weight: 700; margin: 0 0 0.5rem; }
#halal-app .certs { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; font-size: 0.875rem; color: #6b7280; margin: 1rem 0 0; }
#halal-app .dr-tabs { margin: 2rem 0 1rem; padding-bottom: 0; }
#halal-app .dr-filter { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #d1d5db; border-radius: 0.375rem; font: 0.875rem "Inter", sans-serif; margin-bottom: 0.5rem; outline: none; background: #fff; }
#halal-app .dr-filter:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4); }
#halal-app .dr-table td small { color: #6b7280; display: block; }
#halal-app .dr-table td i { color: #6b7280; font-style: normal; font-size: 0.8125rem; }
#halal-app .dr-more { margin: 1rem auto 0; }
#halal-app .loading-block { padding: 4rem 0; text-align: center; color: #6b7280; }

/* ---- responsive */
@media (min-width: 1024px) { #halal-app .dir-grid { grid-template-columns: minmax(0, 1fr) 280px; } }
@media (max-width: 1023px) { #halal-app .facets { display: none; } }
@media (max-width: 767px) {
  #halal-app .dir-bar { flex-direction: column; align-items: stretch; }
  #halal-app .dir-bar .catalogue-tabs { overflow-x: auto; }
  #halal-app .results-table td.name { min-width: 200px; }
  #halal-app .dr-grid { grid-template-columns: 1fr; }
  #halal-app .drawer { padding: 1.5rem 1rem 3rem; }
}
