:root {
    --header-h: 52px;
    --bar-bg: #1c1d24;
    --bar-border: #34353f;
    --bar-text: #eceef4;
    --bar-muted: #8b8f9c;
    --bar-sub: #c3c6d0;
    --control-bg: #2a2b34;
    --control-border: #3d3e49;
    --accent: #f0c674;
    --accent-text: #3a2f10;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
}

[hidden] {
    display: none !important;
}

/* ===== Kopfleiste ===== */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 14px;
    background: var(--bar-bg);
    border-bottom: 0.5px solid var(--bar-border);
    color: var(--bar-text);
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.brand-title {
    font-size: 15px;
    font-weight: 600;
}

.readout {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    overflow: hidden;
    padding-left: 14px;
    border-left: 0.5px solid var(--bar-border);
    color: var(--bar-sub);
    font-size: 14px;
}

.readout-seg {
    white-space: nowrap;
}

.readout-label {
    color: var(--bar-muted);
}

#seg-distance {
    color: var(--bar-text);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* Sprachumschalter */
.lang-switch {
    display: flex;
    background: var(--control-bg);
    border: 0.5px solid var(--control-border);
    border-radius: 8px;
    overflow: hidden;
}

.lang-btn {
    background: transparent;
    color: var(--bar-sub);
    border: none;
    padding: 6px 11px;
    font-size: 13px;
    cursor: pointer;
}

.lang-btn.active {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
}

/* Hamburger-Menü */
.menu-wrap {
    position: relative;
}

.menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    background: var(--control-bg);
    border: 0.5px solid var(--control-border);
    border-radius: 8px;
    cursor: pointer;
}

.burger,
.burger::before,
.burger::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--bar-text);
    border-radius: 2px;
}

.burger {
    position: relative;
}

.burger::before,
.burger::after {
    content: "";
    position: absolute;
    left: 0;
}

.burger::before {
    top: -6px;
}

.burger::after {
    top: 6px;
}

.menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: #22232b;
    border: 0.5px solid var(--control-border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--bar-text);
    border: none;
    padding: 9px 10px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
}

.menu-item:hover {
    background: #2f3039;
}

.menu-sep {
    height: 0.5px;
    background: var(--control-border);
    margin: 4px 6px;
}

/* ===== Karte ===== */
#scroll-container {
    margin-top: var(--header-h);
    width: 100%;
    height: calc(100vh - var(--header-h));
    overflow-x: hidden;
    overflow-y: auto;
}

#placeholderImage,
#imageCanvas {
    width: 100%;
    display: block;
}

/* ===== Overlay ===== */
#overlay {
    position: absolute;
    z-index: 1000;
    max-width: 470px;
    border: 1px solid #ccc;
    background: rgb(154, 153, 150);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
}

#overlayTitle {
    font-size: 16px;
    font-weight: bold;
    color: #222;
}

#overlayImageWrap {
    position: relative;
    display: inline-block;
}

#overlayImage {
    max-width: 450px;
    max-height: 450px;
    display: block;
}

/* Roter Kreis, der den zentrierten Stern im Himmels-Ausschnitt markiert */
#overlayMarker {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 46px;
    height: 46px;
    transform: translate(-50%, -50%);
    border: 3px solid #ff3b3b;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

/* Ladeanzeige, solange das Bild noch nicht da ist */
#overlayLoader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 200px;
    height: 150px;
    color: #333;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 4px solid rgba(0, 0, 0, 0.2);
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    font-size: 0.95rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Lizenzzeile unter dem Bild ===== */
#lizenzZeile {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 450px;
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.35;
    color: #2b2b2b;
}

#lizenzText {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.info-badge {
    flex: none;
    width: 16px;
    height: 16px;
    padding: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 11px;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #444;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.info-badge:hover,
.info-badge:focus-visible {
    background: #2a6bd4;
}

/* ===== Dialog "Bildinformation" ===== */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
}

.dialog {
    width: min(640px, 100%);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.dialog-kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e2e6;
}

.dialog-kopf h2 {
    margin: 0;
    font-size: 17px;
}

.dialog-schliessen {
    width: 32px;
    height: 32px;
    font-size: 22px;
    line-height: 1;
    color: #444;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.dialog-schliessen:hover {
    background: #eee;
}

.dialog-inhalt {
    margin: 0;
    padding: 14px 16px 18px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
}

.dialog-inhalt dt {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6a6a72;
}

.dialog-inhalt dt:first-child {
    margin-top: 0;
}

.dialog-inhalt dd {
    margin: 3px 0 0;
    overflow-wrap: anywhere;
}

.dialog-inhalt a {
    color: #1a5fbf;
}

/* ===== "Wikipedia öffnen" – nur im Touch-Modus ===== */
#overlayOpen {
    display: none;
}

/* ==================== Touch-Modus (Handy/Tablet) ==================== */
/* Klasse .touch wird per JS an <body> gesetzt, wenn kein Hover verfügbar ist. */

body.touch #scroll-container {
    touch-action: pan-x pan-y; /* natives Verschieben; Pinch-Zoom übernimmt JS */
    overflow-x: auto;
}

/* Overlay wird auf Touch-Geräten zur Info-Karte am unteren Rand. */
body.touch #overlay {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    top: auto !important;
    margin: 0 auto;
    max-width: 500px;
    max-height: 80vh;
    overflow: auto;
}

body.touch #overlayImageWrap {
    display: block;
}

body.touch #overlayImage {
    max-width: 100% !important;
    max-height: 45vh !important;
    width: auto !important;
    height: auto !important;
    margin-top: 8px;
}

body.touch #lizenzZeile {
    max-width: none;
    font-size: 12px;
}

body.touch #lizenzText {
    white-space: normal;
}

body.touch .info-badge {
    width: 22px;
    height: 22px;
    font-size: 14px;
}

body.touch #overlayOpen {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    font-size: 1.05rem;
    font-weight: bold;
    color: #fff;
    background-color: #2a6bd4;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

body.touch #overlayOpen:active {
    background-color: #1f549f;
}

/* ===== Responsive: Segmente gestuft ausblenden, Entfernung bleibt ===== */
@media (max-width: 900px) {
    #seg-position {
        display: none;
    }
}

@media (max-width: 640px) {
    #seg-ra {
        display: none;
    }

    .readout {
        border-left: none;
        padding-left: 0;
    }
}

@media (max-width: 420px) {
    .brand-title {
        display: none;
    }
}
