@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono:wght@400;500&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

/* ── MD3 Color Tokens (neutral/black primary scheme) ─────────────────────── */
:root {
  /* Primary */
  --md-primary:              #1c1b1f;
  --md-on-primary:           #ffffff;
  --md-primary-container:    #e6e1e5;
  --md-on-primary-container: #1c1b1f;

  /* Secondary */
  --md-secondary:              #625b71;
  --md-on-secondary:           #ffffff;
  --md-secondary-container:    #e8def8;
  --md-on-secondary-container: #1d1935;

  /* Surface */
  --md-background:            #fffbfe;
  --md-surface:               #fffbfe;
  --md-surface-variant:       #e7e0ec;
  --md-surface-container-low: #f7f2fa;
  --md-surface-container:     #f3edf7;
  --md-surface-container-high:#ece6f0;
  --md-on-surface:            #1c1b1f;
  --md-on-surface-variant:    #49454f;

  /* Outline */
  --md-outline:         #79747e;
  --md-outline-variant: #cac4d0;

  /* Semantic risk colors (outside MD3 system) */
  --risk-low:  #1b5e20;
  --risk-med:  #e65100;
  --risk-high: #b71c1c;
  --risk-crit: #7b0000;

  /* Positive / negative */
  --positive: #1b5e20;
  --negative: #b71c1c;

  /* MD3 Shape */
  --shape-none:        0px;
  --shape-extra-small: 4px;
  --shape-small:       8px;
  --shape-medium:      12px;
  --shape-large:       16px;
  --shape-extra-large: 28px;
  --shape-full:        9999px;

  /* MD3 Elevation (light theme) */
  --elev-1: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
  --elev-2: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);

  /* MD3 State layers */
  --state-hover:   rgba(28,27,31,0.08);
  --state-pressed: rgba(28,27,31,0.12);
  --state-focused: rgba(28,27,31,0.12);
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
body {
  background: var(--md-background);
  color: var(--md-on-surface);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.43;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── MD3 Top App Bar ─────────────────────────────────────────────────────── */
/* Spec: height 64dp, surface color, no border at rest, elev-2 when scrolled */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 64px;
  background: var(--md-surface);
  flex-shrink: 0;
  gap: 12px;
}
header.scrolled { box-shadow: var(--elev-2); }

/* Logo — editorial display, not a UI element so serif is acceptable */
.logo {
  font-family: 'Libre Baskerville', serif;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  flex-shrink: 0;
}
.logo em {
  font-style: normal;
  display: inline-block;
  background: linear-gradient(120deg, #f8d888 0%, #f0a500 55%, #c47800 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* MD3 Label Small — 11sp / 0.5 tracking */
.logo small {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.5px;
  color: var(--md-on-surface-variant);
  display: block;
  margin-top: 2px;
}

/* ── MD3 Filter Chips ────────────────────────────────────────────────────── */
/* Spec: 32dp height, ShapeFull, Label Medium (12sp/500/0.5px), outlined+filled */
.header-center { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.cat-btn {
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--md-outline-variant);
  background: transparent;
  color: var(--md-on-surface-variant);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  border-radius: var(--shape-full);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  position: relative;
  overflow: hidden;
}
.cat-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  border-radius: inherit;
  transition: background 0.1s;
}
.cat-btn:hover::after   { background: var(--state-hover); }
.cat-btn:active::after  { background: var(--state-pressed); }
.cat-btn.active {
  border-color: transparent;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}


/* ── App layout ──────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── MD3 Navigation Drawer (permanent) ───────────────────────────────────── */
/* Surface container, 280dp wide — list items are NavigationDrawerItems */
.commodity-list {
  border-right: 1px solid var(--md-outline-variant);
  overflow-y: auto;
  background: var(--md-surface-container-low);
}

/* MD3 Search bar in drawer header */
.list-search {
  padding: 8px 12px;
  position: sticky;
  top: 0;
  background: var(--md-surface-container-low);
  z-index: 5;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.list-search input {
  width: 100%;
  height: 40px;
  border: none;
  background: var(--md-surface-container);
  padding: 0 36px 0 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--md-on-surface);
  outline: none;
  border-radius: var(--shape-full);
  letter-spacing: 0.25px;
  flex: 1;
  box-sizing: border-box;
}
.list-search input::placeholder { color: var(--md-on-surface-variant); }
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--md-surface-container-highest, rgba(128,128,128,0.2));
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--md-on-surface-variant);
  font-size: 11px;
  line-height: 1;
  padding: 0;
  transition: opacity 0.15s;
}
.search-clear.visible { display: flex; }
.search-clear:hover { opacity: 0.7; }
.c-item.kbd-focus { background: var(--md-surface-container-high, rgba(255,255,255,0.08)) !important; outline: 1px solid var(--md-primary, #f0a500); outline-offset: -1px; }

/* MD3 Drawer section label — Label Medium */
.cat-header {
  padding: 16px 16px 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  position: sticky;
  top: 56px;
  z-index: 4;
  background: var(--md-surface-container-low);
}

/* MD3 Navigation Drawer Item */
/* Spec: 56dp height, active = secondary-container fill, shape-large indicator */
.c-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 56px;
  cursor: pointer;
  border-radius: var(--shape-large);
  margin: 2px 8px;
  position: relative;
  transition: background 0.1s;
}
.c-item::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  transition: background 0.1s;
  pointer-events: none;
}
.c-item:hover::after { background: var(--state-hover); }
.c-item.active {
  background: var(--md-secondary-container);
}
.c-item.active .c-name,
.c-item.active .c-pct { color: var(--md-on-secondary-container); }
.c-item.active .c-meta { color: var(--md-on-surface-variant); }

