/* ============================================================
   Design-Tokens
   ============================================================ */
:root {
    /* CONEC Corporate Identity – Blau + Weiß (CI: #054D91) */
    --conec: #054D91;                  /* CONEC CI-Blau */
    --conec-dark: #043a6e;             /* dunklere CI-Stufe */
    --conec-bright: #2b8ff0;           /* helle CI-Tönung (Marker/Glow) */
    --bg-color: #030d1a;

    /* Panel: durchgehend CONEC-Blau, weiße Schrift */
    --panel-bg: linear-gradient(180deg, rgba(5, 77, 145, 0.94), rgba(4, 52, 100, 0.94));
    --panel-border: rgba(255, 255, 255, 0.18);

    --dot-color: #ffffff;              /* UI-Akzent auf Blau = Weiß */
    --dot-glow: rgba(43, 143, 240, 0.55);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.74);
    --accent: #ffffff;                 /* Tooltip-Default (per JS überschrieben) */
    --beam-color: #8fd8ff;             /* Netzwerk-Blau (helles Cyan) */
    --pulse-duration: 2000ms;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg-color);
    overflow: hidden;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

#globeViz {
    width: 100vw;
    height: 100vh;
    position: relative;
    background:
        radial-gradient(ellipse 60% 50% at 50% 45%, rgba(90,110,140,0.05) 0%, rgba(10,10,15,0) 62%),
        var(--bg-color);
}

/* Vignette + oberer Verlauf für Tiefe/Kontrast der UI */
.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    background:
        radial-gradient(ellipse at center, transparent 55%, rgba(3, 8, 14, 0.55) 100%),
        linear-gradient(to bottom, rgba(3, 8, 14, 0.45) 0%, transparent 22%, transparent 80%, rgba(3, 8, 14, 0.5) 100%);
}

/* ============================================================
   Branding / Header
   ============================================================ */
.brand {
    position: fixed;
    top: 28px;
    left: 32px;
    z-index: 20;
    animation: fadeInUp 0.9s 0.2s both;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--conec-bright);
    box-shadow: 0 0 10px var(--conec-bright), 0 0 22px var(--dot-glow);
    position: relative;
    flex-shrink: 0;
}
.brand-dot::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid var(--conec-bright);
    opacity: 0.5;
    animation: brandPulse 2.4s ease-out infinite;
}

/* Offizielles Amphenol-CONEC-Logo (lokal) auf weißer Section –
   Weiße Fläche liegt auf dem Link-Element (robust auf iOS/Dark Mode),
   nicht auf dem <img>; Original-Farben bleiben unverändert. */
.brand-logo-link {
    display: inline-block;
    text-decoration: none;
    background: #ffffff;
    padding: 12px 18px;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* iOS: nicht automatisch abdunkeln/invertieren */
    color-scheme: light;
    -webkit-appearance: none;
    forced-color-adjust: none;
}
.brand-logo-link:hover { transform: translateY(-1px); }
.brand-logo-link:focus-visible {
    outline: 2px solid var(--conec-bright);
    outline-offset: 3px;
}
.brand-logo {
    display: block;
    height: 64px;
    width: auto;
    background: transparent;
}

/* ============================================================
   Sprach-Umschalter (oben rechts, über dem Panel)
   ============================================================ */
.lang-switch {
    position: fixed;
    top: 26px;
    right: 28px;
    z-index: 21;
    width: 248px;
    display: flex;
    gap: 3px;
    padding: 4px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    animation: fadeInUp 0.9s 0.28s both;
}

.lang-btn {
    flex: 1;
    min-width: 0;
    padding: 6px 0;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: rgba(255, 255, 255, 0.66);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.12); color: #ffffff; }
.lang-btn.active {
    background: #ffffff;
    color: var(--conec);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.lang-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 1px;
}

/* ============================================================
   Standort-Panel (Legende)
   ============================================================ */
.legend {
    position: fixed;
    top: 78px;
    right: 28px;
    z-index: 20;
    width: 248px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 16px 16px 10px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    animation: fadeInUp 0.9s 0.35s both;
}

/* Header ist zugleich der Auf-/Zu-Klapp-Button */
.legend-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 0 4px 12px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.25s;
}
.legend-head:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
    border-radius: 6px;
}
.legend-title {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-secondary);
}
.legend-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.legend-count {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 20px;
    padding: 2px 9px;
}
.legend-chevron {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.8);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.legend-list {
    list-style: none;
    margin-top: 6px;
    max-height: min(60vh, 460px);
    overflow-y: auto;
    padding-right: 2px;
    /* für die Klapp-Animation */
    opacity: 1;
    transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.25s ease, margin-top 0.35s ease;
}

