/* ============================================================
   Yellow Pages Malta — Marketing Dashboard
   Built on the design system tokens in ./tokens/.
   Only token variables are used for colour, type and spacing.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-subtle);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--color-ink);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: var(--container-pad);
}

/* ---------- Header ---------- */

.site-header {
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
  padding-block: var(--space-3);
}

.logo { height: 40px; width: auto; flex: none; }

.header-rule {
  width: 1px;
  height: var(--space-8);
  background: var(--border-default);
  flex: none;
}

.header-title {
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  padding: var(--space-1);
  gap: var(--space-1);
}

.tab {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--radius-pill);
  padding: var(--space-2) 18px;
  background: transparent;
  color: var(--yp-ink-600);
  font-weight: var(--fw-medium);
  transition: background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}

.tab:hover { color: var(--color-ink); }

.tab[aria-selected="true"] {
  background: var(--color-brand);
  color: var(--color-on-brand);
  font-weight: var(--fw-bold);
}

/* ---------- Freshness pill ---------- */

.freshness {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}

.freshness-dot {
  width: 7px; height: 7px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  flex: none;
}

.freshness[data-state="fresh"] .freshness-dot { background: var(--yp-verified); }
.freshness[data-state="stale"] .freshness-dot { background: var(--yp-star); }
.freshness[data-state="error"] .freshness-dot { background: var(--yp-error); }
.freshness[data-state="fresh"] #freshness-text,
.freshness[data-state="stale"] #freshness-text { color: var(--text-muted); }

