/* Breakout Vietnam — Trade & Travel Week interactive chart-window map component */

.mapbox {
  position: relative;
  margin-top: 14px;
  border: 1px solid var(--line, #1f2836);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg2, #0e121a);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

/* Top bar ("chart window" header) */
.tm-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 6px 12px;
  background: var(--bg2, #0e121a);
  border-bottom: 1px solid var(--line, #1f2836);
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 12px;
}

.tm-top-l {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.tm-sym {
  font-weight: 700;
  color: var(--text, #e3e8f0);
  letter-spacing: -0.2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tm-sym::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--green, #26d07c));
  box-shadow: 0 0 0 3px rgba(38, 208, 124, 0.16);
  flex: none;
}

.tm-sep {
  color: var(--dim, #717d91);
}

.tm-ticker {
  color: var(--c, var(--green, #26d07c));
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-tf {
  display: inline-grid;
  grid-template-columns: auto auto;
  background: var(--bg, #0a0d13);
  border: 1px solid var(--line, #1f2836);
  border-radius: 6px;
  padding: 2px;
  flex: none;
}

.tm-tf button {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted, #949fb2);
  cursor: pointer;
  line-height: 1.2;
}

.tm-tf button:hover {
  color: var(--text, #e3e8f0);
}

.tm-tf button[aria-pressed="true"] {
  background: var(--panel2, #171f2c);
  color: var(--text, #e3e8f0);
  box-shadow: inset 0 0 0 1px var(--line, #1f2836);
}

/* Map body (light paper-like canvas) */
.tm-stage {
  position: relative;
  height: 420px;
  background: #f5f7fa;
  color: #1e2530;
  overflow: hidden;
  user-select: none;
}

.tm-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Subtle trading-chart grid overlay on the light map */
.tm-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(91, 101, 118, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 101, 118, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  z-index: 1;
}

/* Bottom bar (measure readout + day stepper) */
.tm-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 6px 12px;
  background: var(--bg2, #0e121a);
  border-top: 1px solid var(--line, #1f2836);
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 12px;
}

.tm-measure {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted, #949fb2);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-measure b {
  color: var(--text, #e3e8f0);
  font-weight: 600;
}

.tm-measure .tm-delta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--c, var(--green, #26d07c));
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tm-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.tm-step {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text, #e3e8f0);
  background: var(--panel, #121823);
  border: 1px solid var(--line, #1f2836);
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  line-height: 1.2;
  transition: border-color 0.15s, background-color 0.15s;
}

.tm-step:hover:not(:disabled) {
  background: var(--panel2, #171f2c);
  border-color: var(--dim, #717d91);
}

.tm-step:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* Markers (real <button> elements) */
.tm-pin {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  outline: none;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

/* MapLibre positions markers with transform on an absolutely positioned element;
   .tm-pin's position:relative must not override that, or markers stack inline and drift. */
.maplibregl-marker.tm-pin,
.maplibregl-marker.tm-chip {
  position: absolute;
}

/* BASE marker: gold rounded tag ★ BASE with dark text + pulse ring */
.tm-pin-base {
  background: #f5c249;
  color: #141004;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1.5px solid #ffffff;
  box-shadow: 0 2px 8px rgba(10, 13, 19, 0.25);
  white-space: nowrap;
  z-index: 3;
}

.tm-pin-base::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 1.5px solid #f5c249;
  opacity: 0.65;
  animation: tm-pulse 2.2s ease-out infinite;
  pointer-events: none;
}

@keyframes tm-pulse {
  0% { transform: scale(0.92); opacity: 0.75; }
  75% { transform: scale(1.28); opacity: 0; }
  100% { transform: scale(1.28); opacity: 0; }
}

/* Day marker dot (12px default, 18px active) */
.tm-pin-day {
  width: 24px;
  height: 24px;
}

.tm-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c, #26d07c);
  color: #06110b;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(10, 13, 19, 0.28);
  transition: width 0.18s ease, height 0.18s ease, font-size 0.18s ease, box-shadow 0.18s ease;
}

.tm-pin-day.is-active {
  z-index: 6;
}

.tm-pin-day:hover,
.tm-pin-day:focus-visible {
  z-index: 7;
}

.tm-pin-day.is-active .tm-dot {
  width: 20px;
  height: 20px;
  font-size: 10.5px;
  box-shadow: 0 0 0 3px rgba(10, 13, 19, 0.16), 0 3px 10px rgba(10, 13, 19, 0.35);
}

.tm-pin:focus-visible .tm-dot,
.tm-pin-base:focus-visible {
  outline: 2px solid #0a0d13;
  outline-offset: 2px;
}

/* Price-label-style tag next to active/hovered dot */
.tm-tag {
  position: absolute;
  left: calc(50% + 13px);
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 5px;
  background: #0a0d13;
  color: #ffffff;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(10, 13, 19, 0.32);
  pointer-events: none;
}

/* Small arrow pointing to the dot */
.tm-tag::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 50%;
  margin-top: -4px;
  border-width: 4px 4px 4px 0;
  border-style: solid;
  border-color: transparent #0a0d13 transparent transparent;
}

.tm-tag i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c, #26d07c);
  display: inline-block;
}

/* Flip tag to left side when near right edge */
.tm-pin-day.is-flip .tm-tag {
  left: auto;
  right: calc(50% + 13px);
}

.tm-pin-day.is-flip .tm-tag::before {
  left: auto;
  right: -4px;
  border-width: 4px 0 4px 4px;
  border-color: transparent transparent transparent #0a0d13;
}

.tm-pin-day.is-active .tm-tag,
.tm-pin-day:hover .tm-tag,
.tm-pin-day:focus-visible .tm-tag {
  display: inline-flex;
}

/* Tiny tooltip with place description on hover (desktop) */
.tm-desc {
  position: absolute;
  left: calc(50% + 13px);
  top: calc(50% + 16px);
  display: none;
  background: rgba(10, 13, 19, 0.92);
  color: #d5dce7;
  font-family: var(--body, Inter, sans-serif);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(10, 13, 19, 0.22);
}

.tm-pin-day.is-flip .tm-desc {
  left: auto;
  right: calc(50% + 13px);
}

@media (hover: hover) and (pointer: fine) {
  .tm-pin-day:hover .tm-desc,
  .tm-pin-day:focus-visible .tm-desc {
    display: block;
  }
}

/* Midpoint measure chip on the route arc */
.tm-chip {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  font-weight: 600;
  color: #1e2530;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cbd3df;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(10, 13, 19, 0.14);
  pointer-events: none;
  z-index: 4;
}

/* MapLibre attribution & cooperative gesture styling */
.tm-stage .maplibregl-ctrl-bottom-right {
  z-index: 3;
}

.tm-stage .maplibregl-ctrl-attrib {
  background: rgba(245, 247, 250, 0.85) !important;
  color: #4a5363 !important;
  font-family: var(--body, Inter, sans-serif);
  font-size: 10px !important;
  line-height: 1.3 !important;
  padding: 2px 6px !important;
  border-radius: 4px 0 0 0;
  box-shadow: none !important;
}

.tm-stage .maplibregl-ctrl-attrib a {
  color: #363f4d !important;
}

.tm-stage .maplibregl-compact-show,
.tm-stage .maplibregl-ctrl-attrib-button {
  display: none !important;
}

/* SVG Fallback schematic */
.tm-svg-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #d8e6f2;
  overflow: hidden;
}

.tm-svg-bg {
  width: 100%;
  height: 100%;
  display: block;
}

.tm-svg-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tm-svg-pins .tm-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.tm-svg-pins .tm-chip {
  position: absolute;
  transform: translate(-50%, -50%);
}

.tm-svg-attrib {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 3;
  background: rgba(245, 247, 250, 0.88);
  color: #4a5363;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px 0 0 0;
}

/* Responsive mobile rules */
@media (max-width: 700px) {
  .tm-stage {
    height: 340px;
  }
  .tm-top {
    padding: 6px 10px;
    font-size: 11px;
  }
  .tm-bot {
    padding: 6px 10px;
    font-size: 11px;
  }
  .tm-measure .tm-from {
    display: none;
  }
  .tm-step {
    padding: 4px 7px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tm-pin-base::before {
    animation: none;
  }
  .tm-dot {
    transition: none;
  }
}
