/* ==========================================================================
   Data Center Resource Ledger (/ledger). Builds on css/style.css tokens.
   ========================================================================== */

.ledger-header { padding-bottom: 36px; }
.ledger { padding: 32px 0 64px; }

/* ---------- Review status ---------- */
.review-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  padding: 14px 18px;
  margin-bottom: 24px;
  border: 1px solid rgba(242, 184, 75, 0.45);
  border-left: 4px solid #f2b84b;
  border-radius: var(--radius-sm);
  background: rgba(242, 184, 75, 0.08);
  color: var(--text);
  font-size: 0.95rem;
}
.review-banner strong { color: #f6cf86; }
.review-banner a { color: #f6cf86; text-decoration: underline; }

.rv {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.rv-imported {
  color: var(--text-muted);
  border-color: rgba(167, 195, 182, 0.4);
  background: repeating-linear-gradient(135deg, rgba(167, 195, 182, 0.12) 0 5px, transparent 5px 10px);
}
.rv-needs { color: #f6cf86; border-color: rgba(242, 184, 75, 0.6); background: rgba(242, 184, 75, 0.12); }
.rv-conflict { color: #ff9b8f; border-color: rgba(255, 110, 95, 0.65); background: rgba(255, 110, 95, 0.12); }
.rv-reviewed { color: var(--accent); border-color: rgba(74, 232, 122, 0.55); background: rgba(74, 232, 122, 0.1); }
.rv-other { color: var(--text-muted); border-color: var(--border); }

.agent-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px dashed rgba(167, 195, 182, 0.5);
  color: var(--text);
  font-size: 0.75rem;
  white-space: nowrap;
}
.agent-tag small { color: var(--text-faint); font-size: 0.7rem; }

/* ---------- Tabs ---------- */
.ledger-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  scrollbar-width: thin;
}
.ledger-tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.ledger-tabs button:hover { color: var(--text); }
.ledger-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.ledger-tabs .count { color: var(--text-faint); font-weight: 400; margin-left: 4px; }

.ledger-message { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 14px; }
.ledger-message:empty { display: none; }
.ledger-message.error {
  color: #ffb4aa;
  padding: 12px 16px;
  border: 1px solid rgba(255, 110, 95, 0.5);
  border-radius: var(--radius-sm);
  background: rgba(255, 110, 95, 0.08);
}

/* ---------- Filters ---------- */
.ledger-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.ledger-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 0;
}
.ledger-filters .f-search { flex: 1 1 240px; }
.ledger-filters .f-check { flex-direction: row; align-items: center; gap: 8px; font-size: 0.88rem; padding-bottom: 9px; }
.ledger-filters input[type="search"],
.ledger-filters select {
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  max-width: 100%;
}
.ledger-filters select { max-width: 220px; }
.ledger-filters input:focus-visible,
.ledger-filters select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ledger-filters .btn-ghost { padding: 8px 4px; }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; }

/* ---------- Map ---------- */
.map-wrap { position: relative; margin-bottom: 16px; }
#ledger-map {
  height: 460px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-alt);
  z-index: 0;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid; }
.leaflet-container { font-family: var(--font); }
/* OpenStreetMap's standard tiles, darkened to sit on the site's dark background. */
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-2); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; font-size: 0.85rem; line-height: 1.45; }
.leaflet-popup-content strong { display: block; font-size: 0.92rem; margin-bottom: 2px; }
.leaflet-popup-content .popup-meta { color: var(--text-muted); margin-bottom: 6px; }
.leaflet-popup-content button.link { margin-top: 6px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); }
.leaflet-control-attribution { font-size: 0.7rem; }

