/* Bright theme built on the ReAtlas logo: navy #132B55, teal #0BADBF, off-white #F7F9F8 */
:root {
  --navy: #132B55;
  --navy-2: #1e3d74;
  --teal: #0BADBF;
  --teal-2: #7fe3ee;
  --teal-50: #e7f8fa;
  --fx: var(--teal);
  --accent: #FF6B8B;
  --ink: #0f2147;
  --ink-2: #5b6d88;
  --ink-3: #93a3b8;
  --surface: rgba(255, 255, 255, 0.94);
  --line: rgba(19, 43, 85, 0.08);
  --radius: 24px;
  --shadow: 0 1px 2px rgba(19, 43, 85, 0.06), 0 22px 48px -22px rgba(19, 43, 85, 0.35);
  --display: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--ink); background: #eef6f8; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Static backdrop (no per-frame work): soft aurora + dot grid, darker for the night style */
.backdrop {
  position: fixed; inset: 0;
  background:
    radial-gradient(55% 45% at 12% 8%, rgba(11, 173, 191, 0.22), transparent 70%),
    radial-gradient(45% 40% at 92% 92%, rgba(255, 107, 139, 0.14), transparent 70%),
    radial-gradient(40% 40% at 50% 50%, #ffffff, transparent 75%),
    linear-gradient(180deg, #f5fafc, #e3f0f5);
}
.backdrop::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(19, 43, 85, 0.12) 1px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 35%, #000 80%);
  mask-image: radial-gradient(ellipse at center, transparent 35%, #000 80%);
}
.backdrop::after {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 0.8s ease;
  background: radial-gradient(60% 60% at 50% 50%, #1b3a70, #0a1631 70%, #060e22);
}
body[data-style='night'] .backdrop::after { opacity: 1; }
body[data-style='night'] .wordmark b { color: #fff; }

#globe { position: fixed; inset: 0; }

/* Loader */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 18px; background: linear-gradient(180deg, #f5fafc, #e3f0f5); font-weight: 600; color: var(--ink-2); }
.loader img { width: 84px; height: 84px; border-radius: 50%; box-shadow: 0 0 0 10px rgba(11, 173, 191, 0.12), 0 20px 50px -10px rgba(11, 173, 191, 0.6); animation: breathe 1.6s ease-in-out infinite; }
.loader.error span { color: #c23a5c; }
@keyframes breathe { 50% { transform: scale(1.08); } }

/* Brand */
.brand { position: fixed; top: 20px; left: 24px; z-index: 6; display: flex; align-items: center; gap: 12px; }
.brand img { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 8px 24px -8px rgba(11, 173, 191, 0.7); }
.wordmark { font-family: 'Montserrat', var(--display); font-weight: 800; font-size: 27px; letter-spacing: -0.3px; color: var(--teal); }
.wordmark b { color: var(--navy); font-weight: 800; transition: color 0.6s; }

/* Shared pill navs with a sliding highlight (GSAP moves .glider) */
.styles, .dock {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid #fff; border-radius: 999px; box-shadow: var(--shadow);
}
.styles { top: 20px; }
.dock { bottom: 24px; }
.glider { position: absolute; left: 0; top: 0; border-radius: 999px; opacity: 0; pointer-events: none; z-index: 0; }
.styles .glider { background: linear-gradient(135deg, #12c3d6, #0a8fa7); box-shadow: 0 8px 20px -8px rgba(11, 173, 191, 0.9); }
.dock .glider { background: linear-gradient(135deg, var(--navy-2), var(--navy)); box-shadow: 0 8px 22px -8px rgba(19, 43, 85, 0.8); }

.style-btn, .dock-btn {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: color 0.25s, background 0.25s, transform 0.2s;
}
@media (max-width: 1240px) and (min-width: 901px) { .dock-btn span { display: none; } .dock-btn { padding: 10px 12px; } }
.style-btn { padding: 8px 14px; font-size: 12.5px; }
.style-btn:hover, .dock-btn:hover { color: var(--ink); background: rgba(19, 43, 85, 0.05); }
.style-btn:active, .dock-btn:active { transform: scale(0.95); }
.style-btn.active, .dock-btn.active { color: #fff; background: transparent; }
.dock-btn.icon { padding: 10px; }
.dock-btn[aria-pressed='true'] { color: var(--teal); }
#spinBtn[aria-pressed='true'] .lucide { animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dock-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.mobile-only { display: none; }

/* Panels */
.panel { position: fixed; z-index: 5; background: var(--surface); border: 1px solid #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
body:not(.lite) .panel, body:not(.lite) .styles, body:not(.lite) .dock { background: rgba(255, 255, 255, 0.78); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4); }
.panel.left { top: 86px; left: 24px; width: 330px; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.panel.right { top: 86px; right: 24px; bottom: 24px; width: 320px; padding: 18px 12px 12px; display: flex; flex-direction: column; }

.eyebrow { margin: 0 0 10px; font-size: 10.5px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; color: var(--ink-3); }

/* Report chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.chip .lucide { width: 15px; height: 15px; }
.chip:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -12px rgba(19, 43, 85, 0.5); }
.chip.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--navy-2), var(--navy)); box-shadow: 0 10px 24px -10px rgba(19, 43, 85, 0.7), 0 0 0 3px rgba(11, 173, 191, 0.25); }
.chip.active .lucide { color: var(--accent); fill: var(--accent); }
.chip.soon { color: var(--ink-3); border-style: dashed; background: transparent; }
.chip small { font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--teal-50); color: #0a8fa7; letter-spacing: 0.8px; text-transform: uppercase; }

/* Report info */
.info h1 { margin: 0; font-family: var(--display); font-size: 25px; font-weight: 800; line-height: 1.1; letter-spacing: -0.6px; color: var(--navy); }
.info p { margin: 8px 0 16px; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 11px 10px; border-radius: 16px; background: var(--teal-50); }
.stat:nth-child(2) { background: #eef2fb; }
.stat:nth-child(3) { background: #fff0f3; }
.stat b { display: block; font-family: var(--display); font-size: 19px; font-weight: 800; color: var(--navy); letter-spacing: -0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 10px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.8px; }

.ticker { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 18px; background: linear-gradient(135deg, #e3f7fa, #fff0f3); }
.ticker-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 12px; background: #fff; color: var(--accent); box-shadow: 0 6px 14px -8px rgba(255, 107, 139, 0.8); }
.ticker-icon .lucide { fill: var(--accent); animation: beat 1.4s ease-in-out infinite; }
.ticker p { margin: 0; font-size: 13px; font-weight: 500; line-height: 1.5; color: var(--ink); }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }

/* Ranking list */
.rank-head { padding: 0 6px 12px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 14px; background: #f1f6f9; border: 1px solid transparent; color: var(--ink-3); transition: border-color 0.2s, box-shadow 0.2s; }
.search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(11, 173, 191, 0.15); background: #fff; }
#search { flex: 1; min-width: 0; padding: 10px 0; border: 0; background: transparent; outline: none; font-size: 13px; color: var(--ink); }
.rank-list { list-style: none; margin: 0; padding: 0 2px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(19, 43, 85, 0.2) transparent; }
.rank-list li {
  display: grid; grid-template-columns: 36px 1fr auto; grid-template-rows: auto 5px; column-gap: 10px; row-gap: 5px;
  align-items: center; padding: 9px 8px; border-radius: 14px; cursor: pointer; transition: background 0.2s, transform 0.2s;
}
.rank-list li:hover { background: #f1f6f9; transform: translateX(-2px); }
.rank-list li.active { background: var(--teal-50); box-shadow: inset 3px 0 0 var(--teal); }
.rank-list .r { grid-row: span 2; display: grid; place-items: center; height: 30px; border-radius: 10px; font-family: var(--display); font-weight: 800; font-size: 12.5px; color: var(--ink-2); background: #f1f6f9; }
.rank-list li:nth-child(1) .r { color: #fff; background: linear-gradient(135deg, var(--navy-2), var(--navy)); }
.rank-list li:nth-child(2) .r, .rank-list li:nth-child(3) .r { color: #fff; background: linear-gradient(135deg, #12c3d6, #0a8fa7); }
.rank-list .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-list .v { font-family: var(--display); font-size: 13px; font-weight: 700; color: var(--navy); }
.rank-list .bar { grid-column: 2 / 4; height: 5px; border-radius: 5px; background: #edf2f6; overflow: hidden; }
.rank-list .bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #7fe3ee, var(--teal), var(--navy)); }
.source { margin: 10px 6px 0; font-size: 10px; color: var(--ink-3); line-height: 1.4; }

/* Detail card */
.detail {
  position: fixed; left: 24px; bottom: 24px; width: 330px; z-index: 7; max-height: calc(100vh - 300px); overflow-y: auto; scrollbar-width: thin;
  background: #fff; border-radius: var(--radius); box-shadow: 0 30px 60px -24px rgba(19, 43, 85, 0.5), 0 0 0 1px rgba(19, 43, 85, 0.05);
}
.dc-head {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, rgba(127, 227, 238, 0.55), transparent 50%), linear-gradient(135deg, var(--navy), #0a7f9c);
}
.dc-rank { min-width: 50px; height: 50px; padding: 0 8px; display: grid; place-items: center; border-radius: 16px; background: #fff; color: var(--navy); font-family: var(--display); font-weight: 800; font-size: 18px; box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.5); }
.dc-head h3 { margin: 0 0 4px; font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, 0.2); }
.close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; color: #fff; background: rgba(255, 255, 255, 0.15); transition: background 0.2s, transform 0.2s; }
.close:hover { background: rgba(255, 255, 255, 0.3); transform: rotate(90deg); }
.dc-body { padding: 16px 18px 18px; }
.dc-value { margin: 0; font-family: var(--display); font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -1.5px; color: var(--navy); }
.dc-value span { font-size: 22px; color: var(--teal); margin-left: 2px; }
.dc-label { margin: 4px 0 14px; font-size: 12px; color: var(--ink-2); }
.cmp { display: grid; grid-template-columns: 84px 1fr 46px; gap: 8px; align-items: center; font-size: 11.5px; color: var(--ink-2); }
.cmp > span:nth-child(3n+1) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp .track { height: 8px; border-radius: 6px; background: #edf2f6; overflow: hidden; }
.cmp .track i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--teal), #0a7f9c); }
.cmp .track.dim i { background: #b9c6d6; }
.cmp b { text-align: right; font-weight: 700; color: var(--ink); }
.multiple { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: #f1f6f9; font-size: 13px; font-weight: 600; }
.multiple em { font-style: normal; font-family: var(--display); font-weight: 800; color: var(--accent); }
.split { margin-top: 14px; }
.split-title { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.split-bar { display: flex; gap: 3px; height: 12px; }
.split-bar i { border-radius: 4px; }
.split-key { display: flex; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--ink-2); flex-wrap: wrap; }
.split-key span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; background: var(--c); }
.split-key b { color: var(--ink); }
.note { display: flex; gap: 10px; margin: 14px 0 0; padding: 12px; border-radius: 14px; font-size: 12.5px; line-height: 1.5; background: #fff0f3; color: #7a2a40; }
.note .lucide { width: 16px; height: 16px; color: var(--accent); margin-top: 2px; }
body.has-detail .panel.left .ticker, body.has-detail .panel.left .info { display: none; }

/* Legend */
.legend { margin: 10px 6px 0; padding: 10px 12px; border-radius: 14px; background: #f1f6f9; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.legend .grad { height: 8px; border-radius: 6px; margin: 6px 0 4px; }
.legend .ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); }

/* Tour progress */
.tour-bar { position: fixed; top: 82px; left: 50%; transform: translateX(-50%); z-index: 6; min-width: 280px; padding: 10px 20px; text-align: center; border-radius: 999px; background: var(--navy); color: #fff; box-shadow: var(--shadow); font-size: 12px; font-weight: 700; letter-spacing: 0.6px; }
.tour-progress { margin-top: 7px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.tour-progress i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--teal), var(--accent)); }

/* Hover tooltip (moved with transform only) */
.tip { position: fixed; left: 0; top: 0; z-index: 8; pointer-events: none; padding: 9px 13px; border-radius: 12px; background: #fff; box-shadow: 0 12px 30px -12px rgba(19, 43, 85, 0.45); font-size: 12px; color: var(--ink-2); will-change: transform; }
.tip b { display: block; font-family: var(--display); font-size: 14px; color: var(--navy); }
.tip em { font-style: normal; font-weight: 700; color: var(--teal); }
.tip .muted { color: var(--ink-3); }

/* Library theming: Tippy tooltips + Notyf toasts */
.tippy-box[data-theme~='reatlas'] { background: var(--navy); color: #fff; border-radius: 10px; font-size: 12px; font-weight: 600; box-shadow: 0 10px 24px -10px rgba(19, 43, 85, 0.7); }
.tippy-box[data-theme~='reatlas'][data-placement^='top'] > .tippy-arrow::before { border-top-color: var(--navy); }
.tippy-box[data-theme~='reatlas'][data-placement^='bottom'] > .tippy-arrow::before { border-bottom-color: var(--navy); }
.notyf__toast { border-radius: 16px !important; max-width: 420px !important; box-shadow: 0 20px 40px -18px rgba(19, 43, 85, 0.7) !important; }
.notyf__wrapper { padding: 14px 6px !important; }
.notyf__message { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 600; font-size: 13px; }
.notyf__ripple { background: linear-gradient(135deg, var(--navy), #0a7f9c) !important; }

/* ---------- Globe markers (HTML overlays from globe.gl). Animate transform/opacity only. ---------- */
.marker { position: relative; width: 0; height: 0; pointer-events: none; }
.pin {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  width: var(--s, 25px); height: var(--s, 25px); border-radius: 50%; border: 2px solid #fff; cursor: pointer; pointer-events: auto;
  display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 11px; color: #fff;
  background: linear-gradient(135deg, var(--navy-2), var(--navy)); box-shadow: 0 4px 12px -2px rgba(19, 43, 85, 0.6);
  transition: transform 0.2s;
}
.pin::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--fx); animation: ping 2.2s ease-out infinite; }
.pin:hover, .marker.selected .pin { transform: translate(-50%, -50%) scale(1.22); }
.marker.selected .pin { background: linear-gradient(135deg, #ff8aa3, var(--accent)); }
@keyframes ping { from { transform: scale(1); opacity: 0.9; } to { transform: scale(2.1); opacity: 0; } }
.tag {
  position: absolute; left: 0; top: calc(var(--s, 25px) / 2 + 6px); transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  padding: 3px 9px; border-radius: 99px; background: #fff; color: var(--navy); font-size: 10.5px; font-weight: 700; box-shadow: 0 4px 10px -4px rgba(19, 43, 85, 0.45);
}
.particles i { position: absolute; left: 0; top: 0; opacity: 0; color: var(--accent); pointer-events: none; }
.particles svg { width: 13px; height: 13px; fill: currentColor; display: block; }

/* FX preset "rise": icons float up from the marker. Add .fx-<name> presets for new topics. */
.fx-rise .particles i { animation: fx-rise 3s ease-out infinite; animation-delay: calc(var(--k) * 1s); }
@keyframes fx-rise {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), -60px) scale(1.1) rotate(var(--rot)); opacity: 0; }
}
.marker.burst .particles i { animation-duration: 1.4s; }

.cont-label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); pointer-events: none;
  display: grid; justify-items: center; padding: 10px 16px; border-radius: 18px; white-space: nowrap;
  background: #fff; box-shadow: 0 14px 30px -14px rgba(19, 43, 85, 0.6), 0 0 0 3px rgba(11, 173, 191, 0.25);
  animation: float 4s ease-in-out infinite; animation-delay: calc(var(--i) * -0.7s);
}
.cont-label .cr { font-size: 10px; font-weight: 800; color: var(--accent); letter-spacing: 1px; }
.cont-label .cn { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.cont-label .cv { font-family: var(--display); font-size: 22px; font-weight: 800; color: var(--navy); }
@keyframes float { 50% { transform: translate(-50%, calc(-50% - 8px)); } }

/* Lite mode: drop the per-frame extras */
.lite .particles, .lite .pin::after { display: none; }
.lite .cont-label { animation: none; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .brand { top: 14px; left: 16px; }
  .brand img { width: 36px; height: 36px; }
  .wordmark { font-size: 21px; }
  .styles { top: 12px; left: auto; right: 16px; transform: none; }
  .style-btn span { display: none; }
  .style-btn { padding: 8px; }
  .panel.left { top: 64px; left: 16px; right: 16px; width: auto; padding: 12px 14px; gap: 10px; }
  .panel.left .info p, .panel.left .ticker, .panel.left .picker .eyebrow { display: none; }
  .info h1 { font-size: 17px; margin-bottom: 8px; }
  .stat { padding: 7px 9px; }
  .stat b { font-size: 15px; }
  .panel.right { top: auto; left: 16px; right: 16px; bottom: 86px; width: auto; height: 55vh; transform: translateY(120%); opacity: 0; transition: transform 0.35s, opacity 0.35s; }
  body.list-open .panel.right { transform: none; opacity: 1; }
  .detail { left: 16px; right: 16px; bottom: 86px; width: auto; max-height: 50vh; }
  .dock { bottom: 16px; max-width: calc(100% - 32px); }
  .dock-btn span { display: none; }
  .dock-btn { padding: 10px; }
  .mobile-only { display: flex; }
  .tour-bar { top: auto; bottom: 80px; min-width: 0; width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
