/* ═══════════════════════════════════════════════════════════════
   MACHINE WORLD // CONSOLE — Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg:           #050805;
    --fg:           #d8fbe2;
    --muted:        #7aab88;
    --green:        #00ff41;
    --green-dim:    #00b833;
    --green-dark:   #003310;
    --cyan:         #00e5ff;
    --stroke:       #0f2a12;
    --red:          #ff2b2b;
    --amber:        #ffb300;
    --panel-bg:     #020902;
    --panel-border: #1a5c2a;
    --font-mono:    'Share Tech Mono', 'VT323', ui-monospace, monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── Body + background layers ── */
body {
    font-family: var(--font-mono);
    color: var(--fg);
    background: #000;
    min-height: 100vh;
    overflow-x: hidden;
}

/* matrix rain canvas */
#rain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* CRT scanlines */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.18) 2px,
        rgba(0,0,0,0.18) 4px
    );
}

/* subtle vignette */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}

/* ── Header / HUD ── */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(0,5,0,0.82);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--stroke);
}

.hdr {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Wordmark with glitch */
.wordmark {
    color: var(--green);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(0,255,65,.55);
    position: relative;
    animation: glitch-idle 6s infinite;
}

@keyframes glitch-idle {
    0%, 90%, 100% { clip-path: none; transform: none; }
    91% {
        clip-path: inset(20% 0 60% 0);
        transform: translate(-3px, 0);
        color: var(--cyan);
    }
    92% {
        clip-path: inset(60% 0 10% 0);
        transform: translate(3px, 0);
        color: var(--green);
    }
    93% { clip-path: none; transform: none; }
}

/* HUD metrics */
.hud-metrics {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .5px;
}

.hud-metric {
    display: flex;
    align-items: center;
    gap: 5px;
}

.hud-metric .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: hud-pulse 2s ease-in-out infinite;
}

.hud-metric .dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.hud-metric .dot.red   { background: var(--red);   box-shadow: 0 0 6px var(--red);   }

@keyframes hud-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .35; }
}

.hud-clock {
    font-size: 13px;
    color: var(--green);
    text-shadow: 0 0 8px rgba(0,255,65,.4);
    letter-spacing: 1px;
    border-left: 1px solid var(--stroke);
    padding-left: 16px;
}

nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-left: 1px solid var(--stroke);
    padding-left: 16px;
}

.navlink {
    text-decoration: none;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--stroke);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 12px;
    letter-spacing: .5px;
    text-transform: uppercase;
    transition: color .15s, border-color .15s, box-shadow .15s;
}

.navlink:hover,
.navlink.active {
    color: var(--green);
    border-color: var(--green-dim);
    box-shadow: 0 0 10px rgba(0,255,65,.2);
}

/* ── Boot sequence screen ── */
.sequence-container {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 10vw;
    transition: opacity .5s;
}

.sequence-text {
    font-family: var(--font-mono);
    color: var(--green);
    font-size: clamp(14px, 2vw, 18px);
    line-height: 1.8;
    text-shadow: 0 0 10px rgba(0,255,65,.7);
    white-space: pre-wrap;
    max-width: 700px;
}

.sequence-text .seq-prefix {
    color: var(--muted);
    margin-right: 6px;
}

.sequence-cursor {
    display: inline-block;
    width: 10px;
    height: 1.1em;
    background: var(--green);
    vertical-align: text-bottom;
    box-shadow: 0 0 8px var(--green);
    animation: blink .7s step-start infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.seq-progress-wrap {
    margin-top: 24px;
    width: min(500px, 80vw);
}

.seq-progress-label {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.seq-progress-track {
    height: 3px;
    background: var(--green-dark);
    border-radius: 2px;
    overflow: hidden;
}

.seq-progress-fill {
    height: 100%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
    border-radius: 2px;
    width: 0%;
    transition: width .4s ease;
}

.matrix-code {
    position: fixed;
    bottom: 24px;
    right: 24px;
    font-size: 11px;
    color: var(--green-dim);
    opacity: .5;
    letter-spacing: 1px;
    font-family: monospace;
}

/* ── Console form panel ── */
.sequence-form-container {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 101;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.console-panel {
    position: relative;
    background: rgba(2,9,2,0.92);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 28px 28px 22px;
    box-shadow:
        0 0 0 1px rgba(0,255,65,.08),
        0 0 40px rgba(0,255,65,.12),
        inset 0 0 40px rgba(0,255,65,.04);
    backdrop-filter: blur(12px);
    max-width: 640px;
    width: 92%;
}

/* corner bracket decorations */
.console-panel::before,
.console-panel::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--green);
    border-style: solid;
}
.console-panel::before {
    top: -1px; left: -1px;
    border-width: 2px 0 0 2px;
}
.console-panel::after {
    bottom: -1px; right: -1px;
    border-width: 0 2px 2px 0;
}

/* panel title bar */
.panel-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--stroke);
}

