@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&display=swap');

:root {
  --green:      #00FF41;
  --green-mid:  #00CC33;
  --green-dim:  #008F11;
  --green-glow: rgba(0, 255, 65, 0.35);
  --bg:         #060606;
  --win-bg:     #050505;
}

*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  overflow: hidden;
}

body {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  color: var(--green);
  font-size: 14px;
  line-height: 1.6;
  animation: body-flicker 14s infinite;
}

@keyframes body-flicker {
  0%, 87%, 90%, 94%, 97%, 100% { opacity: 1;    }
  88%                           { opacity: 0.93; }
  91%                           { opacity: 0.87; }
  95%                           { opacity: 0.96; }
}

/* CRT OVERLAYS (full screen) */

.crt-scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 900;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px, transparent 2px,
    rgba(0,0,0,0.12) 2px, rgba(0,0,0,0.12) 4px
  );
}

.crt-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 901;
  background: radial-gradient(
    ellipse at center,
    transparent 42%,
    rgba(0,0,0,0.46) 72%,
    rgba(0,0,0,0.84) 100%
  );
}

@keyframes roll { from { top: -4px; } to { top: 100vh; } }

.crt-roll {
  position: fixed; left: 0; top: 0; width: 100%; height: 3px;
  pointer-events: none; z-index: 902;
  background: linear-gradient(to right,
    transparent,
    rgba(0,255,65,0.05) 20%,
    rgba(0,255,65,0.05) 80%,
    transparent
  );
  animation: roll 10s linear infinite;
}

#crt-noise {
  position: fixed; inset: 0; pointer-events: none;
  z-index: 903; opacity: 0.036; mix-blend-mode: screen;
}

.crt-edge {
  position: fixed; inset: 0; pointer-events: none; z-index: 904;
  box-shadow:
    inset 0 0 90px rgba(0,0,0,0.70),
    inset 0 0 35px rgba(0,0,0,0.45),
    inset 8px 0 22px rgba(0,0,0,0.35),
    inset -8px 0 22px rgba(0,0,0,0.35);
}

/* LOADING SCREEN */

#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 26px; z-index: 800;
  transition: opacity 0.5s ease;
}

#loading-screen.hidden { opacity: 0; pointer-events: none; }

.loading-title {
  font-size: 12px; letter-spacing: 0.44em; color: var(--green);
  text-shadow: 0 0 10px var(--green-glow), 0 0 24px rgba(0,255,65,0.16);
}

.loading-bar-wrap { display: flex; align-items: center; gap: 10px; }

.bar-bracket {
  font-size: 22px; color: var(--green-mid); line-height: 1;
  text-shadow: 0 0 6px var(--green-glow);
}

.loading-blocks { display: flex; gap: 5px; }

.lb {
  width: 14px; height: 20px;
  background: transparent;
  border: 1px solid var(--green-dim);
  transition: background 0.08s ease, box-shadow 0.08s ease, border-color 0.08s ease;
}

.lb.on {
  background: var(--green); border-color: var(--green);
  box-shadow: 0 0 7px var(--green-glow), 0 0 16px rgba(0,255,65,0.18);
}

.loading-pct { font-size: 12px; min-width: 40px; color: var(--green-mid); }

/* MAIN WRAPPER centres everything on screen */

#main-screen {
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  gap: 10px;
  padding-top: clamp(40px, 4vw, 500px);
  padding-right: 24px;
  padding-bottom: 24px;
  padding-left: 24px;
  opacity: 0; transition: opacity 0.5s ease;
}

#main-screen.visible { opacity: 1; }

/* ASCII HEADER (green box) */

.ascii-header {
  margin-bottom: clamp(8px, 2vw, 50px);
  font-size: clamp(13px, 2.75vw, 17px);
  line-height: 1.1; white-space: pre;
  color: var(--green);
  text-align: center;
  flex-shrink: 0;
  text-shadow:
    -1px 0 0 rgba(255,0,0,0.22),
     1px 0 0 rgba(0,80,255,0.22),
     0 0 8px var(--green-glow),
     0 0 22px rgba(0,255,65,0.12);
}

/* TERMINAL WINDOW (red box) */

.terminal-window {
  display: flex;
  flex-direction: row;
  width: min(1140px, calc(100vw - 80px));
  height: min(620px, 74vh);
  border: 1px solid rgba(0,255,65,0.45);
  background: var(--win-bg);
  box-shadow:
    0 0 18px rgba(0,255,65,0.08),
    0 0 48px rgba(0,255,65,0.04),
    inset 0 0 30px rgba(0,0,0,0.35);
  flex-shrink: 0;
  overflow: hidden;
}

/* BLUE COL terminal output + input */

.term-col {
  flex: 1;
  min-width: 480px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0,255,65,0.18);
  padding: 18px 20px 14px;
  overflow: hidden;
}

