/* Geist Mono — matches feranmi.space homepage */
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-mono/GeistMono-Variable.woff2') format('woff2');
}

:root {
  --bg: #000000;
  --bg-raised: #111111;
  --bg-raised-hover: #1a1a1a;
  --ink: #d1d5db;
  --ink-dim: #9ca3af;
  --ink-faint: #6b7280;
  --rule: #374151;
  --amber: #60a5fa;
  --amber-dim: #3b82f6;
  --sage: #60a5fa;
  --sage-dim: #2563eb;
  --serif-display: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --serif-body: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --code-bg: #0a0a0a;
  --code-head: #141414;
  --code-scroll: #4b5563;
}

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

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 2px;
}

.shell {
  max-width: 38.75rem; /* 620px — a touch wider so the text column breathes */
  margin: 120px 0 120px 120px;
  padding: 0;
}

/* ---- terminal header / signature element ---- */
.prompt {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--sage);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.prompt .cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--amber);
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.prompt-cmd { color: var(--ink-dim); }

h1.site-title {
  font-family: var(--serif-display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 4px 0 10px;
}

.tagline {
  color: var(--ink-dim);
  font-size: 14px;
  max-width: 480px;
  margin-bottom: 36px;
}

/* ---- filters as ledger toggles ---- */
.filters {
  display: flex;
  gap: 18px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.filters button {
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 6px 0;
  position: relative;
}
.filters button::before { content: "["; color: var(--ink-faint); margin-right: 2px; }
.filters button::after { content: "]"; color: var(--ink-faint); margin-left: 2px; }
.filters button.active { color: var(--ink); }
.filters button[data-filter="technical"].active { color: var(--amber); }
.filters button[data-filter="technical"].active::before,
.filters button[data-filter="technical"].active::after { color: var(--amber-dim); }
.filters button[data-filter="essays"].active { color: var(--sage); }
.filters button[data-filter="essays"].active::before,
.filters button[data-filter="essays"].active::after { color: var(--sage-dim); }

hr.divider {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 8px 0 28px;
}

/* ---- ledger entries ---- */
.entry {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 20px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
  transition: background 0.15s ease, margin 0.15s ease, padding 0.15s ease;
  cursor: pointer;
}
.entry:hover { background: var(--bg-raised); margin: 0 -16px; padding: 22px 16px; }
.entry:hover .entry-title { color: var(--amber); }
.entry[data-type="essay"]:hover .entry-title { color: var(--sage); }

.entry-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  padding-top: 3px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tick {
  width: 14px;
  height: 3px;
  background: var(--amber);
  margin-bottom: 2px;
}
.entry[data-type="essay"] .tick { background: var(--sage); }

.entry-title {
  font-family: var(--serif-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  transition: color 0.15s ease;
}
.entry-desc {
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.55;
}

.entry.hidden { display: none; }

/* ---- essay view ---- */
.back-link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 40px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--sage); }

.essay-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--sage);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.essay-meta .tick { width: 14px; height: 3px; background: var(--sage); margin: 0; }
.essay-meta .dim { color: var(--ink-faint); }

h2.essay-title {
  font-family: var(--serif-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
  line-height: 1.15;
}

/* Series navigation in essay header */
.series-nav {
  margin-top: -30px;
  margin-bottom: 30px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  gap: 12px;
}
.series-nav a {
  color: var(--ink-faint);
  transition: color 0.15s ease;
}
.series-nav a:hover {
  color: var(--amber);
}

.essay-quote {
  font-family: var(--serif-body);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-dim);
  border-left: 2px solid var(--sage-dim);
  padding-left: 18px;
  margin-bottom: 32px;
}

