/*
Theme Name: Terminal Console FSE
Author: Lukasz Kokoszka
Description: A retro monospaced grid theme with dynamic typing simulation, glowing letters, CRT static image placeholders and a switchable color scheme (dark, light, console green, console amber).
Version: 1.1.0
Requires at least: 6.5
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: terminal-console-fse
*/

/* --- COLOR SCHEMES (selected via <html data-theme="...">) --- */

:root,
:root[data-theme="dark"] {
    --console-bg: #000000;
    --console-fg: #ffffff;
    --console-glow: rgba(255, 255, 255, 0.5);
    --console-cursor: url("assets/cursor-white.gif");
    --console-icon: url("assets/favicon-white.gif");
}

:root[data-theme="light"] {
    --console-bg: #ffffff;
    --console-fg: #000000;
    --console-glow: rgba(0, 0, 0, 0.3);
    --console-cursor: url("assets/cursor-black.gif");
    --console-icon: url("assets/favicon-black.gif");
}

:root[data-theme="green"] {
    --console-bg: #000000;
    --console-fg: #33ff33;
    --console-glow: rgba(51, 255, 51, 0.55);
    --console-cursor: url("assets/cursor-green.gif");
    --console-icon: url("assets/favicon-green.gif");
}

:root[data-theme="amber"] {
    --console-bg: #000000;
    --console-fg: #ffb000;
    --console-glow: rgba(255, 176, 0, 0.55);
    --console-cursor: url("assets/cursor-amber.gif");
    --console-icon: url("assets/favicon-amber.gif");
}

body {
    background-color: var(--console-bg);
    color: var(--console-fg);
    text-shadow: 0 0 4px var(--console-glow), 0 0 8px var(--console-glow);
}

/* Scanline overlay for vintage monitor feel */
body::before {
    content: " ";
    display: block;
    position: fixed;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%);
    background-size: 100% 4px;
    opacity: 0.4;
    z-index: 99999;
    pointer-events: none;
}

/* Dark scanlines show as gray bars on a white background. */
:root[data-theme="light"] body::before {
    display: none;
}

/* --- HEADER & THEME SWITCHER --- */

.console-header {
    border-bottom: 2px solid currentColor;
    padding-bottom: 20px;
    margin-bottom: 40px;
    align-items: center;
}

.console-logo {
    gap: 12px;
    align-items: center;
}

.console-logo::before {
    content: "";
    flex: none;
    width: 32px;
    height: 32px;
    background: var(--console-icon) no-repeat center / contain;
    image-rendering: pixelated;
}

.wp-block-navigation {
    --wp--style--block-gap: 24px;
}

.console-header-actions {
    gap: 32px;
}

.wp-block-navigation__responsive-container.is-menu-open {
    background-color: var(--console-bg);
    color: var(--console-fg);
}

.wp-site-blocks {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.wp-site-blocks > main {
    flex: 1;
    width: 100%;
}

.console-footer {
    border-top: 2px solid currentColor;
    padding-top: 20px;
    margin-top: 40px;
    padding-bottom: 20px;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.console-theme-switcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.console-theme-switcher select {
    background: var(--console-bg);
    color: var(--console-fg);
    border: 1px solid currentColor;
    border-radius: 0;
    padding: 4px 8px;
    font: inherit;
    text-transform: uppercase;
    text-shadow: inherit;
    cursor: pointer;
}

.console-theme-switcher select:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* --- TYPEWRITER CURSOR --- */

.console-loading-cursor {
    display: inline-block;
    width: 12px;
    height: 1.2em;
    /* The GIF itself blinks; one file per theme color */
    background: var(--console-cursor) no-repeat center / 100% 100%;
    image-rendering: pixelated;
    vertical-align: middle;
}

/* --- CRT TV STATIC PLACEHOLDER --- */

.crt-screen {
    position: relative;
    overflow: hidden;
    width: fit-content;
    max-width: 100%;
    min-height: 120px;
    background: #000;
    border: 3px solid currentColor;
    border-radius: var(--crt-radius, 16px);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
}

/* Core sets featured images to width:100%; keep the natural size instead */
.wp-site-blocks .crt-screen img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
}

/* Horizontal scanlines and edge vignette stay on the image after it loads */
.crt-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
    pointer-events: none;
    background:
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0, rgba(0, 0, 0, 0.3) 1px, transparent 1px, transparent 3px),
        radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.7);
}

.crt-noise {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    transition: opacity 0.4s ease;
}

.crt-noise.is-fading {
    opacity: 0;
}

/* --- POST GRID --- */

.console-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    padding: 20px 0;
    list-style: none;
    margin: 0;
    grid-auto-rows: 1fr;
}

/* Core adds block-gap margins to every list item after the first, which offsets cards vertically. */
.console-grid > li {
    margin: 0;
}

.console-grid-item {
    border: 1px solid currentColor;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 15px;
}

.console-grid-item > * {
    margin-block: 0;
}

.console-grid-item .wp-block-post-excerpt {
    height: 7.5em;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
    mask-image: linear-gradient(to bottom, #000 55%, transparent);
}

.console-meta {
    margin: 20px 0;
    font-size: 0.8rem;
    opacity: 0.7;
}
