/* Shared atlas UI components.
 * Both roles use the same header, sidebar, section, controls and typographic
 * rules. Page stylesheets only describe role-specific behavior or tools.
 * Future hand-drawn artwork can replace these surfaces through tokens.
 */
/* Navigation across atlas roles */
.atlas-header {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    min-height: var(--ds-header-height);
    height: var(--ds-header-height);
    background: var(--ds-color-header);
    color: #fff;
    padding: 8px 18px;
    font-family: var(--ds-font-body);
}
.atlas-header .atlas-brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.atlas-header .atlas-brand strong {
    font: 22px/1.2 var(--ds-font-display);
    color: #fff;
}
.atlas-header .atlas-brand small {
    color: #bfd1c4;
    font: 11px/1.4 var(--ds-font-body);
}
.atlas-header .atlas-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-left: auto;
}
.atlas-header .atlas-header-actions > a,
.atlas-header .atlas-header-actions > button {
    box-sizing: border-box;
    display: inline-block;
    border-radius: var(--ds-radius-control);
    border: 1px solid #587866;
    background: var(--ds-color-primary);
    color: #fff;
    padding: 7px 10px;
    font: 13px/1.35 var(--ds-font-body);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.atlas-header .atlas-header-actions > :is(a,button):hover {
    background: #416e55;
    color: #fff;
}
.atlas-header .atlas-header-actions > :is(a,button):focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.atlas-link-short { display: none; }

/* Continuous paper panel: identical in the editor and in the read-only atlas */
.atlas-sidebar {
    box-sizing: border-box;
    width: var(--ds-sidebar-width);
    color: var(--ds-color-text);
    background: var(--ds-color-panel);
    border-left: 1px solid var(--ds-color-border);
    font: 13px/1.5 var(--ds-font-body);
    padding: 4px 18px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-color: #b5c3b8 transparent;
    scrollbar-width: thin;
}
#right-ui-panel.atlas-sidebar {
    position: fixed;
    top: var(--ds-header-height);
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 1000;
    width: var(--ds-sidebar-width);
    height: auto;
    max-height: none;
    padding: 4px 18px 20px;
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
}
.player-sidebar.atlas-sidebar {
    flex: 0 0 var(--ds-sidebar-width);
    width: var(--ds-sidebar-width);
    padding: 4px 18px 20px;
}
#right-ui-panel.atlas-sidebar > *,
.player-sidebar.atlas-sidebar > * {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    min-width: 0;
    flex: none;
}

/* Common section rhythm, including master-only collapsible groups */
.atlas-sidebar .atlas-section {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: var(--ds-section-space) 0;
    border: 0;
    border-bottom: 1px solid var(--ds-color-border-soft);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    font-family: var(--ds-font-body);
}
.atlas-sidebar .atlas-section:last-child {
    border-bottom: 0;
}
.atlas-sidebar .atlas-section-title,
#right-ui-panel.atlas-sidebar .master-panel-heading {
    display: block;
    margin: 0 0 12px;
    color: var(--ds-color-heading);
    font: 18px/1.3 var(--ds-font-display);
    letter-spacing: 0;
}
.atlas-sidebar .atlas-section > summary {
    display: list-item;
    margin: -2px 0 0;
    padding: 2px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ds-color-heading);
    font: 18px/1.3 var(--ds-font-display);
    cursor: pointer;
}
.atlas-sidebar .atlas-section > summary:hover,
.atlas-sidebar .atlas-section[open] > summary {
    border: 0;
    border-radius: 0;
    background: transparent;
}
.atlas-sidebar .atlas-section > summary:hover { color: var(--ds-color-primary); }
.atlas-sidebar .atlas-section[open] > summary { margin-bottom: 12px; }
.atlas-sidebar .map-layer-panel-content,
.atlas-sidebar .biome-catalog-content {
    padding: 0;
}
.atlas-sidebar .atlas-section p,
.atlas-sidebar .atlas-section .map-layer-hint,
.atlas-sidebar .atlas-section .quick-search-hint {
    line-height: 1.5;
}
.atlas-sidebar .atlas-section .note { margin: 12px 0 0; }

/* Shared inputs and controls */
.atlas-sidebar :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea) {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 35px;
    padding: 8px 9px;
    background: var(--ds-color-paper);
    border: 1px solid var(--ds-input-border);
    border-radius: var(--ds-radius-control);
    color: var(--ds-color-text);
    font: 13px/1.4 var(--ds-font-body);
}
.atlas-sidebar :is(input[type="checkbox"], input[type="radio"]) {
    accent-color: var(--ds-color-primary);
}
.atlas-sidebar label {
    color: var(--ds-color-text);
    font: 13px/1.45 var(--ds-font-body);
}
.atlas-sidebar button {
    box-sizing: border-box;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--ds-color-primary-border);
    border-radius: var(--ds-radius-control);
    background: var(--ds-color-paper);
    color: var(--ds-color-primary);
    font: 600 12px/1.4 var(--ds-font-body);
    cursor: pointer;
}
.atlas-sidebar button:hover:not(:disabled) {
    background: var(--ds-color-surface-hover);
    border-color: var(--ds-color-primary);
}
.atlas-sidebar button:disabled { opacity: .55; cursor: default; }
.atlas-sidebar :is(button,input,select,textarea,summary):focus-visible {
    outline: var(--ds-focus-outline);
    outline-offset: 2px;
}

