/*
 * style.css - red/black terminal theme.
 * Change the colors below to re-theme the whole site.
 */
:root {
  --bg: #000000;
  --panel: #070000;
  --panel-light: #120202;
  --red: #ff2b2b;
  --red-bright: #ff5c5c;
  --red-dim: #8a1414;
  --red-dark: #3a0606;
  --text: #f2c4c4;
  --muted: #a86a6a;
  --font: "Fira Code", "JetBrains Mono", "Source Code Pro", "DejaVu Sans Mono",
    Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --glow: 0 0 6px rgba(255, 43, 43, 0.6);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--red-dim) var(--panel);
}

/* Old-CRT scanlines on top of everything (clicks pass through). */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  z-index: 10;
}

a {
  color: var(--red-bright);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: #fff;
  background: var(--red-dim);
  outline: none;
}

::selection {
  background: var(--red);
  color: #000;
}

/* ---------- Window frame ---------- */

.window {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  /* Nearly full width, with a small gap on each side. */
  width: calc(100% - 24px);
  margin: 0 auto;
  border: 1px solid var(--red-dim);
  box-shadow: 0 0 30px rgba(255, 0, 0, 0.15);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel-light);
  border-bottom: 1px solid var(--red-dim);
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--red-dark);
  border: 1px solid var(--red-dim);
}

.dot:first-child {
  background: var(--red);
}

.titlebar .title {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Header navigation (looks like editor tabs) ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  background: var(--panel);
  border-bottom: 1px solid var(--red-dim);
}

.tabs a {
  padding: 6px 18px;
  color: var(--muted);
  border-right: 1px solid var(--red-dark);
}

.tabs a.active {
  color: var(--red-bright);
  background: var(--bg);
  border-bottom: 2px solid var(--red);
  font-weight: bold;
  text-shadow: var(--glow);
}

.tabs a:hover {
  color: #fff;
}

/* ---------- Two panes: file tree + editor ---------- */

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-right: 3px solid var(--red-dark);
  padding-bottom: 16px;
}

.sidebar-title {
  padding: 6px 12px;
  color: var(--red);
  font-weight: bold;
  background: var(--panel-light);
  border-bottom: 1px solid var(--red-dark);
  text-shadow: var(--glow);
}

.tree-root {
  padding: 8px 12px 4px;
  color: var(--red-bright);
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree a {
  display: block;
  padding: 5px 12px 5px 30px;
  color: var(--text);
  position: relative;
}

.tree a::before {
  content: "\2261";
  position: absolute;
  left: 14px;
  color: var(--red-dim);
}

.tree a.active {
  background: var(--red-dark);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--red);
}

.file-name {
  display: block;
}

.file-date {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-tab {
  align-self: flex-start;
  padding: 6px 18px;
  color: var(--red-bright);
  background: var(--bg);
  border-right: 1px solid var(--red-dark);
  border-bottom: 2px solid var(--red);
  font-weight: bold;
}

.editor-bar {
  background: var(--panel);
  border-bottom: 1px solid var(--red-dark);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 40px;
}

/* ---------- Terminal look ---------- */

.cmd {
  margin: 0 0 10px;
  word-break: break-all;
}

.prompt {
  color: var(--red);
  font-weight: bold;
  text-shadow: var(--glow);
}

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--red);
  animation: blink 1s steps(1) infinite;
}

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

.output {
  margin: 0 0 24px;
}

.banner {
  margin: 0 0 12px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--red);
  text-shadow: var(--glow);
  font-size: 14px;
  line-height: 1;
  overflow-x: auto;
}

.ls {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}

.ls li {
  margin-bottom: 14px;
}

.ls-date {
  color: var(--muted);
}

.ls-title {
  color: var(--red-bright);
  font-weight: bold;
}

.ls-desc {
  display: block;
  color: var(--text);
  padding-left: 11ch;
  font-size: 14px;
}

.pager {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
}

.pager .disabled {
  color: var(--red-dark);
}

.page-info {
  color: var(--muted);
}

.error {
  color: var(--red);
}

/* ---------- A single post ---------- */

.back {
  display: none;
}

