:root {
  --bg: #010403;
  --panel: rgba(1, 18, 10, 0.72);
  --green: #48ff91;
  --green-soft: rgba(72, 255, 145, 0.35);
  --green-dim: #13884e;
  --green-faint: rgba(72, 255, 145, 0.1);
  --warning: #ffcc66;
  --danger: #ff5f78;
  --text-dim: #80b99b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(16, 92, 52, 0.22), transparent 36%),
    radial-gradient(circle at 20% 80%, rgba(25, 255, 132, 0.08), transparent 30%),
    var(--bg);
  color: var(--green);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.04em;
}

.screen-noise,
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
}

.screen-noise {
  opacity: 0.09;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.7) 1px, transparent 1px);
  background-size: 5px 5px;
  animation: noise-shift 0.25s infinite steps(2);
}

.scanlines {
  opacity: 0.18;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(72, 255, 145, 0.18) 4px
  );
}

.site-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.topbar,
.terminal-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid var(--green-soft);
  background: rgba(0, 12, 7, 0.86);
  box-shadow: 0 0 24px var(--green-faint);
  padding: 12px 16px;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.intercept-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
  gap: 18px;
}

.intercept-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(360px, 1.4fr) minmax(230px, 0.8fr);
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--green-soft);
  background:
    linear-gradient(135deg, rgba(72, 255, 145, 0.08), transparent 45%),
    var(--panel);
  box-shadow:
    inset 0 0 36px rgba(72, 255, 145, 0.05),
    0 0 28px rgba(72, 255, 145, 0.08);
  padding: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 22px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow: 0 0 18px var(--green-soft);
}

.call-card {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.call-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--green-faint);
  padding-bottom: 8px;
}

.call-card span,
.meter-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.call-card strong {
  color: var(--green);
  font-size: 0.8rem;
  text-align: right;
}

.meter-block {
  display: grid;
  gap: 8px;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.meter-status {
  color: var(--green);
  font-size: 0.72rem;
  text-transform: uppercase;
  min-width: 52px;
  text-align: right;
}

.meter-status.is-done {
  color: var(--warning);
  text-shadow: 0 0 12px rgba(255, 204, 102, 0.35);
}

.meter {
  height: 9px;
  border: 1px solid var(--green-soft);
  background: rgba(0, 0, 0, 0.4);
  margin-bottom: 8px;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green-dim), var(--green));
  box-shadow: 0 0 16px var(--green-soft);
  transition: none;
  will-change: width;
}

.center-panel {
  display: grid;
  grid-template-rows: 260px minmax(130px, 1fr) auto;
  align-items: center;
  justify-items: center;
  min-height: 0;
}

.prism-wrap {
  display: grid;
  place-items: center;
  width: min(240px, 42vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(72, 255, 145, 0.16), transparent 58%);
  animation: prism-pulse 2.4s ease-in-out infinite;
}

.prism-mark {
  width: 70%;
  color: var(--green);
  filter: drop-shadow(0 0 10px rgba(72, 255, 145, 0.45));
}

.prism-mark path,
.prism-mark circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trace-log {
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  font-size: 0.82rem;
}

.trace-log li {
  border-left: 2px solid var(--green-dim);
  margin-bottom: 8px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text-dim);
}

.trace-log li[data-level="warn"] {
  border-left-color: var(--warning);
  color: var(--warning);
}

.trace-log li[data-level="ok"] {
  border-left-color: var(--green);
  color: var(--green);
}

.login-button {
  align-self: end;
  justify-self: center;
  margin-top: 18px;
  border: 1px solid var(--green);
  background:
    linear-gradient(90deg, transparent, rgba(72, 255, 145, 0.12), transparent),
    rgba(0, 12, 7, 0.92);
  color: var(--green);
  box-shadow:
    0 0 18px rgba(72, 255, 145, 0.28),
    inset 0 0 18px rgba(72, 255, 145, 0.08);
  padding: 14px 42px;
  font: inherit;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  animation: login-flicker 1.8s steps(2, end) infinite;
}

.login-button:hover,
.login-button:focus {
  outline: none;
  background: rgba(72, 255, 145, 0.16);
  box-shadow:
    0 0 28px rgba(72, 255, 145, 0.45),
    inset 0 0 22px rgba(72, 255, 145, 0.16);
}

.login-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-button::before {
  content: "[ ";
  color: var(--text-dim);
}

.login-button::after {
  content: " ]";
  color: var(--text-dim);
}

.hex-stream {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.65;
}

.terminal-screen {
  display: flex;
  flex-direction: column;
  position: relative;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--green-soft);
  background:
    radial-gradient(circle at 50% 15%, rgba(72, 255, 145, 0.12), transparent 32%),
    rgba(0, 8, 4, 0.92);
  box-shadow:
    inset 0 0 70px rgba(72, 255, 145, 0.08),
    0 0 36px rgba(72, 255, 145, 0.08);
}

.terminal-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  min-height: 48px;
  background: rgba(0, 12, 7, 0.96);
  backdrop-filter: blur(3px);
}

.terminal-output {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 72px 24px 24px;
  font-size: clamp(0.9rem, 2vw, 1.04rem);
  line-height: 1.65;
  overscroll-behavior: contain;
  scrollbar-color: var(--green-dim) rgba(0, 0, 0, 0.35);
}

.terminal-line {
  min-height: 1.4em;
  color: var(--green);
}

.terminal-line.echo {
  color: var(--warning);
  margin-top: 14px;
}

