/* ============================================================
   FONTS
   ============================================================ */

@font-face {
  font-family: 'Kingthings Spikeless';
  src: url('fonts/KingthingsSpikeless.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}


/* ============================================================
   TOKENS
   ============================================================ */

:root {
  --bg:           #0a0a0a;
  --bg-code:      #08090c;
  --bg-code-2:    #0e0f13;
  --bg-code-line: #14151a;
  --fg:           #ededed;
  --fg-1:         #d8d8d8;
  --fg-2:         #888;
  --fg-3:         #555;
  --fg-4:         #2a2a2a;
  --line:         #1a1a1a;
  --line-2:       #2c2c2c;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --serif:   'Roboto', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, monospace;
}


/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  background: var(--bg);
  color: var(--fg-1);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

::-webkit-scrollbar       { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-2); }
::-webkit-scrollbar-thumb:hover { background: var(--fg-3); }


/* ============================================================
   LAYOUT
   ============================================================ */

.container {
  max-width: 990px;
  margin: 0 auto;
  padding: 80px 40px 60px;
  position: relative;
}


/* ============================================================
   HEADER
   ============================================================ */

header {
  border-bottom: 1px solid var(--line);
  padding: 18px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
}

.header-left  { justify-self: start; }
.header-right { justify-self: end; }

.blog-name-slot {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  background: var(--bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  cursor: text;
  outline: none;
  min-width: 140px;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.25s;
}

.blog-name-slot:empty::before {
  content: 'YOUR BLOG NAME';
  color: var(--fg-3);
}

.blog-name-slot:focus,
.blog-name-slot:hover:not(:focus) {
  background: var(--fg);
  color: var(--bg);
  box-shadow:
    0 0 0 1px var(--fg),
    0 0 24px rgba(255,255,255,0.45),
    0 0 60px rgba(255,255,255,0.15);
}

.blog-name-slot:focus::before,
.blog-name-slot:hover:not(:focus)::before { color: var(--bg); }

.kbd-hints {
  display: flex;
  gap: 12px;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.kbd-hints kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  padding: 2px 6px;
  color: var(--fg-1);
  margin-right: 4px;
}

nav { display: flex; gap: 8px; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  background: var(--bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.25s, transform 0.15s;
}

.nav-btn:hover {
  background: var(--fg);
  color: var(--bg);
  box-shadow:
    0 0 0 1px var(--fg),
    0 0 24px rgba(255,255,255,0.45),
    0 0 60px rgba(255,255,255,0.15);
}

.nav-btn:active { transform: translateY(1px); }


/* ============================================================
   ABOUT PAGE
   ============================================================ */

/* about.html uses .about-header instead of the global header
   to avoid grid/border conflicts */

.home-header {
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
}
.about-header {
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
}

.home-logo {
  font-family: 'Kingthings Spikeless', var(--display);
  font-size: 34px;
  font-weight: 400;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.01em;
  line-height: 1;
}

.about-section {
  max-width: 640px;
  margin: 64px auto 80px;
  padding: 0 32px;
}

.about-title {
  font-family: var(--display);
  font-size: 38px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  margin-bottom: 28px;
  text-align: center;
}

.about-photo {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 28px;
}

.about-body {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--fg);
  line-height: 1.7;
  margin-bottom: 80px;
}

.about-body p { margin-bottom: 20px; }

/* Social Icons */
.social-icons {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  margin: 40px 0 48px;
}

.social-icons a {
  color: var(--fg);
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
}

.social-icons a:hover { opacity: 0.65; }


/* ============================================================
   COVER IMAGE
   ============================================================ */

.cover {
  margin: 0 0 56px;
  width: 100%;
  max-width: 1200px;
  border: 0px solid var(--line-2);
  background: var(--bg-code);
  overflow: hidden;
  line-height: 0;
}

.cover img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 1200px;
  object-fit: cover;
}


/* ============================================================
   ARTICLE — TITLE & LEDE
   ============================================================ */

h1.article-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(40px, 5.5vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin-bottom: 24px;
  color: var(--fg);
}

.lede {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.5;
  color: var(--fg-2);
  margin-bottom: 64px;
  font-style: italic;
}


/* ============================================================
   ARTICLE — BODY
   ============================================================ */

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 { color: var(--fg); }

.article-body h1 {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 80px 0 24px;
}

.article-body h2 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 80px 0 24px;
}