.c-icon { font-size: 1rem; flex-shrink: 0; width: 24px; text-align: center; }
.c-body { flex: 1; min-width: 0; }
/* MD3 Title Small — 14sp / 500 / 0.1px */
.c-name {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--md-on-surface);
}
/* MD3 Label Small — 11sp / 400 / 0.5px */
.c-meta {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--md-on-surface-variant);
  margin-top: 1px;
}
.c-right { text-align: right; flex-shrink: 0; }
/* MD3 Label Medium — 12sp / 500 / 0.5px */
.c-pct {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}
.c-risk { width: 6px; height: 6px; border-radius: 50%; margin: 2px auto 0; }

/* ── Detail panel ────────────────────────────────────────────────────────── */
.detail { display: flex; flex-direction: column; overflow: hidden; background: var(--md-surface); }

.detail-header {
  padding: 16px 24px 0;
  background: var(--md-surface);
  flex-shrink: 0;
}
.dh-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* Commodity title — Display Small (36sp) adapted to fit */
.dh-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.01em;
  color: var(--md-on-surface);
}
/* MD3 Body Medium */
.dh-desc {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.25px;
  color: var(--md-on-surface-variant);
  margin-top: 6px;
  max-width: 640px;
  line-height: 1.65;
}

/* MD3 Filled Card — shape-medium, surface-variant bg */
.chokepoint-box {
  background: var(--md-primary);
  color: var(--md-on-primary);
  padding: 12px 16px;
  flex-shrink: 0;
  min-width: 180px;
  border-radius: var(--shape-medium);
}
.cp-label {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.7;
}
.cp-country {
  font-family: 'Roboto', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}
.cp-pct {
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  letter-spacing: 0.4px;
  opacity: 0.7;
  margin-top: 2px;
}

/* ── MD3 Primary Tabs ────────────────────────────────────────────────────── */
/* Spec: 48dp height, 3dp indicator, on-surface-variant inactive, on-surface active */
.dh-tabs {
  display: flex;
  margin-top: 12px;
  border-bottom: 1px solid var(--md-outline-variant);
}
.tab-btn {
  height: 48px;
  padding: 0 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--md-on-surface-variant);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s, background 0.1s;
  border-radius: var(--shape-extra-small) var(--shape-extra-small) 0 0;
  position: relative;
}
.tab-btn:hover { background: var(--state-hover); color: var(--md-on-surface); }
.tab-btn.active { color: var(--md-on-surface); border-bottom-color: var(--md-primary); }

/* ── Panels ──────────────────────────────────────────────────────────────── */
.two-panel { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; overflow: hidden; }
.panel { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; background: var(--md-surface); }
.panel + .panel { border-left: 1px solid var(--md-outline-variant); }

/* MD3 Label Medium */
.panel-label {
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--md-outline-variant);
  flex-shrink: 0;
}

/* Treemap — MD3 shape-medium container */
.treemap { flex: 1; min-height: 180px; overflow-y: auto; padding-top: 4px; }

/* ── Production share: Number-forward hero + bar list ─────────────────────── */
.hb-hero-wrap {
  padding: 4px 0 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--md-outline-variant);
}
.hb-hero-top {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 10px;
}
.hb-hero-num {
  font-family: 'Libre Baskerville', serif;
  font-size: 4.2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}
