/* ============================================================
   Terminal Theme — Phosphor green TTY aesthetic
   ============================================================ */

/* --- Globals: square corners, mono stack --- */

:root {
  --radius: 0;
}

.terminal-page {
  font-family: var(--font-body, "IBM Plex Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  letter-spacing: 0.01em;
}

.terminal-page * {
  border-radius: 0 !important;
}

/* --- Typography helpers --- */

.terminal-heading {
  font-family: var(--font-heading, "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  /* Inherit colour from context so headings placed on an inverted band
     (e.g. a bg-primary CTA) read as primary-foreground, not a hardcoded
     foreground that goes dark-on-bright and fails contrast. */
  color: inherit;
}

.terminal-mono {
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
}

.terminal-prose {
  font-family: var(--font-body, "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  color: hsl(var(--foreground));
  line-height: 1.6;
  max-width: 80ch;
}

.terminal-prose a {
  color: hsl(var(--accent));
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* --- ASCII frame (image override + figure wrappers) --- */

.ascii-frame {
  display: inline-block;
  padding: 0.5rem;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
  position: relative;
}

.ascii-frame::before,
.ascii-frame::after {
  content: "+";
  position: absolute;
  color: hsl(var(--border));
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 700;
}

.ascii-frame::before {
  top: -0.5em;
  left: -0.5em;
}

.ascii-frame::after {
  bottom: -0.5em;
  right: -0.5em;
}

.ascii-frame figcaption {
  display: block;
  margin-top: 0.5rem;
  color: hsl(var(--muted-foreground));
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.875rem;
  text-align: center;
}

/* --- CRT scanlines overlay --- */

.crt-scanlines {
  position: relative;
}

.crt-scanlines::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    hsl(var(--background) / 0.15) 2px,
    hsl(var(--background) / 0.15) 3px
  );
}

/* --- Caret blink keyframe + utility --- */

@keyframes caret-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.caret-blink::after {
  content: "_";
  display: inline-block;
  margin-left: 0.15em;
  animation: caret-blink 1s step-end infinite;
  animation-name: caret-blink;
  color: hsl(var(--foreground));
}

/* --- Bracketed button (override) --- */

.terminal-button {
  font-family: var(--font-mono, ui-monospace, monospace);
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  padding: 0.4rem 0.8rem;
  text-decoration: none;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
}

.terminal-button:hover {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
}

.terminal-button:hover::after {
  content: "_";
  position: absolute;
  margin-left: 0.2em;
  animation: caret-blink 1s step-end infinite;
  animation-name: caret-blink;
}

/* --- Bracketed nav --- */

.terminal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.terminal-nav a {
  color: hsl(var(--foreground));
  text-decoration: none;
  white-space: nowrap;
}

.terminal-nav a:hover {
  color: hsl(var(--accent));
}

/* --- ASCII header block --- */

.ascii-header {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: hsl(var(--accent));
  padding: 1rem 0;
  border-bottom: 1px solid hsl(var(--border));
  white-space: pre;
  overflow-x: auto;
}

.ascii-header pre {
  margin: 0;
  font-family: inherit;
  line-height: 1.1;
}

.ascii-header .prompt-line {
  margin-top: 0.5rem;
  color: hsl(var(--foreground));
}

/* --- Man-page header --- */

.manpage-header {
  font-family: var(--font-mono, ui-monospace, monospace);
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: hsl(var(--foreground));
}

.manpage-header .left,
.manpage-header .center,
.manpage-header .right {
  flex: 1;
}

.manpage-header .center { text-align: center; }
.manpage-header .right  { text-align: right; }

/* --- TOC (left rail on article) --- */

.terminal-toc {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: hsl(var(--muted-foreground));
  padding: 1rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.terminal-toc h4 {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: hsl(var(--foreground));
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
}

.terminal-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.terminal-toc li {
  margin: 0.2rem 0;
}

.terminal-toc a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
}

.terminal-toc a:hover {
  color: hsl(var(--foreground));
}

@media (max-width: 768px) {
  .terminal-toc {
    display: none;
  }
}

/* --- Code console block --- */

.code-console {
  font-family: var(--font-mono, ui-monospace, monospace);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  overflow-x: auto;
  color: hsl(var(--card-foreground));
}

.code-console .cmd-line {
  display: flex;
  align-items: center;
  gap: 0.5em;
  color: hsl(var(--accent));
  margin: 0;
}

.code-console .cmd-prompt {
  color: hsl(var(--accent));
}

.code-console .cmd-text {
  color: hsl(var(--foreground));
}

.code-console pre {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  color: hsl(var(--muted-foreground));
  font-family: inherit;
}

/* --- Keybinding table --- */

.keybind-table {
  font-family: var(--font-mono, ui-monospace, monospace);
  border-collapse: collapse;
  margin: 1rem 0;
  width: 100%;
  max-width: 80ch;
  color: hsl(var(--foreground));
}

.keybind-table th,
.keybind-table td {
  border-bottom: 1px dashed hsl(var(--border));
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.keybind-table th {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--accent));
  font-weight: 600;
}

.keybind-table kbd {
  font-family: inherit;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  padding: 0.05rem 0.4rem;
  margin-right: 0.25rem;
  font-size: 0.875em;
}

/* --- Boot log --- */

.boot-log {
  font-family: var(--font-mono, ui-monospace, monospace);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 1rem;
  border: 1px solid hsl(var(--border));
  margin: 1rem 0;
  white-space: pre-wrap;
  overflow-x: auto;
}

.boot-log .boot-line {
  display: block;
  opacity: 0;
  animation: boot-line-in 0.2s ease-out forwards;
}

@keyframes boot-line-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.boot-log .boot-cursor {
  display: inline-block;
  color: hsl(var(--accent));
  animation: caret-blink 1s step-end infinite;
  animation-name: caret-blink;
}

/* --- Footer --- */

.terminal-footer {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: hsl(var(--muted-foreground));
  border-top: 1px solid hsl(var(--border));
  padding: 1rem 0;
  margin-top: 2rem;
  text-align: center;
}

.terminal-footer .terminal-footer-rule {
  color: hsl(var(--border));
  margin: 0.25rem 0;
  letter-spacing: 0.2em;
}

.terminal-footer .terminal-footer-motd {
  color: hsl(var(--foreground));
  margin: 0.5rem 0;
}

.terminal-footer .terminal-footer-links {
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.terminal-footer a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
}

.terminal-footer a:hover {
  color: hsl(var(--foreground));
}

.terminal-footer .terminal-footer-signup {
  margin: 0.75rem auto;
  max-width: 40ch;
}

.terminal-footer .terminal-footer-signup input[type="email"] {
  font-family: inherit;
  background: hsl(var(--input));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  padding: 0.4rem 0.6rem;
}
