/* ============================================================
   TOM HERMANN — COMMODORE 64 / DEMO SCENE THEME
   Palette based on the original C64 hardware color values
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

/* ── Color variables ─────────────────────────────────────── */
:root {
    --c64-black:        #000000;
    --c64-white:        #ffffff;
    --c64-red:          #883932;
    --c64-cyan:         #67b6bd;
    --c64-purple:       #8b3f96;
    --c64-green:        #55a049;
    --c64-blue:         #40318d;
    --c64-yellow:       #bfce72;
    --c64-orange:       #8b5429;
    --c64-brown:        #574200;
    --c64-light-red:    #b86962;
    --c64-dark-grey:    #505050;
    --c64-mid-grey:     #787878;
    --c64-light-green:  #94e089;
    --c64-light-blue:   #7869c4;
    --c64-light-grey:   #9f9f9f;

    /* Screen colors — the iconic blue-on-blue C64 default */
    --screen-bg:        #4040b8;
    --screen-border:    #4040b8;
    --screen-text:      #7878f8;
    --screen-hi:        #ffffff;
    --screen-cyan:      #67b6bd;
    --screen-yellow:    #bfce72;

    --font-pixel:  'Press Start 2P', monospace;
    --font-term:   'VT323', monospace;
}

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

html {
    height: 100%;
    background: var(--screen-border);
}

body {
    min-height: 100%;
    background: var(--screen-bg);
    color: var(--screen-text);
    font-family: var(--font-term);
    font-size: 1.4rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    /* CRT scanline overlay */
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 3px,
            rgba(0,0,0,0.08) 3px,
            rgba(0,0,0,0.08) 4px
        );
}

/* ── CRT vignette ────────────────────────────────────────── */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.45) 100%);
    pointer-events: none;
    z-index: 1000;
}

/* ── Demo-scene raster scroller bar ─────────────────────── */
.scroller-wrap {
    overflow: hidden;
    height: 2.2rem;
    background: var(--c64-black);
    border-bottom: 2px solid var(--screen-text);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.scroller-track {
    display: flex;
    white-space: nowrap;
    animation: scroll-left 32s linear infinite;
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    letter-spacing: 0.15em;
}

.scroller-track span {
    padding-right: 6rem;
}

/* each character gets a color from the raster palette */
.scroller-track .r1 { color: var(--c64-light-red);   }
.scroller-track .r2 { color: var(--c64-yellow);       }
.scroller-track .r3 { color: var(--c64-light-green);  }
.scroller-track .r4 { color: var(--c64-cyan);         }
.scroller-track .r5 { color: var(--screen-text);      }
.scroller-track .r6 { color: var(--c64-light-blue);   }

@keyframes scroll-left {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ── Raster bars (demo scene classic) ───────────────────── */
.raster-bars {
    height: 8px;
    background: linear-gradient(
        to right,
        var(--c64-red),
        var(--c64-orange),
        var(--c64-yellow),
        var(--c64-light-green),
        var(--c64-cyan),
        var(--c64-light-blue),
        var(--c64-purple),
        var(--c64-red)
    );
    background-size: 200% 100%;
    animation: raster-cycle 3s linear infinite;
    flex-shrink: 0;
}

@keyframes raster-cycle {
    0%   { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* ── Main layout ─────────────────────────────────────────── */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
}

/* ── Screen frame ────────────────────────────────────────── */
.screen {
    width: 100%;
    max-width: 640px;
    border: 3px solid var(--screen-text);
    padding: 2rem 2.5rem;
    position: relative;
    background: var(--screen-bg);
}

/* corner decorations */
.screen::before,
.screen::after {
    content: '+';
    position: absolute;
    color: var(--screen-hi);
    font-family: var(--font-pixel);
    font-size: 0.5rem;
}
.screen::before { top: 4px; left: 6px; }
.screen::after  { top: 4px; right: 6px; }

/* ── Boot header ─────────────────────────────────────────── */
.boot-header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--screen-text);
    padding-bottom: 1.5rem;
}

.name-art {
    display: inline-block;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.3rem, 1.1vw, 0.52rem);
    line-height: 1.15;
    color: var(--screen-hi);
    white-space: pre;
    overflow-x: auto;
    margin-bottom: 0.75rem;
    text-align: left;
}

.boot-header .sys-line {
    font-family: var(--font-term);
    font-size: 1.1rem;
    color: var(--screen-cyan);
    letter-spacing: 0.1em;
}

.boot-header .ready-line {
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    color: var(--screen-hi);
    margin-top: 1rem;
    letter-spacing: 0.1em;
}

/* ── Link list ───────────────────────────────────────────── */
.link-list {
    list-style: none;
    margin-bottom: 2rem;
}

.link-list li {
    margin-bottom: 0.6rem;
    font-family: var(--font-term);
    font-size: 1.4rem;
}

.link-list li::before {
    content: '> ';
    color: var(--screen-hi);
}

/* Focused row: replace > with blinking block cursor */
.link-list li:focus-within::before {
    content: '\2588 ';
    animation: blink 0.8s step-end infinite;
}