.essay-body {
  font-family: var(--serif-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
}
.essay-body p { margin-bottom: 22px; }

/* Subheadings and formatting inside essays */
.essay-body h2, .essay-body h3 {
  font-family: var(--serif-display);
  font-weight: 600;
  color: var(--ink);
  margin-top: 36px;
  margin-bottom: 14px;
}
.essay-body h2 {
  font-size: 21px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
}
.essay-body h3 {
  font-size: 18px;
}
.essay-body hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 32px 0;
}
.essay-body a {
  color: var(--sage);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.essay-body a:hover {
  color: var(--amber);
}
.essay-body ul, .essay-body ol {
  margin-left: 24px;
  margin-bottom: 22px;
}
.essay-body li {
  margin-bottom: 8px;
}

/* Tabular display for privacy policy */
.essay-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}
.essay-body th {
  border-bottom: 2px solid var(--rule);
  padding: 8px;
  font-family: var(--mono);
  color: var(--ink-dim);
  text-align: left;
}
.essay-body td {
  border-bottom: 1px solid var(--rule);
  padding: 8px;
}

/* Code Styles */
pre {
  background-color: var(--code-bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  tab-size: 4;
  margin-bottom: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--code-scroll) var(--code-bg);
}
pre::-webkit-scrollbar { height: 10px; }
pre::-webkit-scrollbar-track { background: var(--code-bg); border-radius: 0 0 6px 6px; }
pre::-webkit-scrollbar-thumb { background: var(--code-scroll); border-radius: 6px; border: 2px solid var(--code-bg); }
pre::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* Code blocks stay within the text column; long lines scroll or soft-wrap. */
.essay-body .code-wrap {
  width: 100%;
  margin-bottom: 24px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  background: var(--code-bg);
}
.essay-body .code-wrap pre {
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--code-bg);
}

/* keep the code font small and consistent across Shiki output (pre.astro-code) */
.essay-body .code-wrap pre,
.essay-body pre.astro-code {
  font-size: 11px;
}

/* Shiki has no `mermaid` grammar, so those blocks render as plain text; hide the
   raw source until the mermaid script swaps it for the rendered diagram. */
.essay-body pre[data-language="mermaid"] {
  display: none;
}

/* header bar: language label + actions */
.code-wrap .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 14px;
  background: var(--code-head);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
}
.code-wrap .code-lang {
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: lowercase;
}
.code-wrap .code-actions {
  display: flex;
  gap: 6px;
}
.code-wrap .code-actions button {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 2px 9px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.code-wrap .code-actions button:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
}
.code-wrap .copy-btn.copied {
  color: var(--sage-dim);
  border-color: var(--sage);
}
.code-wrap .wrap-btn.active {
  color: var(--amber);
  border-color: var(--amber);
}

/* soft-wrap mode: wrap long lines instead of scrolling */
.code-wrap pre.soft-wrap {
  overflow-x: hidden;
}
.code-wrap pre.soft-wrap code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

code {
  font-family: var(--mono);
  background-color: var(--bg-raised);
  color: var(--amber);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
}

/* ---- math (KaTeX) ---- */
/* let a long display formula scroll inside the column instead of overflowing it */
.essay-body .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  /* left-align so a formula wider than the column starts at the left edge and
     scrolls rightward, instead of being clipped on both sides when centered */
  text-align: left;
  padding: 6px 2px;
  margin: 22px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
/* KaTeX centers the inner .katex block by default; left-align it too so short and
   long formulas line up consistently with the left-aligned essay column */
.essay-body .katex-display > .katex { text-align: left; }
.essay-body .katex { color: var(--ink); }

/* ---- reading progress bar ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 200;
  pointer-events: none;
  background: transparent;
}
.reading-progress-bar {
  height: 100%;
  width: 0;
  background: var(--amber);
  transition: width 0.08s linear;
}

/* ---- table of contents (right rail) ---- */
.toc {
  display: none; /* shown on wide screens only, see media query below */
}
@media (min-width: 1180px) {
  .toc {
    display: block;
    position: fixed;
    top: 140px;
    right: 44px;
    width: 210px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    z-index: 90;
    font-family: var(--mono);
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
  }
}
.toc-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
  padding-left: 10px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc-link {
  display: block;
  padding: 4px 0 4px 10px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ink-faint);
  border-left: 2px solid var(--rule);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-link[data-depth="3"] {
  padding-left: 22px;
  font-size: 11px;
}
.toc-link:hover { color: var(--ink); }
.toc-link.active {
  color: var(--amber);
  border-left-color: var(--amber);
}

