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

:root {
    --dark-purple: #1B1534;
    --purple: #8A00E5;
    --gradient-end: #4D217A;
    --teal: #00d4ff;
    --grey-1: #F9F8F8;
    --grey-2: #F0F0F0;
    --white: #FFFFFF;
    --land: rgba(255, 255, 255, 0.07);
    --land-foreign: rgba(255, 255, 255, 0.035);
    --coast: rgba(200, 170, 255, 0.75);
    --coast-foreign: rgba(160, 140, 200, 0.45);
    --sea: transparent;
    --turbine: rgba(220, 200, 255, 0.85);
    --platform: var(--teal);
    --string: rgba(0, 212, 255, 0.45);
    --export-cable: rgba(0, 212, 255, 0.7);
}

html, body {
    height: 100%;
    background: var(--dark-purple);
    color: var(--white);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(138, 0, 229, 0.18) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 80%, rgba(77, 33, 122, 0.30) 0%, transparent 60%),
        var(--dark-purple);
}

#particles {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.55;
}

/* ── Header ─────────────────────────────────────── */
.topbar {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 1.5rem;
    padding: 0.6rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(27, 21, 52, 0.55);
    backdrop-filter: blur(6px);
}

.wordmark img {
    height: 26px;
    width: auto;
    display: block;
}

.title-block { text-align: left; min-width: 0; }
.title-block h1 {
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}
.title-block h1 strong { font-weight: 600; color: var(--purple); }
.subtitle { display: none; }