.icon-btn {
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--yp-ink-600);
  border-radius: var(--radius-pill);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: var(--fs-body);
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.icon-btn:hover { background: var(--surface-muted); border-color: var(--border-strong); }
.icon-btn[data-busy="true"] i { animation: spin 700ms linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */

.main {
  padding-block: var(--space-10) var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.panel[hidden], .state[hidden], .notice-stack[hidden] { display: none; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.section-title.on-dark { color: var(--text-on-dark); }

.section-meta { font-size: 13px; color: var(--text-muted); }
.section-meta.on-dark { color: var(--text-on-dark-muted); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.card-flush { padding: 0; overflow: hidden; }

.card-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.card-sub {
  margin: var(--space-1) 0 var(--space-4);
  font-size: 13px;
  color: var(--text-muted);
}

.card-head-icon {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--fs-h4);
}

/* ---------- KPI cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
}

/* Six cards in a five-column grid leaves one orphan on its own row. 3x2 reads as
   a deliberate layout instead. data-count is set by renderKpis(). */
.kpi-grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* flex:1 lets the label box soak up the row's spare height. Grid rows are equal
   height, so value and meter then land on the same baseline in every card no
   matter how many lines the label wraps to. */
.kpi-label {
  flex: 1;
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  min-height: 34px;
  display: flex;
  align-items: flex-start;
  align-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-value {
  font-size: 28px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
  font-variant-numeric: tabular-nums;
}

.kpi-value.is-empty { color: var(--text-subtle); }

/* margin-top:auto pins meters to the card floor, so they line up across the row
   however many lines each label wraps to. */
.kpi-meter { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: var(--space-1); }

.meter-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  transition: width var(--dur-slow) var(--ease-out);
}

/* Over budget on an inverted metric is a warning, not an achievement */
.meter-fill.is-over { background: var(--yp-error); }

.meter-legend {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 11.5px;
  color: var(--text-subtle);
}

.meter-legend strong { font-weight: var(--fw-semibold); color: var(--yp-ink-600); }

/* Accent bar for KPI cards with no target (client tab) */
.kpi-accent {
  width: 28px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  margin-top: auto;
}

.badge-est {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--text-subtle);
  background: var(--surface-muted);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: help;
  white-space: nowrap;
}

/* ---------- Takeaways ---------- */

.takeaways {
  background: var(--surface-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
}

.takeaways .section-head { margin-bottom: var(--space-5); }

.takeaway-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
}

.takeaway { display: flex; gap: 14px; align-items: flex-start; }

.takeaway-num {
  flex: none;
  width: var(--space-8); height: var(--space-8);
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  color: var(--color-on-brand);
  font-weight: var(--fw-bold);
  font-size: 15px;
  display: grid; place-items: center;
}

.takeaway p {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  color: var(--yp-ink-150);
  text-wrap: pretty;
}

.takeaway-empty {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  color: var(--text-on-dark-muted);
}

/* ---------- Month on month ---------- */

.mom-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.mom-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.mom-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  background: var(--color-brand-soft);
  font-size: 15px;
  font-weight: var(--fw-bold);
}

.mom-head i { font-size: var(--fs-h4); color: var(--color-ink); }

.mom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 13px var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.mom-row-label {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--yp-ink-600);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

.mom-row-prev {
  font-size: 11.5px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.mom-row-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

.mom-row-value {
  font-size: var(--fs-body);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
}

.mom-row-value.is-empty { color: var(--text-subtle); font-weight: var(--fw-medium); }

.delta {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.delta i { font-size: var(--fs-xs); }
.delta--up   { color: var(--yp-verified); background: var(--yp-verified-soft); }
.delta--down { color: var(--yp-error);    background: var(--yp-error-soft); }
.delta--flat { color: var(--text-muted);  background: var(--surface-muted); }

/* ---------- Lists (initiatives, campaigns, ads) ---------- */

.list { display: flex; flex-direction: column; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-subtle);
}

.list-row:first-child { border-top: none; padding-top: 0; }

.list-row-main { min-width: 0; }

.list-row-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.list-row-title.strong { font-weight: var(--fw-semibold); }

.list-row-sub {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  margin-top: 2px;
}

.list-row-side { display: flex; align-items: center; gap: var(--space-2); flex: none; }

.list-row-icon { font-size: var(--fs-lg); color: var(--text-muted); flex: none; }

.list-lead { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }

/* ---------- Pills ---------- */

.pill {
  flex: none;
  font-size: 11.5px;
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
  color: var(--text-muted);
  background: var(--surface-muted);
}

.pill--live      { color: var(--yp-verified); background: var(--yp-verified-soft); }
.pill--ongoing   { color: var(--color-ink);   background: var(--yp-yellow-100); }
.pill--progress  { color: var(--color-ink);   background: var(--yp-yellow-50); }
.pill--planned   { color: var(--text-muted);  background: var(--surface-muted); }
.pill--paid      { color: var(--color-on-brand); background: var(--color-brand); }
.pill--free      { color: var(--text-muted);  background: var(--surface-muted); }

/* ---------- Landing page table ---------- */

.table-wrap { overflow-x: auto; }

.lp-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13.5px;
  /* Fixed layout keeps the column widths, which lets long names ellipsize
     instead of wrapping — uniform row heights, so the pager never shifts. */
  table-layout: fixed;
}

.lp-table td.lp-client,
.lp-table td.lp-heading {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lp-filler td { color: transparent; user-select: none; }

.lp-table thead th {
  background: var(--color-brand-soft);
  padding: 14px var(--space-6);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}

.lp-table th.num, .lp-table td.num { text-align: right; }

.lp-table tbody td {
  padding: 13px var(--space-6);
  border-top: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.lp-table tbody tr:hover { background: var(--surface-subtle); }

.lp-client { font-weight: var(--fw-semibold); }
.lp-heading { color: var(--yp-ink-600); }

/* Client names that link to the listing's landing page */
.lp-client-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.lp-client-link:hover {
  text-decoration-color: var(--color-brand);
  text-decoration-thickness: 2px;
}
.lp-table td.num { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }

/* Column widths: rank, then the design's 2fr 2fr 1fr 1fr 1fr grid */
.lp-table th:nth-child(2), .lp-table th:nth-child(3) { width: 25%; }
.lp-table th:nth-child(4), .lp-table th:nth-child(5), .lp-table th:nth-child(6) { width: 14%; }

/* ---------- Notices ---------- */

.notice-stack { display: flex; flex-direction: column; gap: var(--space-2); }

.notice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  background: var(--color-brand-soft);
  border: 1px solid var(--yp-yellow-200);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  line-height: var(--lh-snug);
  color: var(--yp-ink-700);
}

.notice i { color: var(--yp-yellow-700); font-size: var(--fs-body); flex: none; margin-top: 1px; }
.notice p { margin: 0; text-wrap: pretty; }

/* Reserved for "this is not live data" — must outrank the routine notices. */
.notice--strong {
  background: var(--yp-error-soft);
  border-color: var(--yp-error);
  color: var(--yp-ink-800);
  font-weight: var(--fw-medium);
}

.notice--strong i { color: var(--yp-error); }

/* ---------- States ---------- */

.state { display: flex; flex-direction: column; gap: var(--space-6); align-items: center; }

.state-text { margin: 0; font-size: 13px; color: var(--text-muted); }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
  width: 100%;
}

.skeleton-card {
  height: 132px;
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg,
    var(--surface-card) 30%, var(--surface-muted) 50%, var(--surface-card) 70%);
  background-size: 250% 100%;
  box-shadow: var(--shadow-sm);
  animation: shimmer 1.4s var(--ease-standard) infinite;
}

