@import url('https://fonts.googleapis.com/css2?family=VT323&display=block');

:root {
  --phosphor: #33ff33;
  --phosphor-dim: #1a9c1a;
  --phosphor-glow: rgba(51, 255, 51, 0.15);
  --phosphor-bright: #88ff88;
  --bg: #0a0a0a;
  --amber: #ffb000;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: content-box;
  cursor: none;
}

@media (pointer: coarse) {
  * { cursor: auto; }
}

/* Portrait mobile: show rotate message */
.rotate-msg {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  color: var(--phosphor);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 20px;
  text-shadow: 0 0 5px var(--phosphor-glow);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.8;
}

.rotate-msg pre {
  font: inherit;
  color: inherit;
  text-shadow: inherit;
}

@media (orientation: portrait) and (pointer: coarse) {
  .rotate-msg { display: flex; }
  .scene { display: none; }
}

html, body {
  height: 100dvh;
  overflow: hidden;
}

body {
  background: #000;
  color: var(--phosphor);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 20px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

/* === SCENE (background image as container) === */

.scene {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
}

/* JS positions .scene-frame to cover viewport while maintaining aspect ratio,
   so percentage-based CRT placement stays accurate */
.scene-frame {
  position: absolute;
}

.scene-img {
  width: 100%; height: 100%;
  display: block;
}

/* Image sits above the CRT so its alpha hole reveals the terminal behind */
.scene-frame { z-index: 2; pointer-events: none; }
.crt-housing { z-index: 1; }

/* === CRT SCREEN mapped onto monitor in photo === */
/* JS layoutScene() sets position/size */

.crt-housing {
  position: absolute;
  overflow: hidden;
  /* JS sets matrix3d transform to match monitor perspective */
}

/* Boot screen and main screen wrappers must fill the housing */
#boot-screen, #main-screen {
  width: 100%;
  height: 100%;
}

.crt {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}

/* Scanlines */
.crt::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(0, 0, 0, 0.2) 3px, rgba(0, 0, 0, 0.2) 4px
  );
  pointer-events: none;
  z-index: 100;
  border-radius: 8px;
}

/* Vignette */
.crt::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.75) 100%);
  pointer-events: none;
  z-index: 101;
  border-radius: 8px;
}

/* Glass reflection handled by the alpha-masked background image */
.crt-glass { display: none; }

/* === MOBILE: full-screen CRT, no scene photo === */
@media (max-width: 1024px) and (orientation: landscape) {
  .scene-frame { display: none; }
  .crt-housing {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    z-index: 1;
  }
  .crt-housing::after { display: none; }
  .crt-glass {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 102;
  }
}

.crt * { text-shadow: 0 0 5px var(--phosphor-glow); }

/* Green phosphor glow cast onto the scene around the monitor */
.crt-housing::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at center, rgba(51,255,51,0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 3;
}

@keyframes flicker {
  0% { opacity: 0.97; }
  5% { opacity: 0.95; }
  10% { opacity: 0.98; }
  15% { opacity: 0.96; }
  20% { opacity: 0.99; }
  80% { opacity: 0.98; }
  85% { opacity: 0.95; }
  90% { opacity: 0.97; }
  100% { opacity: 0.98; }
}

.crt { animation: flicker 4s infinite; }

/* === SCREEN CONTENT === */

.screen {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen-content {
  height: 100%;
  padding: 4% 5%;
  overflow: hidden;
}

/* === ALL TEXT IS PRE === */

/* JS sets --term-font-size based on actual screen width */
.terminal-pre {
  font-family: 'VT323', 'Courier New', monospace;
  font-size: var(--term-font-size, 14px);
  line-height: 1.5;
  color: var(--phosphor);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep scrollable */
.doc-scroll::-webkit-scrollbar { display: none; }
.doc-scroll { scrollbar-width: none; }

.tap-target { pointer-events: auto; cursor: pointer; }

/* === STATUS BAR === */

.status-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--phosphor-dim);
  color: var(--amber);
  padding: 1% 5%;
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.5);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: var(--term-font-size, 14px);
  line-height: 1.5;
}

.status-bar .keys { color: var(--phosphor-dim); }
.status-bar kbd { color: var(--phosphor-bright); font-family: inherit; }

/* === CURSOR === */

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

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--phosphor);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

/* === LINKS — render as plain text === */

a, a:visited, a:hover, a:active {
  color: inherit;
  text-decoration: none;
  text-shadow: inherit;
  pointer-events: none;
}

::selection {
  background: var(--phosphor-dim);
  color: var(--bg);
}