.link-list a {
    color: var(--screen-yellow);
    text-decoration: none;
    letter-spacing: 0.05em;
    transition: color 0.1s, background 0.1s;
}

.link-list a:hover,
.link-list a:focus {
    color: var(--screen-bg);
    background: var(--screen-yellow);
    outline: none;
}

/* Reveal number hint on focused row */
.link-list li:focus-within .cmd {
    color: var(--screen-hi);
}

.link-list .cmd {
    color: var(--screen-text);
    font-size: 1rem;
    margin-left: 0.5rem;
}

/* Keyboard hint shown below the link list */
.kbd-hint {
    font-family: var(--font-pixel);
    font-size: 0.4rem;
    color: var(--screen-text);
    opacity: 0.6;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
}

/* ── Blinking cursor ─────────────────────────────────────── */
.cursor {
    display: inline-block;
    width: 0.7em;
    height: 1.1em;
    background: var(--screen-hi);
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

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

/* ── Footer ──────────────────────────────────────────────── */
footer {
    flex-shrink: 0;
    text-align: center;
    padding: 0.75rem 1rem;
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--screen-text);
    border-top: 2px solid var(--screen-text);
    letter-spacing: 0.1em;
    opacity: 0.8;
}

footer a {
    color: var(--screen-cyan);
    text-decoration: none;
}
footer a:hover { text-decoration: underline; }

/* ── Error pages ─────────────────────────────────────────── */
.error-screen {
    text-align: center;
    padding: 4rem 2rem;
}

.error-code {
    font-family: var(--font-pixel);
    font-size: clamp(2rem, 10vw, 5rem);
    color: var(--c64-light-red);
    display: block;
    margin-bottom: 1rem;
    animation: flicker 2s step-end infinite;
}

@keyframes flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
    20%, 22%, 24%, 55%                      { opacity: 0.4; }
}

.error-msg {
    font-family: var(--font-term);
    font-size: 1.4rem;
    color: var(--screen-text);
    margin-bottom: 2rem;
}

.btn-home {
    display: inline-block;
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    color: var(--screen-bg);
    background: var(--screen-yellow);
    padding: 0.6em 1.2em;
    text-decoration: none;
    letter-spacing: 0.1em;
    transition: background 0.1s;
}
.btn-home:hover { background: var(--screen-hi); }

/* ── ASCII Art generator ─────────────────────────────────── */
.ascii-screen {
    max-width: 860px;
}

.ascii-form {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ascii-form-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ascii-form-actions {
    margin-top: 0.25rem;
}

.c64-label {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--screen-text);
    letter-spacing: 0.1em;
    width: 2.5rem;
    flex-shrink: 0;
}

.c64-input,
.c64-select {
    background: var(--c64-black);
    border: 1px solid var(--screen-text);
    color: var(--screen-yellow);
    font-family: var(--font-term);
    font-size: 1.4rem;
    padding: 0.2em 0.5em;
    outline: none;
    appearance: none;
    border-radius: 0;
    letter-spacing: 0.05em;
}

.c64-input {
    flex: 1;
    text-transform: uppercase;
}

.c64-input::placeholder {
    color: var(--screen-text);
    opacity: 0.5;
}

.c64-input:focus,
.c64-select:focus {
    border-color: var(--screen-hi);
    color: var(--screen-hi);
}

.c64-select {
    flex: 1;
    cursor: pointer;
}

.c64-select option {
    background: var(--c64-black);
    color: var(--screen-yellow);
}

.c64-btn {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    color: var(--screen-bg);
    background: var(--screen-yellow);
    border: none;
    padding: 0.5em 1.2em;
    cursor: pointer;
    transition: background 0.1s;
}

.c64-btn:hover,
.c64-btn:focus {
    background: var(--screen-hi);
    outline: none;
}

.c64-btn-secondary {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    color: var(--screen-text);
    background: transparent;
    border: 1px solid var(--screen-text);
    padding: 0.5em 1.2em;
    text-decoration: none;
    transition: color 0.1s, border-color 0.1s;
}

.c64-btn-secondary:hover {
    color: var(--screen-hi);
    border-color: var(--screen-hi);
}

.ascii-result {
    border-top: 1px solid var(--screen-text);
    padding-top: 1.25rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.ascii-output {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(0.45rem, 1.2vw, 0.7rem);
    line-height: 1.15;
    color: var(--screen-yellow);
    white-space: pre;
    margin: 0;
}

.ascii-hint {
    border-top: 1px solid var(--screen-text);
    padding-top: 1.25rem;
    margin-bottom: 1.25rem;
    font-family: var(--font-term);
    font-size: 1.2rem;
    color: var(--screen-text);
    opacity: 0.7;
    line-height: 2;
}

.ascii-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.ascii-footer-row a {
    font-family: var(--font-pixel);
    font-size: 0.45rem;
    color: var(--screen-cyan);
    text-decoration: none;
    letter-spacing: 0.1em;
}

.ascii-footer-row a:hover {
    color: var(--screen-hi);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .screen { padding: 1.5rem 1.2rem; }
    .link-list .cmd { display: none; }
}