.live-totals {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    justify-content: flex-end;
    overflow-x: auto;
}
.totals-row { display: flex; flex-direction: column; align-items: flex-end; }
.totals-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.65rem;
}
.totals-value {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 0.95rem;
    color: var(--white);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ── Stage / map ────────────────────────────────── */
.stage {
    position: relative;
    flex: 1;
    z-index: 1;
    overflow: hidden;
}

.map-wrap {
    position: absolute;
    inset: 0;
}

#map {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}
#map.dragging { cursor: grabbing; }

/* ── Map glyph styles ───────────────────────────── */
.land {
    fill: var(--land);
    stroke: var(--coast);
    stroke-width: 0.6;
    stroke-linejoin: round;
}
.land.foreign {
    fill: var(--land-foreign);
    stroke: var(--coast-foreign);
    stroke-width: 0.4;
}

.windfarm {
    cursor: pointer;
    transition: filter 0.2s;
}
.windfarm:hover { filter: brightness(1.4); }

.wf-core {
    fill: var(--purple);
    filter: drop-shadow(0 0 6px var(--purple));
}
.wf-ring {
    fill: none;
    stroke: rgba(138, 0, 229, 0.6);
    stroke-width: 0.8;
    animation: wf-orbit 14s linear infinite;
    transform-origin: center;
    transform-box: fill-box;
}
.wf-pulse {
    fill: none;
    stroke: var(--purple);
    stroke-width: 1.2;
    opacity: 0.55;
    animation: wf-pulse 3.2s ease-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}
.wf-wind { transition: opacity 0.3s, transform 0.5s; }
.wf-wind-arrow {
    fill: rgba(220, 200, 255, 0.85);
    filter: drop-shadow(0 0 3px var(--white));
}
.windfarm.pre-op .wf-core,
.windfarm.pre-op .wf-pulse,
.windfarm.pre-op .wf-ring {
    stroke: rgba(255, 255, 255, 0.45);
    fill: rgba(255, 255, 255, 0.5);
    filter: none;
}
.windfarm.pre-op .wf-core { fill: rgba(255, 255, 255, 0.65); }

@keyframes wf-pulse {
    0%   { transform: scale(0.8); opacity: 0.65; }
    100% { transform: scale(2.4); opacity: 0; }
}
@keyframes wf-orbit {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.hvdc {
    cursor: pointer;
}
.hvdc-path {
    fill: none;
    stroke: rgba(0, 212, 255, 0.55);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 4px rgba(0, 212, 255, 0.4));
}
.hvdc.pre-op .hvdc-path {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-dasharray: 4 4;
    filter: none;
}
.hvdc-flow {
    fill: none;
    stroke: var(--teal);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-dasharray: 4 16;
    stroke-dashoffset: 0;
    filter: drop-shadow(0 0 4px var(--teal));
    animation: flow-dash 4s linear infinite;
    opacity: 0.35;
}
@keyframes flow-dash {
    to { stroke-dashoffset: -20; }
}
.hvdc:hover .hvdc-path { stroke-width: 2.4; }

/* ── Traveling electrons (the sexy bit) ─────────── */
.electron {
    fill: var(--teal);
    filter: drop-shadow(0 0 6px var(--teal)) drop-shadow(0 0 12px rgba(0, 212, 255, 0.5));
    pointer-events: none;
}
.electron.export {
    fill: var(--purple);
    filter: drop-shadow(0 0 4px var(--purple)) drop-shadow(0 0 8px rgba(138, 0, 229, 0.4));
}
.windfarm.pre-op + .electron,
g.windfarm-export[data-status="construction"] .electron,
g.hvdc.pre-op .electron {
    display: none;
}

.endpoint-dot {
    fill: var(--teal);
    filter: drop-shadow(0 0 3px var(--teal));
}

/* ── Windfarm export cables ────────────────────── */
.export-cable {
    fill: none;
    stroke: var(--export-cable);
    stroke-width: 1.2;
    stroke-linecap: round;
    opacity: 0.6;
    filter: drop-shadow(0 0 2px rgba(0, 212, 255, 0.3));
}
.export-flow {
    fill: none;
    stroke: var(--teal);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-dasharray: 4 10;
    filter: drop-shadow(0 0 4px var(--teal));
    animation: flow-dash 3s linear infinite;
    opacity: 0.3;
}
.windfarm.pre-op ~ .export-cable,
g.windfarm-export[data-status="construction"] .export-cable {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-dasharray: 3 5;
}
.windfarm-export[data-status="construction"] .export-flow {
    display: none;
}

/* ── SE Offices ─────────────────────────────────── */
.office {
    cursor: pointer;
}
.office-marker {
    fill: var(--white);
    stroke: var(--purple);
    stroke-width: 1.5;
    filter: drop-shadow(0 0 6px var(--purple));
}
.office-coc {
    stroke: var(--purple);
    stroke-width: 0.8;
    fill: none;
    opacity: 0.6;
    animation: office-pulse 3s ease-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}
@keyframes office-pulse {
    0%   { transform: scale(0.6); opacity: 0.7; }
    100% { transform: scale(2.4); opacity: 0; }
}
.office-label {
    fill: var(--white);
    font-size: 9px;
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-weight: 500;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(27, 21, 52, 0.95);
    stroke-width: 3;
    stroke-linejoin: round;
    pointer-events: none;
}
.office-coc-badge {
    fill: var(--purple);
    font-size: 7px;
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(27, 21, 52, 0.95);
    stroke-width: 2.5;
    pointer-events: none;
}

/* ── Country labels + sea grid ─────────────────── */
.country-label {
    fill: rgba(255, 255, 255, 0.25);
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 300;
    text-anchor: middle;
    pointer-events: none;
}
.country-label.home {
    fill: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.22em;
}
.country-label.small { font-size: 9px; letter-spacing: 0.12em; }
.graticule {
    fill: none;
    stroke: rgba(138, 0, 229, 0.06);
    stroke-width: 0.5;
    stroke-dasharray: 2 4;
}
.scanning-beam {
    fill: none;
    stroke: rgba(0, 212, 255, 0.12);
    stroke-width: 0.5;
    pointer-events: none;
    animation: scan-rotate 60s linear infinite;
    transform-origin: center;
}
@keyframes scan-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Per-turbine deep-zoom layer ────────────────── */
.wf-turbine, .wf-platform, .wf-string {
    display: none;
    pointer-events: none;
}
.show-turbines .wf-turbine,
.show-turbines .wf-platform,
.show-turbines .wf-string {
    display: inline;
}
.show-turbines g.windfarm .wf-pulse,
.show-turbines g.windfarm .wf-ring,
.show-turbines g.windfarm .wf-core {
    opacity: 0;
    transition: opacity 0.3s;
}
.wf-turbine {
    fill: var(--turbine);
    filter: drop-shadow(0 0 1px var(--turbine));
}
.wf-platform {
    fill: var(--platform);
    stroke: var(--white);
    stroke-width: 0.4;
    filter: drop-shadow(0 0 3px var(--platform));
}
.wf-string {
    fill: none;
    stroke: var(--string);
    stroke-width: 0.3;
    stroke-linecap: round;
}

.label {
    fill: rgba(255, 255, 255, 0.6);
    font-size: 9px;
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    pointer-events: none;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(27, 21, 52, 0.85);
    stroke-width: 3;
    stroke-linejoin: round;
}

/* ── Hero callout (floating on map) ─────────────── */
.hero-callout {
    position: absolute;
    top: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.7rem 1.5rem;
    background: rgba(15, 11, 30, 0.6);
    border: 1px solid rgba(138, 0, 229, 0.35);
    border-radius: 6px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 30px rgba(138, 0, 229, 0.18);
    z-index: 5;
    pointer-events: none;
}
.hero-callout .hero-pulse {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 8px var(--teal);
    animation: hero-pulse 1.5s ease-out infinite;
}
@keyframes hero-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50%      { opacity: 1;   transform: scale(1.1); }
}
.hero-text {
    display: flex; flex-direction: column; align-items: center;
    line-height: 1;
}
.hero-num {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--white);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 14px rgba(138, 0, 229, 0.6);
    letter-spacing: -0.01em;
}
.hero-lbl {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 0.35rem;
}
.hero-divider {
    width: 1px;
    height: 32px;
    background: rgba(138, 0, 229, 0.4);
}

