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

/* ─── VARIABLES ───────────────────────────────────────────── */

:root {
  --bg:          #1c1c1c;
  --fg:          #bcbcbc;
  --purple:      #8787af;
  --pink:        #af87af;
  --cyan:        #87afaf;
  --green:       #87af87;
  --yellow:      #d7af5f;
  --red:         #af5f5f;
  --orange:      #d7875f;
  --comment:     #585858;
  --selbg:       #444444;
  --current-line:#303030;
  --darkbg:      #121212;
}

/* ─── RESET ───────────────────────────────────────────────── */

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  height: 100%;
  overflow: hidden;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--pink); text-decoration: underline; }

/* ─── CRT EFFECTS ─────────────────────────────────────────── */

/* Scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.025) 2px,
    rgba(0,0,0,0.025) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Vignette */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
  z-index: 9998;
}

/* ─── HEX BACKGROUND CANVAS ──────────────────────────────── */

#hexbg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* ─── TERMINAL STAGE ──────────────────────────────────────── */

.terminal-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  position: relative;
  z-index: 1;
  padding: 20px;
}

/* ─── MAC TERMINAL WINDOW ─────────────────────────────────── */

.mac-terminal {
  width: min(860px, 96vw);
  height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(135,135,175,0.25),
    0 0 60px rgba(135,135,175,0.08),
    0 28px 56px rgba(0,0,0,0.7);
  transition: width 0.38s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.38s;
  flex-shrink: 0;
}

/* Title bar */
.mac-titlebar {
  background: var(--darkbg);
  border-bottom: 1px solid rgba(135,135,175,0.2);
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  flex-shrink: 0;
  position: relative;
  user-select: none;
}

.mac-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}

.mac-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.mac-dot-red    { background: #ff5f57; }
.mac-dot-yellow { background: #ffbd2e; }
.mac-dot-green  { background: #28c840; }

.mac-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--comment);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Terminal body */
.mac-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
  padding: 18px 22px 14px;
}

/* Output area */
.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 10px;
}

.terminal-output::-webkit-scrollbar         { width: 4px; }
.terminal-output::-webkit-scrollbar-track   { background: transparent; }
.terminal-output::-webkit-scrollbar-thumb   { background: var(--comment); border-radius: 2px; }

.terminal-logo {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--current-line);
  margin-bottom: 12px;
}

.terminal-logo img,
.glitch-logo-gif {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

/* Input wrap */
.terminal-input-wrap {
  flex-shrink: 0;
  padding-top: 10px;
}

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--purple);
  padding: 8px 12px;
  background: rgba(135,135,175,0.04);
}

.terminal-input-row:focus-within {
  border-color: var(--cyan);
}

.terminal-prompt {
  color: var(--cyan);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  caret-color: var(--cyan);
}

#terminal-input:disabled {
  opacity: 0.35;
  cursor: default;
}

.terminal-input-hint {
  color: var(--comment);
  font-size: 11px;
  padding: 5px 2px 0;
  letter-spacing: 0.3px;
  user-select: none;
}

/* ─── OUTPUT LINES ────────────────────────────────────────── */

.output-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.75;
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-word;
  animation: fadeIn 0.1s ease-out;
}

.output-cmd      { color: var(--comment); }
.output-response { color: var(--fg); }
.output-system   { color: var(--green); font-size: 12px; }
.output-dim      { color: var(--comment); font-size: 12px; }
.output-error    { color: var(--red); }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── SCREENSHOT GALLERY ─────────────────────────────────── */

.screenshot-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 16px;
  outline: none;
}

.sg-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 11px;
  line-height: 1.5;
}

.sg-counter    { color: var(--yellow); font-weight: bold; }
.sg-caption    { color: var(--fg); flex: 1; }
.sg-keys       { color: var(--comment); white-space: nowrap; }

.sg-img-wrap {
  border: 1px solid var(--comment);
  border-radius: 4px;
  overflow: hidden;
  max-width: 100%;
}

.sg-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  background: var(--bg);
}

.sg-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding-top: 4px;
}

.sg-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--comment);
  display: inline-block;
  transition: background 0.15s;
}

.sg-dot-active { background: var(--yellow); }

/* ─── ANSI LOGO (HTML fragment from tdfrender) ────────────── */

.ansi-logo {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: clamp(7px, 1vw, 13px);
  line-height: 1.15;
  display: inline-block;
  animation: logoPulse 5s ease-in-out infinite;
}

@keyframes logoPulse {
  0%,100% { filter: brightness(1); }
  50%     { filter: brightness(1.15); }
}

/* ─── ANSI COLOUR HELPERS ─────────────────────────────────── */