/* ---- heading anchor links ---- */
html { scroll-behavior: smooth; }
.essay-body h2, .essay-body h3 { scroll-margin-top: 24px; }
.heading-anchor {
  margin-left: 10px;
  color: var(--ink-faint);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.essay-body h2:hover .heading-anchor,
.essay-body h3:hover .heading-anchor { opacity: 0.6; }
.heading-anchor:hover { opacity: 1; color: var(--amber); }

/* Kudos widget (Svbtle-style hold-to-kudo) */
@keyframes kudo-bounce {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.12); }
  65% { transform: scale(0.96); }
}

.kudo-group {
  margin-top: 48px;
}

figure.kudo {
  position: relative;
  margin: 0;
  padding: 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 0;
  -webkit-touch-callout: none;
  user-select: none;
}

figure.kudo a {
  position: relative;
  display: block;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--bg);
  cursor: default;
  transition: border-color 1s ease-in;
  text-decoration: none;
}

figure.kudo div.filling {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--ink);
  transform: scale(0.3);
  transition: transform 1s ease-out, background-color 1s ease-out;
}

figure.kudo.activated div.filling,
figure.kudo.complete div.filling {
  transform: scale(1);
  background-color: var(--sage);
}

figure.kudo.activated a,
figure.kudo.complete a {
  border-color: var(--sage);
}

figure.kudo.complete div.filling {
  animation: kudo-bounce 0.65s ease;
}

figure.kudo.complete div.filling::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

figure.kudo div.num {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  padding-left: 14px;
  padding-right: 6px;
  line-height: 1;
}

figure.kudo div.txt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  line-height: 1;
}

figure.kudo.activated div.txt {
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  padding-left: 14px;
}

figure.kudo.side {
  display: none;
}

@media (min-width: 721px) {
  figure.kudo.side {
    display: flex;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 10px 10px;
    border-radius: 8px;
    background: var(--bg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    transform: scale(0.92);
    opacity: 0.92;
    transition: transform 0.35s cubic-bezier(0.165, 0.63, 0.14, 0.82),
                opacity 0.35s cubic-bezier(0.165, 0.63, 0.14, 0.82);
  }

  figure.kudo.side:hover {
    transform: scale(1);
    opacity: 1;
  }

  figure.kudo.side a {
    width: 40px;
    height: 40px;
    border-width: 2px;
    margin-bottom: 4px;
  }

  figure.kudo.side div.filling {
    width: 30px;
    height: 30px;
    top: 3px;
    left: 3px;
  }

  figure.kudo.side div.num,
  figure.kudo.side div.txt {
    padding: 0;
    text-align: center;
    float: none;
    display: block;
  }

  figure.kudo.side div.num {
    font-size: 16px;
    line-height: 1.2;
  }

  figure.kudo.side div.txt {
    font-size: 10px;
    line-height: 1.2;
  }

  figure.kudo.side.activated {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  figure.kudo.side.activated div.txt {
    font-size: 13px;
    padding-left: 0;
    max-width: 72px;
    line-height: 1.2;
  }
}

/* Footer style */
footer {
  margin-top: 80px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
}
footer a {
  color: var(--ink-dim);
  transition: color 0.15s ease;
}
footer a:hover {
  color: var(--sage);
}

@media (max-width: 720px) {
  .shell { margin: 40px 18px 100px; max-width: none; }
  h1.site-title { font-size: 28px; }
  .entry { grid-template-columns: 1fr; gap: 8px; }
  .entry-meta { flex-direction: row; gap: 10px; }
  h2.essay-title { font-size: 24px; }
}
