@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* ── Reset & Basis ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --parchment-dark:  #1a0e08;
    --parchment-mid:   #2a1a0a;
    --parchment-light: #3d2510;
    --gold:            #8B6914;
    --gold-bright:     #c9982e;
    --text-main:       #d4b896;
    --text-dim:        #8a6a50;
    --border:          1px solid #8B6914;
    --shadow:          0 4px 24px rgba(0,0,0,0.7);
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--parchment-dark);
    overflow: hidden;
    font-family: 'Crimson Text', Georgia, serif;
    color: var(--text-main);
}

/* ── Karte ── */
#map {
    width: 100vw;
    height: 100vh;
    background: var(--parchment-dark);
}

/* ── Leaflet-Controls im Fantasy-Stil ── */
.leaflet-control-zoom a {
    background: var(--parchment-mid) !important;
    color: var(--gold-bright) !important;
    border: var(--border) !important;
    font-family: 'Cinzel', serif !important;
    font-size: 16px !important;
    line-height: 28px !important;
    width: 30px !important;
    height: 30px !important;
}
.leaflet-control-zoom a:hover {
    background: var(--parchment-light) !important;
    color: #fff !important;
}
.leaflet-control-zoom {
    border: var(--border) !important;
    box-shadow: var(--shadow) !important;
}
.leaflet-control-attribution {
    background: rgba(26, 14, 8, 0.8) !important;
    color: var(--text-dim) !important;
    font-family: 'Crimson Text', serif !important;
    font-size: 11px !important;
}
.leaflet-control-attribution a { color: var(--gold) !important; }

/* ── Legende ── */
#legend {
    position: fixed;
    top: 0;
    right: 0;
    width: 220px;
    height: 100vh;
    background: rgba(26, 14, 8, 0.92);
    border-left: var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

#legend-header {
    padding: 18px 16px 12px;
    border-bottom: var(--border);
    flex-shrink: 0;
}
#legend-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--gold-bright);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
#legend-header p {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

#legend-list {
    overflow-y: auto;
    flex: 1;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--gold) var(--parchment-dark);
}
#legend-list::-webkit-scrollbar { width: 5px; }
#legend-list::-webkit-scrollbar-track { background: var(--parchment-dark); }
#legend-list::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.legend-item:hover { background: var(--parchment-light); }

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.2);
}

.legend-name {
    font-family: 'Crimson Text', serif;
    font-size: 14px;
    color: var(--text-main);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-count {
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ── Tooltip ── */
.map-tooltip {
    position: fixed;
    pointer-events: none;
    z-index: 2000;
    background: var(--parchment-mid);
    border: var(--border);
    border-radius: 3px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    min-width: 140px;
    max-width: 220px;
    display: none;
}
.map-tooltip.visible { display: block; }

.tooltip-name {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--gold-bright);
    margin-bottom: 4px;
}
.tooltip-detail {
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    color: var(--text-dim);
}
.tooltip-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: middle;
    border: 1px solid rgba(255,255,255,0.2);
}

/* ── Lade-Overlay ── */
#loading {
    position: fixed;
    inset: 0;
    background: var(--parchment-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    flex-direction: column;
    gap: 16px;
    transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }

#loading h1 {
    font-family: 'Cinzel', serif;
    font-size: 22px;
    color: var(--gold-bright);
    letter-spacing: 0.1em;
}
#loading p {
    font-family: 'Crimson Text', serif;
    font-size: 15px;
    color: var(--text-dim);
}

/* ── Fehlermeldung ── */
#error-msg {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #4a0a0a;
    border: 1px solid #8B2020;
    color: #ffaaaa;
    font-family: 'Crimson Text', serif;
    padding: 10px 20px;
    border-radius: 3px;
    z-index: 3000;
    display: none;
}
#error-msg.visible { display: block; }
