/**
 * R2026.10 Phase A — Rodia Map Studio immersive shell
 * UX LOCK: map ≥85%, site chrome hidden, panels overlay, no card wrapper
 * Uses Rodia theme tokens only (--color-* from theme.css)
 */

/* --- Hide site chrome; map studio fills viewport --- */
body.map-studio-active {
    overflow: hidden;
}

body.map-studio-active .site-top,
body.map-studio-active .site-footer,
body.map-studio-active .nav-backdrop,
body.map-studio-active .ad-banner {
    display: none !important;
}

body.map-studio-active main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    margin: 0;
    max-width: none;
}

body.map-studio-active .toast-stack {
    z-index: 10000;
}

/* --- Shell --- */
.map-studio-shell {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    background: var(--color-bg);
}

.map-studio-shell .scheme-cad-workspace {
    flex: 1 1 auto;
    min-height: 0 !important;
    height: auto !important;
    border: none;
    border-radius: 0;
    margin: 0;
}

/* --- Top bar 48px (LOCK) --- */
body.map-studio-active .map-studio-topbar.scheme-map-topbar {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    z-index: 20;
    flex-shrink: 0;
    min-height: 48px;
    max-height: 48px;
    padding: 0 12px;
    gap: 8px;
    flex-wrap: nowrap;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: none;
    backdrop-filter: none;
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view .map-studio-topbar.scheme-map-topbar {
    background: var(--color-surface);
}

.map-studio-topbar__leading {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    max-width: min(280px, 28vw);
}

.map-studio-topbar__exit {
    padding: 4px 8px !important;
    min-width: 32px;
    font-size: 13px;
    line-height: 1;
}

.map-studio-topbar__title {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-studio-topbar__crumb {
    font-size: 11px;
    color: var(--color-muted);
    white-space: nowrap;
}

body.map-studio-active .scheme-map-topbar .scheme-search-wrap {
    flex: 1;
    min-width: 120px;
    max-width: 420px;
}

body.map-studio-active .scheme-map-topbar .scheme-map-floatbar__actions {
    flex-shrink: 0;
}

/* --- Workspace grid: map-first, no inspector column --- */
body.map-studio-active .scheme-cad-workspace.scheme-mode-view,
body.map-studio-active .scheme-cad-workspace.scheme-mode-view.has-inspector,
body.map-studio-active .scheme-cad-workspace.scheme-mode-edit,
body.map-studio-active .scheme-cad-workspace.scheme-mode-edit.has-inspector {
    grid-template-columns: minmax(0, 1fr);
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view .scheme-cad-main,
body.map-studio-active .scheme-cad-workspace.scheme-mode-edit .scheme-cad-main {
    grid-column: 1 / -1;
}

/* Edit rail/toolbar — overlay, не сжимает карту (LOCK №2) */
body.map-studio-active .scheme-cad-workspace.scheme-mode-edit .scheme-cad-toolbar {
    position: fixed;
    left: 0;
    top: 48px;
    bottom: 28px;
    width: 48px;
    z-index: 85;
    grid-column: auto;
}

/* --- Inspector overlay (LOCK №2) --- */
body.map-studio-active .scheme-cad-inspector {
    position: fixed;
    top: 48px;
    right: 0;
    bottom: 28px;
    width: 320px;
    max-width: min(320px, 92vw);
    z-index: 90;
    grid-column: auto !important;
    transform: translateX(100%);
    transition: transform 200ms ease-out;
    border-left: 1px solid var(--color-border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
}

body.map-studio-active .scheme-cad-workspace.has-inspector .scheme-cad-inspector {
    transform: translateX(0);
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view.has-inspector .scheme-cad-canvas-wrap,
body.map-studio-active .scheme-cad-workspace.scheme-mode-edit.has-inspector .scheme-cad-canvas-wrap {
    /* карта не сжимается — inspector поверх */
    width: 100%;
}

/* --- Map viewport ≥85% --- */
body.map-studio-active .scheme-cad-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.map-studio-active .scheme-cad-canvas-wrap {
    flex: 1 1 auto;
    min-height: 0 !important;
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view .scheme-cad-canvas-wrap {
    min-height: 0 !important;
}

body.map-studio-active #scheme-canvas {
    min-height: 0 !important;
}

/* --- Status bar 28px --- */
body.map-studio-active .scheme-cad-statusbar {
    flex-shrink: 0;
    min-height: 28px;
    max-height: 28px;
    padding: 0 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface-elevated);
    border-top: 1px solid var(--color-border);
    overflow: hidden;
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view .scheme-cad-statusbar {
    display: none;
}

body.map-studio-active .scheme-map-status-view,
body.map-studio-active .scheme-cad-main > .scheme-cad-statusbar {
    display: none !important;
}

/* --- Edit mode accent (subtle) --- */
body.map-studio-active .scheme-cad-workspace.scheme-mode-edit .map-studio-topbar {
    box-shadow: inset 0 -2px 0 var(--color-accent);
}

/* --- Hide legacy page chrome remnants --- */
body.map-studio-active .scheme-page-head,
body.map-studio-active .scheme-notice,
body.map-studio-active .scheme-cad-topbar,
body.map-studio-active .scheme-cad-dock,
body.map-studio-active .scheme-map-layers,
body.map-studio-active .scheme-layers-panel,
body.map-studio-active #scheme-advanced-panel,
body.map-studio-active .scheme-layers-panel-btn {
    display: none !important;
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view .scheme-cad-toolbar {
    display: none !important;
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-view .scheme-cad-inspector {
    top: 48px;
}

body.map-studio-active .scheme-cad-workspace.scheme-mode-edit .scheme-cad-inspector {
    top: 48px;
}

@media (max-width: 900px) {
    body.map-studio-active .scheme-cad-inspector {
        width: 100%;
        max-width: none;
        bottom: 0;
    }

    body.map-studio-active .map-studio-topbar__title {
        max-width: 120px;
    }
}

/* PlayCanvas scheme — не immersive fullscreen: шапка сайта + контекстная полоса */
body.playcanvas-spike-active.map-studio-active .site-top {
    display: block !important;
}

body.playcanvas-spike-active.map-studio-active.is-scheme-immersive .site-top {
    display: none !important;
}

body.playcanvas-spike-active.map-studio-active .map-studio-shell {
    height: calc(100dvh - 64px);
    max-height: calc(100dvh - 64px);
}

body.playcanvas-spike-active.map-studio-active.is-scheme-immersive .map-studio-shell {
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}