.hb-hero-pct-sign {
  font-family: 'Roboto Mono', monospace;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-left: 1px;
  opacity: 0.55;
  vertical-align: baseline;
}
.hb-hero-info {
  padding-bottom: 5px;
  flex: 1;
  min-width: 0;
}
.hb-hero-country {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--md-on-surface);
  line-height: 1;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hb-hero-label {
  font-family: 'Libre Baskerville', serif;
  font-size: 11px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--md-on-surface-variant);
}
.hb-hero-track {
  height: 5px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-full);
  overflow: hidden;
}
.hb-hero-fill {
  height: 100%;
  border-radius: var(--shape-full);
  transition: width 0.55s cubic-bezier(0.2,0,0,1);
}

/* Remaining bar rows */
.hb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--md-outline-variant);
}
.hb-name {
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  letter-spacing: 0.25px;
  color: var(--md-on-surface-variant);
  min-width: 80px;
  flex-shrink: 0;
}
.hb-track {
  flex: 1;
  height: 6px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-full);
  overflow: hidden;
}
.hb-fill {
  height: 100%;
  border-radius: var(--shape-full);
  transition: width 0.4s cubic-bezier(0.2,0,0,1);
}
.hb-val {
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Key Data: Hero + Micro Bars ──────────────────────────────────────────── */
.fact-hero {
  padding: 10px 0 14px 14px;
  border-left: 3px solid;
  margin-bottom: 14px;
}
.fact-hero-label {
  font-family: 'Roboto', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  margin-bottom: 4px;
}
.fact-hero-val {
  font-family: 'Libre Baskerville', serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.fact-bar-row {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--md-outline-variant);
  gap: 6px;
}
.fact-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.fact-bar-key {
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  letter-spacing: 0.25px;
  color: var(--md-on-surface-variant);
}
.fact-bar-val {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface);
  white-space: nowrap;
}
.fact-micro-track {
  height: 3px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-full);
  overflow: hidden;
}
.fact-micro-fill {
  height: 100%;
  border-radius: var(--shape-full);
  opacity: 0.65;
  transition: width 0.45s cubic-bezier(0.2,0,0,1);
}

/* Risk section */
.risk-section { margin-top: 16px; }
.risk-title {
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  margin-bottom: 12px;
}
.risk-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.risk-label { font-family: 'Roboto', sans-serif; font-size: 13px; letter-spacing: 0.25px; flex: 1; min-width: 0; }
/* MD3 Linear Progress — 4dp height, ShapeFull */
.risk-bar-bg {
  flex: 2;
  height: 4px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-full);
}
.risk-bar-fill {
  height: 100%;
  border-radius: var(--shape-full);
  transition: width 0.4s cubic-bezier(0.2,0,0,1);
}
.risk-score { font-family: 'Roboto Mono', monospace; font-size: 11px; letter-spacing: 0.5px; min-width: 70px; text-align: right; }

/* MD3 Outlined Card — geo flag rows */
.geo-flag-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-medium);
  margin-bottom: 8px;
  background: var(--md-surface);
}
.geo-flag-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.geo-flag-text {
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  letter-spacing: 0.25px;
  line-height: 1.6;
  color: var(--md-on-surface);
}
.geo-flag-text strong { font-weight: 500; }

