/* Lucida Blog — terminal theme.
   Dark editor surfaces, mono labels, amber + green accents.
   Fonts (IBM Plex Sans, JetBrains Mono) load from baseof.html. */

:root {
  --bg: #0d1117;
  --paper: #161b22;
  --chrome: #1c2129;
  --code-bg: #0b0e13;
  --text: #c9d1d9;
  --strong: #f0f3f6;
  --muted: #7d8590;
  --line: #30363d;
  --rule-strong: #6e7681;
  --rule-faint: rgba(240, 246, 252, 0.08);
  --accent: #f2b84b;
  --accent-2: #7ee787;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "PingFang SC", monospace;
  --sans: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
  --wide: min(1100px, calc(100% - 2rem));
  --narrow: min(780px, calc(100% - 2rem));
  --traffic-lights:
    radial-gradient(circle at 16px 50%, #ff5f56 4.5px, transparent 5.5px),
    radial-gradient(circle at 32px 50%, #ffbd2e 4.5px, transparent 5.5px),
    radial-gradient(circle at 48px 50%, #27c93f 4.5px, transparent 5.5px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.7;
}

a {
  color: inherit;
}

/* ---------- Header: a prompt line ---------- */

.site-header,
.site-footer,
.page {
  margin: 0 auto;
}

.site-header,
.site-footer {
  width: var(--wide);
}

.site-header {
  border-bottom: 1px dashed var(--line);
}

.site-header .inner,
.site-footer .inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.site-header .inner {
  padding: 1.2rem 0 1rem;
}

.brand,
nav a {
  text-decoration: none;
}

.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--strong);
}

.brand::before {
  content: "~/";
  color: var(--accent-2);
}

.brand::after {
  content: "▍";
  margin-left: 0.2rem;
  color: var(--accent);
  animation: cursor-blink 1.1s steps(1) infinite;
}

.brand-tagline {
  margin-left: 0.9rem;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

.brand-tagline::before {
  content: "# ";
}

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

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

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1.1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--muted);
}

nav a::before {
  content: "./";
  opacity: 0.55;
}

nav a.language-link::before {
  content: "";
}

nav a:hover,
nav a:focus-visible {
  color: var(--strong);
}

.nav-link.active {
  color: var(--accent);
}

/* ---------- Layout ---------- */

.page {
  width: var(--wide);
  padding: 2rem 0 3rem;
}

body[data-kind="page"] .page {
  width: var(--narrow);
}

.archive-header {
  margin-bottom: 1.25rem;
}

.archive-header h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.2;
  color: var(--strong);
}

.archive-intro p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

/* ---------- Archive cards (blog + paper) ---------- */

.post-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.post-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease;
}

.post-card-link:hover,
.post-card-link:focus-within {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.post-card-anchor {
  display: block;
  height: 100%;
  padding: 1.1rem 1.25rem 1.3rem;
  text-decoration: none;
}

.post-card h2 {
  margin: 0 0 0.5rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.3;
  color: var(--strong);
  transition: color 140ms ease;
}

.post-card-link:hover h2,
.post-card-link:focus-within h2 {
  color: var(--accent);
}

.meta {
  font-family: var(--mono);
  color: var(--accent-2);
}

.post-card .meta {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
}

.post-card .meta::before {
  content: "// ";
  color: var(--muted);
}

.post-card p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ---------- Tag pages: one window with ls-style rows ---------- */

.taxonomy-list,
body[data-kind="term"] .post-list {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.taxonomy-list::before,
body[data-kind="term"] .post-list::before {
  content: "~/tags $ ls --sort=count";
  display: block;
  height: 32px;
  padding: 0 1rem 0 72px;
  line-height: 32px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--traffic-lights), var(--chrome);
  border-bottom: 1px solid var(--line);
}

body[data-kind="term"] .post-list::before {
  content: "~/tags/" attr(data-term) " $ ls -t";
}

.taxonomy-list .post-card,
body[data-kind="term"] .post-list .post-card {
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--line);
  border-radius: 0;
  overflow: visible;
}