.terminal-line.error {
  color: var(--danger);
}

.terminal-input-line {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  border-top: 1px solid var(--green-soft);
  padding: 16px 20px;
  background: rgba(0, 8, 4, 0.96);
  backdrop-filter: blur(3px);
}

.terminal-input-line input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  caret-color: var(--green);
}

.terminal-input-line input:disabled {
  opacity: 0.55;
}

.is-hidden {
  display: none !important;
}

.terminal-active {
  overflow: hidden;
}

.terminal-active .site-shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.terminal-active .intercept-screen {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@keyframes noise-shift {
  from {
    transform: translate(0, 0);
  }

  to {
    transform: translate(-2px, 2px);
  }
}

@keyframes prism-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.82;
  }

  50% {
    transform: scale(1.035);
    opacity: 1;
  }
}

@keyframes login-flicker {
  0%,
  100% {
    opacity: 1;
    transform: translateX(0);
  }

  48% {
    opacity: 0.86;
    transform: translateX(-1px);
  }

  50% {
    opacity: 1;
    transform: translateX(1px);
  }

  52% {
    opacity: 0.82;
    transform: translateX(0);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .site-shell {
    padding: 14px;
  }

  .intercept-grid {
    grid-template-columns: 1fr;
  }

  .intercept-screen {
    min-height: auto;
  }

  .center-panel {
    grid-template-rows: 220px 220px auto;
  }

  .topbar,
  .terminal-header {
    flex-direction: column;
  }

  .terminal-screen {
    height: calc(100vh - 28px);
    height: calc(100dvh - 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/*
  Mobile terminal viewport fix.

  When the terminal opens, lock the app to the visible viewport so the
  terminal cannot start partially above the browser window.
*/

body.terminal-active {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.terminal-active .site-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 24px;
  overflow: hidden;
}

body.terminal-active .terminal-screen {
  width: 100%;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
}

@media (max-width: 900px) {
  body.terminal-active .site-shell {
    padding: 10px;
  }

  body.terminal-active .terminal-screen {
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  body.terminal-active .terminal-header {
    gap: 6px;
    padding: 10px 12px;
    font-size: 0.74rem;
  }

  body.terminal-active .terminal-output {
    padding: 86px 14px 18px;
    font-size: 0.82rem;
  }

  body.terminal-active .terminal-input-line {
    padding: 12px 14px;
    font-size: 0.86rem;
  }
}

/*
  Mobile-safe terminal layout.

  This overrides the previous fixed/absolute terminal behavior.
  The terminal becomes a true viewport-sized grid:
    header = fixed top row
    output = scrollable middle row
    input  = fixed bottom row

  --app-height is set by app.js using visualViewport when available.
*/

:root {
  --app-height: 100vh;
}

body.terminal-active {
  position: static !important;
  width: 100%;
  height: var(--app-height) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.terminal-active .site-shell {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  width: 100%;
  height: var(--app-height) !important;
  min-height: 0 !important;
  padding: 10px !important;
  overflow: hidden !important;
}

body.terminal-active .terminal-screen {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.terminal-active .terminal-header {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: 10;
  min-height: 0 !important;
  padding: 10px 12px;
}

body.terminal-active .terminal-output {
  min-height: 0 !important;
  height: auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 14px !important;
  -webkit-overflow-scrolling: touch;
}

body.terminal-active .terminal-input-line {
  position: relative !important;
  z-index: 10;
  flex: none !important;
  padding: 12px 14px;
}

@media (max-width: 900px) {
  body.terminal-active .terminal-header {
    gap: 4px;
    font-size: 0.68rem;
    line-height: 1.25;
  }

  body.terminal-active .terminal-output {
    font-size: 0.78rem;
    line-height: 1.55;
  }

  body.terminal-active .terminal-input-line {
    font-size: 0.82rem;
  }
}

/*
  Initial Null Prism boot logo.

  The main interface stays hidden while the symbol fades in/out.
  After the boot sequence, the signal trace interface fades in.
*/

.boot-logo-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(72, 255, 145, 0.08), transparent 34%),
    #010403;
  opacity: 1;
  pointer-events: none;
}

.boot-prism-mark {
  width: min(280px, 58vw);
  color: var(--green);
  opacity: 0;
  transform: scale(0.86);
  filter:
    drop-shadow(0 0 8px rgba(72, 255, 145, 0.45))
    drop-shadow(0 0 24px rgba(72, 255, 145, 0.22));
  transition:
    opacity 1.2s ease,
    transform 1.2s ease,
    filter 1.2s ease;
}

.boot-prism-mark path,
.boot-prism-mark circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 4.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.is-booting {
  overflow: hidden;
}

body.is-booting .site-shell {
  opacity: 0;
  visibility: hidden;
}

body.boot-logo-visible .boot-prism-mark {
  opacity: 1;
  transform: scale(1);
  filter:
    drop-shadow(0 0 10px rgba(72, 255, 145, 0.55))
    drop-shadow(0 0 32px rgba(72, 255, 145, 0.28));
}

body.boot-logo-fading .boot-logo-screen {
  opacity: 0;
  transition: opacity 0.85s ease;
}

body.boot-logo-fading .boot-prism-mark {
  opacity: 0;
  transform: scale(1.08);
}

body.boot-complete .intercept-screen {
  animation: interface-fade-in 0.85s ease both;
}

@keyframes interface-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot-prism-mark,
  .boot-logo-screen,
  body.boot-complete .intercept-screen {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
