/* ============================================================
   DATALOGIC MEMOR 12 — FEATURE EXPLORER
   Giao diện tối, kính mờ, phát sáng (chuyển thể từ product-3d gốc)
   ============================================================ */

:root {
  --bg-0: #030a0c;
  --bg-1: #07171b;
  --bg-2: #0a2228;
  --panel: rgba(10, 30, 34, 0.72);
  --panel-border: rgba(140, 220, 220, 0.14);
  --panel-border-strong: rgba(140, 220, 220, 0.28);
  --text: #e8f4f2;
  --text-dim: #8fb0ad;
  --text-faint: #5a7a78;
  --accent: #6fe8d8;
  --accent-soft: rgba(111, 232, 216, 0.16);
  --gold: #ffd27a;
  --gold-soft: rgba(255, 210, 122, 0.18);
  --pink: #f08ab0;
  --purple: #b08ae8;
  --radius: 16px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

::selection { background: rgba(111, 232, 216, 0.3); }

/* ---------- Nền ---------- */
#starfield {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}
.nebula {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 50% 42%, rgba(20, 70, 75, 0.35), transparent 70%),
    radial-gradient(ellipse 40% 35% at 78% 20%, rgba(60, 40, 90, 0.18), transparent 70%),
    radial-gradient(ellipse 45% 40% at 18% 75%, rgba(15, 60, 55, 0.22), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 50%, transparent 40%, rgba(2, 7, 8, 0.75) 100%);
}

/* ---------- Header ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  overflow: hidden;
  color: var(--gold);
  background: linear-gradient(145deg, rgba(255, 210, 122, 0.12), rgba(111, 232, 216, 0.06));
  border: 1px solid rgba(255, 210, 122, 0.25);
  box-shadow: 0 0 18px rgba(255, 210, 122, 0.12), inset 0 0 12px rgba(255, 210, 122, 0.06);
}
.brand-icon img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 15px; letter-spacing: 0.2px; font-weight: 300; }
.brand-name b { font-weight: 700; color: var(--gold); }
.brand-sub { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.4px; }

.toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
.tool-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); cursor: pointer;
  transition: all 0.22s ease;
}
.tool-btn:hover { color: var(--accent); background: var(--accent-soft); }
.tool-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(111, 232, 216, 0.3);
  box-shadow: 0 0 14px rgba(111, 232, 216, 0.15);
}
.tool-sep { width: 1px; height: 20px; background: var(--panel-border); margin: 0 3px; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  font-family: var(--font); font-size: 12.5px; font-weight: 500;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border-strong);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-outline:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(111, 232, 216, 0.2);
}

/* ---------- Timeline trái ---------- */
.timeline {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  z-index: 30;
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 0 14px 10px;
}
.tl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 8px;
  border: none; background: transparent;
  font-family: var(--font); font-size: 11.5px;
  color: var(--text-faint); cursor: pointer;
  border-radius: 0 999px 999px 0;
  transition: all 0.25s ease;
  text-align: left;
}
.tl-item .tl-tick {
  width: 14px; height: 1.5px; background: var(--text-faint);
  transition: all 0.25s ease;
  flex-shrink: 0;
}
.tl-item:hover { color: var(--text); }
.tl-item:hover .tl-tick { background: var(--accent); width: 20px; }
.tl-item.active {
  color: var(--bg-0);
  background: #e9f5f2;
  font-weight: 600;
  box-shadow: 0 0 22px rgba(233, 245, 242, 0.25);
}
.tl-item.active .tl-tick { background: var(--bg-0); width: 18px; }

/* ---------- Cảnh SVG ---------- */
.scene-wrap {
  position: fixed; inset: 0; z-index: 10;
  cursor: grab;
}
.scene-wrap.dragging { cursor: grabbing; }
.scene-wrap.blurred { filter: blur(9px) brightness(0.5); pointer-events: none; }
.scene-wrap { transition: filter 0.5s ease; }
#scene { width: 100%; height: 100%; display: block; }

.node { cursor: pointer; }
.node .halo { transition: opacity 0.3s ease; opacity: 0.55; }
.node:hover .halo { opacity: 1; }
.node .node-label-group { transition: opacity 0.3s ease; }
.node-icon { pointer-events: none; opacity: 0.9; }
.node:hover .node-icon { opacity: 1; }
.link-line { pointer-events: none; }
.link-core { stroke-dasharray: 3 14; animation: flowDash 2.8s linear infinite; }
@keyframes flowDash { to { stroke-dashoffset: -170; } }

