/* Apple //e Emulator - Monitor Styles
   Monitor frame, screen, fullscreen, and full page mode
*/

/* Monitor frame - holds canvas for full-page mode */
#monitor-frame {
    display: none;
}

/* Screen styles */
#screen {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
    outline: none;
    width: 560px;
    height: 384px;
}

#screen:focus {
    outline: none;
}

/* Fullscreen styles */
:fullscreen #app {
    background: #000;
}

:fullscreen header,
:fullscreen footer,
:fullscreen #debugger-panel {
    display: none;
}

:fullscreen main {
    padding: 0;
    align-items: center;
    justify-content: center;
}

:fullscreen .emulator-section {
    gap: 0;
}

:fullscreen #monitor-frame {
    transform: scale(1.1);
}

/* Full page mode */
body.full-page-mode {
    overflow: hidden;
}

body.full-page-mode header,
body.full-page-mode footer {
    display: none !important;
}

body.full-page-mode .debug-window {
    display: none !important;
}

body.full-page-mode main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    margin: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

body.full-page-mode .emulator-section {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

body.full-page-mode #monitor-frame {
    display: flex;
    max-width: 100%;
    max-height: 100%;
    align-items: center;
    justify-content: center;
}

body.full-page-mode #screen {
    width: auto;
    height: auto;
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 560 / 384;
}

/* Constrain by height on wide screens */
@media (min-aspect-ratio: 560/384) {
    body.full-page-mode #screen {
        height: 100vh;
        width: auto;
    }
}

/* Constrain by width on tall screens */
@media (max-aspect-ratio: 560/384) {
    body.full-page-mode #screen {
        width: 100vw;
        height: auto;
    }
}

/* Screen window canvas fills content area */
#screen-window .debug-window-content {
    padding: 0;
    overflow: hidden;
    background: #000;
}

.screen-window-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.screen-window-content #screen {
    display: block;
}

/* Viewport lock button in screen window header */
.screen-window-lock {
    position: relative;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    margin-right: 6px;
    border-radius: var(--radius-sm);
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s, background 0.15s, border-color 0.15s;
}

.screen-window-lock:hover {
    opacity: 1;
    color: var(--text-primary);
    background: var(--overlay-hover);
    border-color: var(--overlay-white-10);
}

.screen-window-lock.active {
    opacity: 1;
    color: var(--accent-green);
    background: var(--accent-green-bg);
    border-color: var(--accent-green-border-light);
}

.screen-window-lock.active:hover {
    background: var(--accent-green-bg-strong);
    border-color: var(--accent-green-border);
}

/* Stack both icons in the same grid cell so they overlap */
.screen-window-lock svg {
    grid-area: 1 / 1;
    transition: opacity 0.15s;
}

.screen-window-lock .lock-icon-locked {
    opacity: 0;
}

.screen-window-lock .lock-icon-unlocked {
    opacity: 1;
}

.screen-window-lock.active .lock-icon-unlocked {
    opacity: 0;
}

.screen-window-lock.active .lock-icon-locked {
    opacity: 1;
}

/* Charset switch in screen window header */
.screen-window-charset-switch {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    margin-right: 8px;
}

.screen-window-charset-switch .charset-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s;
}

.screen-window-charset-switch:has(#screen-window-charset-toggle:not(:checked)) .charset-label:first-of-type,
.screen-window-charset-switch:has(#screen-window-charset-toggle:checked) .charset-label:last-of-type {
    color: var(--accent-green);
}

.screen-window-charset-switch .charset-toggle {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 14px;
    cursor: pointer;
}

.screen-window-charset-switch .charset-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.screen-window-charset-switch .charset-slider {
    position: absolute;
    inset: 0;
    background: var(--input-bg-deeper);
    border: 1px solid var(--overlay-active);
    border-radius: 7px;
    transition: all 0.2s;
}

.screen-window-charset-switch .charset-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}

.screen-window-charset-switch .charset-toggle input:checked + .charset-slider {
    border-color: var(--accent-green-dim);
}

.screen-window-charset-switch .charset-toggle input:checked + .charset-slider::before {
    transform: translateX(10px);
    background: var(--accent-green);
}

.screen-window-charset-switch .charset-toggle:hover .charset-slider {
    border-color: var(--text-muted);
}

/* Full page toolbar - auto-hiding top bar */
.full-page-toolbar-wrapper {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: none;
    flex-direction: column;
    align-items: center;
}

body.full-page-mode .full-page-toolbar-wrapper {
    display: flex;
}

.full-page-toolbar-trigger {
    width: 300px;
    height: 10px;
}

.full-page-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(10, 10, 11, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: none;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transform: translateY(-100%);
    transition: transform 0.25s ease;
    pointer-events: auto;
}

.full-page-toolbar-wrapper:hover .full-page-toolbar {
    transform: translateY(0);
}

.fp-toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: var(--font-sans);
}

.fp-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.12);
}

/* Power icon button */
.fp-power-btn {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
}

.fp-power-btn svg {
    width: 16px;
    height: 16px;
}

.fp-power-btn.off {
    color: rgba(255, 255, 255, 0.35);
}

.fp-power-btn:not(.off) {
    color: #4ade80;
}

.fp-power-btn:not(.off):hover {
    background: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.2);
}

/* Text buttons */
.fp-text-btn {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Exit button accent */
.fp-exit-btn {
    color: rgba(255, 255, 255, 0.5);
}

.fp-exit-btn:hover {
    color: #fff;
}

/* Separator */
.fp-toolbar-separator {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

/* Text selection overlay styling */
.text-selection-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: var(--radius-lg);
}

/* Text selection context menu */
.text-select-context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-medium);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xs);
    min-width: 140px;
}

.text-select-context-menu .context-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 0.15s;
}

.text-select-context-menu .context-menu-item:hover {
    background: var(--bg-panel);
}

.text-select-context-menu .context-menu-item .shortcut {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: var(--space-md);
}