/* ── Controls ───────────────────────────────────── */
.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 5;
}
.map-controls button {
    width: 36px;
    height: 36px;
    background: rgba(27, 21, 52, 0.7);
    border: 1px solid rgba(138, 0, 229, 0.4);
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    transition: background 0.15s, border-color 0.15s;
}
.map-controls button:hover {
    background: rgba(138, 0, 229, 0.3);
    border-color: var(--purple);
}

.legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(27, 21, 52, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    backdrop-filter: blur(4px);
    font-size: 0.75rem;
    z-index: 5;
}
.legend-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.15rem 0;
}
.legend-row .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--purple);
    box-shadow: 0 0 6px var(--purple);
}
.legend-row .line {
    width: 24px; height: 2px;
    background: var(--teal);
    box-shadow: 0 0 4px var(--teal);
}
.legend-row .hvdc-pre {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: none;
}
.legend-note {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
}

.status-tag {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    padding: 0.4rem 0.8rem;
    background: rgba(27, 21, 52, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    backdrop-filter: blur(4px);
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    z-index: 5;
}

/* ── Detail panel ───────────────────────────────── */
.detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 100%;
    height: 100%;
    background: rgba(15, 11, 30, 0.92);
    border-left: 1px solid rgba(138, 0, 229, 0.3);
    backdrop-filter: blur(10px);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 8;
    overflow-y: auto;
}
.detail-panel.open { transform: translateX(0); }
.panel-close {
    position: absolute;
    top: 0.5rem; right: 0.75rem;
    width: 32px; height: 32px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.panel-close:hover { color: var(--white); }
.panel-content {
    padding: 2.5rem 1.5rem 2rem;
}
.panel-content h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.panel-type {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.7rem;
    color: var(--purple);
    margin-bottom: 1.5rem;
}
.panel-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat {
    padding: 0.75rem;
    background: rgba(138, 0, 229, 0.08);
    border: 1px solid rgba(138, 0, 229, 0.2);
    border-radius: 4px;
}
.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.25rem;
}
.stat-value {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 1rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.panel-section { margin-bottom: 1.25rem; }
.panel-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.4rem;
    font-weight: 500;
}
.panel-section p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}
.preop-toggle {
    display: flex;
    gap: 0.25rem;
    margin: 0.5rem 0 1rem;
    padding: 0.25rem;
    background: rgba(138, 0, 229, 0.08);
    border: 1px solid rgba(138, 0, 229, 0.2);
    border-radius: 4px;
}
.preop-toggle button {
    flex: 1;
    padding: 0.4rem 0.5rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
}
.preop-toggle button.active {
    background: var(--purple);
    color: var(--white);
}
.preop-toggle button:hover:not(.active) {
    color: rgba(255, 255, 255, 0.85);
}