.taxonomy-list .post-card:last-child,
body[data-kind="term"] .post-list .post-card:last-child {
  border-bottom: 0;
}

.taxonomy-list .post-card:hover,
.taxonomy-list .post-card:focus-within,
body[data-kind="term"] .post-list .post-card:hover,
body[data-kind="term"] .post-list .post-card:focus-within {
  transform: none;
  background: rgba(242, 184, 75, 0.05);
}

/* Tags index rows: count | #tag | latest titles */
.taxonomy-card {
  display: grid;
  grid-template-columns: 5.5rem minmax(9rem, 15rem) minmax(0, 1fr);
  align-items: baseline;
  column-gap: 1.25rem;
  padding: 0.6rem 1.25rem;
}

.taxonomy-title-link {
  display: contents;
  text-decoration: none;
}

.taxonomy-card h2 {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--accent);
}

.taxonomy-card h2::before {
  content: "#";
  opacity: 0.55;
}

.taxonomy-card:hover h2,
.taxonomy-card:focus-within h2 {
  color: var(--strong);
}

.taxonomy-card .meta {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 0.78rem;
  text-align: right;
}

.taxonomy-preview {
  grid-column: 3;
  grid-row: 1;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.taxonomy-preview-link {
  color: var(--muted);
  text-decoration: none;
}

.taxonomy-preview-link:hover,
.taxonomy-preview-link:focus-visible {
  color: var(--strong);
}

.taxonomy-separator {
  margin: 0 0.3rem;
  opacity: 0.5;
}

/* Single tag page */
.term-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.term-header h1 {
  color: var(--accent);
}

.term-header h1::before {
  content: "#";
  opacity: 0.55;
}

.term-header .meta {
  margin: 0;
  font-size: 0.85rem;
}

.term-header .meta::before {
  content: "// ";
  color: var(--muted);
}

/* Single tag page rows: date | title + summary */
body[data-kind="term"] .post-card-anchor {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  column-gap: 1.25rem;
  height: auto;
  padding: 0.85rem 1.25rem;
}

body[data-kind="term"] .post-card h2 {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 1.02rem;
}

body[data-kind="term"] .post-card .meta {
  grid-column: 1;
  grid-row: 1 / span 2;
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
}

body[data-kind="term"] .post-card .meta::before {
  content: none;
}

body[data-kind="term"] .post-card p:not(.meta) {
  grid-column: 2;
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Article: one editor window ---------- */

.post {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 0 2.5rem 2.5rem;
  overflow-x: hidden;
}

.post::before {
  content: "";
  display: block;
  height: 28px;
  margin: 0 -2.5rem 2rem;
  background: var(--traffic-lights), var(--chrome);
  border-bottom: 1px solid var(--line);
}

.post-header {
  margin-bottom: 1.15rem;
}

.post-header h1 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  line-height: 1.15;
  color: var(--strong);
}

.post-header h1::before {
  content: "# ";
  font-family: var(--mono);
  color: var(--accent-2);
}

.prose {
  min-width: 0;
  overflow-x: auto;
}

.prose p:first-child {
  margin-top: 0;
}

.prose h2,
.prose h3 {
  color: var(--strong);
  font-weight: 700;
  line-height: 1.3;
}

.prose h2 {
  font-size: 1.45rem;
}

.prose h3 {
  font-size: 1.15rem;
}

.prose h2::before,
.prose h3::before {
  font-family: var(--mono);
  color: var(--accent-2);
}

.prose h2::before {
  content: "## ";
  opacity: 0.8;
}

.prose h3::before {
  content: "### ";
  opacity: 0.7;
}

.prose strong {
  color: var(--strong);
}

.prose ul,
.prose ol {
  margin: 0.85rem 0;
  padding-left: 1.45rem;
}

.prose li > ul,
.prose li > ol {
  margin: 0.25rem 0 0.65rem;
}

.prose li + li {
  margin-top: 0.2rem;
}

.prose a,
.source-block a,
.terms a {
  color: var(--accent);
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
}

.prose a:hover,
.prose a:focus-visible,
.source-block a:hover,
.source-block a:focus-visible,
.terms a:hover,
.terms a:focus-visible {
  text-decoration-style: solid;
}

.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem 0.9rem 1.25rem;
  background: rgba(126, 231, 135, 0.06);
  border-left: 3px solid var(--accent-2);
  border-radius: 0 6px 6px 0;
}