/* MD3 Assist Chips — geo tags */
/* Spec: 32dp height, ShapeFull, Label Large (14sp/500/0.1px) */
.geo-tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-right: 4px;
  margin-bottom: 4px;
  border-radius: var(--shape-full);
  border: 1px solid transparent;
}
.tag-sanction   { background:#fff3e0; color:#bf360c; border-color:#ffccbc; }
.tag-ban        { background:#fce4ec; color:#880e4f; border-color:#f48fb1; }
.tag-dispute    { background:#fffde7; color:#f57f17; border-color:#fff176; }
.tag-instability{ background:#e8eaf6; color:#283593; border-color:#9fa8da; }
.tag-climate    { background:#e8f5e9; color:#1b5e20; border-color:#a5d6a7; }

/* Sparkline */
.spark-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
/* Label Medium */
.spark-title  { font-family: 'Roboto', sans-serif; font-size: 12px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; color: var(--md-on-surface-variant); }
/* Headline Small */
.spark-val    { font-family: 'Roboto', sans-serif; font-size: 20px; font-weight: 400; color: var(--md-on-surface); }
.spark-change { font-family: 'Roboto Mono', monospace; font-size: 12px; letter-spacing: 0.5px; }
.spark-change.pos { color: var(--positive); }
.spark-change.neg { color: var(--negative); }
canvas.sparkline { width: 100%; display: block; }

/* ── Map view ────────────────────────────────────────────────────────────── */
.map-view { flex: 1; display: grid; grid-template-columns: 1fr 256px; min-height: 0; overflow: hidden; }
.map-container { position: relative; overflow: hidden; background: #dce8f0; }
.map-container svg { width: 100%; height: 100%; }
.map-legend { padding: 16px; border-left: 1px solid var(--md-outline-variant); overflow-y: auto; background: var(--md-surface-container-low); }

/* MD3 Segmented button in map legend */
.map-mode-toggle {
  display: flex;
  border: 1px solid var(--md-outline);
  border-radius: var(--shape-full);
  overflow: hidden;
  margin-bottom: 16px;
  height: 40px;
}
.mmt-btn {
  padding: 0 16px;
  background: transparent;
  border: none;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--md-on-surface);
  cursor: pointer;
  transition: background 0.1s;
  flex: 1;
  text-align: center;
}
.mmt-btn + .mmt-btn { border-left: 1px solid var(--md-outline); }
.mmt-btn:hover  { background: var(--state-hover); }
.mmt-btn.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

.map-country-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--md-outline-variant); }
.map-c-swatch { width: 10px; height: 10px; flex-shrink: 0; border-radius: var(--shape-extra-small); }
.map-c-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'Roboto', sans-serif; font-size: 13px; letter-spacing: 0.25px; }
.map-c-val { font-family: 'Roboto Mono', monospace; font-size: 12px; font-weight: 500; color: var(--md-on-surface); }

/* MD3 Tooltip / Rich Tooltip */
/* Spec: surface container, shape-small, elev-2 */
.map-tooltip {
  position: absolute;
  background: var(--md-surface-container);
  padding: 12px 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 200px;
  box-shadow: var(--elev-2);
  z-index: 10;
  border-radius: var(--shape-small);
}
.map-tooltip.vis { opacity: 1; }
.mt-name {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  margin-bottom: 8px;
  color: var(--md-on-surface);
}
.mt-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--md-outline-variant); font-family: 'Roboto', sans-serif; font-size: 13px; }
.mt-key { color: var(--md-on-surface-variant); }

/* Treemap hover tooltip */
.tree-tooltip {
  position: absolute;
  background: var(--md-surface-container);
  padding: 6px 12px;
  pointer-events: none;
  border-radius: var(--shape-small);
  box-shadow: var(--elev-2);
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--md-on-surface);
  white-space: nowrap;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.1s;
}
.tree-tooltip .tt-pct {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  margin-left: 8px;
}
.tree-tooltip.vis { opacity: 1; }

/* ── Magazine layout ──────────────────────────────────────────────────────── */

/* Detail panel — header fixed, body scrolls */
#detail-hdr { flex-shrink: 0; }
.detail-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* Placeholder (before any selection) */
.dh-placeholder { padding: 40px 32px; border-bottom: 1px solid var(--md-outline-variant); }
.dh-ph-title { font-family: 'Libre Baskerville', serif; font-size: 28px; font-weight: 700; color: var(--md-on-surface-variant); margin-bottom: 8px; }
.dh-ph-sub { font-size: 14px; color: var(--md-on-surface-variant); max-width: 500px; line-height: 1.6; }

/* Gradient header (written by JS renderHeader) */
.dh-grad { padding: 28px 24px 26px; color: #fff; }
.dh-grad-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dh-grad-cat { font-size: 10px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.65; margin-bottom: 10px; }
.dh-grad-title { font-family: 'Libre Baskerville', serif; font-size: 3.2rem; font-weight: 700; line-height: 0.95; letter-spacing: -0.03em; }
.dh-grad-right { text-align: right; flex-shrink: 0; padding-top: 2px; }
.dh-grad-cp-label { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.6; margin-bottom: 4px; }
.dh-grad-cp-country { font-family: 'Libre Baskerville', serif; font-size: 1.4rem; font-weight: 700; line-height: 1; margin-bottom: 3px; }
.dh-grad-cp-pct { font-size: 11px; opacity: 0.72; font-family: 'Roboto Mono', monospace; }
.dh-rule { height: 1px; background: rgba(255,255,255,0.18); margin-bottom: 16px; }
.dh-standfirst { font-family: 'Libre Baskerville', serif; font-size: 13.5px; line-height: 1.72; opacity: 0.88; max-width: 720px; }

/* Section label used throughout magazine sections */
.sec-label { font-size: 9px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--md-on-surface-variant); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }

