/* The tech page (page-tech.js) */

.tech-tree {
    overflow: auto;
    max-height: 70vh;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    cursor: grab;
    touch-action: pan-x pan-y;
}

.tech-tree.dragging {
    cursor: grabbing;
    user-select: none;
}

.tech-svg {
    display: block;
}

.tech-lines path {
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.5;
    opacity: 0.6;
}

.tech-node {
    cursor: pointer;
    outline: none;
}

.tech-node rect {
    fill: var(--panel-solid);
    stroke: var(--line);
    stroke-width: 1.5;
}

.tech-node:hover rect,
.tech-node:focus-visible rect {
    stroke: var(--text);
}

.tech-node text {
    fill: var(--text);
    pointer-events: none;
}

.tech-name {
    font-size: 12.5px;
    font-weight: 600;
}

.tech-meta {
    font-size: 11px;
    fill: var(--muted) !important;
}

/* The previous era's tech, rooting this era's chains */
.tech-node.other-era rect {
    stroke-dasharray: 4 3;
}

.tech-node.other-era {
    opacity: 0.75;
}

/* info.cpp's colours: blue selected, orange prerequisites, green researched */
.tech-node.selected rect,
.tech-legend .swatch.selected {
    stroke: #4fa3ff;
    fill: rgba(79, 163, 255, 0.22);
    background: rgba(79, 163, 255, 0.22);
    border-color: #4fa3ff;
}

.tech-node.prereq rect,
.tech-legend .swatch.prereq {
    stroke: #ff9a3c;
    fill: rgba(255, 154, 60, 0.18);
    background: rgba(255, 154, 60, 0.18);
    border-color: #ff9a3c;
}

.tech-node.researched rect,
.tech-legend .swatch.researched {
    stroke: #3fbf6a;
    fill: rgba(63, 191, 106, 0.18);
    background: rgba(63, 191, 106, 0.18);
    border-color: #3fbf6a;
}

.tech-node.selected rect,
.tech-node.prereq rect,
.tech-node.researched rect {
    stroke-width: 2.5;
}

.tech-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 13px;
    color: var(--muted);
}

.tech-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tech-legend .swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 2px solid;
}

.tech-flavour {
    margin: 0;
    font-size: 12px;
    font-style: italic;
    color: var(--muted);
}

/* The tree with the selected tech's panel beside it, under it on narrow screens */
.tech-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 14px;
    align-items: start;
}

.tech-panel {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 10px;
    background: var(--field);
    border: 1px solid var(--line);
}

.tech-panel-head h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.tech-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tech-panel .tiles {
    grid-template-columns: 1fr 1fr;
}

.tech-panel .tile {
    background: var(--panel-solid);
}

.tech-unlocks,
.tech-related {
    display: grid;
    gap: 4px;
}

.tech-related-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.tech-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tech-chip {
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid #ff9a3c;
    font-size: 13px;
}

.tech-chip.is-done {
    border-color: #3fbf6a;
}

/* Progress: one row per era */
.tech-eras {
    display: grid;
    gap: 6px;
}

.tech-era {
    all: unset;
    cursor: pointer;
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 90px;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--field);
}

.tech-era:hover,
.tech-era:focus-visible {
    border-color: var(--accent);
}

.tech-era-name {
    font-weight: 600;
}

.tech-era-track {
    height: 10px;
    border-radius: 999px;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    overflow: hidden;
}

.tech-era-fill {
    display: block;
    height: 100%;
    background: var(--accent);
}

.tech-era-count {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.tech-era.current {
    border-color: var(--accent);
}

.tech-era.current .tech-era-count {
    color: var(--text);
    font-weight: 700;
}

.tech-era.later .tech-era-name {
    color: var(--muted);
}

@media (max-width: 900px) {
    .tech-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .tech-era {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 10px;
    }

    .tech-era-track {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}
