/* =========================================
   EDITOR, TOOLBAR, & CRT EFFECTS
   ========================================= */

/* Toolbar */
/* Toolbar (Horizontal Top-Left) */
#rt-toolbar {
    position: fixed;
    top: 48px;
    left: 0;
    width: 100%;
    height: 34px;
    /* Slimmer */
    background: var(--header-bg);
    border-bottom: 1px solid var(--main-color);
    display: flex;
    flex-direction: row;
    /* FORCE ROW */
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding: 0 10px;
    z-index: 100;
    /* Above screen wrapper, below header (2000) */
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
}

#rt-toolbar.toolbar-hidden {
    display: none;
    transform: none;
}

.toolbar-group {
    display: flex;
    flex-direction: row;
    gap: 2px;
    align-items: center;
    width: auto;
    margin-bottom: 0;
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--main-color);
    opacity: 0.5;
    margin: 0 5px;
    color: var(--main-color);
}

#rt-toolbar button {
    background: transparent;
    border: 1px solid transparent;
    color: var(--main-color);
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    padding: 4px 8px;
    width: auto;
    height: auto;
    display: inline-block;
    border-radius: 2px;
    white-space: nowrap;
    min-width: 24px;
}



#rt-toolbar button:hover {
    border-color: var(--main-color);
    background: rgba(255, 255, 255, 0.1);
}

/* Screen Wrapper & CRT Effects */
#screen-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
}

#editor-container::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.02) 0%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
    z-index: 12;
}

#editor-container::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 3px 100%;
    opacity: var(--scanline-opacity);
    pointer-events: none;
    z-index: 10;
}

#rolling-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20%;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.1), transparent);
    opacity: var(--rolling-bar-opacity);
    animation: roll var(--rolling-bar-speed) linear infinite;
    pointer-events: none;
    z-index: 15;
}

@keyframes roll {
    from {
        top: -20%;
    }

    to {
        top: 120%;
    }
}

/* Editor Text Area */
#editor {
    width: 100%;
    max-width: none;
    height: var(--view-height);
    text-align: justify;
    background: transparent;
    border: none;
    outline: none;
    color: var(--main-color);
    font-family: var(--font-family), var(--cjk-stack);
    font-size: var(--font-size);
    letter-spacing: var(--letter-spacing);
    line-height: var(--line-height);
    text-shadow: calc(var(--aberration-offset) * -1) 0 rgba(255, 0, 0, 0.5), var(--aberration-offset) 0 rgba(0, 0, 255, 0.5), 0 0 calc(var(--glow-strength) * 10px) var(--main-color);
    padding: 0 40px;
    padding-top: 40px;
    padding-bottom: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    white-space: pre-wrap;
    /* Visible Lines Mask */
    mask-image: linear-gradient(to bottom, transparent calc(50% - var(--vis-lines-pct)/2), black calc(50% - var(--vis-lines-pct)/2), black calc(50% + var(--vis-lines-pct)/2), transparent calc(50% + var(--vis-lines-pct)/2));
    -webkit-mask-image: linear-gradient(to bottom, transparent calc(50% - var(--vis-lines-pct)/2), black calc(50% - var(--vis-lines-pct)/2), black calc(50% + var(--vis-lines-pct)/2), transparent calc(50% + var(--vis-lines-pct)/2));
}

/* =========================================
   BLOCK CURSOR MODE
   ========================================= */
body.block-cursor-mode #editor {
    caret-shape: block;
    /* For browsers that support it */
}

/* Fallback / Visual Hack for Block Cursor */
body.block-cursor-mode #editor,
body.block-cursor-mode #editor * {
    caret-color: var(--main-color);
}

/* If supported, make caret thick */
@supports (caret-shape: block) {
    body.block-cursor-mode #editor {
        caret-shape: block;
    }
}

/* Linter Marks */
.lint-mark {
    text-decoration: underline wavy var(--main-color);
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    font-weight: 400 !important;
    background-color: transparent !important;
    text-shadow: inherit;
    display: inline;
}

.lint-mark:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    cursor: help;
}