/* Fact strip — inside gradient header */
.dh-fact-strip { display: flex; flex-wrap: wrap; margin: 22px -24px -26px; border-top: 1px solid rgba(255,255,255,0.15); overflow: hidden; }
.dh-fact-item { flex: 1; min-width: 130px; padding: 16px 24px; border-right: 1px solid rgba(255,255,255,0.15); }
.dh-fact-item:last-child { border-right: none; }
.dh-fact-label { font-family: 'Roboto', sans-serif; font-size: 8px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase; color: #fff; opacity: 0.58; margin-bottom: 8px; }
.dh-fact-val { font-family: 'Libre Baskerville', serif; font-size: 1.65rem; font-weight: 700; color: #fff; line-height: 1; letter-spacing: -0.025em; }

/* 3-column main content row */
.mag-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.mag-col { padding: 20px 24px; }
.mag-border-left { border-left: 1px solid var(--md-outline-variant); }
.mag-border-top { border-top: 1px solid var(--md-outline-variant); }

/* Fact rows used in price history panel */
.fact-row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--md-outline-variant); }
.fact-key { font-size: 11px; color: var(--md-on-surface-variant); letter-spacing: 0.25px; }
.fact-val { font-family: 'Roboto Mono', monospace; font-size: 11px; font-weight: 500; color: var(--md-on-surface); }

