/* Meridian Quality Index — public site. Institutional factsheet aesthetic:
   navy header, white content, dense data tables, "as of" stamps. */

:root {
  --navy: #0a1f44;
  --navy-light: #15315f;
  --accent: #c9a227;        /* muted gold */
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e2e5ea;
  --row-alt: #f6f7f9;
  --bg: #ffffff;
  --pos: #1b7a43;
  --neg: #b00020;
  --maxw: 1080px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--navy-light); }

/* ---- header / nav ---- */
.site-header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  flex-wrap: wrap;
}
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}
.brand {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
}
.brand .tick { color: var(--accent); }
.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.site-nav a {
  color: #cdd5e1;
  text-decoration: none;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 3px;
}
.site-nav a:hover { color: #fff; background: var(--navy-light); }
.site-nav a.active { color: #fff; border-bottom: 2px solid var(--accent); border-radius: 0; }

/* ---- layout ---- */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 24px 64px;
}
section { margin-bottom: 36px; }
h1 { font-size: 26px; margin: 0 0 4px; font-weight: 600; }
h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--navy);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 14px;
}
h3 { font-size: 15px; margin: 18px 0 6px; }
p { margin: 0 0 12px; }
.lead { font-size: 17px; color: #333; max-width: 70ch; }
.muted { color: var(--muted); }
.asof { color: var(--muted); font-size: 12.5px; margin: 2px 0 14px; }

/* ---- hero stat pills ---- */
.pills { display: flex; gap: 14px; flex-wrap: wrap; margin: 18px 0 8px; }
.pill {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 18px;
  min-width: 140px;
  background: var(--row-alt);
}
.pill .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.pill .v { font-size: 22px; font-weight: 600; color: var(--navy); margin-top: 2px; }

/* ---- characteristics grid ---- */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 28px;
}
.facts .row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dotted var(--line);
  padding: 6px 0;
}
.facts .row .k { color: var(--muted); }
.facts .row .v { font-weight: 600; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th, table.data td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child,
table.data th.l, table.data td.l { text-align: left; }
table.data thead th {
  color: var(--navy);
  font-weight: 600;
  border-bottom: 2px solid var(--navy);
  cursor: default;
  user-select: none;
}
table.data.sortable thead th { cursor: pointer; }
table.data.sortable thead th:hover { background: var(--row-alt); }
table.data tbody tr:nth-child(even) { background: var(--row-alt); }
table.data td.num { font-variant-numeric: tabular-nums; }
.sort-ind { color: var(--accent); font-size: 11px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #eef1f5;
  color: var(--navy);
}
.tag.add { background: #e6f4ec; color: var(--pos); }

/* ---- bars (sector weights) ---- */
.barlist { display: grid; grid-template-columns: 1fr; gap: 6px; max-width: 560px; }
.barlist .item { display: grid; grid-template-columns: 150px 1fr 56px; gap: 10px; align-items: center; }
.barlist .name { color: var(--ink); font-size: 14px; }
.barlist .track { background: var(--row-alt); border-radius: 3px; height: 16px; overflow: hidden; }
.barlist .fill { background: var(--navy); height: 100%; }
.barlist .pct { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---- callout / placeholder ---- */
.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: var(--row-alt);
  padding: 16px 18px;
  border-radius: 4px;
  color: #444;
}
.callout strong { color: var(--navy); }

/* ---- toolbar ---- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
button.btn, a.btn {
  border: 1px solid var(--navy);
  background: #fff;
  color: var(--navy);
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
button.btn:hover, a.btn:hover { background: var(--navy); color: #fff; }

/* ---- methodology prose ---- */
.prose { max-width: 74ch; }
.prose ul { margin: 0 0 14px; padding-left: 20px; }
.prose li { margin-bottom: 5px; }
.prose code { background: var(--row-alt); padding: 1px 5px; border-radius: 3px; font-size: 13px; }

/* ---- footer ---- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--row-alt);
  color: var(--muted);
  font-size: 12.5px;
}
.site-footer .inner { max-width: var(--maxw); margin: 0 auto; padding: 20px 24px; }
.site-footer .disclaimer { max-width: 80ch; }
.site-footer a { color: var(--navy-light); }

.err { color: var(--neg); font-size: 14px; }

/* ============================================================
   Mobile (phones / narrow tablets)
   ============================================================ */
@media (max-width: 720px) {
  body { font-size: 16px; }

  /* --- hamburger nav --- */
  .site-header .bar { padding: 0 16px; min-height: 52px; }
  .nav-toggle { display: block; order: 2; }
  .brand { order: 1; font-size: 16px; }
  .site-nav {
    order: 3;
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    gap: 0;
    padding-bottom: 8px;
  }
  .site-nav.open { display: flex; }
  .site-nav a {
    padding: 13px 8px;
    font-size: 16px;
    border-radius: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }
  .site-nav a.active { border-bottom: 1px solid var(--accent); color: var(--accent); }

  /* --- layout --- */
  main { padding: 20px 16px 56px; }
  h1 { font-size: 22px; }
  .lead { font-size: 16px; }

  /* --- hero pills: full-width stack --- */
  .pills { gap: 10px; }
  .pill { flex: 1 1 100%; min-width: 0; }

  /* --- characteristics: stack key above value, no clipping --- */
  .facts { grid-template-columns: 1fr; }
  .facts .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 8px 0;
  }
  .facts .row .v { font-size: 16px; }

  /* --- sector bars: stack name above the bar so names never clip --- */
  .barlist { max-width: none; gap: 12px; }
  .barlist .item {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name pct" "track track";
    column-gap: 10px;
    row-gap: 4px;
  }
  .barlist .name { grid-area: name; font-size: 13px; }
  .barlist .pct { grid-area: pct; }
  .barlist .track { grid-area: track; }

  /* --- generic tables scroll instead of clipping the page --- */
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 8px 8px; }

  /* --- constituents: render rows as tap-friendly cards --- */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards thead { display: none; }
  table.cards tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #fff;
  }
  table.cards tbody tr:nth-child(even) { background: #fff; }
  table.cards td {
    border: none;
    padding: 4px 0;
    text-align: right;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    white-space: normal;
  }
  table.cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    padding-right: 12px;
  }
  /* ticker = card title; hide its label and enlarge */
  table.cards td.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--navy);
    border-bottom: 1px dotted var(--line);
    padding-bottom: 6px;
    margin-bottom: 4px;
  }
  table.cards td.card-title::before { content: none; }
  /* hide lower-value columns on mobile cards */
  table.cards td.hide-mobile { display: none; }

  .toolbar { gap: 8px; }
  .toolbar h2 { font-size: 14px; }
}
