@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800;900&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    touch-action: none;
}

code, pre, .font-mono, .CodeMirror {
    font-family: 'Fira Code', monospace !important;
}

/* -------------------------------------------------------------
   НАЛАШТУВАННЯ РЕДАКТОРА CODEMIRROR ТА КРАПОЧОК ВІДСТУПІВ
   ------------------------------------------------------------- */
.CodeMirror {
    height: 100% !important;
    background: #090e1b !important;
    color: #e2e8f0 !important;
    font-size: 13.5px;
    line-height: 1.6;
}

.CodeMirror-gutters {
    background: #060a14 !important;
    border-right: 1px solid #1e293b !important;
}

.CodeMirror-linenumber {
    color: #475569 !important;
    padding: 0 8px 0 4px !important;
}

/* Ледь помітні крапочки для відступів */
.cm-indent-guide {
    position: relative;
    display: inline-block;
}

.cm-indent-guide::before {
    content: "·";
    position: absolute;
    left: 0;
    color: rgba(255, 255, 255, 0.14);
    font-weight: bold;
    pointer-events: none;
}

/* -------------------------------------------------------------
   РОЗДІЛЮВАЧІ ВІКОН (SPLITTERS)
   ------------------------------------------------------------- */
.gutter-h {
    width: 9px;
    background: #0c1326;
    border-left: 1px solid #1e293b;
    border-right: 1px solid #1e293b;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    touch-action: none;
    z-index: 20;
    transition: background 0.15s ease;
}

.gutter-h:hover, .gutter-h.active {
    background: #0284c7;
}

.gutter-h-line {
    width: 1px;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
}

.gutter-v {
    height: 9px;
    background: #0c1326;
    border-top: 1px solid #1e293b;
    border-bottom: 1px solid #1e293b;
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    touch-action: none;
    z-index: 20;
    transition: background 0.15s ease;
}

.gutter-v:hover, .gutter-v.active {
    background: #0284c7;
}

.gutter-v-line {
    height: 1px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
}

.gutter-icon {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* -------------------------------------------------------------
   ПЛОЩИНА ТА СЦЕНА ВІКНА ПОДІЙ (ВІЛЬНИЙ ЗУМ + ПКМ ПАНОРАМУВАННЯ)
   ------------------------------------------------------------- */
#eventStageContainer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #040711;
    user-select: none;
    touch-action: none;
}

#eventStageContainer.is-panning {
    cursor: grabbing !important;
}

/* Viewport займає 100% простору та передає кліки активним дітям */
#stageViewport {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    pointer-events: none;
}

#stageViewport > * {
    pointer-events: auto;
}

#turtleCanvasContainer {
    position: relative;
    margin: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    border: 1px solid #1e293b;
    overflow: hidden;
    flex-shrink: 0;
}

#turtleCanvasContainer:empty {
    display: none;
    border: none;
    box-shadow: none;
}

#turtleCanvasContainer canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
    display: block !important;
    border-radius: 12px;
}

/* -------------------------------------------------------------
   ВІКНА ПРОГРАМ З КНОПКАМИ ТА ПОЛЯМИ ВВЕДЕННЯ (GUI WINDOWS)
   ------------------------------------------------------------- */
#guiLayer {
    z-index: 30;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

/* flex-shrink: 0 запобігає будь-якому стисканню картки у смужку */
.gui-window-card {
    background: #0d1424;
    border: 1px solid #334155;
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.85);
    overflow: hidden;
    width: 340px;
    max-width: 95vw;
    flex-shrink: 0 !important;
    animation: zoomIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.gui-header-bar {
    background: #162035;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.gui-btn {
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
}
.gui-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}
.gui-btn:active {
    transform: scale(0.97);
}

@keyframes zoomIn {
    0% { transform: scale(0.92); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* -------------------------------------------------------------
   ПОЛОТНО ДЛЯ PYGAME WEB (SDL2 WASM)
   ------------------------------------------------------------- */
#canvas {
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85);
    border: 1px solid #1e293b;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    max-width: 100%;
    max-height: 100%;
}
#canvas:focus {
    box-shadow: 0 0 0 2px #0284c7, 0 12px 35px rgba(0, 0, 0, 0.85);
}

/* Кастомний скролбар */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #060a14;
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* -------------------------------------------------------------
   ВКЛАДКИ ФАЙЛІВ ТА МОДУЛІВ У РЕДАКТОРІ
   ------------------------------------------------------------- */
#fileTabsBar::-webkit-scrollbar {
    height: 4px;
}

.file-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    color: #94a3b8;
    background: #0f172a;
    border: 1px solid #1e293b;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.file-tab:hover {
    color: #e2e8f0;
    border-color: #334155;
}

.file-tab.active {
    color: #38bdf8;
    background: #0c192c;
    border-color: #0284c7;
    box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.25);
}

.file-tab-entry {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
    cursor: pointer;
}

.file-tab-close {
    color: #64748b;
    font-size: 11px;
    line-height: 1;
    padding: 1px 3px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.file-tab-close:hover {
    color: #fda4af;
    background: rgba(244, 63, 94, 0.2);
}

#plotLayer {
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

#plotLayer img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    border: 1px solid #334155;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.75);
    background: #ffffff;
}