#terminal-output {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--green-dim) transparent;
}

#terminal-output::-webkit-scrollbar       { width: 3px; }
#terminal-output::-webkit-scrollbar-track { background: transparent; }
#terminal-output::-webkit-scrollbar-thumb { background: var(--green-dim); border-radius: 2px; }

.tline {
  font-size: 13px; line-height: 1.72;
  white-space: pre-wrap; word-break: break-word;
}

.tline.dim    { color: var(--green-dim); }
.tline.mid    { color: var(--green-mid); }

.tline.bright {
  color: var(--green); font-weight: 700;
  text-shadow:
    -1px 0 0 rgba(255,0,0,0.18),
     1px 0 0 rgba(0,80,255,0.18),
     0 0 7px var(--green-glow);
}

.tline.error  { color: #ff3333; text-shadow: 0 0 8px rgba(255,51,51,0.42); }
.tline.user-input { color: var(--green-mid); opacity: 0.72; }
.tline.spacer { height: 6px; display: block; }

.tline.help-row {
  display: flex; gap: 0; color: var(--green-mid); font-size: 13px;
}

.help-cmd  { min-width: 96px; color: var(--green); font-weight: 700; }

.help-note { color: var(--green-dim); font-style: italic; margin-left: 6px; }

/* INPUT ROW */

.input-row {
  flex-shrink: 0;
  border-top: 1px solid rgba(0,255,65,0.12);
  padding-top: 10px; margin-top: 8px;
  display: flex; align-items: center; gap: 8px;
}

.prompt-char {
  color: var(--green); font-size: 16px; font-weight: 700;
  text-shadow: 0 0 9px var(--green-glow);
  flex-shrink: 0; user-select: none;
}

.input-display-wrap {
  flex: 1; display: flex; align-items: center; overflow: hidden;
}

#input-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px; color: var(--green);
  text-shadow: 0 0 5px var(--green-glow);
  white-space: pre; pointer-events: none; user-select: none;
}

@keyframes blink-cursor { 0%,49%{opacity:1} 50%,100%{opacity:0} }

.block-cursor {
  display: inline-block; width: 10px; height: 16px;
  background: var(--green); box-shadow: 0 0 9px var(--green-glow);
  vertical-align: text-bottom; margin-left: 1px;
  animation: blink-cursor 1s step-end infinite;
  flex-shrink: 0;
}

.hidden-input {
  position: absolute; left: -9999px; top: 0;
  opacity: 0; width: 1px; height: 1px;
  border: none; outline: none;
  background: transparent; color: transparent;
}

/* YELLOW COL system status panel */

.status-panel {
  width: 290px; flex-shrink: 1; min-width: 0;
  padding: 14px 14px 10px;
  display: flex; flex-direction: column;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  height: 100%;
}
.status-panel::-webkit-scrollbar { display: none; }

/* Threat feed fills remaining panel space */
.threat-feed-wrap {
  flex: 1;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sp-title {
  font-size: 9px; letter-spacing: 0.36em;
  color: var(--green); font-weight: 700;
  text-align: center; margin-bottom: 6px;
  text-shadow: 0 0 8px var(--green-glow);
}

.sp-sep {
  color: var(--green-dim); font-size: 9px;
  opacity: 0.5; margin: 4px 0 3px; line-height: 1;
}

.sp-row {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 4px; line-height: 1.88;
}

.sp-key { color: var(--green-dim); font-size: 9px; flex-shrink: 0; min-width: 42px; }
.sp-val { color: var(--green-mid); font-size: 10px; text-align: right; flex: 1; }
.sp-val.hi { color: var(--green); }

.sp-bar-wrap { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: flex-end; }
.sp-bar-track { font-size: 9px; color: var(--green); letter-spacing: 0.5px; text-shadow: 0 0 4px var(--green-glow); }
.sp-bar-pct   { font-size: 9px; color: var(--green-mid); min-width: 28px; text-align: right; }

@keyframes dot-pulse { 0%,49%{opacity:1} 50%,100%{opacity:0.15} }
.sp-dot { display: inline-block; animation: dot-pulse 1.5s ease-in-out infinite; color: var(--green); }

/* ABOUT PAGE - two row layout */

.about-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.about-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  flex: 1;
  min-height: 0;
}

.about-row-sep {
  height: 1px;
  flex-shrink: 0;
  background: rgba(0,255,65,0.14);
}