/* ---------- Results + table ---------- */
.results-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ledger-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ledger-table th, .ledger-table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.ledger-table thead th { background: var(--surface); color: var(--text-muted); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.ledger-table th button { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.ledger-table th button[aria-sort]::after { content: " \25B4"; }
.ledger-table th button[aria-sort="descending"]::after { content: " \25BE"; }
.ledger-table tbody tr:last-child td { border-bottom: 0; }
.ledger-table tbody tr.clickable { cursor: pointer; }
.ledger-table tbody tr.clickable:hover { background: rgba(255, 255, 255, 0.03); }
.ledger-table td.num, .ledger-table th.num { text-align: right; white-space: nowrap; }
.ledger-table .sub { display: block; color: var(--text-faint); font-size: 0.78rem; }
.ledger-table td:first-child { min-width: 200px; }

button.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  text-align: left;
}
.ledger-table button.link { color: var(--text); text-decoration: none; font-weight: 600; }
.ledger-table button.link:hover { color: var(--accent); text-decoration: underline; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; font-size: 0.88rem; color: var(--text-muted); }
.pager button { padding: 6px 14px; }

/* ---------- Tracker cards ---------- */
.tracker-intro { color: var(--text-muted); max-width: 760px; }
.tracker-list { display: grid; gap: 12px; }
.t-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  min-width: 0;
}
.t-card-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 8px; font-size: 0.8rem; color: var(--text-faint); }
.t-card h3 { font-size: 1.02rem; margin: 0 0 6px; line-height: 1.35; overflow-wrap: anywhere; }
.t-card .t-fac { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 10px; }
.t-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 18px; margin: 0 0 10px; font-size: 0.86rem; }
.t-facts div { min-width: 0; }
.t-facts dt { color: var(--text-faint); font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.t-facts dd { margin: 0; overflow-wrap: anywhere; }
.t-text { font-size: 0.88rem; margin: 0 0 8px; overflow-wrap: anywhere; }
.t-text b { color: var(--text-muted); font-weight: 600; }
.t-card details { font-size: 0.82rem; margin-top: 6px; }
.t-card summary { cursor: pointer; color: var(--text-muted); }
.t-card a, .detail-drawer a, .attribution a, .prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.all-fields { display: grid; grid-template-columns: minmax(110px, 180px) 1fr; gap: 4px 12px; margin: 8px 0 0; }
.all-fields dt { color: var(--text-faint); overflow-wrap: anywhere; }
.all-fields dd { margin: 0; overflow-wrap: anywhere; }
.score-bar { display: inline-block; width: 80px; height: 6px; background: var(--surface-2); border-radius: 3px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--text-muted); }
.empty-note { color: var(--text-faint); font-size: 0.9rem; padding: 20px 0; }

.market-context { margin-bottom: 16px; }
.market-context summary { cursor: pointer; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }

/* ---------- Detail drawer ---------- */
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 100%);
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 1000;
  overflow-y: auto;
  visibility: hidden;
}
.detail-drawer.open { transform: none; visibility: visible; }
.detail-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 999; }
.detail-inner { padding: 22px 24px 48px; }
.detail-close {
  position: sticky;
  top: 0;
  float: right;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.detail-close:hover { border-color: var(--accent); color: var(--accent); }
.detail-drawer h2 { font-size: 1.45rem; margin: 4px 48px 8px 0; overflow-wrap: anywhere; }
.detail-drawer h3 { font-size: 1rem; margin: 26px 0 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.8rem; }
.detail-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-faint); font-size: 0.82rem; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.detail-warn { font-size: 0.86rem; color: var(--text-muted); border-left: 3px solid #f2b84b; padding: 4px 0 4px 12px; margin: 10px 0 4px; }
.detail-drawer .all-fields { font-size: 0.88rem; }
.obs-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.obs-list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.86rem; }
.obs-list .obs-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; }
.obs-list .obs-meta { color: var(--text-faint); font-size: 0.78rem; margin-top: 4px; }
.detail-drawer .t-card { background: var(--surface); margin-bottom: 10px; }

/* ---------- About + credits ---------- */
.prose { max-width: 820px; }
.prose h3 { margin-top: 28px; }
.review-key { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; align-items: start; }
.review-key dd { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.attribution {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.attribution-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 8px; }
.attribution ul { margin: 6px 0; padding-left: 18px; }
.attribution p { margin: 6px 0; }

@media (max-width: 700px) {
  #ledger-map { height: 340px; }
  .ledger-filters select { max-width: none; }
  .ledger-filters label:not(.f-check) { flex: 1 1 140px; }
  .review-key { grid-template-columns: 1fr; }
  /* The site's closed mobile menu widens the layout viewport, so anchor the drawer to the left edge. */
  .detail-drawer { left: 0; right: auto; width: 100vw; border-left: 0; }
  .detail-inner { padding: 18px 16px 40px; }
  .all-fields { grid-template-columns: 1fr; }
  .all-fields dt { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) { .detail-drawer { transition: none; } }
