/* ============================================================
   KreepCore - Imperial Tech Tree (Horizontal Lanes)
   ============================================================ */

/* When imperial tree is active, resource section sticks to top */
body.it-active .section.full-width:has(.resource-compact) {
  top: 0;
}
/* Hide planet-specific resources, keep only ore/helium/plasma/credits */
body.it-active .resource-card[data-resource="energy"],
body.it-active .resource-card[data-resource="qbits"],
body.it-active .resource-card[data-resource="population"] {
  display: none !important;
}
/* Make the 4 remaining cards fill the row evenly, show only amount */
body.it-active .resource-compact .resource-card {
  flex: 1 1 calc(25% - var(--grid-gap, 6px));
}
body.it-active .resource-card .res-rate,
body.it-active .resource-card .res-pct,
body.it-active .resource-card .res-bar,
body.it-active .res-combined-box {
  display: none !important;
}

.it-view {
  padding: 8px 0 20px;
}

/* === Lane (one per branch) === */
.it-lane {
  margin-bottom: 4px;
}

.it-lane-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 4px;
  position: sticky;
  left: 0;
}

.it-lane-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--lane-color, #64748b);
  box-shadow: 0 0 8px color-mix(in srgb, var(--lane-color) 40%, transparent);
}

.it-lane-header-text {
  flex: 1;
}

.it-lane-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--lane-color, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.it-lane-subtitle {
  font-size: 0.65rem;
  color: rgba(148, 163, 184, 0.6);
  font-family: var(--font-mono);
}

/* Level badge */
.it-lane-level {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--lane-color, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim-40);
}
.it-lane-level-num {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--lane-color, #64748b);
  font-family: var(--font-mono);
}

/* Progress bar toward next level */
.it-lane-progress {
  height: 3px;
  margin: 0 16px 4px;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.it-lane-progress-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms ease;
}

/* Milestone separator between level tiers */
.it-milestone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  align-self: stretch;
}
.it-milestone-line {
  width: 1px;
  flex: 1;
  background: rgba(148, 163, 184, 0.15);
}
.it-milestone-reached .it-milestone-line {
  background: var(--lane-color, #64748b);
  opacity: 0.4;
}
.it-milestone-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(148, 163, 184, 0.35);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  white-space: nowrap;
  writing-mode: vertical-lr;
  text-orientation: mixed;
}
.it-milestone-reached .it-milestone-label {
  color: var(--lane-color, #64748b);
  opacity: 0.7;
}

/* Horizontal scroll track for nodes */
.it-lane-nodes {
  display: flex;
  gap: 10px;
  padding: 6px 16px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}
.it-lane-nodes::-webkit-scrollbar { display: none; }

/* === Node card === */
.it-node {
  flex: 0 0 auto;
  width: 140px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(10, 15, 28, 0.85);
  overflow: hidden;
  scroll-snap-align: start;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  display: flex;
  flex-direction: column;
}

/* Node art thumbnail */
.it-node-art {
  width: 100%;
  height: 80px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
}
.it-node-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.it-node-art-empty {
  background: linear-gradient(135deg, rgba(30,40,60,0.5), rgba(15,20,35,0.5));
}

/* Node info section */
.it-node-info {
  padding: 8px 10px;
  flex: 1;
}

.it-node-type {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--it-color, #64748b);
  text-transform: uppercase;
  font-family: var(--font-mono);
  margin-bottom: 2px;
}

.it-node-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.2;
  margin-bottom: 4px;
}

.it-node-effect {
  font-size: 0.62rem;
  color: rgba(148, 163, 184, 0.7);
  line-height: 1.3;
  margin-bottom: 4px;
}

.it-node-cost {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.65rem;
}

.it-node-cost-item {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Research button */
.it-node-btn {
  display: block;
  width: calc(100% - 16px);
  margin: 0 8px 8px;
  padding: 6px 0;
  border: 1px solid var(--it-color, #64748b);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--it-color, #64748b);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.it-node-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px color-mix(in srgb, var(--it-color) 35%, transparent);
}

/* Done checkmark */
.it-node-done {
  text-align: center;
  padding: 4px 0 8px;
  color: #22c55e;
  font-size: 1rem;
  font-weight: 700;
}

/* === State styles === */
.it-state-unlocked {
  border-color: color-mix(in srgb, var(--it-color) 40%, transparent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--it-color) 20%, transparent);
}
.it-state-unlocked .it-node-art img {
  opacity: 1;
}

.it-state-available {
  border-color: color-mix(in srgb, var(--it-color) 30%, transparent);
}
.it-state-available .it-node-art img {
  opacity: 0.7;
}

.it-state-locked {
  opacity: 0.45;
  border-color: rgba(30, 41, 59, 0.5);
}
.it-state-locked .it-node-art img {
  filter: saturate(0.2) brightness(0.4);
}
.it-state-locked .it-node-name {
  color: rgba(148, 163, 184, 0.5);
}

/* === Type-specific accents === */
.it-node-keystone {
  width: 160px;
  border-width: 2px;
}
.it-node-keystone .it-node-art { height: 90px; }

.it-node-blueprint {
  width: 130px;
  border-style: dashed;
}

.it-node-variant {
  width: 130px;
  border-left: 3px solid var(--it-color, #64748b);
}

/* === Detail panel (reused from before) === */
.it-detail-panel {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 32px));
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  z-index: 100;
  cursor: default;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px var(--scrim-50);
}

.it-detail-hero {
  width: 100%;
  height: 100px;
  overflow: hidden;
}
.it-detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.it-detail-header {
  padding: 0 16px 12px;
}
.it-detail-type {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--it-color, #64748b);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.it-detail-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
}
.it-detail-cost {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 16px 10px;
  font-size: 0.85rem;
}
.it-cost-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #cbd5e1;
}
.it-cost-icon { font-size: 0.9rem; }
.it-detail-effects { margin: 0 16px 12px; }
.it-effect {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.8);
  padding: 2px 0;
}
.it-effect-bp { color: #22d3ee; font-weight: 600; }
.it-btn-unlock {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 10px;
  border: 1px solid var(--it-color, #64748b);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--it-color, #64748b);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms ease;
}
.it-btn-unlock:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 12px color-mix(in srgb, var(--it-color) 40%, transparent);
}
.it-unlocked-badge {
  text-align: center;
  padding: 8px 16px 16px;
  color: #22c55e;
  font-weight: 700;
  font-size: 0.85rem;
}
.it-detail-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: rgba(148, 163, 184, 0.5);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.it-detail-close:hover { color: #f1f5f9; }