/* Main Workspace Flex */
#workspace-flex {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    z-index: 5;
    transition: flex-direction 0.3s ease;
}

#workspace-flex.orient-vertical {
    flex-direction: column;
}

#editor-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    filter: blur(var(--blur-amount));
    animation: flicker 0.15s infinite;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 1;
    min-width: 300px;
    min-height: 0;
    box-shadow: inset 0 0 150px rgba(0, 0, 0, var(--vignette-opacity));
    transform: translate(var(--jitter-x), var(--jitter-y));
}

#panel-resizer {
    flex: 0 0 auto;
    background: transparent;
    z-index: 50;
    transition: background 0.2s;
}

#panel-resizer:hover,
#panel-resizer.active {
    background: rgba(0, 255, 65, 0.2);
}

/* DECK POSITIONS */
#game-deck-panel.panel-hidden {
    display: none !important;
}

#workspace-flex.pos-left {
    flex-direction: row;
}

#workspace-flex.pos-left #game-deck-panel {
    order: -1;
    width: 300px;
    height: 100%;
    border-right: 1px solid var(--main-color);
    border-bottom: none;
}

#workspace-flex.pos-left #panel-resizer {
    width: 8px;
    height: 100%;
    cursor: col-resize;
    order: 0;
}

#workspace-flex.pos-left #editor-container {
    width: auto;
    flex: 1;
}

#workspace-flex.pos-right {
    flex-direction: row;
}

#workspace-flex.pos-right #game-deck-panel {
    order: 3;
    width: 300px;
    height: 100%;
    border-left: 1px solid var(--main-color);
    border-bottom: none;
}

#workspace-flex.pos-right #panel-resizer {
    order: 2;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

#workspace-flex.pos-right #editor-container {
    width: auto;
    flex: 1;
}

#workspace-flex.pos-top {
    flex-direction: column;
}

#workspace-flex.pos-top #game-deck-panel {
    order: -1;
    width: 100%;
    height: 300px;
    border-bottom: 1px solid var(--main-color);
}

#workspace-flex.pos-top #panel-resizer {
    width: 100%;
    height: 8px;
    cursor: row-resize;
    order: 0;
}

#workspace-flex.pos-top #editor-container {
    height: auto;
    flex: 1;
}

#workspace-flex.pos-bottom {
    flex-direction: column;
}

#workspace-flex.pos-bottom #game-deck-panel {
    order: 3;
    width: 100%;
    height: 300px;
    border-top: 1px solid var(--main-color);
    border-bottom: none;
}

#workspace-flex.pos-bottom #panel-resizer {
    order: 2;
    width: 100%;
    height: 8px;
    cursor: row-resize;
}

#workspace-flex.pos-bottom #editor-container {
    height: auto;
    flex: 1;
}





#workspace-flex.pos-top #editor-container {
    height: auto;
    flex: 1;
}

#workspace-flex.pos-bottom {
    flex-direction: column;
}

#workspace-flex.pos-bottom #game-deck-panel {
    order: 2;
    width: 100%;
    height: 300px;
    border-top: 1px solid var(--main-color);
    border-bottom: none;
}

#workspace-flex.pos-bottom #editor-container {
    height: auto;
    flex: 1;
}

@keyframes flicker {
    0% {
        opacity: 0.99;
    }

    50% {
        opacity: calc(1 - var(--flicker-strength));
    }

    100% {
        opacity: 1;
    }
}

/* Rhythm Graph */
#rhythm-graph {
    height: 60px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    opacity: 1;
    overflow-x: auto;
    padding-bottom: 2px;
}

.rhythm-bar {
    background: var(--main-color);
    width: 6px;
    min-height: 4px;
    flex-shrink: 0;
    transition: height 0.3s ease;
}

/* Linter Options */
#linter-options label {
    justify-content: flex-start;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}

#linter-options input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

/* Bottom Bar */
#bottom-bar {
    height: 60px;
    background: var(--header-bg);
    position: relative;
    border-top: 1px solid var(--main-color);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

canvas#wave-bar {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0.5;
}