/* ============================================================
   meijistory@cli — Matrix Rain CLI
   Theme: purple → magenta → pink gradient over Matrix rain
   ============================================================ */

:root {
  --bg: #07040f;
  --bg-deep: #04020a;
  --fg: #f4e8ff;
  --fg-dim: #b89cd9;
  --muted: #7a5e9a;
  /* Solid mid-tone used for glows / borders / scrollbars.
     Sits in the middle of the gradient (fuchsia). */
  --accent: #d946ef;
  --accent-2: #ec4899;
  --accent-warm: #ffb86b;
  --success: #6cffb8;
  --danger: #ff5c7a;
  --link: #f472b6;
  /* The signature purple → magenta → pink gradient, applied to
     prominent text (banner, prompts, links, headings). */
  --accent-gradient: linear-gradient(135deg, #a855f7 0%, #d946ef 45%, #ec4899 80%, #f472b6 100%);
  --accent-gradient-soft: linear-gradient(135deg, rgba(168, 85, 247, 0.85), rgba(236, 72, 153, 0.85));
  --border: rgba(217, 70, 239, 0.20);
  --border-strong: rgba(217, 70, 239, 0.45);
  --shadow-glow: 0 0 24px rgba(217, 70, 239, 0.28), 0 0 64px rgba(236, 72, 153, 0.10);
  --terminal-bg: rgba(10, 4, 18, 0.74);
  --mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", "SF Mono", "Menlo", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #150826 0%, #0a0418 55%, #04020a 100%);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ============================================================
   Matrix Rain Canvas
   ============================================================ */
#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  filter: contrast(1.05) saturate(1.1);
}

/* ============================================================
   CRT / Scanline overlay for depth
   ============================================================ */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0.18) 3px
    );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.65) 100%);
}

/* Subtle flicker animation */
@keyframes flicker {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.5; }
  73%      { opacity: 0.58; }
}
.scanlines { animation: flicker 6s infinite steps(8); }

/* ============================================================
   Terminal Window
   ============================================================ */
.terminal {
  position: relative;
  z-index: 10;
  width: min(1100px, 92vw);
  height: min(86vh, 760px);
  margin: 7vh auto 0;
  background: var(--terminal-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    var(--shadow-glow),
    0 0 0 1px rgba(217, 70, 239, 0.06) inset,
    0 30px 80px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: terminalIn 0.7s ease-out both;
}

@keyframes terminalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   Titlebar (mac-style window chrome)
   ============================================================ */
.titlebar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(20, 8, 32, 0.95), rgba(12, 4, 22, 0.95));
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.titlebar-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4);
}
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }

.titlebar-title {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.4px;
}

.titlebar-meta {
  font-size: 11px;
  color: var(--muted);
}

/* ============================================================
   Terminal Body
   ============================================================ */
.terminal-body {
  flex: 1;
  padding: 18px 22px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  color: var(--fg);
  font-size: 13.5px;
}

.terminal-body::-webkit-scrollbar { width: 8px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb {
  background: rgba(217, 70, 239, 0.28);
  border-radius: 4px;
}
.terminal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 72, 153, 0.45);
}

