/* ═══════════════════════════════════════════════════════════════
   MRNUKE CRT TERMINAL BLOG — styles.css
   Retro CRT terminal aesthetic with full mobile support.
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --green:        #33FF33;
    --green-dim:    #1A8C1A;
    --green-dark:   #0D4D0D;
    --bg:           #000000;
    --bg-off:       #0A0A0A;
    --font-stack:   'Courier New', Courier, monospace;
    --dock-height:  18vh;
    --dock-min-h:   140px;
    --bar-width:    40;
    --transition-speed: 0.65s;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    font-family: var(--font-stack);
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    text-rendering: optimizeSpeed;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* ── CRT-style text selection (phosphor-invert) ──────────── */
::selection {
    background: #33FF33;
    color: #000000;
    text-shadow: none;
}
::-moz-selection {
    background: #33FF33;
    color: #000000;
    text-shadow: none;
}

/* ── CRT Scanline Overlay ─────────────────────────────────── */
#crt-scanlines {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 9000;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.12) 0px,
        rgba(0, 0, 0, 0.12) 1px,
        transparent   1px,
        transparent   3px
    );
}

/* ── CRT Vignette (darkened corners) ──────────────────────── */
#crt-vignette {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 9001;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.45) 100%
    );
}

/* ── CRT Flicker (subtle brightness oscillation) ──────────── */
#crt-flicker {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 9002;
    pointer-events: none;
    background: transparent;
    animation: crt-flicker 0.08s infinite alternate;
    opacity: 0.03;
}

@keyframes crt-flicker {
    0%   { opacity: 0.02; }
    50%  { opacity: 0.04; }
    100% { opacity: 0.01; }
}

/* ── App Shell ────────────────────────────────────────────── */
#app {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ── Content Viewport (top ~82% when visible) ─────────────── */
#content-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 1rem;
    transition: opacity var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1),
                max-height var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

#content-viewport.content-hidden {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
}

#content-viewport.content-visible {
    opacity: 1;
    max-height: calc(100vh - var(--dock-min-h));
}

/* Hide native scrollbar (custom CRT bar replaces it) */
#content-viewport {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#content-viewport::-webkit-scrollbar {
    display: none;
}

#article-container {
    width: 100%;
    max-width: 760px;
    color: var(--green);
    line-height: 1.75;
    font-size: 0.95rem;
    padding-bottom: 1rem;
}

#article-body {
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.5);
    word-wrap: break-word;
    overflow-wrap: break-word;
    -webkit-user-select: text;
    user-select: text;
}

#article-meta {
    -webkit-user-select: text;
    user-select: text;
}

/* Article typography */
#article-body h1 {
    font-size: 1.6rem;
    color: var(--green);
    border-bottom: 1px solid var(--green-dim);
    padding-bottom: 0.4rem;
    margin-bottom: 1.2rem;
    margin-top: 0.5rem;
    text-shadow: 0 0 12px rgba(51, 255, 51, 0.7);
    letter-spacing: 0.02em;
}

#article-body h2 {
    font-size: 1.25rem;
    color: var(--green);
    margin-top: 1.6rem;
    margin-bottom: 0.7rem;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.5);
}

#article-body h3 {
    font-size: 1.05rem;
    color: var(--green);
    margin-top: 1.3rem;
    margin-bottom: 0.5rem;
}

#article-body p {
    margin-bottom: 0.9rem;
    color: #2BCC2B;
}

#article-body strong, #article-body b {
    color: var(--green);
    text-shadow: 0 0 4px rgba(51, 255, 51, 0.4);
}

#article-body em, #article-body i {
    color: #44DD44;
}

#article-body a, #article-body a:visited {
    color: #66FF66;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#article-body ul, #article-body ol {
    margin: 0.6rem 0 0.9rem 1.5rem;
    color: #2BCC2B;
}

#article-body li {
    margin-bottom: 0.3rem;
}

#article-body code {
    background: rgba(51, 255, 51, 0.1);
    padding: 0.1em 0.35em;
    border: 1px solid var(--green-dim);
    color: var(--green);
    font-family: var(--font-stack);
    font-size: 0.9em;
}

#article-body pre {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--green-dim);
    padding: 0.8rem 1rem;
    margin: 0.8rem 0;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.55;
    text-shadow: none;
}

#article-body pre code {
    background: none;
    border: none;
    padding: 0;
}

#article-body hr {
    border: none;
    border-top: 1px dashed var(--green-dim);
    margin: 1.4rem 0;
}

#article-body blockquote {
    border-left: 3px solid var(--green-dim);
    padding-left: 1rem;
    margin: 0.8rem 0;
    color: #249924;
    font-style: italic;
}

/* Article meta footer */
#article-meta {
    margin-top: 1.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--green-dark);
    font-size: 0.8rem;
    color: var(--green-dim);
}
.meta-sep { margin: 0 0.6rem; }

/* ── CRT Scroll Progress Bar ──────────────────────────────── */
#scroll-bar {
    position: fixed;
    right: 8px;
    top: 10%;
    height: 80%;
    width: 6px;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.4s;
}
#scroll-bar:hover {
    width: 10px;
    right: 6px;
}
#scroll-bar.visible {
    opacity: 1;
}

#scroll-track {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(51, 255, 51, 0.06);
    border: 1px solid rgba(51, 255, 51, 0.15);
    border-radius: 3px;
}

#scroll-thumb {
    position: absolute;
    top: 0; left: 1px;
    width: calc(100% - 2px);
    height: 0%;
    background: var(--green);
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(51, 255, 51, 0.6),
                0 0 12px rgba(51, 255, 51, 0.25);
    transition: height 0.15s ease-out;
}

/* ── Terminal ─────────────────────────────────────────────── */
#terminal {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-off);
    border-top: 2px solid var(--green-dim);
    position: relative;
    z-index: 10;
    transition: height var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

