/* ============================================ */
/* GAME-MENUS.CSS - DOM Menus (Building &     */
/* Research), Menu Headers, Building Grid,    */
/* Research Columns, Progress Bars            */
/* ============================================ */

/* ============================================ */
/* DOM MENUS - Building & Research             */
/* ============================================ */
.menu-overlay {
    pointer-events: auto !important;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100 !important;
}

.menu-overlay * {
    pointer-events: auto !important;
}

.dom-menu {
    width: 950px;
    background: rgba(20, 25, 40, 0.98);
    border-radius: 16px;
    overflow: hidden;
}

.dom-menu.research {
    background: linear-gradient(180deg, rgba(20, 38, 58, 0.97), rgba(15, 30, 50, 0.95), rgba(12, 25, 45, 0.97));
}

.dom-menu.research {
    width: 1260px;
}

.dom-menu.building {
    box-shadow: 0 0 0 3px #44ff44, 0 0 30px rgba(68, 255, 68, 0.3);
}

.dom-menu.research {
    box-shadow: 0 0 0 2px rgba(130, 200, 255, 0.35), 0 0 25px rgba(100, 180, 255, 0.25);
}

/* Menu Header */
.dom-menu-header {
    display: flex;
    align-items: center;
    padding: 20px 25px;
    position: relative;
}

.dom-menu.building .dom-menu-header {
    background: rgba(68, 255, 68, 0.1);
    border-bottom: 2px solid rgba(68, 255, 68, 0.3);
}

.dom-menu.research .dom-menu-header {
    background: rgba(20, 45, 70, 0.6);
    border-bottom: 2px solid rgba(100, 180, 255, 0.25);
}

.dom-advisor-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 30px;
}

.dom-advisor-portrait {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(180deg, #2a2a3a 0%, #1a1a2a 100%);
    border: 3px solid #44ff44;
    position: relative;
    overflow: hidden;
}

.dom-menu.research .dom-advisor-portrait {
    border-color: #4488cc;
    background: linear-gradient(180deg, #1a3048 0%, #0f2030 100%);
}

.dom-advisor-name {
    margin-top: 8px;
    font-size: 14px;
    color: #44ff44;
}

.dom-menu.research .dom-advisor-name {
    color: #5588aa;
}

.dom-menu-title-section {
    flex: 1;
}

.dom-menu-title {
    font-size: 30px;
    font-weight: bold;
    margin: 0 0 5px 0;
    text-shadow: 0 0 10px currentColor;
}

.dom-menu.building .dom-menu-title {
    color: #44ff44;
}

.dom-menu.research .dom-menu-title {
    color: #aaddff;
    text-shadow: 0 0 12px rgba(100, 180, 255, 0.4);
}

.dom-menu-subtitle {
    font-size: 16px;
    color: #888;
    margin: 0;
}

.dom-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 85, 85, 0.2);
    border: 2px solid #ff5555;
    border-radius: 8px;
    color: #ff5555;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.dom-close-btn:hover {
    background: rgba(255, 85, 85, 0.4);
    box-shadow: 0 0 15px rgba(255, 85, 85, 0.5);
}

/* Menu Content */
.dom-menu-content {
    padding: 20px;
}