.node-label {
  font-family: var(--font);
  font-size: 12px;
  fill: var(--text);
  paint-order: stroke;
  stroke: rgba(3, 10, 12, 0.75);
  stroke-width: 3px;
}
.node-badge-bg { fill: rgba(8, 24, 28, 0.85); stroke: rgba(140, 220, 220, 0.25); stroke-width: 0.6; }
.node-badge-text { font-family: var(--font); font-size: 8.5px; fill: var(--text-dim); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 10px 14px;
  background: rgba(8, 26, 30, 0.92);
  border: 1px solid var(--panel-border-strong);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  font-size: 12px; line-height: 1.5;
  max-width: 240px;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}
.tooltip.show { opacity: 1; transform: translateY(0); }
.tooltip .tt-name { font-weight: 600; font-size: 13px; }
.tooltip .tt-type { color: var(--accent); font-size: 10.5px; letter-spacing: 0.4px; }
.tooltip .tt-hint { color: var(--text-faint); font-size: 10.5px; margin-top: 4px; }

/* ---------- Chế độ tiêu điểm ---------- */
.focus-view[hidden] { display: none; }
.focus-view {
  position: fixed; inset: 0; z-index: 20;
  display: block;
  animation: focusIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes focusIn {
  from { opacity: 0; transform: scale(1.06); }
  to   { opacity: 1; transform: scale(1); }
}
.focus-view.leaving { animation: focusOut 0.35s ease forwards; }
@keyframes focusOut {
  to { opacity: 0; transform: scale(1.05); }
}

.back-btn {
  position: absolute; top: 78px; left: 26px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  background: var(--panel); color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 999px; cursor: pointer;
  font-family: var(--font); font-size: 12px;
  backdrop-filter: blur(12px);
  transition: all 0.25s ease;
  z-index: 5;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

.focus-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.focus-planet-col {
  position: absolute; left: 11%; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.focus-planet-label { text-align: center; }
.focus-planet-label .fp-name { font-size: 19px; font-weight: 600; letter-spacing: 0.3px; }
.focus-planet-label .fp-en { font-size: 11.5px; color: var(--text-faint); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }

.focus-planet {
  position: relative;
  width: 210px; height: 210px;
  display: grid; place-items: center;
}
.planet-sphere {
  width: 120px; height: 120px; border-radius: 50%;
  position: relative;
  overflow: hidden;
  animation: spherePulse 4s ease-in-out infinite;
}
.sphere-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(10, 20, 22, 0.82);
}
.sphere-icon svg { filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.25)); }
.sphere-photo {
  position: absolute; inset: 6%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}
@keyframes spherePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
.orbit-ring {
  position: absolute; border-radius: 50%;
  border: 1px dashed rgba(140, 220, 220, 0.25);
}
.ring-1 { inset: 10px; animation: spinCW 26s linear infinite; border-style: dotted; }
.ring-2 { inset: -14px; animation: spinCCW 40s linear infinite; opacity: 0.6; }
@keyframes spinCW  { to { transform: rotate(360deg); } }
@keyframes spinCCW { to { transform: rotate(-360deg); } }

.focus-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 260px; }
.mini-badge {
  padding: 4px 11px; border-radius: 999px;
  background: rgba(8, 24, 28, 0.85);
  border: 1px solid var(--panel-border);
  font-size: 10px; color: var(--text-dim); letter-spacing: 0.3px;
}
.mini-badge b { color: var(--text); }

/* Thẻ nhánh */
.focus-cards {
  position: absolute; left: 36%; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 16px;
  width: 240px;
}
.branch-card {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  padding: 15px 17px;
  background: linear-gradient(120deg, rgba(10, 34, 40, 0.9), rgba(8, 22, 26, 0.75));
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.28s ease;
  opacity: 0;
  transform: translateX(24px);
  animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--d, 0s);
  overflow: hidden;
}
@keyframes cardIn { to { opacity: 1; transform: translateX(0); } }
.branch-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(111, 232, 216, 0.08) 70%, rgba(111, 232, 216, 0.16));
  opacity: 0; transition: opacity 0.3s ease;
}
.branch-card:hover::before, .branch-card.selected::before { opacity: 1; }
.branch-card:hover, .branch-card.selected {
  border-color: rgba(255, 210, 122, 0.55);
  box-shadow: 0 0 24px rgba(255, 210, 122, 0.12), 0 8px 30px rgba(0, 0, 0, 0.4);
  transform: translateX(4px);
}
.branch-card .bc-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(111, 232, 216, 0.2);
}
.branch-card .bc-num { font-size: 19px; font-weight: 700; line-height: 1.1; }
.branch-card .bc-label { font-size: 11px; color: var(--text-dim); }