.about-cell {
  flex: 1;
  padding: 10px 16px;
  border-right: 1px solid rgba(0,255,65,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.about-cell:last-child { border-right: none; }
.about-cell.wide       { grid-column: span 2; }

.sec-num {
  font-size: 8px;
  color: var(--green-dim);
  opacity: 0.35;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.sec-hdr {
  font-size: clamp(8px, 0.95vw, 11px); font-weight: 700;
  color: var(--green); letter-spacing: 0.12em;
  text-shadow:
    -1px 0 0 rgba(255,0,0,0.18),
     1px 0 0 rgba(0,80,255,0.18),
     0 0 6px var(--green-glow);
}

.sec-rule { color: var(--green-dim); font-size: 9px; opacity: 0.45; margin: 2px 0 6px; line-height: 1; }
.sec-row  { font-size: clamp(8px, 1.05vw, 12px); color: var(--green-mid); line-height: 1.72; }
.sec-row.key { color: var(--green-dim); font-size: clamp(7px, 0.85vw, 9.5px); letter-spacing: 0.05em; margin-top: 2px; }
.sec-row.val { color: var(--green); font-size: clamp(8px, 0.95vw, 11px); font-weight: 700; }
.sec-row.dim { color: var(--green-dim); font-size: clamp(8px, 0.95vw, 11px); }

/* ABOUT FOOTER (scrolling ticker) */

.about-footer {
  flex-shrink: 0;
  height: 20px;
  border-top: 1px solid rgba(0,255,65,0.14);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.about-footer-track {
  display: inline-block;
  white-space: nowrap;
  animation: footer-scroll 45s linear infinite;
}

.about-footer-track span {
  font-size: 9px;
  color: var(--green-dim);
  opacity: 0.5;
  letter-spacing: 0.06em;
}

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

/* THREAT FEED */
.threat-feed {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  min-height: 0;
}
.threat-line {
  font-size: 10px;
  line-height: 1.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--green-dim);
}
.threat-line.ok   { color: var(--green-dim); }
.threat-line.warn { color: #cc9900; text-shadow: 0 0 6px rgba(204,153,0,0.4); }
.threat-line.crit { color: #cc2200; text-shadow: 0 0 6px rgba(204,34,0,0.4); }

/* PROCESS LIST */
.proc-list { display: flex; flex-direction: column; }
.proc-row  {
  display: flex; gap: 0;
  font-size: 9px; line-height: 1.75;
  color: var(--green-dim);
}
.proc-pid  { min-width: 36px; color: var(--green-dim); }
.proc-name { flex: 1; color: var(--green-mid); }
.proc-stat { min-width: 30px; text-align: right; }
.proc-stat.run { color: var(--green); }
.proc-stat.slp { color: var(--green-dim); opacity: 0.6; }

/* HISTOGRAM */
.sp-hist {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--green);
  text-shadow: 0 0 5px var(--green-glow);
  line-height: 1.4;
}

/* REROUTE FLASH */
@keyframes reroute-flash {
  0%,100% { opacity: 1; }
  30%,70% { opacity: 0.1; }
}
.rerouting { animation: reroute-flash 0.6s ease; }

/* HIDE STATUS */
@media (max-width: 860px) {
  .status-panel { display: none; }
}

/* MOBILE RESIZE */
@media (max-width: 900px) {
  html, body {
    overflow-y: auto;
  }

  #main-screen {
    height: auto;
    min-height: 100vh;
    justify-content: flex-start;
  }

  .terminal-window {
    height: auto;
    overflow: visible;
  }

  .term-col {
    min-width: 0;
    overflow: visible;
  }

  #terminal-output {
    overflow: visible;
  }

  .about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: auto;
    overflow: visible;
  }

  .about-row {
    display: contents;
  }

  .about-row-sep {
    display: none;
  }

  .about-cell {
    height: auto;
    min-height: 0;
    overflow: visible;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Hide right border on specialisations */
  .about-row:first-child > .about-cell:nth-child(2) {
    border-right: none;
  }

  /* Row 1: IDENTITY | SPECIALISATIONS */
  .about-row:first-child > .about-cell:nth-child(1) {
    order: 1;
    box-shadow: 0 1px 0 rgba(0,255,65,0.14);
    padding-bottom: 14px;
  }
  .about-row:first-child > .about-cell:nth-child(2) {
    order: 2;
    box-shadow: 0 1px 0 rgba(0,255,65,0.14);
    padding-bottom: 14px;
  }

  /* Row 2: PROFILE full width */
  .about-cell.wide {
    order: 3;
    grid-column: span 2;
    border-right: none;
    box-shadow: 0 1px 0 rgba(0,255,65,0.14);
    height: auto;
    overflow: visible;
    overflow-wrap: break-word;
    word-break: break-word;
    padding-bottom: 14px;
  }

  /* Row 3: HOBBIES | STATUS */
  .about-row:first-child > .about-cell:nth-child(3) {
    order: 4;
    border-right: 1px solid rgba(0,255,65,0.08);
  }
  .about-row:last-child > .about-cell:not(.wide) {
    order: 5;
    border-right: none;
  }

  .tline {
    font-size: 10px;
  }

  .tline.help-row {
    font-size: 10px;
  }

  .help-cmd {
    min-width: 60px;
    flex-shrink: 0;
  }
}