@keyframes shimmer {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}

.error-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-10);
  max-width: 620px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.error-icon { font-size: var(--fs-h2); color: var(--yp-error); }

.error-title {
  margin: 0;
  font-size: var(--fs-h4);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.error-body { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-body); }

.error-detail {
  margin: 0;
  width: 100%;
  text-align: left;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-size: var(--fs-2xs);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--yp-ink-600);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
}

.btn-primary {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  background: var(--color-brand);
  color: var(--color-on-brand);
  border-radius: var(--radius-pill);
  padding: 10px var(--space-6);
  margin-top: var(--space-2);
  transition: background var(--dur-fast) var(--ease-out);
}

.btn-primary:hover { background: var(--color-brand-hover); }

.empty {
  padding: var(--space-6) 0;
  font-size: 13px;
  color: var(--text-subtle);
  text-align: center;
}

.lp-table .empty-cell { padding: var(--space-8) var(--space-6); text-align: center; color: var(--text-subtle); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-card);
  padding-block: var(--space-5);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}

/* ---------- Focus ---------- */

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .kpi-grid, .skeleton-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mom-grid { grid-template-columns: 1fr; }
  .takeaway-grid { grid-template-columns: 1fr; gap: var(--space-4); }
}

@media (max-width: 760px) {
  .header-inner { gap: var(--space-3); }
  .header-rule, .header-title { display: none; }
  .header-actions { margin-left: auto; width: auto; }
  .tabs { flex: 1; }
  .tab { flex: 1; padding-inline: var(--space-3); }
  .kpi-grid, .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .main { padding-block: var(--space-6) var(--space-12); gap: var(--space-8); }
  .takeaways { padding: var(--space-6); }
  .section-title { font-size: var(--fs-h4); }
}

@media (max-width: 460px) {
  .kpi-grid, .skeleton-grid { grid-template-columns: 1fr; }
  .freshness { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header, .site-footer, .icon-btn, .tabs { display: none !important; }
  .panel[hidden] { display: flex !important; }
  body { background: var(--surface-card); }
  .card, .kpi, .mom-card { box-shadow: none; border: 1px solid var(--border-subtle); }
}

/* ============================================================
   Billboard map
   ============================================================ */

.map-wrap { position: relative; }

.map {
  height: 460px;
  width: 100%;
  background: var(--surface-muted);
}

/* Leaflet injects its own chrome; keep it in the design's type and radii. */
.map .leaflet-container { font-family: var(--font-sans); }

.map .leaflet-popup-content-wrapper,
.map .leaflet-tooltip {
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-ink);
  box-shadow: var(--shadow-md);
}

.map .leaflet-tooltip { background: var(--surface-card); border: 1px solid var(--border-default); }
.map .leaflet-tooltip-top::before { border-top-color: var(--border-default); }
.map .leaflet-control-attribution { font-size: 10px; }
.map .leaflet-bar a { color: var(--color-ink); }

/* Brand pin. A ring rather than a teardrop, so overlapping sites stay readable. */
.bb-pin { background: none; border: none; }

.bb-pin-dot {
  display: block;
  width: 20px; height: 20px;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  border: 3px solid var(--yp-ink-800);
  box-shadow: 0 2px 6px rgba(23,23,23,0.4);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out);
}

.bb-pin:hover .bb-pin-dot,
.bb-pin:focus-visible .bb-pin-dot { transform: scale(1.25); }

/* A site with no creative yet — hollow, so it reads as incomplete. */
.bb-pin--empty .bb-pin-dot {
  background: var(--surface-card);
  border-color: var(--yp-ink-400);
}

.map-empty {
  margin: 0;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  font-size: 13px;
  color: var(--text-subtle);
  text-wrap: pretty;
}

/* ---------- Companion list ---------- */

.bb-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1px;
  background: var(--border-subtle);
  border-top: 1px solid var(--border-subtle);
}

.bb-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card);
  border: none;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.bb-item:hover { background: var(--color-brand-soft); }
.bb-item-icon { font-size: var(--fs-body); color: var(--color-brand-pressed); flex: none; }
.bb-item--empty .bb-item-icon { color: var(--text-subtle); }
.bb-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bb-item-name { font-weight: var(--fw-semibold); color: var(--color-ink); }