/* Full-screen terminal (boot & shell modes) */
#terminal.terminal-full {
    height: 100vh;
}

/* Minimized dock (viewing mode) */
#terminal.terminal-docked {
    height: var(--dock-height);
    min-height: var(--dock-min-h);
}

#terminal-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.8rem;
    overflow: hidden;
}

/* ── Output Region ────────────────────────────────────────── */
#output-region {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#output-region::-webkit-scrollbar {
    width: 6px;
}

#output-region::-webkit-scrollbar-track {
    background: transparent;
}

#output-region::-webkit-scrollbar-thumb {
    background: var(--green-dark);
    border-radius: 3px;
}

#output-content {
    color: var(--green);
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    text-shadow: 0 0 4px rgba(51, 255, 51, 0.35);
    padding-bottom: 0.3rem;
}

/* Output line types */
.output-line {
    min-height: 1.4em;
}

.output-line.dim {
    color: var(--green-dim);
    text-shadow: 0 0 2px rgba(51, 255, 51, 0.2);
}

.output-line.bright {
    color: var(--green);
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.6);
}

.output-line.error {
    color: #FF4444;
    text-shadow: 0 0 6px rgba(255, 68, 68, 0.5);
}

.output-line.success {
    color: #44FF44;
    text-shadow: 0 0 8px rgba(68, 255, 68, 0.5);
}

.output-line.progress {
    color: #66FF66;
    text-shadow: 0 0 5px rgba(102, 255, 102, 0.5);
}

/* ── Input Line ───────────────────────────────────────────── */
#input-line {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-top: 0.2rem;
    padding-top: 0.3rem;
    border-top: 1px solid rgba(51, 255, 51, 0.08);
}

#prompt-text {
    color: var(--green);
    font-size: 0.9rem;
    white-space: pre;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
    flex-shrink: 0;
}

#input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

#cmd-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--green);
    font-family: var(--font-stack);
    font-size: 0.9rem;
    caret-color: var(--green);
    padding: 0;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    text-shadow: 0 0 4px rgba(51, 255, 51, 0.4);
}

#cmd-input::placeholder {
    color: var(--green-dark);
}

#cmd-input:focus {
    outline: none;
}

/* Blinking block caret (shown when input is empty / as visual cue) */
#caret {
    position: absolute;
    left: 0;
    top: 0;
    color: var(--green);
    font-size: 0.9rem;
    pointer-events: none;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.8);
    animation: blink 1s step-end infinite;
    display: none; /* hidden by default; shown via JS when input empty */
}

#caret.visible {
    display: inline;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ── Mobile Keyboard Toggle Button ────────────────────────── */
#kb-toggle {
    position: fixed;
    bottom: calc(var(--dock-height) + 12px);
    right: 12px;
    z-index: 9500;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--green-dim);
    background: rgba(0, 0, 0, 0.85);
    color: var(--green);
    font-size: 1.2rem;
    cursor: pointer;
    display: none; /* hidden on desktop */
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(51, 255, 51, 0.25);
    transition: bottom var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#kb-toggle:active {
    background: rgba(51, 255, 51, 0.15);
}

/* ── Responsive: Tablet ───────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --dock-height: 22vh;
        --dock-min-h: 130px;
    }
    #article-container {
        font-size: 0.88rem;
        padding: 0 0.25rem;
    }
    #article-body h1 { font-size: 1.35rem; }
    #article-body h2 { font-size: 1.1rem; }
    #terminal-inner {
        padding: 0.45rem 0.55rem;
    }
    #output-content {
        font-size: 0.82rem;
    }
    #prompt-text { font-size: 0.82rem; }
    #cmd-input   { font-size: 0.82rem; }
}

/* ── Responsive: Mobile ───────────────────────────────────── */
@media (max-width: 480px) {
    :root {
        --dock-height: 26vh;
        --dock-min-h: 120px;
    }
    #content-viewport {
        padding: 0.8rem 0.5rem;
    }
    #article-container {
        font-size: 0.8rem;
        line-height: 1.65;
        max-width: 100%;
    }
    #article-body h1 { font-size: 1.2rem; }
    #article-body h2 { font-size: 1rem; }
    #article-body h3 { font-size: 0.9rem; }
    #article-body pre {
        font-size: 0.72rem;
        padding: 0.5rem 0.65rem;
    }
    #article-body code { font-size: 0.82em; }
    #terminal-inner {
        padding: 0.35rem 0.45rem;
    }
    #output-content {
        font-size: 0.75rem;
        line-height: 1.45;
    }
    #prompt-text { font-size: 0.75rem; }
    #cmd-input   { font-size: 0.75rem; }
    #kb-toggle {
        display: flex;
    }
}

/* ── Responsive: Very Small ───────────────────────────────── */
@media (max-width: 360px) {
    :root {
        --dock-height: 30vh;
        --dock-min-h: 110px;
    }
    #article-container {
        font-size: 0.74rem;
    }
    #article-body h1 { font-size: 1.1rem; }
    #output-content { font-size: 0.7rem; }
    #prompt-text { font-size: 0.7rem; }
    #cmd-input   { font-size: 0.7rem; }
}

/* ── Landscape mobile — keep dock reasonable ──────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --dock-height: 28vh;
        --dock-min-h: 100px;
    }
    #content-viewport {
        padding: 0.4rem 0.6rem;
    }
    #article-container {
        font-size: 0.75rem;
        line-height: 1.5;
    }
}

/* ── Reduced motion preference ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #terminal,
    #content-viewport,
    #kb-toggle {
        transition-duration: 0.01s !important;
    }
    #caret {
        animation: none !important;
    }
    #crt-flicker {
        animation: none !important;
    }
}