.se-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(90deg, var(--purple), var(--gradient-end));
    color: var(--white);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 2px;
    margin-bottom: 0.5rem;
}

/* ── Tooltip ────────────────────────────────────── */
.tooltip {
    position: absolute;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 11, 30, 0.92);
    border: 1px solid rgba(138, 0, 229, 0.4);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--white);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.tooltip.show { opacity: 1; }
.tooltip strong { color: var(--purple); }
.tooltip-name { font-weight: 600; margin-bottom: 0.2rem; }
.tooltip-meta { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: rgba(255,255,255,0.7); }

/* ── Activity ticker ───────────────────────────── */
.ticker {
    position: relative;
    z-index: 10;
    overflow: hidden;
    padding: 0.45rem 0;
    background: rgba(15, 11, 30, 0.85);
    border-top: 1px solid rgba(138, 0, 229, 0.15);
    border-bottom: 1px solid rgba(138, 0, 229, 0.15);
    white-space: nowrap;
    backdrop-filter: blur(6px);
}
.ticker-track {
    display: inline-block;
    white-space: nowrap;
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    animation: ticker-scroll 80s linear infinite;
    padding-left: 100%;
}
.ticker-track:hover { animation-play-state: paused; }
.tick { margin-right: 2.5rem; }
.tick .tick-name { color: var(--purple); margin-right: 0.4rem; }
.tick .tick-mw { color: var(--teal); font-weight: 500; }
.tick .tick-wind { color: rgba(255, 255, 255, 0.55); margin-left: 0.25rem; }
.tick .tick-arrow { color: var(--teal); }
.tick.idle .tick-mw { color: rgba(255, 255, 255, 0.4); }
@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-100%); }
}

/* ── Stat strip (above footer) ──────────────────── */
.stat-strip {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(90deg, rgba(27, 21, 52, 0.7), rgba(77, 33, 122, 0.4), rgba(27, 21, 52, 0.7));
    border-top: 1px solid rgba(138, 0, 229, 0.25);
    backdrop-filter: blur(6px);
}
.strip-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}
.strip-num {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--purple);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 12px rgba(138, 0, 229, 0.5);
    line-height: 1.1;
}
.strip-lbl {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
}
@media (max-width: 900px) {
    .stat-strip { grid-template-columns: repeat(3, 1fr); }
}

/* ── Footer ─────────────────────────────────────── */
.footer-bar {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 2rem;
    background: rgba(27, 21, 52, 0.55);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(6px);
}
.footer-bar a { color: rgba(255, 255, 255, 0.7); text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,0.3); }
.footer-bar a:hover { color: var(--purple); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    .topbar {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 0.5rem 1rem;
        padding: 0.75rem 1rem;
    }
    .title-block { grid-column: 2; text-align: left; }
    .live-totals {
        grid-column: 1 / -1;
        justify-content: space-between;
        gap: 0.5rem;
    }
    .detail-panel { width: 100%; }
    .legend { font-size: 0.65rem; padding: 0.5rem 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
    .wf-pulse, .wf-ring, .hvdc-flow { animation: none; }
}
