body {
    margin: 0;
    font-family: Arial, sans-serif;
    color: #071f41;
}

#layout {
    display: flex;
    height: 100vh;
    background: #f3efe7;
    position: relative;
}

#map {
    width: 62%;
    height: 100%;
}

/* ====================
   DETAILS PANEL — flex column so footer sticks to bottom
   ==================== */

#details {
    width: 38%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #c9c9c9;
    background: #f8f4ec;
    line-height: 1.55;
    box-sizing: border-box;
    overflow: hidden;
}

#detailsPanelInner {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    box-sizing: border-box;
}

/* ====================
   DESKTOP STICKY FOOTER
   ==================== */

#desktopFooter {
    flex-shrink: 0;
    background: #082b5f;
    border-top: 1px solid rgba(255,255,255,0.15);
}

#desktopFooterLinks {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 10px 16px;
}

#desktopFooterAttrib {
    padding: 6px 16px 10px;
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    line-height: 1.5;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ====================
   CLUSTER CIRCLES
   ==================== */
.cluster-circle,
.cluster-circle-blue,
.cluster-circle-purple,
.cluster-circle-red,
.cluster-circle-teal,
.cluster-circle-green {
    width: 32px;
    height: 32px;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.cluster-circle        { background: #082b5f; }
.cluster-circle-blue   { background: #1a4a8a; }
.cluster-circle-purple { background: #5a2880; }
.cluster-circle-red    { background: #8a2020; }
.cluster-circle-teal   { background: #1a6a7a; }
.cluster-circle-green  { background: #2d6e2d; }

/* ====================
   MOBILE OVERLAY ELEMENTS
   ==================== */

#mobileFilterBar {
    display: none;
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

#mobileHomeBtn {
    display: none;
    position: absolute;
    top: 12px;
    right: 8px;
    z-index: 1000;
    background: #082b5f;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#mobileExpandBtn {
    display: none;
    position: absolute;
    bottom: calc(48vh + 14px);
    right: 10px;
    z-index: 1000;
    background: rgba(8,43,95,0.85);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ====================
   FILTER BAR (DESKTOP PANEL)
   ==================== */

#filterBar {
    margin-bottom: 18px;
}

#categoryFilterDesktop,
#categoryFilter {
    padding: 11px 16px;
    border: 2px solid #082b5f;
    border-radius: 8px;
    background: #fffdf8;
    color: #082b5f;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    max-width: 260px;
}

#categoryFilterDesktop:focus,
#categoryFilter:focus {
    outline: none;
    border-color: #1a4a8a;
    box-shadow: 0 0 0 3px rgba(8,43,95,0.15);
}

/* ====================
   PLACE CARD
   ==================== */

.place-card {
    background: #fffdf8;
    border: 1px solid #d7d0c4;
    border-radius: 10px;
    padding: 26px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.place-card h1 {
    margin: 0 0 18px 0;
    font-size: 34px;
    color: #082b5f;
    border-bottom: none;
    padding-bottom: 6px;
}

.place-card h2 {
    font-size: 24px;
    margin: 28px 0 12px;
    color: #082b5f;
    padding-top: 0;
    border-top: none;
}

.intro {
    font-size: 17px;
    color: #555;
}

/* ====================
   RETURN TO MAP BUTTON
   ==================== */

.return-map {
    display: inline-block;
    margin: 0 0 16px 0;
    padding: 7px 16px;
    background: #082b5f;
    border: 1px solid #082b5f;
    border-radius: 20px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.return-map:hover {
    background: #0b3d80;
}

.return-icon {
    font-size: 18px;
    vertical-align: middle;
    margin-right: 5px;
}

/* ====================
   LITERATURE LIST
   ==================== */

.literature-list {
    columns: 1;
    padding-left: 20px;
    margin: 0;
}

.literature-list li {
    margin-bottom: 7px;
    line-height: 1.45;
}

/* ====================
   INFO + PARTNER PANELS
   ==================== */

.info-panel,
.partner-panel {
    margin-top: 16px;
    padding: 18px;
    border-radius: 8px;
}

.info-panel {
    border: 1px solid #bdd4ef;
    background: #eef6ff;
}

.panel-title {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 14px;
    color: #082b5f;
}

/* ====================
   BUTTONS
   ==================== */

.action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.button {
    display: inline-block;
    padding: 9px 0;
    width: 120px;
    text-align: center;
    border: 1px solid #0b4fa3;
    border-radius: 5px;
    background: #fff;
    color: #073f88;
    text-decoration: none;
    font-size: 13px;
    box-sizing: border-box;
    white-space: nowrap;
}

.button:hover {
    background: #eaf2ff;
}

.secondary-button {
    border-color: #0b4fa3;
    color: #073f88;
}

.secondary-button:hover {
    background: #eaf2ff;
}

/* ====================
   PARTNER PANEL
   ==================== */

.partner-panel {
    border: 1px solid #e2c47d;
    background: #fff8e8;
}

.partner-panel.literary { border-color: #e2c47d; background: #fff8e8; }
.partner-panel.horrible { border-color: #c4a8d0; background: #f5f0f7; }
.partner-panel.military { border-color: #8fba9f; background: #eef4f0; }
.partner-panel.maritime { border-color: #7ab0d0; background: #eef6ff; }
.partner-panel.ancient  { border-color: #5a9e5a; background: #f0f7f0; }

.partner-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.partner-icon {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.partner-icon.literary { background: #f5e4b8; }
.partner-icon.horrible { background: #e8d8f0; }
.partner-icon.military { background: #cce3d5; }
.partner-icon.maritime { background: #c0d8f0; }
.partner-icon.ancient  { background: #c8e6c8; }

.partner-name {
    font-size: 14px;
    font-weight: bold;
    color: #082b5f;
    line-height: 1.3;
}

.partner-tagline {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.partner-body {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    margin: 8px 0 10px;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 8px;
}

.partner-cta {
    display: inline-block;
    font-size: 12px;
    font-weight: bold;
    padding: 5px 12px;
    border-radius: 5px;
    border: 1px solid;
    text-decoration: none;
}

.partner-cta.literary { border-color: #ba8b1d; color: #7a5c1e; background: #fffdf6; }
.partner-cta.horrible { border-color: #9b6db8; color: #6a3d82; background: #faf5ff; }
.partner-cta.military { border-color: #4a9b6a; color: #2a6645; background: #f2faf5; }
.partner-cta.maritime { border-color: #1a6a9a; color: #0a4a7a; background: #f0f8ff; }
.partner-cta.ancient  { border-color: #2d6e2d; color: #1a4a1a; background: #f0f7f0; }

.partner-example-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 4px;
    background: #f0e8d0;
    color: #7a5c1e;
    margin-bottom: 8px;
}

.advertise-bar {
    margin-top: 10px;
    padding: 8px 12px;
    border-top: 1px dashed rgba(0,0,0,0.12);
    font-size: 12px;
    color: #888;
    text-align: right;
}

.advertise-bar a {
    color: #0b4fa3;
    text-decoration: none;
    font-weight: bold;
}

.advertise-bar a:hover {
    text-decoration: underline;
}

/* ====================
   PROJECT FOOTER (inline, inside place card)
   ==================== */

.project-footer {
    margin-top: 12px;
    font-size: 13px;
    color: #555;
    text-align: right;
}

/* Source credit in detail panel footer */
.source-credit {
    display: block;
    margin-top: 6px;
    color: #999;
    font-size: 11px;
}

/* Hide About link on mobile — it's in the footer nav instead */
@media (max-width: 768px) {
    .desktop-only { display: none; }
}

/* ====================
   SHARED FOOTER BUTTON STYLES
   ==================== */

.footer-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

.footer-btn:hover {
    color: white;
}

.footer-copy {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}

/* ====================
   MOBILE FOOTER
   ==================== */

#mobileFooter {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: #082b5f;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    align-items: center;
    justify-content: space-around;
    border-top: 1px solid rgba(255,255,255,0.15);
}

/* ====================
   MODAL
   ==================== */

#modalOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
}

#modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2001;
    background: #fffdf8;
    border-radius: 12px;
    border: 1px solid #d7d0c4;
    width: 90%;
    max-width: 540px;
    max-height: 80vh;
    overflow: hidden;
    flex-direction: column;
}

#modal.open,
#modalOverlay.open {
    display: flex;
}

#modalHeader {
    background: #082b5f;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#modalTabs {
    display: flex;
}

.modal-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    font-weight: 600;
    padding: 14px 16px;
    cursor: pointer;
    transition: color 0.15s;
}

.modal-tab.active {
    color: white;
    border-bottom-color: white;
}

.modal-tab:hover {
    color: white;
}

#modalClose {
    background: none;
    border: none;
    color: white;
    font-size: 26px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 12px;
    line-height: 1;
}

#modalClose:hover {
    color: white;
    opacity: 0.8;
}

#modalBody {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

#modalBody h2 {
    font-size: 20px;
    font-weight: 700;
    color: #082b5f;
    margin: 0 0 12px;
}

#modalBody h3 {
    font-size: 15px;
    font-weight: 700;
    color: #082b5f;
    margin: 20px 0 6px;
}

#modalBody p {
    font-size: 14px;
    color: #444;
    line-height: 1.6;
    margin: 0 0 10px;
}

#modalBody ul {
    font-size: 14px;
    color: #444;
    line-height: 1.8;
    padding-left: 20px;
    margin: 0 0 12px;
}

#modalBody a {
    font-size: 13px;
    color: #0b4fa3;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 8px;
}

#modalBody a:hover {
    text-decoration: underline;
}

.attribution-block {
    background: #f0f4fa;
    border-left: 3px solid #1a4a8a;
    padding: 8px 12px;
    font-size: 13px;
    color: #333;
    font-style: italic;
    margin: 6px 0 8px;
    border-radius: 0 4px 4px 0;
}

.contact-link {
    display: inline-block;
    font-size: 16px;
    font-weight: 600;
    color: #082b5f;
    margin: 8px 0 20px;
}

/* ====================
   MOBILE
   ==================== */

@media (max-width: 768px) {

    #layout {
        flex-direction: column;
    }

    #map {
        width: 100%;
        height: calc(52vh - env(safe-area-inset-top));
        transition: height 0.3s ease;
    }

    #details {
        width: auto;
        height: calc(48vh - env(safe-area-inset-bottom));
        border-left: none;
        border-top: 1px solid #ccc;
        transition: transform 0.3s ease, height 0.3s ease;
        /* Override desktop flex padding — padding is on inner div */
        padding: 0;
    }

    #detailsPanelInner {
        padding: 14px;
        padding-bottom: calc(14px + 52px + env(safe-area-inset-bottom));
    }

    /* Hide desktop footer on mobile */
    #desktopFooter {
        display: none;
    }

    #details.panel-hidden {
        transform: translateY(100%);
        pointer-events: none;
    }

    #details.panel-hidden {
        display: none;
    }

    #mobileFilterBar {
        display: block;
        top: calc(12px + env(safe-area-inset-top));
    }

    #mobileHomeBtn {
        display: flex;
        top: calc(12px + env(safe-area-inset-top));
    }

    #mobileExpandBtn {
        display: flex;
        bottom: calc(48vh + 14px);
    }

    #filterBar {
        display: none;
    }

    .place-card {
        padding: 18px;
    }

    .place-card h1 {
        font-size: 26px;
    }

    .literature-list {
        columns: 1;
    }

    .project-footer {
        text-align: left;
    }

    #mobileFooter {
        display: flex;
    }

    #modal {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }
}

/* ====================
   MOBILE MAP EXPANDED STATE
   ==================== */

/* Filter active: full height map, hide panel */
#layout.filter-active #map {
    height: calc(100vh - 52px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
}

#layout.filter-active #details {
    display: none;
}

/* Map expanded: full height, hide panel and expand button */
#layout.map-expanded #map {
    height: calc(100vh - 52px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
}

#layout.map-expanded #details {
    display: none;
}

#layout.map-expanded #mobileExpandBtn {
    display: none;
}

/* ====================
   CUSTOM MOBILE DROPDOWN
   ==================== */

#categoryFilterCustom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #fffdf8;
    border: 2px solid #082b5f;
    border-radius: 22px;
    color: #082b5f;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    min-width: 180px;
    justify-content: space-between;
}

#categoryFilterDropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #082b5f;
    border-radius: 12px;
    overflow: hidden;
    min-width: 200px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 1001;
}

#categoryFilterDropdown.open {
    display: block;
}

.filter-option {
    padding: 14px 20px;
    color: rgba(255,255,255,0.85);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.filter-option:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

.filter-option.selected {
    color: white;
    font-weight: 700;
}