.fg-purple  { color: var(--purple); }
.fg-pink    { color: var(--pink); }
.fg-cyan    { color: var(--cyan); }
.fg-green   { color: var(--green); }
.fg-yellow  { color: var(--yellow); }
.fg-red     { color: var(--red); }
.fg-orange  { color: var(--orange); }
.fg-comment { color: var(--comment); }
.fg-fg      { color: var(--fg); }
.bold       { font-weight: bold; }

/* ─── ANIMATIONS ──────────────────────────────────────────── */

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

.blink {
  animation: blink 1s step-end infinite;
}

/* ─── SELECTION & SCROLLBAR ──────────────────────────────── */

::selection {
  background: var(--selbg);
  color: var(--fg);
}

::-webkit-scrollbar         { width: 6px; height: 6px; }
::-webkit-scrollbar-track   { background: var(--darkbg); }
::-webkit-scrollbar-thumb   { background: var(--selbg); }
::-webkit-scrollbar-thumb:hover { background: var(--comment); }

/* ─── DOCS SPLIT PANEL ───────────────────────────────────── */

.terminal-workspace {
  display: flex;
  align-items: stretch;
}

.terminal-workspace.docs-open .mac-terminal {
  width: clamp(360px, 42vw, 500px);
  border-radius: 8px 0 0 8px;
  box-shadow:
    0 0 0 1px rgba(135,135,175,0.25),
    0 28px 56px rgba(0,0,0,0.7);
}

.docs-splitbar {
  width: 0;
  background: rgba(135, 135, 175, 0.35);
  flex-shrink: 0;
  transition: width 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: col-resize;
}

.terminal-workspace.docs-open .docs-splitbar {
  width: 3px;
}

.docs-panel {
  width: 0;
  height: min(92vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 0;
  opacity: 0;
  flex-shrink: 0;
  transition:
    width 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s 0.12s,
    border-radius 0.38s;
}

.terminal-workspace.docs-open .docs-panel {
  width: clamp(320px, 46vw, 620px);
  border-radius: 0 8px 8px 0;
  opacity: 1;
  box-shadow:
    0 0 0 1px rgba(135,135,175,0.25),
    0 0 60px rgba(135,135,175,0.08),
    0 28px 56px rgba(0,0,0,0.7);
}

.docs-panel-titlebar {
  background: var(--darkbg);
  border-bottom: 1px solid rgba(135,135,175,0.2);
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  flex-shrink: 0;
  position: relative;
  user-select: none;
}

.docs-panel-close {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--comment);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  font-family: 'JetBrains Mono', monospace;
  transition: color 0.15s;
}

.docs-panel-close:hover { color: var(--red); }

.docs-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.docs-panel-body::-webkit-scrollbar         { width: 4px; }
.docs-panel-body::-webkit-scrollbar-track   { background: transparent; }
.docs-panel-body::-webkit-scrollbar-thumb   { background: var(--comment); border-radius: 2px; }

/* ── Pane content styles (used by screen components) ── */

.term-pane-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--current-line);
}

.tui-panel-header {
  padding: 8px 18px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--purple);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.term-pane {
  padding: 18px 20px;
  font-family: 'JetBrains Mono', monospace;
}

.section-header {
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 16px;
  font-weight: normal;
}

.tui-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--current-line);
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--comment);
  text-transform: uppercase;
}

.tui-step-header .step-num {
  color: var(--cyan);
}

.code-block {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  background: var(--darkbg);
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
  margin-bottom: 8px;
  color: var(--fg);
}

/* ─── SHIKI CODE BLOCKS ──────────────────────────────────── */

.code-wrap {
  margin-bottom: 8px;
}

.code-wrap .astro-code {
  font-family: 'JetBrains Mono', 'Courier New', monospace !important;
  font-size: 12px !important;
  line-height: 1.7 !important;
  padding: 14px 16px !important;
  border-radius: 0 !important;
  background: var(--darkbg) !important;
  overflow-x: auto;
}

.code-wrap .astro-code code {
  font-family: inherit !important;
}

/* ─── ATTRIBUTION FOOTER ─────────────────────────────────── */

.terminal-attribution {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--comment);
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  white-space: nowrap;
  z-index: 2;
  pointer-events: auto;
}

.terminal-attribution a {
  color: var(--comment);
  text-decoration: none;
  transition: color 0.15s;
}

.terminal-attribution a:hover {
  color: var(--purple);
  text-decoration: none;
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .terminal-workspace.docs-open .mac-terminal { width: 100%; border-radius: 8px; }
  .terminal-workspace.docs-open .docs-splitbar { width: 0; }
  .terminal-workspace.docs-open .docs-panel { width: 0; opacity: 0; }
}

@media (max-width: 600px) {
  .mac-body { padding: 12px 14px 10px; }
  .output-line { font-size: 12px; }
  #terminal-input { font-size: 12px; }
  .terminal-prompt { font-size: 12px; }
}
