/**
 * Anabaptist Trail Core — map styles.
 * v0.2.0 adds the historic-style frame (parchment mat, dark olive border,
 * serif title plate, corner ornaments, compass rose).
 *
 * Palette:
 *   #f0e7d0  parchment (mat)
 *   #4a5234  dark olive (frame, ornaments)
 *   #2f3e26  deeper olive (frame shadow)
 *   #607244  primary olive (pins, primary buttons)
 *   #2f3e46  navy (text, sidebar)
 *   #f2ede6  cream (page accents)
 */

/* ─── HISTORIC FRAME ─────────────────────────────────────────────────────── */

.at-map-frame {
    position: relative;
    margin: 56px auto 32px;
    padding: 14px;
    background:
        linear-gradient(135deg, #4a5234 0%, #3a422a 50%, #4a5234 100%);
    border-radius: 3px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.08) inset,
        0 -1px 0 rgba(0,0,0,0.2) inset,
        0 12px 36px rgba(47, 62, 70, 0.28);
    max-width: 1200px;
}

.at-map-frame-title {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: #4a5234;
    color: #f0e7d0;
    padding: 8px 32px;
    border-radius: 2px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    z-index: 5;
    text-align: center;
    line-height: 1.2;
    border: 1px solid #2f3e26;
    max-width: 90%;
    box-sizing: border-box;
}

.at-map-frame-title-main {
    display: block;
    font-family: Georgia, "Times New Roman", "Iowan Old Style", serif;
    font-size: 0.95em;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.at-map-frame-title-sub {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.7em;
    font-style: italic;
    letter-spacing: 0.05em;
    margin-top: 2px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.at-map-frame-mat {
    position: relative;
    background: #f0e7d0;
    background-image:
        radial-gradient(ellipse at top left, rgba(160,140,90,0.08), transparent 60%),
        radial-gradient(ellipse at bottom right, rgba(74,82,52,0.06), transparent 60%);
    padding: 18px;
    border: 1px solid #2f3e26;
    border-radius: 1px;
}

.at-map-frame-inner {
    position: relative;
    overflow: hidden;
    border: 2px solid #4a5234;
    border-radius: 1px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15) inset;
}

/* ─── CORNER ORNAMENTS ───────────────────────────────────────────────────── */

.at-map-corner {
    position: absolute;
    width: 26px;
    height: 26px;
    pointer-events: none;
    z-index: 2;
}
.at-map-corner svg { width: 100%; height: 100%; display: block; }
.at-map-corner-tl { top: 4px; left: 4px; }
.at-map-corner-tr { top: 4px; right: 4px; transform: scaleX(-1); }
.at-map-corner-bl { bottom: 4px; left: 4px; transform: scaleY(-1); }
.at-map-corner-br { bottom: 4px; right: 4px; transform: scale(-1, -1); }

/* ─── MAP WRAPPER ────────────────────────────────────────────────────────── */

.at-map-wrapper {
    position: relative;
    width: 100%;
    background: #f2ede6;
    overflow: hidden;
}

#at-map {
    width: 100%;
    height: 100%;
}

/* ─── COMPASS ROSE ───────────────────────────────────────────────────────── */

.at-map-compass {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 68px;
    height: 68px;
    z-index: 999;
    opacity: 0.92;
    pointer-events: none;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
    transition: opacity 0.3s ease;
}
.at-map-compass svg { width: 100%; height: 100%; display: block; }

.at-map-wrapper:hover .at-map-compass { opacity: 1; }

@media (max-width: 600px) {
    .at-map-compass { width: 52px; height: 52px; bottom: 12px; right: 12px; }
}

/* ─── CUSTOM PINS ────────────────────────────────────────────────────────── */

.at-map-pin {
    background: transparent;
    border: 0;
}

.at-map-pin svg {
    width: 28px;
    height: 36px;
    display: block;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

/* ─── SIDEBAR (desktop) / BOTTOM SHEET (mobile) ──────────────────────────── */

.at-map-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100%;
    height: 100%;
    background: #ffffff;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 1000;
}

.at-map-sidebar.is-open {
    transform: translateX(0);
}

.at-map-sidebar-close {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    z-index: 2;
}
.at-map-sidebar-close:hover { color: #2f3e46; }

.at-map-sidebar-content { padding: 24px; }

.at-map-sidebar-image {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 0 16px;
    border-radius: 4px;
}

.at-map-sidebar-title {
    margin: 0 0 12px;
    font-size: 1.4em;
    line-height: 1.2;
    color: #2f3e46;
}

.at-map-sidebar-meta {
    margin: 4px 0;
    font-size: 0.92em;
    color: #555;
}

.at-map-sidebar-excerpt {
    margin: 16px 0;
    line-height: 1.55;
    color: #2f3e46;
}

.at-map-sidebar-notes {
    background: #f6f4ef;
    padding: 12px 14px;
    border-left: 3px solid #607244;
    margin: 16px 0;
    font-size: 0.92em;
    color: #3a3f45;
}

.at-map-sidebar-actions {
    display: flex;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.at-map-sidebar-button {
    flex: 1;
    min-width: 140px;
    padding: 10px 16px;
    text-align: center;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s ease, background 0.2s ease;
    font-family: inherit;
}

.at-map-button-primary {
    background: #607244;
    color: #ffffff !important;
}
.at-map-button-primary:hover,
.at-map-button-primary:focus {
    background: #4f5e38;
    color: #ffffff !important;
}

.at-map-button-secondary {
    background: #f6f4ef;
    color: #3a3f45 !important;
    border: 1px solid #d8cec2;
}
.at-map-button-secondary:hover,
.at-map-button-secondary:focus {
    background: #ece4d6;
    color: #3a3f45 !important;
}
.at-map-button-secondary:disabled {
    opacity: 0.7;
    cursor: default;
}

/* Mobile: convert sidebar into bottom sheet */
@media ( max-width: 768px ) {
    .at-map-sidebar {
        width: 100%;
        height: 70%;
        top: auto;
        bottom: 0;
        right: 0;
        transform: translateY(100%);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
    }
    .at-map-sidebar.is-open {
        transform: translateY(0);
    }
}

/* ─── MARKER CLUSTER STYLING ─────────────────────────────────────────────── */

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: rgba(96, 114, 68, 0.4);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: rgba(96, 114, 68, 0.85);
    color: #ffffff;
    font-weight: 600;
}

/* ─── RESPONSIVE FRAME ───────────────────────────────────────────────────── */

@media (max-width: 700px) {
    .at-map-frame { padding: 8px; margin-top: 44px; }
    .at-map-frame-mat { padding: 10px; }
    .at-map-frame-title { padding: 6px 18px; top: -18px; }
    .at-map-frame-title-main { font-size: 0.78em; letter-spacing: 0.12em; }
    .at-map-corner { width: 20px; height: 20px; }
}