.panel-titlebar-dots {
    display: flex;
    gap: 5px;
}

.panel-titlebar-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--stroke);
}

.panel-titlebar-dots span:nth-child(1) { background: var(--red); box-shadow: 0 0 6px var(--red); }
.panel-titlebar-dots span:nth-child(2) { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.panel-titlebar-dots span:nth-child(3) { background: var(--green); box-shadow: 0 0 6px var(--green); }

.panel-titlebar-label {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-left: 6px;
}

/* terminal input row */
.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(0,0,0,.7);
    border: 1px solid var(--stroke);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.terminal-input-row:focus-within {
    border-color: var(--green-dim);
    box-shadow: 0 0 16px rgba(0,255,65,.18);
}

.terminal-prompt {
    padding: 11px 10px 11px 14px;
    color: var(--green);
    font-size: 15px;
    text-shadow: 0 0 8px rgba(0,255,65,.5);
    user-select: none;
    flex-shrink: 0;
}

.terminal-input-row input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--fg);
    padding: 11px 14px 11px 4px;
    font-family: var(--font-mono);
    font-size: 15px;
    caret-color: var(--green);
    outline: none;
}

.terminal-input-row input::placeholder { color: rgba(169,216,183,.3); }

.btn-send {
    background: var(--green-dark);
    color: var(--green);
    border: none;
    border-left: 1px solid var(--stroke);
    padding: 11px 18px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: rgba(0,255,65,.15);
    box-shadow: 0 0 14px rgba(0,255,65,.25) inset;
}

.btn-send:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* loading indicator */
.wave-signal {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 22px;
    margin-top: 14px;
}

.wave-bar {
    width: 3px;
    background: var(--green);
    border-radius: 2px;
    animation: wave 1.2s ease-in-out infinite;
    box-shadow: 0 0 5px rgba(0,255,65,.5);
}
.wave-bar:nth-child(1){ height: 4px;  animation-delay: 0s;   }
.wave-bar:nth-child(2){ height: 8px;  animation-delay: .1s;  }
.wave-bar:nth-child(3){ height: 14px; animation-delay: .2s;  }
.wave-bar:nth-child(4){ height: 18px; animation-delay: .3s;  }
.wave-bar:nth-child(5){ height: 22px; animation-delay: .4s;  }
.wave-bar:nth-child(6){ height: 18px; animation-delay: .5s;  }
.wave-bar:nth-child(7){ height: 14px; animation-delay: .6s;  }
.wave-bar:nth-child(8){ height: 8px;  animation-delay: .7s;  }
.wave-bar:nth-child(9){ height: 4px;  animation-delay: .8s;  }

@keyframes wave {
    0%,100% { transform: scaleY(.3); opacity: .4; }
    50%      { transform: scaleY(1);  opacity: 1;  }
}

.signal-text {
    color: var(--muted);
    font-size: 12px;
    margin-left: 8px;
    letter-spacing: .5px;
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%,100% { opacity: .5; }
    50%      { opacity: 1;  }
}

/* response area */
.sequence-response {
    display: none;
    margin-top: 16px;
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--stroke);
    border-radius: 4px;
    padding: 14px 16px;
    background: rgba(0,0,0,.8);
    color: #b8ffd0;
    font-size: 14px;
    line-height: 1.65;
    text-shadow: 0 0 5px rgba(0,255,65,.1);
    scrollbar-width: thin;
    scrollbar-color: var(--green-dim) #000;
}

.sequence-response::-webkit-scrollbar       { width: 6px; }
.sequence-response::-webkit-scrollbar-track { background: #000; }
.sequence-response::-webkit-scrollbar-thumb { background: var(--green-dim); border-radius: 3px; }

/* self-destruct timer */
.self-destruct-timer {
    display: none;
    margin-top: 14px;
    padding: 7px 14px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    letter-spacing: .5px;
    border: 1px solid var(--red);
    color: var(--red);
    background: rgba(255,43,43,.08);
    box-shadow: 0 0 14px rgba(255,43,43,.25);
    animation: pulse-red 1s ease-in-out infinite;
}

@keyframes pulse-red {
    0%,100% { box-shadow: 0 0 10px rgba(255,43,43,.2); }
    50%      { box-shadow: 0 0 22px rgba(255,43,43,.5); }
}

.self-destruct-timer.warning {
    border-color: var(--amber);
    color: var(--amber);
    background: rgba(255,179,0,.08);
    box-shadow: 0 0 14px rgba(255,179,0,.25);
    animation: none;
}

.self-destruct-timer.danger {
    animation: pulse-red .4s ease-in-out infinite;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .hud-metrics { display: none; }
    nav { border-left: none; padding-left: 0; }
    .console-panel { padding: 20px 16px 18px; }
}
