* { box-sizing: border-box; }

body {
    margin: 0;
    background: #f5f2eb;
    color: #302f2c;
    font-family: Georgia, "Times New Roman", serif;
}

header {
    max-width: 1100px;
    margin: auto;
    padding: 42px 18px 24px;
    text-align: center;
}

h1 {
    font-size: clamp(30px, 5vw, 54px);
    font-weight: normal;
    margin: 0 0 12px;
}

.subtitle {
    color: #78736d;
    font-size: 16px;
}

main {
    max-width: 1100px;
    margin: auto;
    padding: 0 12px 60px;
}

#globe {
    width: 100%;
    height: clamp(260px, 55vw, 620px);
    background: #101f30;
    border-radius: 8px;
    overflow: hidden;
}

.hint {
    text-align: center;
    color: #777;
    font: 13px Arial, sans-serif;
    margin: 14px 0 35px;
}

section {
    padding: 22px 10px;
    border-top: 1px solid #d8d2c7;
}

h2 { font-weight: normal; }

.maplibregl-popup-content {
    font: 15px Arial, sans-serif;
    border-radius: 6px;
}

@media (max-width: 600px) {
    header { padding-top: 26px; }
    #globe { border-radius: 5px; }
}

/* ATLAS THEMES */
html[data-theme="dark"] body {
    background: #171b20;
    color: #e8e3da;
}

html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .hint {
    color: #aeb4ba;
}

html[data-theme="dark"] section {
    border-color: #41474c;
}

#atlas-settings {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.atlas-switch {
    appearance: none;
    border: 1px solid #bcb4a8;
    background: transparent;
    color: inherit;
    border-radius: 30px;
    padding: 9px 17px;
    font: 14px Arial, sans-serif;
    cursor: pointer;
    min-width: 76px;
    min-height: 40px;
}

.atlas-switch:hover {
    border-color: #cba96d;
}

.atlas-switch:focus-visible {
    outline: 2px solid #cba96d;
    outline-offset: 3px;
}

html[data-theme="dark"] .atlas-switch {
    border-color: #5f6770;
}

html[data-theme="dark"] .atlas-switch:hover {
    border-color: #d5b77d;
}

@media (max-width: 600px) {
    #atlas-settings {
        margin-top: 18px;
    }
}


/* Painting markers */
.maplibregl-popup-content {
    background: #f5f2eb !important;
    color: #29251f !important;
    padding: 13px 17px !important;
    border-radius: 7px !important;
    box-shadow: 0 5px 22px rgba(0,0,0,.35);
}

.atlas-popup-title {
    display: block;
    color: #866636 !important;
    font: 600 16px Georgia, serif;
    line-height: 1.4;
}

a.atlas-popup-title {
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

a.atlas-popup-title:hover {
    color: #866636 !important;
    text-decoration: underline;
}

.maplibregl-popup-tip {
    border-top-color: #f5f2eb !important;
}


/* ATLAS MOBILE UX 2026 */

/* Compact controls in upper-right corner */
header {
    position: relative;
}

#atlas-settings {
    position: absolute;
    top: 10px;
    right: 18px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin: 0 !important;
}

#atlas-settings .atlas-switch {
    min-width: 0;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 13px;
    line-height: 1.2;
}

/* Clear instructions above the globe */
main > .hint {
    font-size: 18px;
    line-height: 1.5;
    font-weight: 500;
    margin: 0 0 16px;
    text-align: center;
}

@media (max-width: 600px) {
    header {
        padding-top: 58px;
    }

    #atlas-settings {
        top: 10px;
        right: 12px;
    }

    #globe {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    main > .hint {
        font-size: 18px;
        line-height: 1.5;
        margin-bottom: 14px;
    }
}


/* ATLAS GLOBE PANEL 2026 */

.atlas-globe-panel {
    background: #ede9e2;
    border: 1px solid #ddd6cc;
    border-radius: 14px;
    padding: 16px;
    margin-top: 7px;
    margin-bottom: 24px;
    overflow: hidden;
}

html[data-theme="dark"] .atlas-globe-panel {
    background: #242a30;
    border-color: #3b434b;
}

/* Instruction inside the panel */
.atlas-globe-panel .hint {
    font-size: inherit;
    line-height: inherit;
    font-weight: normal;
    text-align: left;
    margin: 0 0 14px;
}

