/* The model viewer beside the map (js/model-panel.js): the library's Model viewer button, the panel docked on the
   right, the model's markers and their card on the map, and the line naming the model at the top of the map. */

/* The library: Model viewer as big as Explore in 3D, under it. */
.map-page #open-models { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 38px; margin-top: 8px;
    background: transparent; border-color: var(--accent-line); color: var(--accent); font-weight: 650; }
.map-page #open-models:not(:disabled):hover { background: var(--raised); border-color: var(--accent); }
.map-page #open-models svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }

/* The panel: fixed on the right, as wide as --model-panel-width (dragged at its left edge, kept per browser). */
.model-dock { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1003; display: flex; flex-direction: column; width: var(--model-panel-width, 50vw);
    background: #0b1216; border-left: 1px solid var(--line); box-shadow: -12px 0 32px #0008; }
.map-page .model-dock[hidden] { display: none !important; }
.model-dock-grip { position: absolute; top: 0; bottom: 0; left: -5px; width: 10px; z-index: 2; cursor: ew-resize; }
.model-dock-grip:hover, .model-dock.resizing .model-dock-grip { background: linear-gradient(90deg, transparent 4px, var(--accent-line) 4px 6px, transparent 6px); }
.model-dock.resizing .model-dock-frame { pointer-events: none; }
.model-dock-bar { display: flex; align-items: center; gap: 10px; min-height: 46px; box-sizing: border-box; padding: 0 6px 0 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.model-dock-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.model-dock-frame { flex: 1; width: 100%; border: 0; background: #0b1216; }
/* Only the model viewer (modelfull=1): the panel fills the window over the map, which keeps its size and view behind it. */
.map-page .model-dock-expand { color: var(--muted); }
.map-page .model-dock-expand:hover, .map-page .model-dock-expand[aria-pressed="true"] { color: var(--accent); }
.model-dock-expand svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
body.model-dock-full .model-dock { width: 100vw; border-left: 0; box-shadow: none; }
body.model-dock-full .model-dock-grip { display: none; }
/* The panel stays beside 3D too: the 3D view (and its loading card) take the part it leaves free. The line on the map
   counts 2D markers, so it waits for the 2D map. */
body.model-dock-open #viewer3d-container { right: var(--model-panel-width, 50vw); }
body.model-dock-open :is(#viewer3d-transition, #map-empty) { left: calc((100% - var(--model-panel-width, 50vw)) / 2); }
body.viewer3d-active .model-pins-badge { display: none !important; }

/* The line at the top of the map: the model, how many of it stand here, Model viewer and ×. */
.model-pins-badge { position: fixed; top: var(--edge); left: calc((100vw + 330px) / 2); transform: translateX(-50%); z-index: 1002; display: flex; align-items: center; gap: 8px;
    box-sizing: border-box; max-width: calc(100vw - 2 * var(--edge) - 330px); padding: 4px 4px 4px 12px; background: var(--surface);
    border: 1px solid var(--accent-line); border-radius: 9px; box-shadow: var(--shadow); font-size: 12px; }
body.model-dock-open .model-pins-badge { left: calc((100vw - var(--model-panel-width, 50vw) + 330px) / 2); max-width: calc(100vw - var(--model-panel-width, 50vw) - 2 * var(--edge) - 330px); }
.model-pins-swatch { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #f2c14e; box-shadow: 0 0 0 1.5px #101515; }
.model-pins-name { flex: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pins-count { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.map-page .model-pins-open { flex: none; min-height: 30px; padding: 3px 10px; border-color: var(--accent-line); color: var(--accent); font-size: 12px; }
.map-page .model-pins-clear { width: 30px; height: 30px; font-size: 18px; }

/* A marker's card. */
.model-pin-card { display: flex; flex-direction: column; gap: 3px; min-width: 210px; font-size: 12px; line-height: 1.45; }
.model-pin-name { font-size: 13px; overflow-wrap: anywhere; }
.model-pin-what, .model-pin-coords { color: var(--muted); }
.model-pin-coords { font-variant-numeric: tabular-nums; }
.model-pin-actions { display: flex; gap: 6px; margin-top: 6px; }
.map-page .model-pin-actions button { min-height: 30px; padding: 3px 10px; font-size: 12px; }
.map-page .model-pin-actions .model-pin-3d { background: var(--accent); border-color: var(--accent); color: #171c1c; font-weight: 650; }

@media (max-width: 760px) {
    .model-dock { width: 100vw; border-left: 0; }
    .model-dock-grip { display: none; }
    .map-page .model-dock-expand { display: none; }
    .model-pins-badge { top: calc(var(--edge) + 52px); left: 50%; max-width: calc(100vw - 2 * var(--edge)); }
    .model-pins-name { max-width: 120px; }
    body.model-dock-open .model-pins-badge { display: none; }
    body.model-dock-open #viewer3d-container { right: 0; }
    body.model-dock-open :is(#viewer3d-transition, #map-empty) { left: 50%; }
}
