/* ==========================================================================
   Workshop Terminal Emulator — CRT Monitor & Terminal
   ========================================================================== */

/* Override content-page width for terminal */
.content-page:has(.workshop-terminal) {
    max-inline-size: var(--content-width);
}

/* --- Workshop Terminal Container --- */
.workshop-terminal {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Mode Toggle Switch --- */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-block-end: 1rem;
    font-family: 'Courier New', 'Lucida Console', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    user-select: none;
}

.mode-toggle-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.mode-toggle-label.active {
    color: var(--green);
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.4);
}

.mode-toggle-track {
    width: 3rem;
    height: 1.5rem;
    background: #2a2a2a;
    border-radius: 0.75rem;
    border: 2px solid #444;
    position: relative;
    cursor: pointer;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.mode-toggle-knob {
    width: 1.1rem;
    height: 1.1rem;
    background: linear-gradient(145deg, #666, #444);
    border-radius: 50%;
    position: absolute;
    top: 0.1rem;
    left: 0.1rem;
    transition: left 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.mode-toggle-track.linux .mode-toggle-knob {
    left: calc(100% - 1.3rem);
}

/* --- CRT Monitor Frame --- */
.crt-monitor {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 52rem;
}

.monitor-bezel {
    width: 100%;
    background:
        linear-gradient(180deg,
            #4a4842 0%, #3e3c38 8%,
            #35332f 20%, #2e2c28 50%,
            #28261f 80%, #222018 100%);
    border-radius: 1.75rem;
    padding: 2rem 2.25rem 1.75rem;
    box-shadow:
        0 0 0 3px #1a1810,
        0 2px 0 3px #35332f,
        0 10px 40px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
    position: relative;
    /* Subtle plastic texture */
    background-image:
        radial-gradient(ellipse at 30% 10%, rgba(255, 255, 255, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 90%, rgba(0, 0, 0, 0.15) 0%, transparent 50%);
}

/* Bezel ridge — horizontal seam line below screen */
.monitor-bezel::after {
    content: "";
    position: absolute;
    bottom: 1.1rem;
    left: 2.25rem;
    right: 2.25rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06) 20%, rgba(255, 255, 255, 0.06) 80%, transparent);
}

/* Power LED */
.power-led {
    position: absolute;
    bottom: 0.65rem;
    right: 1.75rem;
    width: 8px;
    height: 8px;
    background: #33ff33;
    border-radius: 50%;
    box-shadow: 0 0 4px #33ff33, 0 0 10px rgba(51, 255, 51, 0.5);
}

/* Monitor Screen */
.monitor-screen {
    background: #050505;
    border: 3px solid #111;
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    min-height: 22rem;
    max-height: 28rem;
    overflow-y: auto;
    position: relative;
    box-shadow:
        inset 0 0 50px rgba(0, 0, 0, 0.9),
        inset 0 0 100px rgba(0, 0, 0, 0.5),
        0 0 8px rgba(0, 0, 0, 0.8);
    font-family: 'Courier New', 'Lucida Console', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--green);
    cursor: text;
}

/* Scanlines overlay */
.monitor-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    border-radius: 0.75rem;
    z-index: 3;
}

/* Screen curvature / heavy vignette for convex glass look */
.monitor-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 0.75rem;
    box-shadow:
        inset 0 0 40px rgba(51, 255, 51, 0.04),
        inset 0 0 80px rgba(0, 0, 0, 0.5),
        inset 0 0 160px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 2;
}

/* Hide scrollbar but keep scrollable */
.monitor-screen::-webkit-scrollbar {
    width: 0;
}

.monitor-screen {
    scrollbar-width: none;
}

/* Monitor Base — chunky neck + wide foot */
.monitor-base {
    width: 8rem;
    height: 2.5rem;
    background: linear-gradient(180deg, #3a3836, #2e2c28 40%, #252320);
    border-radius: 0 0 0.25rem 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    position: relative;
}

.monitor-base::before {
    content: "";
    display: block;
    width: 4rem;
    height: 0.75rem;
    background: linear-gradient(180deg, #3e3c38, #35332f);
    position: absolute;
    top: -0.75rem;
    left: 50%;
    transform: translateX(-50%);
}

.monitor-base::after {
    content: "";
    display: block;
    width: 18rem;
    height: 0.65rem;
    background: linear-gradient(180deg, #2e2c28, #222018);
    border-radius: 0 0 0.5rem 0.5rem;
    position: absolute;
    bottom: -0.65rem;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

/* --- Terminal Content --- */
.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 1.2em;
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.3);
    position: relative;
    z-index: 1;
}

.terminal-line.empty {
    min-height: 1.2em;
}

/* Override link styles inside terminal */
.monitor-screen a {
    color: var(--cyan);
    text-shadow: 0 0 6px rgba(0, 229, 255, 0.3);
}

.monitor-screen a::after {
    display: none;
}

.monitor-screen a:visited {
    color: var(--cyan);
}

.monitor-screen a:hover {
    color: #fff;
}

/* Input area */
.terminal-input-line {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
    min-height: 1.4em;
}

.terminal-prompt {
    flex-shrink: 0;
    color: var(--green);
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.3);
    white-space: pre;
}

#terminal-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 0;
    height: 0;
}

#terminal-input-mirror {
    color: var(--green);
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.3);
    white-space: pre;
}

/* Block cursor */
.terminal-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1.1em;
    background-color: var(--green);
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
    box-shadow: 0 0 4px rgba(51, 255, 51, 0.4);
}

/* --- Sticky Note --- */
.sticky-note {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 15rem;
    padding: 1.25rem 1.15rem 1rem;
    background: linear-gradient(135deg, #f5e6a0, #efe0a0 50%, #ebd890);
    color: #3a3020;
    font-family: 'Comic Sans MS', 'Segoe Script', cursive;
    font-size: 0.9375rem;
    line-height: 1.6;
    transform: rotate(2deg);
    box-shadow:
        2px 3px 10px rgba(0, 0, 0, 0.25),
        0 0 1px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: opacity 0.3s ease;
}

/* Tape strip */
.sticky-note::before {
    content: "";
    position: absolute;
    top: -0.25rem;
    left: 1rem;
    width: 2.5rem;
    height: 0.75rem;
    background: rgba(200, 200, 180, 0.6);
    border-radius: 0 0 2px 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sticky-note-title {
    font-weight: bold;
    font-size: 0.875rem;
    margin-block-end: 0.5rem;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: #8a7f6f;
}

.sticky-note ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sticky-note li {
    margin-block-end: 0.15rem;
}

.sticky-note li::before {
    content: "\2022  ";
}

.sticky-note code {
    background: rgba(0, 0, 0, 0.08);
    color: #2a2010;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: bold;
    padding: 0.05em 0.3em;
    border-radius: 2px;
}

/* --- Responsive --- */
@media screen and (max-width: 50rem) {
    .monitor-screen {
        min-height: 18rem;
        max-height: 24rem;
        font-size: 0.8125rem;
    }

    .monitor-bezel {
        padding: 1.5rem;
        border-radius: 1.25rem;
    }

    .sticky-note {
        position: static;
        width: auto;
        max-width: 18rem;
        margin: 2rem auto 0;
        transform: rotate(1deg);
    }
}

@media screen and (max-width: 30rem) {
    .monitor-screen {
        min-height: 14rem;
        max-height: 20rem;
        font-size: 0.75rem;
        padding: 0.75rem;
    }

    .monitor-base {
        width: 8rem;
    }

    .monitor-base::after {
        width: 10rem;
    }

    .mode-toggle {
        font-size: 0.75rem;
    }
}