.article-body h3 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 48px 0 14px;
}

.article-body h4 {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 32px 0 10px;
}

.article-body p {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.7;
  margin-bottom: 24px;
  color: var(--fg-1);
}

.article-body p strong { color: var(--fg); font-weight: 600; }
.article-body p em     { color: var(--fg); font-style: italic; }

.article-body p code,
.article-body li code,
.article-body td code {
  font-family: var(--mono);
  background: var(--bg-code);
  border: 1px solid var(--line-2);
  padding: 1px 6px;
  font-size: 14px;
  color: var(--fg);
}

.article-body ul,
.article-body ol {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.7;
  color: var(--fg-1);
  margin: 0 0 24px 0;
  padding-left: 24px;
}

.article-body li { margin-bottom: 8px; }
.article-body ul li::marker { color: var(--fg-3); }

.article-body blockquote {
  margin: 32px 0;
  padding: 4px 0 4px 24px;
  border-left: 2px solid var(--fg);
  font-family: var(--serif);
  font-style: italic;
  font-size: 23px;
  line-height: 1.55;
  color: var(--fg-1);
}

.article-body blockquote p {
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-family: var(--mono);
  font-size: 15px;
}

.article-body th,
.article-body td {
  border: 1px solid var(--line-2);
  padding: 10px 14px;
  text-align: left;
  color: var(--fg-1);
}

.article-body th {
  background: var(--bg-code);
  color: var(--fg);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}


/* ============================================================
   CODE BLOCKS
   ============================================================ */

.article-body pre {
  margin: 32px 0;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-code) 100%);
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.03),
    0 1px 0 rgba(255,255,255,0.02),
    0 8px 32px rgba(0,0,0,0.4);
}

.article-body pre code {
  display: block;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  background: transparent;
  border: 0;
  color: var(--fg-1);
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-code-line);
  border: 1px solid var(--line-2);
  color: var(--fg-2);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 9px;
  cursor: pointer;
  opacity: 0;
  z-index: 2;
  transition: all 0.15s;
}

.article-body pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover         { color: var(--fg); border-color: var(--fg); }
.copy-btn.copied        { color: var(--fg); border-color: var(--fg); opacity: 1; }

/* highlight.js monochrome overrides */
.hljs                                          { background: transparent !important; color: var(--fg-1) !important; }
.hljs-keyword, .hljs-built_in,
.hljs-meta,    .hljs-section                  { color: var(--fg) !important; font-weight: 600 !important; }
.hljs-string,  .hljs-attr                     { color: var(--fg-1) !important; }
.hljs-number,  .hljs-literal                  { color: var(--fg) !important; }
.hljs-comment, .hljs-quote                    { color: var(--fg-3) !important; font-style: italic !important; }
.hljs-function, .hljs-title, .hljs-class,
.hljs-title\.function_, .hljs-title\.class_   { color: var(--fg) !important; font-weight: 500 !important; }
.hljs-variable, .hljs-params                  { color: var(--fg-1) !important; }
.hljs-operator, .hljs-punctuation             { color: var(--fg-2) !important; }
.hljs-name,    .hljs-selector-tag             { color: var(--fg) !important; }


/* ============================================================
   TOC RAIL (Table of Contents)
   ============================================================ */

.toc-rail {
  position: fixed; top: 0; right: 0;
  height: 100vh; width: 360px;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}
