/* =====================================================
   Z-Index Visual Stack Debugger — style.css
   Premium dark mode, isometric 3D visualization
   ===================================================== */

:root {
    --accent: #6C63FF;
    --accent2: #FF6584;
    --bg: #0A0A14;
    --surface: #12121E;
    --surface2: #1A1A28;
    --border: rgba(108, 99, 255, 0.18);
    --text: #E2E0FF;
    --text-muted: #8A87B8;
    --green: #00F5A0;
    --radius: 10px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg: #F4F3FF;
    --surface: #FFFFFF;
    --surface2: #EDECFC;
    --border: rgba(108, 99, 255, 0.15);
    --text: #1A1830;
    --text-muted: #6B6890;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 10% 20%, rgba(108, 99, 255, 0.07) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ── Glass card ───────────────────────────────────── */
.glass-card {
    background: rgba(18, 18, 30, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

[data-theme="light"] .glass-card {
    background: rgba(255, 255, 255, 0.85);
}

/* ── Header ───────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(10, 10, 20, 0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
}

[data-theme="light"] .header {
    background: rgba(244, 243, 255, 0.92);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(108, 99, 255, 0.15);
    border: 1px solid rgba(108, 99, 255, 0.4);
    border-radius: 10px;
}

.logo-title {
    font-size: 1rem;
    font-weight: 700;
}

.logo-sub {
    font-size: 0.65rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Buttons ──────────────────────────────────────── */
.icon-btn {
    width: 34px;
    height: 34px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.icon-btn:hover {
    color: var(--text);
    background: var(--border);
}

.icon-btn-sm {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 5px 10px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn-sm:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #9B8FFF);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.86rem;
    padding: 8px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.btn-primary:hover {
    box-shadow: 0 0 18px rgba(108, 99, 255, 0.45);
    transform: translateY(-1px);
}

.hidden {
    display: none !important;
}

/* ── Main Layout ──────────────────────────────────── */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    align-items: start;
    position: relative;
    z-index: 1;
}

/* ── Editor Panel ─────────────────────────────────── */
.editor-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px 0;
    border-bottom: 1px solid var(--border);
}

.e-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 8px 14px;
    cursor: pointer;
    margin-bottom: -1px;
    transition: all var(--transition);
}

.e-tab:hover {
    color: var(--text);
}

.e-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-spacer {
    flex: 1;
}

.code-pane {
    display: none;
}

.code-pane.active {
    display: flex;
    flex: 1;
}

.code-editor {
    background: var(--surface2);
    border: none;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
    padding: 14px 16px;
    resize: none;
    outline: none;
    flex: 1;
    min-height: 280px;
    width: 100%;
    border-bottom: 1px solid var(--border);
}

.code-editor::placeholder {
    color: var(--text-muted);
}

/* Validation bar */
.validation-bar {
    min-height: 32px;
    padding: 6px 14px;
    font-size: 0.73rem;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.validation-bar.ok {
    color: var(--green);
}

.validation-bar.error {
    color: var(--accent2);
}

/* Settings row */
.settings-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    flex-wrap: wrap;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.settings-label input[type="range"] {
    width: 80px;
    cursor: pointer;
}

input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    cursor: pointer;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 9px;
    background: var(--surface2);
    border: 1px solid var(--border);
    transition: background var(--transition);
}

.slider::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition), background var(--transition);
}

.toggle input:checked+.slider {
    background: rgba(108, 99, 255, 0.25);
    border-color: var(--accent);
}

.toggle input:checked+.slider::before {
    transform: translateX(16px);
    background: var(--accent);
}

/* ── View Panel ────────────────────────────────────── */
.view-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Toolbar */
.view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-title {
    font-size: 0.82rem;
    font-weight: 600;
}

.layer-count {
    font-size: 0.68rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 12px;
    padding: 2px 10px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ISO canvas */
.iso-container {
    min-height: 420px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#isoCanvas {
    display: none;
}

.iso-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 40px;
}

/* ── Inspector ─────────────────────────────────────── */
.inspector {
    padding: 0;
    overflow: hidden;
}

.inspector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.inspector-title {
    font-size: 0.82rem;
    font-weight: 600;
}

.inspector-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.inspector-body {
    padding: 12px;
}

/* Layer stack display */
.layer-stack-display {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.layer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    animation: slide-in 0.25s ease both;
}

.layer-row:hover {
    border-color: var(--accent);
}

.layer-row.selected {
    border-color: var(--accent);
    background: rgba(108, 99, 255, 0.08);
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.layer-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.layer-name {
    flex: 1;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text);
}

.layer-z {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', monospace;
}

.z-label {
    color: var(--text-muted);
}

.z-edit {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    width: 52px;
    padding: 2px 6px;
    outline: none;
    text-align: center;
    transition: border-color var(--transition);
}

.z-edit:focus {
    border-color: var(--accent);
}

.layer-props {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* ── Tutorial Modal ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(6px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modal-in 0.22s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.tut-body {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.tut-section h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.tut-section p,
.tut-section li {
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.tut-section ol,
.tut-section ul {
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tut-section code {
    background: var(--surface2);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--accent);
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 12px;
    }

    .header-inner {
        padding: 10px 14px;
    }

    .toolbar-right {
        flex-wrap: wrap;
    }
}