/* Eingeklappter Zustand */
.legend.collapsed { padding-bottom: 4px; }
.legend.collapsed .legend-head {
    padding-bottom: 0;
    border-bottom-color: transparent;
}
.legend.collapsed .legend-chevron { transform: rotate(-180deg); }
.legend.collapsed .legend-list {
    max-height: 0 !important;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;
    pointer-events: none;
}
/* dezente Scrollbar */
.legend-list::-webkit-scrollbar { width: 5px; }
.legend-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.32); border-radius: 4px; }
.legend-list::-webkit-scrollbar-track { background: transparent; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.legend-item:hover { background: rgba(255, 255, 255, 0.10); transform: translateX(2px); }
.legend-item.active {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 2px 0 0 #ffffff;
}
.legend-home.active { background: rgba(255, 255, 255, 0.20); box-shadow: inset 2px 0 0 #ffffff; }

/* Regions-Kopfzeile (EMEA / AMERICAS / APAC) */
.legend-region {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 4px 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: #ffffff;
}
.legend-region:first-child { margin-top: 0; padding-top: 2px; border-top: 0; }
.legend-region-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rc);
    box-shadow: 0 0 8px var(--rc);
    flex-shrink: 0;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-text { display: flex; flex-direction: column; line-height: 1.3; }
.legend-text strong { font-size: 13.5px; font-weight: 600; }
.legend-text small { font-size: 11.5px; color: var(--text-secondary); }

/* Hinweis unten */
.hint {
    position: fixed;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    font-size: 12.5px;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 8px 18px;
    text-align: center;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* eigene Keyframe, die das -50% X (Zentrierung) NICHT überschreibt */
    animation: fadeInUpCenter 0.9s 0.6s both;
    transition: opacity 0.5s, transform 0.5s;
}
.hint.gone { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }

@keyframes fadeInUpCenter {
    from { opacity: 0; transform: translate(-50%, 14px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   Rechtliches (Impressum / Datenschutz) – unten mittig
   ============================================================ */
.legal {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    animation: fadeInUpCenter 0.9s 0.75s both;
}
.legal-link {
    font-size: 10px;
    letter-spacing: 0.3px;
    color: #ffffff;
    opacity: 0.72;
    text-decoration: none;
    transition: opacity 0.2s;
}
.legal-link:hover { opacity: 1; text-decoration: underline; }
.legal-link:focus-visible { outline: 1px solid #ffffff; outline-offset: 2px; opacity: 1; }
.legal-sep { font-size: 10px; color: #ffffff; opacity: 0.4; }

/* ============================================================
   Pulse-Marker
   ============================================================ */
.pulse-marker {
    position: absolute;
    pointer-events: none;
    transition: opacity 0.4s;
    /* --mc = Ruhefarbe, --ac = Aktivfarbe, --glow = Glow (per JS gesetzt) */
}

.pulse-center {
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    cursor: pointer;
    transition: transform 0.25s, background 0.3s, box-shadow 0.3s;
    background: var(--mc, var(--dot-color));
}

/* Hauptsitz: groß, dauerhaft leuchtend */
.node-home .pulse-center {
    width: 10px; height: 10px;
    background: var(--ac);
    box-shadow: 0 0 10px var(--ac), 0 0 24px var(--glow);
}

/* Länder: gleich groß wie der HQ-Punkt (leichter anklickbar) */
.node-country .pulse-center {
    width: 10px; height: 10px;
    opacity: 0.8;
    box-shadow: 0 0 8px var(--glow);
}

/* Aktives Land: leuchtet auf */
.node-country.active .pulse-center {
    width: 12px; height: 12px;
    opacity: 1;
    background: var(--ac);
    box-shadow: 0 0 12px var(--ac), 0 0 26px var(--glow);
}

.pulse-marker:hover .pulse-center { transform: translate(-50%, -50%) scale(1.4); }

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--ac, var(--dot-color));
    border-radius: 50%;
    opacity: 0;
    animation: pulse var(--pulse-duration) cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
/* Länder-Ringe nur wenn aktiv */
.node-country .pulse-ring { display: none; }
.node-country.active .pulse-ring { display: block; }

@keyframes pulse {
    0%   { width: 0;      height: 0;      opacity: 0.85; border-width: 3px; }
    70%  { opacity: 0.15; }
    100% { width: 90px;   height: 90px;   opacity: 0;    border-width: 0; }
}

/* Label unter dem Marker (bei Hover + wenn aktiv) */
.pulse-label {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translate(-50%, 4px);
    white-space: nowrap;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text-primary);
    background: rgba(5, 12, 21, 0.82);
    border: 1px solid var(--panel-border);
    padding: 3px 9px;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.pulse-marker:hover .pulse-label,
.node-country.active .pulse-label { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   Tooltip
   ============================================================ */
.tooltip {
    position: fixed;
    z-index: 1000;
    min-width: 232px;
    max-width: 300px;
    padding: 16px 18px;
    background: linear-gradient(180deg, rgba(5, 77, 145, 0.96), rgba(4, 45, 88, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top: 2px solid #8fd8ff;
    border-radius: 14px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 26px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -100%) translateY(10px) scale(0.96);
    transform-origin: bottom center;
    transition: opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1), transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    margin-top: -18px;
}
.tooltip.visible {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(0) scale(1);
    pointer-events: auto;
}
.tooltip.hidden { display: none; }

.tooltip::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: rgba(4, 45, 88, 0.96);
    border-right: 1px solid rgba(255, 255, 255, 0.18);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.tooltip-title { font-size: 17px; font-weight: 700; margin-bottom: 3px; }
.tooltip-city {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 9px;
    letter-spacing: 0.2px;
}
.tooltip-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 12px;
}
.tooltip-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    transition: gap 0.2s, opacity 0.2s;
}
.tooltip-link:hover { gap: 8px; opacity: 0.85; }

/* ============================================================
   Loader
   ============================================================ */
.loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: var(--bg-color);
    transition: opacity 0.7s ease;
}
.loader.hidden { opacity: 0; pointer-events: none; }

.loader-core { position: relative; width: 64px; height: 64px; }
.loader-ring {
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-top-color: var(--dot-color);
    border-radius: 50%;
    animation: spin 1.1s linear infinite;
}
.loader-ring:nth-child(2) { inset: 9px;  border-top-color: rgba(99,211,255,0.6); animation-duration: 1.5s; animation-direction: reverse; }
.loader-ring:nth-child(3) { inset: 18px; border-top-color: rgba(43,143,240,0.5); animation-duration: 1.9s; }
.loader-text {
    font-size: 12.5px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* ============================================================
   Animationen
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes brandPulse {
    0%   { transform: scale(1);   opacity: 0.5; }
    100% { transform: scale(2.2); opacity: 0; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Responsive
   ============================================================ */
/* ---- Tablet (Querformat / mittlere Breiten) ---- */
@media (min-width: 769px) and (max-width: 1024px) {
    .brand { top: 22px; left: 24px; }
    .brand-logo { height: 56px; }

    .lang-switch { top: 22px; right: 22px; width: 224px; }
    .legend { top: 74px; right: 22px; width: 224px; }
    .lang-btn { font-size: 11px; }
}

/* ---- Mobil (Panel wandert nach unten, einklappbar) ---- */
@media (max-width: 768px) {
    .brand { top: 12px; left: 14px; }
    .brand-logo-link { padding: 8px 11px; border-radius: 10px; }
    .brand-logo { height: 40px; }
    .brand-dot { width: 9px; height: 9px; }

    .lang-switch {
        top: 12px;
        right: 12px;
        left: auto;
        width: auto;
        gap: 2px;
        padding: 3px;
        flex-wrap: nowrap;
    }
    .lang-btn { padding: 5px 7px; font-size: 11px; }

    .legend {
        top: auto;
        bottom: 86px;
        right: 12px;
        left: 12px;
        width: auto;
        padding: 14px 14px 8px;
    }
    /* Scroll auf der Liste, Höhe begrenzt (Klapp-Animation bleibt aktiv) */
    .legend-list { max-height: 42vh; }
    .legend.collapsed { padding-bottom: 6px; }

    .hint { bottom: 44px; font-size: 11.5px; padding: 7px 14px; }
    .legal { bottom: 16px; }
    .tooltip { max-width: 82vw; }
}

/* ---- Kleine Smartphones: alles kompakter, kein Überlappen ---- */
@media (max-width: 430px) {
    .brand-logo-link { padding: 7px 9px; }
    .brand-logo { height: 34px; }
    .lang-switch { gap: 1px; padding: 2px; }
    .lang-btn { padding: 5px 5px; font-size: 10.5px; letter-spacing: 0; }
    .legend-list { max-height: 38vh; }
}

/* ============================================================
   Performance / Accessibility
   ============================================================ */
.pulse-marker, .pulse-ring { will-change: transform, opacity; }

@media (prefers-reduced-motion: reduce) {
    .pulse-ring { animation: none; opacity: 0.25; width: 46px; height: 46px; }
    .brand-dot::after { animation: none; }
    .tooltip, .legend-item, .hint { transition: none; }
    .loader-ring { animation-duration: 2.4s; }
}