.toc-rail.active { opacity: 1; }
.toc-trigger {
  position: absolute; top: 0; right: 0;
  width: 70px; height: 100%;
  pointer-events: auto;
}
.toc-minimap {
  position: absolute; top: 50%; right: 16px;
  transform: translateY(-50%);
  width: 28px; height: 60vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: auto;
  transition: opacity 0.3s;
}
.toc-minimap-track { width: 1px; height: 100%; background: #333; position: relative; }
.toc-minimap-tick {
  position: absolute; right: -4px;
  width: 9px; height: 1px;
  background: #777;
  transition: all 0.25s;
}
.toc-minimap-tick.active { background: #fff; width: 14px; height: 2px; }
.toc-minimap-thumb {
  position: absolute; right: -2px;
  width: 5px; height: 5px;
  background: #fff;
  border-radius: 50%;
  transition: top 0.1s linear;
}
.toc-minimap-label {
  position: absolute; top: -32px; right: 0;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.toc-panel {
  position: absolute; top: 50%; right: 56px;
  transform: translateY(-50%) translateX(20px);
  width: 280px;
  background: #000;
  border: 1px solid #333;
  padding: 24px 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.toc-rail:hover .toc-panel,
.toc-rail.peek .toc-panel,
.toc-rail.forced-open .toc-panel {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
.toc-rail:hover .toc-minimap,
.toc-rail.peek .toc-minimap,
.toc-rail.forced-open .toc-minimap { opacity: 0.6; }
.toc-panel-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}
.toc-list { list-style: none; }
.toc-list li { margin-bottom: 4px; }
.toc-list a {
  display: block;
  padding: 6px 0 6px 12px;
  border-left: 1px solid #444;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 500;
  color: #bbb;
  text-decoration: none;
  line-height: 1.4;
  transition: all 0.2s;
}
.toc-list a:hover { color: #fff; border-left-color: #888; }
.toc-list a.active {
  color: #fff;
  font-weight: 700;
  border-left-color: #fff;
  padding-left: 14px;
}
.toc-list .lvl-2 { padding-left: 14px; }
.toc-list .lvl-3 { padding-left: 28px; }
.toc-list .lvl-4 { padding-left: 42px; }
.toc-list .lvl-2 a,
.toc-list .lvl-3 a,
.toc-list .lvl-4 a { font-size: 15px; color: #888; font-weight: 500; }
.toc-list .lvl-2 a.active,
.toc-list .lvl-3 a.active,
.toc-list .lvl-4 a.active { color: #fff; font-weight: 700; }


/* ============================================================
   ARTICLES INDEX
   ============================================================ */

.index-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(40px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 56px;
  color: var(--fg);
}

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

.posts-list li {
  border-bottom: 1px solid var(--line-2);
  padding: 28px 0;
}

.posts-list li:first-child { padding-top: 0; }

.posts-list a {
  text-decoration: none;
  display: block;
  transition: opacity 0.2s;
}

.posts-list a:hover { opacity: 0.75; }

.posts-list .post-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 10px;
}

.posts-list h2 {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.posts-list .post-lede {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--fg-2);
  font-style: italic;
  line-height: 1.5;
}


/* ============================================================
   STATE MESSAGES
   ============================================================ */

.state-msg {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--fg-2);
  font-style: italic;
  padding: 40px 0;
}

.state-msg code {
  font-family: var(--mono);
  font-size: 14px;
  background: var(--bg-code);
  border: 1px solid var(--line-2);
  padding: 2px 6px;
  color: var(--fg);
  font-style: normal;
}


/* ============================================================
   FOOTER
   ============================================================ */

footer.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 40px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-family: var(--display);
  font-size: 17px;
  color: var(--fg-2);
  letter-spacing: 0.05em;
}

.footer-name {
  cursor: default;
  transition: color 0.18s;
}

.footer-name:hover { color: var(--fg); }

footer.site-footer a {
  color: var(--fg-2);
  text-decoration: none;
  transition: color 0.18s;
}

footer.site-footer a:hover { color: var(--fg); }


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
  .kbd-hints { display: none; }
}

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

  .container { padding: 50px 24px 60px; max-width: 100%; }

  h1.article-title { font-size: 36px; }
  .lede            { font-size: 19px; }

  header {
    padding: 14px 16px;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .header-left  { justify-self: stretch; }
  .header-right { display: none; }

  nav { gap: 6px; flex-wrap: wrap; justify-content: center; }
  .nav-btn { padding: 7px 12px; font-size: 10px; letter-spacing: 0.12em; }

  .article-body p,
  .article-body ul,
  .article-body ol { font-size: 18px; }

  .article-body,
  .article-body pre,
  .article-body img { max-width: 100%; }

  .article-body pre code {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
  }

  .article-body table { display: block; overflow-x: auto; }
}

@media (max-width: 600px) {
  .about-header  { padding: 18px 20px; }
  .home-logo     { font-size: 28px; }
  .about-section { padding: 0 20px; margin-top: 44px; }
  .about-title   { font-size: 30px; }

  /* overflow fix */
  .post-tile { flex-wrap: wrap; }
  .post-tile-thumb { width: 100%; height: auto; }
}