/* ASCII banner */
.ascii-art {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.05;
  color: var(--accent);
  text-shadow: 0 0 14px rgba(217, 70, 239, 0.55), 0 0 2px rgba(236, 72, 153, 0.9);
  white-space: pre;
  overflow-x: auto;
  margin: 0 0 12px;
  letter-spacing: 0;
  /* Render the banner text with the purple→pink gradient. */
  background-image: var(--accent-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.ascii-art::-webkit-scrollbar { height: 4px; }

.line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.5em;
}

.muted { color: var(--muted); }
.accent {
  /* Gradient-filled text on supported browsers, with solid-color
     fallback for engines that don't support background-clip: text. */
  color: var(--accent);
  background-image: var(--accent-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 8px rgba(217, 70, 239, 0.35);
}
.info { color: var(--accent-2); }
.link {
  color: var(--accent-2);
  background-image: var(--accent-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: underline;
  text-decoration-color: rgba(236, 72, 153, 0.55);
  text-underline-offset: 2px;
}
.success { color: var(--success); }
.warn { color: var(--accent-warm); }
.danger { color: var(--danger); }

/* ============================================================
   Output blocks
   ============================================================ */
.output {
  margin: 6px 0 0;
  display: block;
}

.out-line {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 1px 0;
}

.out-echo {
  color: var(--fg);
}
.out-echo .prompt-user { color: var(--success); }
.out-echo .prompt-sep  { color: var(--fg-dim); }
.out-echo .prompt-path { color: var(--link); }
.out-echo .prompt-dollar { color: var(--fg); }

.out-table {
  border: 1px solid var(--border);
  margin: 6px 0 8px;
  display: inline-block;
  min-width: 360px;
  border-radius: 6px;
  overflow: hidden;
}
.out-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  padding: 4px 10px;
  align-items: center;
  border-bottom: 1px solid rgba(217, 70, 239, 0.10);
}
.out-row:last-child { border-bottom: 0; }
.out-row.header {
  background: rgba(217, 70, 239, 0.08);
  color: var(--accent);
  font-weight: 500;
}

.out-bar {
  display: inline-block;
  height: 10px;
  background: var(--accent-gradient);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(217, 70, 239, 0.55);
}

.out-ascii {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(217, 70, 239, 0.45);
  font-size: 11px;
  line-height: 1.1;
  margin: 6px 0;
}

/* ============================================================
   Prompt
   ============================================================ */
.prompt-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.prompt-label {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  flex: 0 0 auto;
}

.prompt-user   { color: var(--success); font-weight: 500; }
.prompt-sep    { color: var(--fg-dim); }
.prompt-path   { color: var(--link); }
.prompt-dollar { color: var(--fg); margin: 0 6px 0 4px; }

.prompt-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 200px;
  min-width: 120px;
  /* The wrap grows to fill the row, but the input itself is sized by
     the mirror span so the cursor always sits right after the typed
     text — not at the right edge of the row. */
}

/* Invisible mirror that takes the natural width of the typed text.
   Lives in the flex flow so it pushes the cursor along. */
.prompt-mirror {
  color: transparent;
  white-space: pre;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 13.5px;
  letter-spacing: 0.2px;
  padding: 2px 0;
}

.prompt-input {
  /* Overlay the wrap so clicks/keys land on the input, but the input
     itself contributes no width to the flex layout — the mirror does. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13.5px;
  caret-color: transparent;
  padding: 2px 0;
  letter-spacing: 0.2px;
  z-index: 1;
}

.prompt-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.cursor-blink {
  flex: 0 0 auto;
  background-image: var(--accent-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent); /* fallback */
  display: inline-block;
  width: 0.6em;
  margin-left: 1px;
  line-height: 1;
  text-shadow: 0 0 6px rgba(217, 70, 239, 0.85), 0 0 2px rgba(236, 72, 153, 0.9);
  animation: blink 1s steps(2) infinite;
  pointer-events: none;
  /* Cursor sits above the transparent overlay so it stays visible. */
  position: relative;
  z-index: 2;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ============================================================
   Statusbar
   ============================================================ */
.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 26px;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(14, 6, 24, 0.85), rgba(8, 3, 16, 0.95));
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.4px;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-spacer { flex: 1; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(108, 255, 184, 0.7);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .terminal {
    width: 96vw;
    height: 92vh;
    margin: 4vh auto 0;
    border-radius: 8px;
  }
  .ascii-art { font-size: 8px; }
  .terminal-body { padding: 14px 14px 10px; font-size: 12.5px; }
  .titlebar-title { font-size: 11px; }
  .titlebar-meta { display: none; }
}

@media (max-width: 480px) {
  .ascii-art { font-size: 7px; }
  .statusbar { gap: 10px; font-size: 10px; padding: 0 10px; overflow: hidden; }
  .statusbar .status-spacer { display: none; }
}

/* Selection */
::selection {
  background: rgba(217, 70, 239, 0.35);
  color: #fff;
}