/* Keep the existing desktop globe dimensions */
.atlas-globe-panel #globe {
    max-width: 100%;
}

@media (max-width: 600px) {
    .atlas-globe-panel {
        padding: 10px;
        margin-top: 6px;
        border-radius: 12px;
    }

    .atlas-globe-panel .hint {
        font-size: inherit;
        line-height: inherit;
        margin-bottom: 12px;
    }

    .atlas-globe-panel #globe {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}


/* ATLAS INTRO SPACING 2026 */
header > p {
    margin-bottom: 8px;
}

.atlas-globe-panel {
    margin-top: 0;
}

@media (max-width: 600px) {
    .atlas-globe-panel {
        margin-top: 0;
    }
}

/* atlas-spiderfy-v1: temporary fan for overlapping globe markers. */
.atlas-spider-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}
.atlas-spider-lines { position: absolute; inset: 0; overflow: visible; }
.atlas-spider-lines line { stroke: #f8dfa9; stroke-width: 2; }
.atlas-spider-point {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #e7ad49;
    color: #1b1b1b;
    font: 600 13px/1 sans-serif;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 7px rgba(0,0,0,.5);
}
.atlas-spider-point:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* Accessible, crawlable navigation for the bilingual painting collection. */
.atlas-painting-catalog {
    max-width: 1050px;
    margin: 8px auto 12px;
    padding: 0 16px;
    text-align: center;
}
.atlas-painting-catalog details {
    margin: 0;
    padding: 0;
}
.atlas-painting-catalog summary {
    display: inline-block;
    list-style: none;
    cursor: pointer;
    color: #866636;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}
html[data-theme="dark"] .atlas-painting-catalog summary { color: #d5b77d; }
.atlas-painting-catalog summary::-webkit-details-marker { display: none; }
.atlas-painting-catalog summary:hover { text-decoration-thickness: 2px; }
.atlas-painting-catalog summary:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 4px;
}
.atlas-painting-catalog ul {
    max-height: 340px;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 12px 0 0;
    padding: 10px 12px 10px 30px;
    border: 1px solid rgba(160, 160, 160, .35);
    border-radius: 6px;
    list-style-position: outside;
    text-align: left;
}
.atlas-painting-catalog li { margin-bottom: 7px; }
.atlas-painting-catalog a { color: #866636; text-decoration: underline; }
html[data-theme="dark"] .atlas-painting-catalog a { color: #d5b77d; }

/* Keep the SEO catalog directly below the diary page counter. */
#atlas-diary-pages.atlas-diary-with-catalog {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}
#atlas-diary-pages.atlas-diary-with-catalog > button:first-child { justify-self: start; }
#atlas-diary-pages.atlas-diary-with-catalog > button:last-child { justify-self: end; }
.atlas-diary-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    min-width: 0;
}
.atlas-diary-center .atlas-painting-catalog {
    margin: 0;
    padding: 0;
    max-width: none;
    font-size: 14px;
    line-height: 1.3;
}
.atlas-diary-center .atlas-painting-catalog details { position: relative; }
.atlas-diary-center .atlas-painting-catalog summary { font-size: 14px; }
/* The list opens above the link; the close control stays outside its scroll area. */
.atlas-catalog-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: min(420px, calc(100vw - 36px));
    padding: 38px 8px 8px;
    border: 1px solid rgba(160, 160, 160, .35);
    border-radius: 8px;
    background: #f5f2eb;
    box-shadow: 0 7px 22px rgba(0, 0, 0, .23);
    z-index: 30;
}
html[data-theme="dark"] .atlas-catalog-popover { background: #171b20; }
.atlas-catalog-popover ul,
.atlas-diary-center .atlas-catalog-popover ul {
    position: static;
    transform: none;
    width: auto;
    max-height: min(300px, calc(55dvh - 52px));
    margin: 0;
    padding: 5px 10px 8px 30px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}
#atlas-diary-pages button.atlas-catalog-close,
.atlas-catalog-popover button.atlas-catalog-close {
    position: absolute;
    top: 6px;
    right: 7px;
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    min-width: 29px;
    padding: 0;
    margin: 0;
    font: 22px/1 system-ui, sans-serif;
    color: inherit;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 50%;
    cursor: pointer;
}
.atlas-catalog-close:hover { opacity: .75; }
.atlas-catalog-close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* Match the active pagination button rather than the disabled one. */
.atlas-diary-center .atlas-diary-count { color: inherit; }