/* Building Grid */
.building-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.build-item {
    background: rgba(40, 60, 80, 0.8);
    border: 2px solid #4488ff;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.build-item.green { background: rgba(42, 68, 40, 0.8); border-color: #88ff44; }
.build-item.purple { background: rgba(56, 40, 80, 0.8); border-color: #aa44ff; }
.build-item.orange { background: rgba(68, 56, 40, 0.8); border-color: #ffaa44; }
.build-item.cyan { background: rgba(40, 40, 80, 0.8); border-color: #4466aa; }
.build-item.teal { background: rgba(40, 56, 56, 0.8); border-color: #66aaaa; }
.build-item.gray { background: rgba(56, 56, 56, 0.8); border-color: #888888; }
.build-item.red { background: rgba(80, 40, 40, 0.8); border-color: #ff4444; }

.build-item:hover {
    background: rgba(60, 80, 100, 0.9);
    border-color: #44ff44;
    box-shadow: 0 0 20px rgba(68, 255, 68, 0.3);
}

.build-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.build-item.locked:hover {
    border-color: inherit;
    box-shadow: none;
    background: inherit;
}

.build-item.built {
    opacity: 0.5;
}

.build-item.built .item-checkmark {
    display: inline;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.item-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.item-cost {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 17px;
    font-weight: bold;
    color: #ffd700;
}

.item-cost.research {
    color: #77aacc;
}

.dom-coin-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: radial-gradient(circle at 35% 30%, #ffec80 0%, #ffd700 40%, #b8860b 100%);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px #daa520;
}

.item-desc {
    font-size: 14px;
    color: #888;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.item-info {
    font-size: 14px;
    color: #88ff88;
}

.item-info.blue { color: #88aaff; }
.item-info.green { color: #88ff88; }
.item-info.purple { color: #cc88ff; }
.item-info.orange { color: #ffaa66; }
.item-info.cyan { color: #88ddff; }
.item-info.teal { color: #66dddd; }
.item-info.gray { color: #aaaaaa; }
.item-info.red { color: #ff8888; }

.item-checkmark {
    font-size: 24px;
    color: #44ff44;
    display: none;
}

/* Research Columns */
.research-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.research-columns.two-columns {
    grid-template-columns: repeat(2, 1fr);
}

.research-column h4 {
    font-size: 18px;
    color: #aaa;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

.research-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 340px;
    min-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-bottom: 10px;
}

.research-items::-webkit-scrollbar {
    width: 8px;
}

.research-items::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.research-items::-webkit-scrollbar-thumb {
    background: rgba(100, 180, 255, 0.35);
    border-radius: 4px;
}

.research-items::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 180, 255, 0.55);
}

.research-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 380px;
}

.research-item {
    background: rgba(40, 40, 60, 0.8);
    border: 2px solid #666;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.research-item:hover {
    background: rgba(60, 60, 80, 0.9);
    border-color: #aa44ff;
    box-shadow: 0 0 20px rgba(170, 68, 255, 0.3);
}

.research-item.completed {
    opacity: 0.5;
}

.research-item.completed .item-checkmark {
    display: inline;
}

.research-item.completed .item-cost {
    display: none;
}

.research-item.active {
    border-color: #44ff44;
    background: rgba(40, 60, 40, 0.8);
}

.research-item.queued {
    opacity: 0.8;
}

.research-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.research-item.locked:hover {
    border-color: #666;
    box-shadow: none;
    background: rgba(40, 40, 60, 0.8);
}

.research-item.completed:hover {
    border-color: #444;
    box-shadow: none;
    background: rgba(40, 40, 60, 0.8);
}

.queue-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #ffaa00;
    background: #443300;
    padding: 2px 8px;
    border-radius: 4px;
}

.queue-badge.active {
    color: #44ff44;
    background: #224422;
}

.queue-badge-next {
    position: absolute;
    bottom: 8px;
    right: 70px;
    font-size: 11px;
    color: #ffaa00;
    background: #332200;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Progress Bar */
.research-progress-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    background: rgba(10, 22, 38, 0.6);
    border-top: 1px solid rgba(100, 180, 255, 0.15);
}

.progress-label {
    font-size: 15px;
    color: #7799aa;
}

.progress-name {
    font-size: 15px;
    font-weight: bold;
    color: #88bbdd;
    min-width: 140px;
}

.progress-track {
    flex: 1;
    height: 16px;
    background: rgba(20, 42, 65, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3377aa, #77bbee);
    border-radius: 8px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 15px;
    font-weight: bold;
    color: #88bbdd;
    min-width: 100px;
    text-align: right;
}

.no-research-hint {
    color: #ff8888;
    font-size: 15px;
    font-weight: bold;
    margin: 5px 0 0 0;
}

/* ============================================ */
/* RESEARCH TREE (Design 9)                    */
/* ============================================ */
.research-tree-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px;
    overflow-y: auto;
    max-height: 420px;
}

.research-tree-container::-webkit-scrollbar {
    width: 8px;
}

.research-tree-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.research-tree-container::-webkit-scrollbar-thumb {
    background: rgba(100, 180, 255, 0.35);
    border-radius: 4px;
}

/* Scroll hint arrow (first open) */
.research-scroll-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    pointer-events: none;
    flex-shrink: 0;
    animation: scrollHintBlink 0.5s ease-in-out 7 forwards;
}

.scroll-hint-arrow {
    font-size: 36px;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255,255,255,0.9), 0 0 20px rgba(100,180,255,0.5);
    animation: scrollHintBounce 0.5s ease-in-out 7;
}

.scroll-hint-text {
    font-size: 17px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255,255,255,0.7), 0 0 16px rgba(100,180,255,0.4);
    white-space: nowrap;
}

@keyframes scrollHintBlink {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

@keyframes scrollHintBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

.research-branch {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.research-branch[data-category="command"] { background: rgba(50, 100, 255, 0.06); }
.research-branch[data-category="defense"] { background: rgba(0, 200, 255, 0.06); }
.research-branch[data-category="turrets"] { background: rgba(255, 100, 50, 0.06); }
.research-branch[data-category="economy"] { background: rgba(255, 200, 0, 0.06); }

.branch-root {
    min-width: 90px;
    max-width: 90px;
    padding: 12px 8px;
    background: linear-gradient(135deg, rgba(25, 48, 68, 0.9), rgba(15, 32, 52, 0.9));
    border: 1.5px solid rgba(100, 180, 255, 0.35);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #ccddef;
    flex-shrink: 0;
    overflow: hidden;
}

.branch-root-name {
    font-size: 13px;
    font-weight: bold;
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
}

.branch-connector {
    width: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    align-self: stretch;
    position: relative;
}

/* Horizontal line from root to fork point (centered in connector) */
.branch-connector::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;    /* from root to fork left edge */
    height: 2px;
    background: rgba(80, 130, 180, 0.25);
}

/* Vertical fork line centered in connector */
.branch-connector::after {
    content: '';
    position: absolute;
    left: 12px;     /* centered in 25px connector */
    top: 34px;      /* center of first chain: chain-padding(4) + node(60)/2 = 34px */
    bottom: 34px;   /* center of last chain from bottom */
    width: 2px;
    background: rgba(80, 130, 180, 0.25);
}

/* Single independent chain: fork only goes from horizontal line (50%) to first chain center */
.branch-connector.single-independent::after {
    top: 34px;                      /* first chain center */
    bottom: auto;
    height: calc(50% - 34px);      /* from chain center up to horizontal line at 50% */
}

.branch-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.branch-chain {
    display: flex;
    align-items: center;
    gap: 0;
    overflow: visible;
    padding: 4px 0;
}

/* Horizontal stub from the centered fork to the chain's first node/spacer */
.branch-chain::before {
    content: '';
    width: 17px;    /* 11px back into connector (to fork right edge at 14px) + 6px into chain */
    height: 2px;
    background: rgba(80, 130, 180, 0.25);
    flex-shrink: 0;
    margin-left: -11px;   /* extend back into connector to reach centered fork */
    margin-right: -3px;   /* overlap into first element's margin to close gap */
}

/* Dependent chains connect only via dependency spacer, not via fork */
.branch-chain.has-dependency::before {
    display: none;
}

.tree-node {
    min-width: 60px;
    width: 60px;
    height: 60px;
    margin-left: 3px;
    background: rgba(15, 28, 42, 0.5);
    border: 1.5px solid rgba(70, 120, 170, 0.25);
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

/* Canvas building background */
.tree-node-bg {
    position: absolute;
    inset: 0;
    width: 60px;
    height: 60px;
    opacity: 0.45;
    pointer-events: none;
    transition: all 0.2s ease;
}

.tree-node:hover .tree-node-bg {
    opacity: 0.7;
    filter: brightness(1.3) drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
    animation: icon-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes icon-pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

.tree-node:hover {
    transform: scale(1.03);
    z-index: 10;
    border-color: transparent;
    background:
        linear-gradient(rgba(20, 38, 58, 0.9), rgba(20, 38, 58, 0.9)) padding-box,
        conic-gradient(from var(--border-angle), #4488cc, #00ccee, #00cc88, #ddaa33, #4488cc) border-box;
    animation: border-spin 1.5s linear infinite;
}

@keyframes border-spin {
    from { --border-angle: 0deg; }
    to { --border-angle: 360deg; }
}

@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.tree-node.completed {
    border-color: #00bb77;
    background: rgba(0, 40, 35, 0.5);
}

.tree-node.completed::after {
    content: '\2713';
    position: absolute;
    top: -4px;
    right: -4px;
    background: #00bb77;
    color: #000;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 2;
}

.tree-node.active {
    border-color: #ddaa33;
    background: rgba(50, 42, 10, 0.5);
    animation: tree-node-pulse 1.5s ease-in-out infinite;
}

.tree-node.queued {
    border-color: #7755bb;
    background: rgba(30, 22, 50, 0.45);
}

.tree-node.queued::after {
    content: attr(data-queue);
    position: absolute;
    top: -4px;
    right: -4px;
    background: #7755bb;
    color: #fff;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 2;
}

.tree-node.locked {
    opacity: 0.35;
    cursor: not-allowed;
}

.tree-node.locked:hover {
    transform: none;
    border-color: rgba(70, 120, 170, 0.25);
    background: rgba(15, 28, 42, 0.5);
}

.tree-node-tier {
    font-size: 22px;
    line-height: 1;
    color: #ddeeff;
    text-shadow: 0 0 8px rgba(200, 230, 255, 0.5), 0 0 15px rgba(200, 230, 255, 0.3), 1px 1px 3px #000;
    z-index: 1;
}

.tree-node-cost {
    font-size: 14px;
    color: #8899aa;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(200, 230, 255, 0.3), 1px 1px 2px #000;
    z-index: 1;
}

/* Dependency spacer: indents a chain so its tier 1 aligns with parent's tier 2 */
.chain-dependency-spacer {
    width: 81px;   /* margin(3) + node(60) + connector(18) = one full step */
    height: 2px;
    background: transparent;
    flex-shrink: 0;
    position: relative;
}

/* Vertical line from parent node bottom edge down to this chain's spacer center */
.chain-dependency-spacer::before {
    content: '';
    position: absolute;
    left: 33px;     /* center of the parent tier 1 node (3 + 60/2) */
    bottom: 50%;
    width: 2px;
    height: 46px;   /* to parent node bottom edge: 30px(half node) + 4px(child pad) + 8px(gap) + 4px(parent pad) */
    background: rgba(80, 130, 180, 0.25);
}
/* Horizontal connector from vertical line to child chain's first node */
.chain-dependency-spacer::after {
    content: '';
    position: absolute;
    left: 35px;     /* starts after vertical line (33 + 2px) to avoid double intensity */
    top: 50%;
    width: 46px;    /* horizontal line from after vertical to end of spacer (81-35) */
    height: 2px;
    background: rgba(80, 130, 180, 0.25);
    transform: translateY(-50%);
}

.chain-dependency-spacer.completed::before,
.chain-dependency-spacer.completed::after {
    background: #00bb77;
}

.chain-dependency-spacer.active::before,
.chain-dependency-spacer.active::after {
    background: linear-gradient(180deg, #00bb77, #ddaa33);
}

/* 2-tier offset: branches from tier 2 of parent chain (e.g. windTurbine from solar2) */
.chain-dependency-spacer[data-requires-tier="2"] {
    width: 162px;   /* 2 × 81px (2 full tier steps) */
}
.chain-dependency-spacer[data-requires-tier="2"]::before {
    left: 114px;    /* center of parent tier 2: 3+60+18+3+30 */
}
.chain-dependency-spacer[data-requires-tier="2"]::after {
    left: 116px;    /* starts after vertical line (114 + 2px) to avoid double intensity */
    width: 46px;    /* 162-116 */
}

/* 3-tier offset: branches from tier 3 of parent chain (e.g. fusionPlant from solar3) */
.chain-dependency-spacer[data-requires-tier="3"] {
    width: 243px;   /* 3 × 81px (3 full tier steps) */
}
.chain-dependency-spacer[data-requires-tier="3"]::before {
    left: 195px;    /* center of parent tier 3: 3+60+18+3+60+18+3+30 */
}
.chain-dependency-spacer[data-requires-tier="3"]::after {
    left: 197px;    /* starts after vertical line (195 + 2px) */
    width: 49px;    /* extend to F1 node edge: 243-197 + 3px(margin) */
}

/* fusionPlant chain needs relative positioning for the wind connector */
.branch-chain[data-chain="fusionPlant"] {
    position: relative;
}

/* Fusion→Wind connector: vertical line from F1 bottom edge down to W2 top edge */
.fusion-wind-connector {
    width: 0;
    height: 0;
    position: absolute;
    left: 276px;    /* center of F1 node: spacer(243) + margin(3) + half-node(30) */
    top: calc(50% + 30px);  /* bottom edge of F1 node (center + half-height) */
}
.fusion-wind-connector::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 0;
    width: 2px;
    height: 16px;   /* gap only: 4px(pad) + 8px(gap) + 4px(pad) */
    background: rgba(80, 130, 180, 0.25);
}
.fusion-wind-connector.completed::before {
    background: #00bb77;
}
.fusion-wind-connector.active::before {
    background: linear-gradient(180deg, #ddaa33, #00bb77);
}

/* windTurbine spacer must reach through fusionPlant row up to solar row (2 rows) */
.branch-chain[data-chain="windTurbine"] .chain-dependency-spacer::before {
    height: 122px;  /* 46px (1 row) + 68px (fusionPlant row: 4+60+4) + 8px (gap) */
}

.tree-connector {
    width: 21px;
    height: 2px;
    background: rgba(80, 130, 180, 0.25);
    flex-shrink: 0;
    margin-right: -3px; /* overlap into next node's margin-left to close the gap */
}

.tree-connector.completed {
    background: #00bb77;
}

.tree-connector.active {
    background: linear-gradient(90deg, #00bb77, #ddaa33);
}

@keyframes tree-node-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(220, 170, 50, 0.3); }
    50% { box-shadow: 0 0 12px rgba(220, 170, 50, 0.5); }
}

/* Research Tooltip */
.research-tooltip {
    position: absolute;
    background: rgba(8, 18, 30, 0.97);
    border: 1.5px solid rgba(100, 180, 255, 0.4);
    border-radius: 8px;
    padding: 12px 15px;
    min-width: 200px;
    max-width: 280px;
    z-index: 10001;
    pointer-events: none;
    box-shadow: 0 0 15px rgba(80, 160, 240, 0.2);
}

.research-tooltip-title {
    font-size: 14px;
    font-weight: bold;
    color: #ddeeff;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(80, 130, 180, 0.25);
    padding-bottom: 6px;
}

.research-tooltip-desc {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
    line-height: 1.4;
}

.research-tooltip-cost {
    font-size: 12px;
    color: #77aacc;
    font-weight: bold;
}

.research-tooltip-status {
    font-size: 11px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(80, 130, 180, 0.2);
}

.research-tooltip-status.completed { color: #00bb77; }
.research-tooltip-status.active { color: #ddaa33; }
.research-tooltip-status.queued { color: #7755bb; }
.research-tooltip-status.locked { color: #cc6666; }
