/* ===== Biểu đồ đua GDP ASEAN — bar chart race ===== */
.race-wrap { max-width: 1200px; }

.race-card { position: relative; overflow: hidden; }

.race-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 6px;
}
.race-head h2 { color: var(--red-dark); font-size: clamp(18px, 2.6vw, 27px); line-height: 1.1; }
.race-head .cap { color: var(--muted); font-size: 13px; margin-top: 3px; }
.vn-hint {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, rgba(218,41,28,.08), rgba(255,205,0,.16));
  border: 1px solid rgba(218,37,29,.28); color: var(--red-dark);
  font-weight: 800; font-size: 13px; padding: 6px 12px; border-radius: 999px;
}
.vn-star { color: var(--gold-deep); }

/* ---- Vùng vẽ ---- */
.chart {
  position: relative;
  height: clamp(380px, 64vh, 680px);
  margin: 8px 0 2px;
}
.race-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* Số năm lớn chạy nền */
.year-big {
  position: absolute; right: 6px; bottom: -6px; z-index: 0;
  font-weight: 900; font-variant-numeric: tabular-nums;
  font-size: clamp(66px, 17vh, 156px); line-height: .82; letter-spacing: -3px;
  color: rgba(218, 37, 29, .12); pointer-events: none; user-select: none;
}

/* ---- Mỗi thanh (một nước) ---- */
.bar-row {
  position: absolute; left: 0; right: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  transition: transform .5s cubic-bezier(.34, .01, .2, 1);
  will-change: transform;
}
.bar-row.no-anim { transition: none; }
.bar-row.hidden-row { opacity: 0; pointer-events: none; }

.bar-label {
  flex: 0 0 auto; width: clamp(84px, 21%, 190px);
  display: flex; align-items: center; justify-content: flex-end; gap: 7px;
  text-align: right; overflow: hidden;
}
.bar-label .nm {
  font-weight: 700; font-size: clamp(12px, 1.55vw, 18px); color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flag {
  flex: 0 0 auto; width: 28px; height: 19px; border-radius: 3px; display: block;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .16), 0 1px 2px rgba(0, 0, 0, .18);
}

.bar-track { position: relative; flex: 1; height: 70%; min-width: 0; }
.bar-fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0;
  border-radius: 5px; box-shadow: 0 1px 3px rgba(90, 20, 15, .14);
}
.bar-value {
  position: absolute; top: 50%; transform: translateY(-50%); left: 0;
  font-weight: 800; font-variant-numeric: tabular-nums;
  font-size: clamp(12px, 1.5vw, 18px); color: var(--ink); white-space: nowrap;
}

/* Tô đậm Việt Nam */
.bar-row.vn .nm { color: var(--red); font-weight: 900; }
.bar-row.vn .bar-value { color: var(--red-dark); font-weight: 900; }
.bar-row.vn .bar-fill { box-shadow: 0 0 0 2px var(--gold), 0 3px 10px rgba(218, 37, 29, .38); }
.bar-row.vn .flag { box-shadow: inset 0 0 0 1px rgba(0,0,0,.16), 0 0 0 2px rgba(242,183,5,.7); }

/* ---- Điều khiển ---- */
.race-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.spd { display: inline-flex; gap: 4px; }
.spd-btn.active {
  background: linear-gradient(180deg, #ffd23f, var(--gold)); color: #3a2600;
  border-color: transparent; box-shadow: 0 3px 0 var(--gold-deep);
}
.scrub { flex: 1 1 180px; min-width: 150px; height: 8px; accent-color: var(--red); cursor: pointer; }
#scrubYear { font-variant-numeric: tabular-nums; }

.src { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ---- Máy chiếu (màn lớn): thanh dày hơn, chữ to ---- */
@media (min-width: 1100px) {
  .chart { height: clamp(440px, 66vh, 720px); }
  .bar-label .nm, .bar-value { font-size: 19px; }
  .flag { width: 32px; height: 21px; }
}

/* ---- Điện thoại ---- */
@media (max-width: 600px) {
  .chart { height: 60vh; min-height: 340px; }
  .bar-label { width: clamp(64px, 30%, 120px); gap: 5px; }
  .bar-label .nm { font-size: 12px; }
  .flag { width: 22px; height: 15px; }
  .year-big { font-size: clamp(48px, 14vh, 90px); }
  .race-head .cap { font-size: 12px; }
  .vn-hint { font-size: 12px; padding: 5px 10px; }
  .race-controls { gap: 6px; }
  .scrub { flex-basis: 100%; order: 5; }
}