/* Geo flags strip */
.mag-flags-strip { padding: 16px 24px; }
#geo-flags { display: grid; gap: 12px; grid-template-columns: 1fr; }
.flag-card { min-width: 0; border: 1px solid var(--md-outline-variant); padding: 10px 12px; }
.flag-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.flag-tag { font-size: 9px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; padding: 2px 6px; border-radius: 1px; }
.flag-text { font-size: 11px; line-height: 1.65; color: var(--md-on-surface); }
.flag-text strong { font-weight: 600; }
/* Flag tag colors (cleaner on white background) */
.flag-tag.tag-sanction    { background: rgba(220,80,0,0.1);    color: #cc3300; }
.flag-tag.tag-ban         { background: rgba(180,0,80,0.1);    color: #aa0055; }
.flag-tag.tag-dispute     { background: rgba(74,127,165,0.12); color: #4a7fa5; }
.flag-tag.tag-instability { background: rgba(180,60,60,0.11);  color: #c04040; }
.flag-tag.tag-climate     { background: rgba(40,130,60,0.11);  color: #2d7a3a; }

/* Downstream & Market Impact section */
.mag-downstream { padding: 16px 24px 20px; }

#ds-sectors { display: grid; gap: 12px; margin-top: 20px; }
.ds-sector-card { min-width: 0; border: 1px solid var(--md-outline-variant); padding: 10px 12px; }
.ds-sector-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ds-sector-name { font-size: 12px; font-weight: 500; color: var(--md-on-surface); }
.ds-exposure { font-size: 9px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; padding: 2px 6px; border-radius: 1px; flex-shrink: 0; }
.ds-exposure.exp-critical { background: rgba(220,80,0,0.1);    color: #cc3300; }
.ds-exposure.exp-high     { background: rgba(180,100,0,0.12);  color: #a05000; }
.ds-exposure.exp-medium   { background: rgba(74,127,165,0.12); color: #4a7fa5; }
.ds-sector-note { font-size: 11px; color: var(--md-on-surface-variant); line-height: 1.55; }

/* Map section */
.mag-map-section { padding: 20px 24px 24px; }
.mag-map-controls { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.mag-map-label { flex: 1; margin-bottom: 0 !important; }
/* Magazine-style mode buttons (override mmt-btn within controls) */
.mag-map-controls .mmt-btn {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--md-outline-variant);
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  border-radius: 1px;
  height: auto;
  letter-spacing: 0.02em;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex: unset;
}
.mag-map-controls .mmt-btn + .mmt-btn { border-left: 1px solid var(--md-outline-variant); }
.mag-map-controls .mmt-btn.active { background: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); }
.mag-map-controls .mmt-btn:hover:not(.active) { color: var(--md-on-surface); border-color: var(--md-outline); }

/* Map container and SVG in magazine layout */
.mag-map-container { position: relative; width: 100%; background: #dce8f0; }
.mag-map-container svg { width: 100%; height: auto; display: block; }

/* Country legend chips below map */
.mag-country-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.map-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 5px; border: 1px solid var(--md-outline-variant); font-size: 11px; line-height: 1; }
.map-chip-swatch { width: 8px; height: 8px; flex-shrink: 0; border-radius: 1px; }
.map-chip-name { color: var(--md-on-surface); letter-spacing: 0.1px; }
.map-chip-val { font-family: 'Roboto Mono', monospace; font-size: 10px; font-weight: 500; color: var(--md-on-surface-variant); margin-left: 1px; }

/* Detail footer */
.detail-footer {
  padding: 10px 24px 14px;
  font-size: 10px;
  color: var(--md-on-surface-variant);
  opacity: 0.55;
  border-top: 1px solid var(--md-outline-variant);
  line-height: 1.6;
  letter-spacing: 0.02em;
}

/* ── Source links (inline ↗ on section headers) ───────────────────────────── */
.src-link {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--md-outline);
  text-decoration: none;
  line-height: 1;
  transition: color 0.15s;
  margin-left: 2px;
}
.src-link:hover { color: var(--md-primary); }

/* ── Sources strip (Option A) ─────────────────────────────────────────────── */
.mag-sources-section {
  padding: 16px 24px 20px;
}
#sources-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 4px;
}
@media (max-width: 900px) {
  #sources-strip { grid-template-columns: repeat(2, 1fr); }
}
.sources-card {
  border: 1px solid var(--md-outline-variant);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sources-card-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--md-on-surface-variant);
  margin-bottom: 2px;
}
.sources-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-on-surface);
  text-decoration: none;
  line-height: 1.35;
}
.sources-card-name:hover { color: var(--md-primary); text-decoration: underline; }
.sources-card-extra { margin-top: 2px; }
.sources-pdf-link {
  font-size: 11px;
  color: var(--md-primary);
  text-decoration: none;
}
.sources-pdf-link:hover { text-decoration: underline; }
.sources-card-note {
  font-size: 11px;
  color: var(--md-on-surface-variant);
  line-height: 1.5;
  margin-top: 1px;
}

/* ── Sidebar redesign ─────────────────────────────────────────────────────── */

/* Sidebar is now a flex column — only list-body scrolls */
.commodity-list {
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#list-body { flex: 1; overflow-y: auto; }

/* Masthead */
.masthead { padding: 20px 20px 16px; border-bottom: 1px solid var(--md-outline-variant); flex-shrink: 0; }
.masthead-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 5px;
}
.masthead-title em {
  font-style: normal;
  display: inline-block;
  background: linear-gradient(120deg, #f8d888 0%, #f0a500 55%, #c47800 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.masthead-sub { font-size: 10px; color: var(--md-on-surface-variant); letter-spacing: 0.03em; line-height: 1.45; }

/* Search — override sticky positioning, use straight border */
.list-search { position: static; background: #ffffff; border-bottom: 1px solid var(--md-outline-variant); }
.list-search input {
  background: rgba(22,15,2,0.04);
  border: 1px solid rgba(22,15,2,0.1);
  border-radius: 2px;
}
.list-search input:focus { border-color: rgba(22,15,2,0.28); }

/* Category filter pills */
.sidebar-filters {
  display: flex;
  gap: 4px;
  padding: 9px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--md-outline-variant);
  flex-wrap: wrap;
}
/* Override MD3 cat-btn completely */
.sidebar-filters .cat-btn {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 8px;
  height: auto;
  background: transparent;
  border: 1px solid var(--md-outline-variant);
  border-radius: 1px;
  color: var(--md-on-surface-variant);
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.sidebar-filters .cat-btn::after { display: none; }
.sidebar-filters .cat-btn:hover { color: var(--md-on-surface); border-color: var(--md-outline); background: transparent; }
.sidebar-filters .cat-btn.active { background: #1c1b1f; border-color: #1c1b1f; color: #ffffff; }

/* Cat header sticky bg + position reset */
.cat-header { background: #ffffff; top: 0; }

/* List items — square, full-width, amber left border on active */
.c-item { border-radius: 0; margin: 0; padding: 0 14px 0 17px; height: 46px; border-left: 3px solid transparent; }
.c-item:hover::after { display: none; }
.c-item:hover { background: rgba(22,15,2,0.04); }
.c-item.active { background: rgba(22,15,2,0.05); border-left-color: #f0a500; }
.c-item.active .c-name { color: var(--md-on-surface); }
.c-item.active .c-pct { color: var(--md-on-surface-variant); }

.hidden { display: none !important; }