.prose blockquote p {
  margin: 0;
}

.prose hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px dashed var(--line);
}

.prose img {
  display: block;
  width: min(100%, 960px);
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.prose figcaption {
  margin-top: -0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.prose code {
  padding: 0.12rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--accent-2);
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.prose pre,
.prose pre.wp-block-code {
  margin: 1.5rem 0;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.prose pre code,
.prose pre.wp-block-code code {
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.65;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
}

/* Chroma injects inline backgrounds on .highlight pre. */
.prose .highlight pre {
  background-color: var(--code-bg) !important;
  color: #f8f8f2 !important;
  font-size: 0.86rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.prose .highlight pre code {
  color: inherit !important;
  font-size: inherit;
  line-height: inherit;
}

.prose .highlight pre span {
  font-family: inherit;
  font-size: inherit !important;
  line-height: inherit !important;
}

.post-paper .highlight span[style] {
  color: inherit !important;
  background: transparent !important;
}

.prose table {
  width: 100%;
  min-width: min(680px, 100%);
  margin: 1.4rem 0;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.55;
}

.prose th,
.prose td {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.prose th {
  background: var(--chrome);
  color: var(--strong);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.8rem;
}

.prose tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.terms {
  margin-top: 2rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.source-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--muted);
}

.source-block p {
  margin: 0.2rem 0;
}

/* ---------- Paper tables and figures (used in translated papers) ---------- */

.paper-table-figure {
  margin: 1.7rem 0 2rem;
}

.paper-table-figure figcaption {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0 0.65rem;
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  color: var(--strong);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
}

.paper-image-figure img {
  margin: 0 auto 0.9rem;
}

.paper-image-figure figcaption {
  margin-bottom: 0;
}

.prose .paper-acm-table,
.prose .paper-mini-table {
  width: 100%;
  min-width: 0;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.98rem;
  line-height: 1.5;
}

.prose .paper-acm-table th,
.prose .paper-acm-table td,
.prose .paper-mini-table th,
.prose .paper-mini-table td {
  padding: 0.35rem 0.5rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: inherit;
  background: none;
  border: 0;
  overflow-wrap: normal;
  word-break: normal;
}

.prose .paper-acm-table tbody tr,
.prose .paper-mini-table tbody tr {
  background: none;
}

.prose .paper-acm-table thead th {
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule-strong);
  font-weight: 600;
}

.paper-acm-table--axioms th[scope="row"],
.paper-acm-table--proof th[scope="row"] {
  width: 3.8rem;
  padding-left: 0;
  white-space: nowrap;
  font-weight: 600;
}

.paper-acm-table--axioms td:nth-child(2) {
  width: 52%;
  white-space: nowrap;
}

.paper-acm-table--axioms td:nth-child(3) {
  width: 48%;
}

.paper-acm-table--proof td:last-child,
.paper-acm-table--proof th:last-child {
  width: 8.75rem;
  white-space: nowrap;
}

.paper-proof-cell > div + div {
  margin-top: 0.1rem;
}

.paper-proof-indent {
  padding-left: 1.8rem;
}

.paper-acm-table--glossary {
  margin: 1.1rem 0 1.6rem;
}

.paper-acm-table--glossary th:first-child,
.paper-acm-table--glossary td:first-child {
  width: 8.5rem;
  padding-left: 0;
  white-space: nowrap;
}

.paper-acm-table--compare,
.paper-acm-table--matrix {
  margin: 0.15rem 0 0;
}

.prose .paper-acm-table--compare tbody td {
  width: 50%;
}

.prose .paper-acm-table--compare tbody tr + tr td,
.prose .paper-acm-table--matrix tbody tr + tr td {
  border-top: 1px solid var(--rule-faint);
}

.paper-acm-table--compare td:first-child,
.paper-acm-table--compare th:first-child {
  padding-left: 0;
}

.prose .paper-acm-table--matrix {
  font-size: 0.95rem;
}

.prose .paper-acm-table--matrix th + th,
.prose .paper-acm-table--matrix td + td {
  border-left: 1px solid var(--rule-faint);
}

.paper-acm-table--matrix th:first-child,
.paper-acm-table--matrix td:first-child {
  width: 6.6rem;
  padding-left: 0;
  white-space: nowrap;
}

.paper-mini-sections {
  display: grid;
  gap: 1.2rem;
}

.paper-mini-section {
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.paper-mini-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.paper-mini-heading {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

.paper-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.prose .paper-mini-table {
  width: min(100%, 16rem);
  margin: 0 auto;
  font-variant-numeric: tabular-nums;
}

.prose .paper-mini-table th,
.prose .paper-mini-table td {
  padding: 0.15rem 0.45rem;
  text-align: center;
  white-space: nowrap;
}

.prose .paper-mini-table thead th {
  font-weight: 600;
  border-bottom: 2px solid var(--rule-strong);
}

.prose .paper-mini-table thead th:first-child,
.prose .paper-mini-table tbody th {
  border-right: 2px solid var(--rule-strong);
}

.paper-table-note {
  width: min(100%, 34rem);
  margin: 0.55rem auto 0;
}

.paper-table-notes {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.paper-table-notes-title {
  margin: 0 0 0.55rem;
  font-weight: 600;
}

.paper-table-notes ol {
  margin: 0;
  padding-left: 1.4rem;
}

.paper-table-notes li + li {
  margin-top: 0.35rem;
}

.app-video-figure {
  max-width: 28rem;
  margin: 1.5rem auto;
}

.app-video-figure video {
  display: block;
  width: 100%;
  background: var(--code-bg);
  border-radius: 0.75rem;
}

.app-video-figure figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 1rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
}

.footer-mark {
  width: 100%;
  margin: 0;
  padding: 0.7rem 0 3rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: right;
}

.footer-mark::before {
  content: "$ echo \"";
}

.footer-mark::after {
  content: "\"";
}

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  .brand-tagline {
    display: none;
  }

  .site-header .inner {
    gap: 0.75rem;
  }

  .brand {
    flex: 0 1 auto;
    min-width: 0;
  }

  nav {
    flex: 0 0 auto;
    gap: 0.75rem;
  }

  .post {
    padding: 0 1.25rem 1.5rem;
  }

  .post::before {
    margin: 0 -1.25rem 1.5rem;
  }

  .taxonomy-card {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 0.65rem 1rem;
  }

  .taxonomy-card h2 {
    grid-column: 1;
  }

  .taxonomy-card .meta {
    grid-column: 2;
    text-align: left;
  }

  .taxonomy-preview {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 0.2rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  body[data-kind="term"] .post-card-anchor {
    grid-template-columns: minmax(0, 1fr);
    padding: 0.8rem 1rem;
  }

  body[data-kind="term"] .post-card .meta {
    grid-column: 1;
    grid-row: 1;
    margin: 0 0 0.2rem;
  }

  body[data-kind="term"] .post-card h2 {
    grid-column: 1;
    grid-row: 2;
  }

  body[data-kind="term"] .post-card p:not(.meta) {
    grid-column: 1;
  }

  .paper-mini-grid {
    grid-template-columns: 1fr;
  }

  .paper-acm-table--axioms td:nth-child(2),
  .paper-acm-table--axioms td:nth-child(3),
  .paper-acm-table--proof td:last-child,
  .paper-acm-table--proof th:last-child {
    width: auto;
  }
}

/* ---------- 404 ---------- */

body[data-kind="404"] .page {
  width: var(--narrow);
}

.not-found .post-header h1 {
  font-family: var(--mono);
}

.not-found .not-found-shell {
  white-space: pre-wrap;
  word-break: break-all;
}

.not-found-prompt {
  color: var(--accent-2);
}

.not-found-error {
  color: #ff7b72;
}

.not-found-hint {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
}