/* Danh sách bung (fan) */
.focus-fan {
  position: absolute; left: 54%; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px;
  width: 290px; max-height: 74vh; overflow-y: auto;
  padding: 6px;
}
.focus-fan::-webkit-scrollbar { width: 4px; }
.focus-fan::-webkit-scrollbar-thumb { background: rgba(140, 220, 220, 0.2); border-radius: 4px; }
.fan-item {
  padding: 11px 15px;
  background: rgba(8, 24, 28, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  opacity: 0; transform: translateX(30px);
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--d, 0s);
  transition: border-color 0.25s ease;
}
.fan-item:hover { border-color: rgba(111, 232, 216, 0.4); }
.fan-item .fi-name { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.fan-item .fi-name::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}
.fan-item .fi-note { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; padding-left: 14px; }

/* ---------- Panel chi tiết ---------- */
.detail-panel {
  position: fixed; right: 18px; top: 70px; bottom: 20px; z-index: 35;
  width: 330px;
  padding: 20px;
  background: linear-gradient(165deg, rgba(12, 34, 38, 0.92), rgba(6, 18, 22, 0.88));
  border: 1px solid var(--panel-border-strong);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: panelIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-thumb { background: rgba(140, 220, 220, 0.2); border-radius: 4px; }

.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.detail-kicker {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--accent); letter-spacing: 0.6px;
}
.detail-kicker::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
.icon-btn {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--panel-border);
  color: var(--text-dim); cursor: pointer;
  transition: all 0.2s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }

.detail-title { font-size: 21px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.25; }
.detail-sub { font-size: 12px; color: var(--text-dim); line-height: 1.6; margin-top: 7px; }
.detail-chip-row { display: flex; align-items: center; gap: 10px; margin: 13px 0 16px; flex-wrap: wrap; }
.chip {
  padding: 4px 12px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.4px;
}
.chip-active {
  color: #0a2a20;
  background: linear-gradient(120deg, #8af0d8, #5ad8b8);
  box-shadow: 0 0 16px rgba(111, 232, 216, 0.3);
}
.detail-discovery { font-size: 10.5px; color: var(--text-faint); }

.gauge-card {
  padding: 15px 16px;
  border-radius: 14px;
  background:
    radial-gradient(120% 140% at 85% 20%, rgba(240, 90, 120, 0.22), transparent 55%),
    rgba(8, 22, 26, 0.8);
  border: 1px solid rgba(240, 138, 176, 0.22);
  margin-bottom: 14px;
}
.gauge-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); }
.gauge-note {
  padding: 2px 9px; border-radius: 999px;
  background: rgba(240, 138, 176, 0.14); color: var(--pink);
  font-size: 9.5px; font-weight: 600;
}
.gauge-value { font-size: 26px; font-weight: 700; margin: 7px 0 10px; }
.gauge-value small { font-size: 11px; font-weight: 400; color: var(--text-dim); margin-left: 6px; }
.gauge-bars { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.gauge-bars span {
  flex: 1; border-radius: 2px;
  background: linear-gradient(180deg, var(--pink), rgba(240, 138, 176, 0.15));
  opacity: 0.85;
  animation: barGrow 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.gauge-bars span:nth-child(odd) { opacity: 0.5; }
@keyframes barGrow { from { height: 0 !important; } }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.stat-cell {
  padding: 12px 13px;
  background: rgba(8, 24, 28, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}
.stat-cell .sc-value { font-size: 13px; font-weight: 700; line-height: 1.35; }
.stat-cell .sc-label { font-size: 9.8px; color: var(--text-faint); margin-top: 3px; letter-spacing: 0.3px; }

.detail-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.6px;
  color: var(--gold); margin-bottom: 10px;
}
.detail-facts { display: flex; flex-direction: column; gap: 8px; }
.fact-item {
  padding: 11px 13px;
  background: rgba(8, 24, 28, 0.6);
  border-left: 2px solid var(--gold);
  border-radius: 0 10px 10px 0;
  font-size: 11.5px; line-height: 1.55; color: var(--text-dim);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .detail-panel { width: 290px; }
  .focus-cards { left: 40%; }
  .focus-fan { display: none; }
}
@media (max-width: 820px) {
  .timeline { display: none; }
  .detail-panel { left: 14px; right: 14px; width: auto; top: auto; bottom: 14px; max-height: 44vh; }
  .focus-planet-col { left: 50%; top: 22%; transform: translate(-50%, 0); }
  .focus-cards { left: 50%; top: auto; bottom: 44vh; margin-bottom: 14px; transform: translateX(-50%); width: min(340px, 90vw); }
  .back-btn { top: 68px; }
}