.bb-item-note {
  font-size: var(--fs-2xs);
  color: var(--text-subtle);
  line-height: var(--lh-snug);
}

.bb-item .pill { margin-left: auto; font-size: 10px; padding: 2px 8px; }

/* ============================================================
   Lightbox
   ============================================================ */

body.has-lightbox { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(23, 23, 23, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  animation: lb-in var(--dur-base) var(--ease-out);
}

.lightbox[hidden] { display: none; }

@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

.lightbox-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  max-width: 100%;
  max-height: 100%;
}

.lightbox-img {
  max-width: 100%;
  /* Leave room for the caption so a tall creative can't push it off screen. */
  max-height: calc(100vh - 9rem);
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: var(--shadow-lg);
}

/* Show exactly one medium, and only once it has actually decoded. */
.lightbox:not([data-state="ready"]) .lightbox-img,
.lightbox:not([data-state="ready"]) .lightbox-video { display: none; }
.lightbox[data-media="video"] .lightbox-img { display: none; }
.lightbox[data-media="image"] .lightbox-video { display: none; }

.lightbox-video {
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  border-radius: var(--radius-md);
  background: var(--yp-ink-900);
  box-shadow: var(--shadow-lg);
}

.lightbox-caption {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-on-dark);
  text-align: center;
  max-width: 46ch;
  line-height: var(--lh-snug);
  text-wrap: pretty;
}

.lightbox[data-state="loading"] .lightbox-caption::after {
  content: ' · loading…';
  font-weight: var(--fw-regular);
  color: var(--text-on-dark-muted);
}

.lightbox[data-state="error"] .lightbox-caption,
.lightbox[data-state="missing"] .lightbox-caption {
  color: var(--yp-yellow-200);
  font-weight: var(--fw-medium);
}

.lightbox-close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--surface-card);
  color: var(--color-ink);
  font-size: var(--fs-lg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.lightbox-close:hover { background: var(--color-brand); }

@media (max-width: 760px) {
  .map { height: 340px; }
  .lightbox { padding: var(--space-4); }
  .lightbox-img { max-height: calc(100vh - 11rem); }
  .lightbox-close { top: var(--space-3); right: var(--space-3); }
}

/* ============================================================
   Initiative pipeline stepper
   ============================================================ */

.init {
  padding: var(--space-3) 0 var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.init:first-child { border-top: none; padding-top: 0; }

.init-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.init-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }

.init-count {
  flex: none;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  white-space: nowrap;
}

.init-count--unset { color: var(--yp-yellow-700); }

/* One segment per stage: done = charcoal, current = brand yellow, rest = grey.
   Tooltips on each segment carry the stage names. */
.init-track { display: flex; gap: 4px; }

.init-seg {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  cursor: help;
  transition: transform var(--dur-fast) var(--ease-out);
}

.init-seg:hover { transform: scaleY(1.4); }
.init-seg--done { background: var(--yp-ink-600); }
.init-seg--current { background: var(--color-brand); box-shadow: inset 0 0 0 1px var(--yp-yellow-600); }

.init-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.init-stage {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--color-on-brand);
  background: var(--color-brand);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}

.init-next {
  font-size: var(--fs-2xs);
  color: var(--text-subtle);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Highlight pulse when a location is picked from the list. */
.bb-pin--flash .bb-pin-dot {
  animation: bb-flash 0.65s var(--ease-standard) 4;
}

@keyframes bb-flash {
  0%, 100% { transform: scale(1); box-shadow: 0 2px 6px rgba(23,23,23,0.4); }
  50% { transform: scale(1.9); box-shadow: 0 0 0 8px rgba(255,214,1,0.35); }
}

/* "Show all billboards" map control */
.bb-fit-btn {
  width: 34px; height: 34px;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--color-ink);
  font-size: var(--fs-body);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.bb-fit-btn:hover { background: var(--color-brand); }

/* Labels that carry a definition tooltip. The dotted underline appears on
   hover only, so the resting design stays clean. */
.has-def { cursor: help; }
.has-def:hover {
  text-decoration: underline dotted var(--yp-ink-400);
  text-underline-offset: 3px;
}

/* ============================================================
   Landing pages table controls
   ============================================================ */

.lp-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.lp-controls[hidden] { display: none; }

.lp-select {
  font-family: inherit;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--color-ink);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-width: 260px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.lp-select:hover { border-color: var(--border-strong); }

/* Client multi-select: a button that opens a search-and-tick panel */
.lp-picker { position: relative; }

.lp-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--color-ink);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  max-width: 240px;
}