/* Shared modal form and sign-in paper */
.atlas-form-window,
.atlas-login {
    box-sizing: border-box;
    background: var(--ds-color-panel);
    color: var(--ds-color-text);
    border: 1px solid var(--ds-color-border);
    border-radius: var(--ds-radius-panel);
    box-shadow: var(--ds-shadow-panel);
    font-family: var(--ds-font-body);
}
.atlas-form-window h2,
.atlas-login h1 {
    color: var(--ds-color-heading);
    font-family: var(--ds-font-display);
}

/* Text fields in dialogs follow the same input surface as sidebar controls. */
.atlas-form-window :is(input:not([type="checkbox"]):not([type="range"]):not([type="file"]), select, textarea),
.atlas-login :is(input:not([type="checkbox"]), select, textarea) {
    box-sizing: border-box;
    border: 1px solid var(--ds-input-border);
    background: var(--ds-color-paper);
    color: var(--ds-color-text);
    border-radius: var(--ds-radius-control);
}

/* The master map occupies the same unobstructed canvas region as the player.
 * Leaflet's original coordinate system and world bounds remain unchanged. */
#map.atlas-map {
    position: fixed;
    top: var(--ds-header-height);
    left: 0;
    right: auto;
    bottom: 0;
    width: calc(100% - var(--ds-sidebar-width));
    height: calc(100% - var(--ds-header-height));
}

/* The master top bar is its existing authenticated notice in a proper shell. */
#auth-workspace-notice.atlas-header {
    position: fixed;
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    transform: none;
    z-index: 1600;
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: var(--ds-header-height);
    height: var(--ds-header-height);
    padding: 8px 18px;
    background: var(--ds-color-header);
    color: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
#auth-workspace-notice.atlas-header[hidden] { display: none !important; }
#auth-workspace-notice.atlas-header .atlas-brand { flex: 1; }
#auth-workspace-notice.atlas-header .atlas-header-actions {
    margin-left: 0;
    flex-shrink: 0;
}

/* One shared timeline centered above the actual map viewport, not the rail */
@media (min-width: 901px) {
    #timeline-controls {
        left: calc((100vw - var(--ds-sidebar-width)) / 2);
        width: min(760px, calc(100vw - var(--ds-sidebar-width) - 32px));
        min-width: 0;
    }
}
@media (max-width: 900px) {
    #right-ui-panel.atlas-sidebar {
        width: min(270px, 36vw);
        top: var(--ds-header-height);
    }
    #map.atlas-map { width: calc(100% - min(270px, 36vw)); }
    .player-sidebar.atlas-sidebar {
        width: 100%;
        flex: none;
        max-height: 190px;
        border-left: 0;
        border-top: 1px solid var(--ds-color-border);
    }
}
@media (max-width: 600px) {
    .atlas-header { gap: 7px; padding: 7px 10px; }
    .atlas-header .atlas-brand strong { font-size: 17px; }
    .atlas-header .atlas-brand small { font-size: 10px; }
    .atlas-header .atlas-header-actions { gap: 5px; }
    .atlas-header .atlas-header-actions > :is(a,button) {
        padding: 6px;
        font-size: 11px;
    }
    #auth-workspace-notice.atlas-header { padding: 7px 10px; }
    #right-ui-panel.atlas-sidebar {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: min(38vh, 320px);
        padding: 4px 14px 15px;
        border-left: 0;
        border-top: 1px solid var(--ds-color-border);
    }
    #map.atlas-map {
        width: 100%;
        height: calc(100% - var(--ds-header-height) - min(38vh, 320px));
    }
    #timeline-controls { bottom: min(38vh, 320px); }
}

/* The legacy master stylesheet has ID-specific rules. This is the
 * deliberate single high-specificity boundary that removes their floating
 * card styling; role-specific editor controls stay intact. */
#right-ui-panel.atlas-sidebar > .atlas-section {
    margin: 0;
    padding: var(--ds-section-space) 0;
    border: 0;
    border-bottom: 1px solid var(--ds-color-border-soft);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-family: var(--ds-font-body);
}
#right-ui-panel.atlas-sidebar > .atlas-section:last-child { border-bottom: 0; }
#right-ui-panel.atlas-sidebar details.atlas-section {
    overflow: visible;
}
#right-ui-panel.atlas-sidebar details.atlas-section > summary {
    margin: -2px 0 0;
    padding: 2px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ds-color-heading);
    font: 18px/1.3 var(--ds-font-display);
}
#right-ui-panel.atlas-sidebar details.atlas-section[open] > summary {
    margin-bottom: 12px;
    border: 0;
}
#right-ui-panel.atlas-sidebar .atlas-section :is(.map-layer-panel-content,.biome-catalog-content) {
    padding: 0;
}
#right-ui-panel.atlas-sidebar > #map-drawing-controls,
#right-ui-panel.atlas-sidebar > #location-controls {
    padding: var(--ds-section-space) 0;
}

@media (max-width: 420px) {
    .atlas-header .atlas-brand small { display: none; }
    .atlas-header .atlas-brand strong {
        font-size: 16px;
        white-space: nowrap;
    }
    .atlas-header .atlas-header-actions .atlas-link-full { display: none; }
    .atlas-header .atlas-header-actions .atlas-link-short { display: inline; }
}
