/* Countries pages (pipeline/pages/countries.py). Shared classes come from style.css. */

/* chart sections */
.cty-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 6px; }
.cty-head h2 { margin: 0; }
.cty-segs { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.cty-fact { margin: 0 0 12px; color: var(--ink-2); max-width: 78ch; }
/* reserve the chart's height before it is drawn (BC.lineChart 300/400, BC.barChart 260/320) */
.cty-chart { min-height: 300px; }
.cty-chart[data-chart="gr"] { min-height: 260px; }
.cty-grid .cty-chart { min-height: 240px; }
@media (min-width: 688px) {
  .cty-chart { min-height: 400px; }
  .cty-chart[data-chart="gr"] { min-height: 320px; }
  .cty-grid .cty-chart { min-height: 240px; }
}
.cty-err { padding: 16px; margin: 0; }
.cty-grid { display: grid; grid-template-columns: 1fr; gap: 0 24px; }
.cty-grid .cty-sec { display: flex; flex-direction: column; }
.cty-grid h2 { font-size: clamp(20px, 2.4vw, 26px); }
.cty-grid .chart { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.tip .cty-tipnote { color: var(--muted); font-size: 11px; margin-top: 2px; }
@media (min-width: 860px) {
  .cty-grid { grid-template-columns: 1fr 1fr; }
}

/* tables: sticky header row and name column */
.cty-wrap { max-height: min(78vh, 920px); overflow: auto; }
.cty-table tbody th, .cty-years tbody th { text-align: left; font-weight: 600; }
.cty-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); white-space: normal; min-width: 150px; }
.cty-table tbody tr:hover > th, .cty-years tbody tr:hover > th { background: var(--hover); }
.cty-table thead th { z-index: 2; white-space: normal; vertical-align: bottom; }
.cty-table thead th.cty-name { left: 0; z-index: 3; }
.cty-table tbody th a { color: var(--ink); text-decoration: none; }
.cty-table tbody th a:hover { color: var(--accent-ink); text-decoration: underline; }
.cty-table td.text { text-align: left; white-space: normal; color: var(--ink-2); min-width: 160px; }
.cty-table th[data-sort] { min-width: 64px; }
.cty-table thead th[data-sort="text"] { text-align: left; }
.cty-table th[data-sort]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.yr { color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.cty-est { font-style: italic; color: var(--ink-2); }
.cty-fl { font-size: 10px; color: var(--muted); margin-left: 1px; font-style: normal; }
.cty-years thead th:first-child, .cty-years tbody th { position: sticky; left: 0; background: var(--surface); }
.cty-years thead th:first-child { z-index: 2; }
.cty-years tbody th { z-index: 1; }
.cty-details { margin-top: 8px; }
.cty-sources { line-height: 1.7; }

/* ranking bars */
.cty-barcell { width: 24%; min-width: 96px; padding-left: 4px; }
.cty-track { display: block; position: relative; height: 10px; }
.cty-bar { position: absolute; top: 1px; height: 8px; background: var(--s1); border-radius: 3px; }
.cty-bar.neg { background: var(--bad); opacity: 0.75; }
.cty-bar.over::after { content: ""; position: absolute; right: -6px; top: -1px; border-left: 6px solid var(--s1); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
/* inflation is the "cash" color (it eats cash), deflation gray; stock markets are blue like the S&P 500 */
.cty-rank-inf .cty-bar { background: var(--cash); }
.cty-rank-inf .cty-bar.neg { background: var(--line-gray); opacity: 1; }
.cty-rank-inf .cty-bar.over::after { border-left-color: var(--cash); }
.cty-rank-mcap .cty-bar { background: var(--spx); }
.cty-rank-mcap .cty-bar.over::after { border-left-color: var(--spx); }

/* filters */
.cty-filters { margin-bottom: 10px; }
.cty-chips { margin: 0 0 14px; }

/* links */
.cty-region-list { font-size: 14px; color: var(--muted); line-height: 1.9; margin: 16px 0 0; }
.cty-region-list a { color: var(--ink-2); }
.cty-region-list b { color: var(--ink); font-weight: 600; }
.cty-links { line-height: 1.9; margin: 0; }
.cty-callout { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent-soft); }
.cty-callout .card-title { color: var(--accent-ink); }
.stat-sub a { color: var(--ink-2); }

@media (max-width: 640px) {
  .cty-hide-sm { display: none; }
  .cty-table tbody th { min-width: 118px; }
  .cty-segs { margin-left: 0; }
  .cty-filters .search { min-width: 0; flex: 1 1 200px; }
  /* two key figures per row, region pills in one scrollable row */
  .cty-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cty-stats .stat { padding: 12px; }
  .cty-stats .stat-value { font-size: 18px; }
  .cty-chips { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .cty-chips::-webkit-scrollbar { display: none; }
}