.post-header h1 {
  margin: 0 0 6px;
  font-size: 1.6em;
  line-height: 1.3;
  color: var(--red);
  text-shadow: var(--glow);
}

.meta {
  margin: 0 0 24px;
  color: var(--muted);
}

/* Line numbers in a gutter, like a code editor. */
.post-body {
  counter-reset: line;
  border-left: 1px solid var(--red-dark);
  padding-left: 16px;
  margin-left: 42px;
}

.post-body > * {
  position: relative;
  counter-increment: line;
}

.post-body > *::before {
  content: counter(line);
  position: absolute;
  left: -58px;
  top: 0;
  width: 34px;
  text-align: right;
  color: var(--red-dim);
  font-size: 13px;
  font-weight: normal;
  text-shadow: none;
  line-height: inherit;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--red-bright);
  text-shadow: var(--glow);
  line-height: 1.3;
  margin: 1.6em 0 0.6em;
}

.post-body h1 { font-size: 1.4em; }
.post-body h2 { font-size: 1.25em; }
.post-body h3 { font-size: 1.1em; }

.post-body p,
.post-body ul,
.post-body ol {
  margin: 0 0 1em;
}

.post-body strong {
  color: #fff;
}

.post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border: 1px solid var(--red-dim);
}

.post-body a {
  text-decoration: underline;
  text-decoration-color: var(--red-dim);
  word-break: break-word;
}

code {
  font-family: var(--font);
  background: var(--panel-light);
  color: var(--red-bright);
  padding: 1px 5px;
  border: 1px solid var(--red-dark);
  word-break: break-word;
}

pre {
  margin: 0 0 1em;
  padding: 12px 14px;
  background: var(--panel-light);
  border: 1px solid var(--red-dark);
  border-left: 3px solid var(--red);
  overflow-x: auto;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  word-break: normal;
  white-space: pre;
}

blockquote {
  margin: 0 0 1em;
  padding: 4px 14px;
  border-left: 3px solid var(--red-dim);
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px dashed var(--red-dim);
  margin: 1.5em 0;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px dashed var(--red-dim);
}

.post-nav .newer {
  margin-left: auto;
  text-align: right;
}

/* ---------- About page ---------- */

.avatar {
  float: right;
  width: 140px;
  height: auto;
  margin: 0 0 12px 16px;
  /* Keep pixel-art edges sharp when scaled. */
  image-rendering: pixelated;
}

.links {
  list-style: none;
  padding: 0;
}

.links li::before {
  content: "-> ";
  color: var(--red-dim);
}

/* ---------- Footer (status bar) ---------- */

.statusbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 4px 12px;
  background: var(--red-dark);
  color: var(--text);
  font-size: 12px;
  border-top: 1px solid var(--red-dim);
}

.statusbar .group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.statusbar a {
  color: #fff;
}

.mode {
  background: var(--red);
  color: #000;
  font-weight: bold;
  padding: 0 6px;
}

/* ---------- Phones and small tablets ---------- */

@media (max-width: 800px) {
  body {
    font-size: 14px;
  }

  /* Let the whole page scroll normally on phones. */
  .window {
    width: 100%;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
  }

  .workspace {
    flex-direction: column;
  }

  /* Phones get the post list on the home page instead of the file tree. */
  .sidebar {
    display: none;
  }

  .content {
    overflow: visible;
    padding: 16px 14px 32px;
  }

  .back {
    display: inline-block;
    margin-bottom: 12px;
    padding: 2px 8px;
    border: 1px solid var(--red-dim);
  }

  .back::before {
    content: "< ";
  }

  /* Smaller line-number gutter on phones. */
  .post-body {
    margin-left: 26px;
    padding-left: 10px;
  }

  .post-body > *::before {
    left: -38px;
    width: 22px;
    font-size: 11px;
  }

  .ls-desc {
    padding-left: 0;
  }

  /* Scale the 59-column banner to the screen width (minus .content padding),
     leaving headroom for wider fallback glyphs on block characters. */
  .banner {
    font-size: min(14px, calc((100vw - 28px) / 40));
  }

  .avatar {
    width: 100px;
  }

  .post-nav {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
  }
}