.lp-picker-btn:hover { border-color: var(--border-strong); }
.lp-picker-btn.is-active { border-color: var(--color-brand); }
.lp-picker-btn i { font-size: 10px; color: var(--text-subtle); flex: none; }

.lp-picker-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: 280px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.lp-picker-panel[hidden] { display: none; }

.lp-picker-search {
  font-family: inherit;
  font-size: 13px;
  color: var(--color-ink);
  background: var(--surface-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  width: 100%;
}

.lp-picker-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.lp-picker-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}

.lp-picker-item:hover { background: var(--surface-muted); }
.lp-picker-item input { flex: none; accent-color: var(--color-brand); cursor: pointer; }

.lp-picker-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-picker-more {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-subtle);
}

.lp-picker-foot {
  border-top: 1px solid var(--border-default);
  padding-top: var(--space-2);
  display: flex;
  justify-content: flex-end;
}

.lp-picker-clear {
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  color: var(--text-subtle);
  cursor: pointer;
  padding: 2px 4px;
}

.lp-picker-clear:hover { color: var(--yp-ink-800); }

/* Totals line for the active filter */
.lp-totals {
  margin: calc(-1 * var(--space-2)) 0 var(--space-3);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--yp-ink-700);
}

.lp-totals[hidden] { display: none; }

/* Exclude-free toggle: a labelled switch, pushed to the right like the mock. */
.lp-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: var(--yp-ink-600);
  cursor: pointer;
  user-select: none;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  box-shadow: var(--shadow-xs);
}

.lp-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lp-toggle-track {
  width: 34px; height: 18px;
  border-radius: var(--radius-pill);
  background: var(--yp-ink-300);
  position: relative;
  flex: none;
  transition: background var(--dur-base) var(--ease-out);
}

.lp-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  transition: transform var(--dur-base) var(--ease-out);
}

.lp-toggle input:checked + .lp-toggle-track { background: var(--color-brand); }
.lp-toggle input:checked + .lp-toggle-track::after { transform: translateX(16px); }
.lp-toggle input:focus-visible + .lp-toggle-track { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Sortable headers */
.lp-sort {
  border: none;
  background: none;
  font: inherit;
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lp-sort::after {
  content: '';
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid transparent;   /* reserves the space so headers don't shift */
}

.lp-sort.is-sorted::after { border-top-color: var(--color-ink); }
.lp-sort.is-sorted.is-asc::after {
  border-top: none;
  border-bottom: 5px solid var(--color-ink);
}

.lp-table th.rank, .lp-table td.rank {
  width: 44px;
  color: var(--text-subtle);
  font-weight: var(--fw-regular);
  font-variant-numeric: tabular-nums;
}

/* Pagination footer */
.lp-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

.lp-pager[hidden] { display: none; }

.lp-pager-info {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-right: var(--space-2);
}

.lp-pager .icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

@media (max-width: 760px) {
  .lp-toggle { margin-left: 0; }
}

/* Client search box, matching the select styling. */
.lp-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.lp-search-wrap .ph {
  position: absolute;
  left: 10px;
  font-size: var(--fs-sm);
  color: var(--text-subtle);
  pointer-events: none;
}

.lp-search {
  font-family: inherit;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--color-ink);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 32px;
  width: 230px;
  box-shadow: var(--shadow-xs);
}

.lp-search:hover { border-color: var(--border-strong); }
.lp-search::placeholder { color: var(--text-subtle); }

/* Disclosure line for traffic hidden from the landing pages table. */
.lp-note {
  margin: 0;
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: var(--lh-snug);
  text-wrap: pretty;
}

.lp-note[hidden] { display: none; }

/* ============================================================
   Passphrase gate
   ============================================================ */

body.is-locked .site-header,
body.is-locked .main,
body.is-locked .site-footer { display: none; }

.lock {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--surface-subtle);
}

.lock[hidden] { display: none; }

.lock-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-10);
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.lock-logo { height: 36px; width: auto; margin-bottom: var(--space-2); }

.lock-title {
  margin: 0;
  font-size: var(--fs-h4);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.lock-sub { margin: 0; font-size: 13px; color: var(--text-muted); }

.lock-input {
  width: 100%;
  margin-top: var(--space-2);
  padding: 11px 14px;
  font-family: inherit;
  font-size: var(--fs-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  text-align: center;
}

.lock-input:focus { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.lock-btn { width: 100%; }
.lock-btn[disabled] { opacity: 0.6; cursor: default; }

.lock-error {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--yp-error);
  font-weight: var(--fw-semibold);
}
