/* === Catppuccin Mocha — Refined Terminal Blog === */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;1,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;1,9..144,300&display=swap');

/* === Color Tokens === */
:root {
  /* Catppuccin Mocha palette */
  --bg:       #1e1e2e;
  --mantle:   #181825;
  --crust:    #11111b;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --overlay2: #9399b2;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --text:     #cdd6f4;

  --rosewater: #f5e0dc;
  --flamingo:  #f2cdcd;
  --pink:      #f5c2e7;
  --mauve:     #cba6f7;
  --red:       #f38ba8;
  --maroon:    #eba0ac;
  --peach:     #fab387;
  --yellow:    #f9e2af;
  --green:     #a6e3a1;
  --teal:      #94e2d5;
  --sky:       #89dceb;
  --sapphire:  #74c7ec;
  --blue:      #89b4fa;
  --lavender:  #b4befe;

  /* Semantic */
  --border:    var(--surface0);
  --accent:    var(--mauve);
  --accent2:   var(--peach);
  --prompt:    var(--green);
  --dim:       var(--overlay0);

  /* Layout */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --max-width: 800px;
  --gap:       28px;

  /* Transitions */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* === TOC Sidebar === */
h2#toc {
  display: none;
}

#toc-list {
  position: fixed;
  top: 60px;
  /* Anchor to the right edge of the centered article + a gap */
  left: calc(50% + (var(--max-width) / 2) + 40px);
  width: 200px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  list-style: none;
  padding: 4px 0 4px 14px;
  margin: 0;
  font-size: 0.66rem;
  line-height: 1.4;
  font-family: 'JetBrains Mono', monospace;
  border-left: 1px solid var(--surface0);
  opacity: 0.55;
  transition: opacity 0.2s ease;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge */
}

#toc-list::before {
  content: "on this page";
  display: block;
  font-size: 0.65rem;
  color: var(--dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--surface0);
}

#toc-list:hover {
  opacity: 1;
}

#toc-list a {
  display: block;
  color: var(--overlay1);
  font-size: 0.90rem;
  text-decoration: none;
  padding: 4px 0;
  /* allow wrapping instead of truncating */
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  border-left: 2px solid transparent;
  margin-left: -14px;
  padding-left: 14px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

#toc-list a:hover {
  color: var(--mauve);
  border-left-color: var(--mauve);
  text-decoration: none;
}

#toc-list ul {
  list-style: none;
  padding-left: 12px;
  margin: 2px 0;
}

#toc-list ul a {
  font-size: 0.42rem;
  color: var(--overlay0);
}

/* Hide TOC when there isn't enough room beside the article */
@media (max-width: 1280px) {
  #toc-list {
    display: none;
  }
}

/* Anchor jump offset so headings don't land flush against the top */
:target {
  scroll-margin-top: 30px;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  /* subtle noise texture for depth */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(203, 166, 247, 0.07) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#blog, #post {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--gap) var(--gap) 64px;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--crust); }
::-webkit-scrollbar-thumb { background: var(--surface1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Hide scrollbar only on the TOC */
#toc-list::-webkit-scrollbar { display: none; }

/* === Selection === */
::selection {
  background: var(--mauve);
  color: var(--crust);
}

/* === Header === */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap);
  padding-bottom: 16px;
}

.site-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--text);
  letter-spacing: 0.01em;
  text-decoration: none;
}

.site-title::before {
  content: "~/";
  color: var(--prompt);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
}

nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

header a, nav a {
  color: var(--subtext0);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 400;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  letter-spacing: 0.03em;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}

header a:hover, nav a:hover {
  color: var(--mauve);
  border-color: var(--border);
  background: rgba(203, 166, 247, 0.06);
}

/* === Headings === */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  color: var(--text);
  line-height: 1.3;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.9rem; margin-top: 0; }
h2 { font-size: 1.35rem; color: var(--subtext1); }
h3 { font-size: 1.1rem; color: var(--subtext0); font-weight: 400; }

/* terminal prompt only on standalone h1 (post title) */
#post > article > h1::before,
#post > h1::before {
  content: "$ ";
  font-family: 'JetBrains Mono', monospace;
  color: var(--prompt);
  font-size: 0.7em;
  vertical-align: middle;
  opacity: 0.85;
}

/* section h2 markers */
h2::before {
  content: "";
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75em;
  font-style: normal;
}

/* === Blog List === */
#blog {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#blog article {
  position: relative;
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  overflow: hidden;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  cursor: pointer;
}

/* left accent bar */
#blog article::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  transition: background 0.2s var(--ease);
}

#blog article:hover {
  border-color: rgba(203, 166, 247, 0.4);
  transform: translateX(3px);
  box-shadow: -4px 0 20px rgba(203, 166, 247, 0.08), 0 4px 24px rgba(0,0,0,0.3);
}

#blog article:hover::before {
  background: var(--mauve);
}

#blog article h1,
#blog article h2 {
  font-size: 1.05rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 6px;
  letter-spacing: 0;
}

#blog article h1::before,
#blog article h2::before {
  content: none;
}

#blog article p {
  color: var(--subtext0);
  font-size: 0.88rem;
  margin: 0 0 10px;
  line-height: 1.6;
}

.post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
}

.post-meta time::before { content: "⏱ "; }

.tag {
  display: inline-block;
  background: rgba(203, 166, 247, 0.1);
  color: var(--mauve);
  border: 1px solid rgba(203, 166, 247, 0.2);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.tag:hover {
  background: rgba(203, 166, 247, 0.18);
}

/* === Post View === */
#post article {
  background: transparent;
  border: none;
  padding: 0;
}

#post article > * {
  animation: fadeUp 0.4s var(--ease) both;
}

#post article > *:nth-child(1) { animation-delay: 0.05s; }
#post article > *:nth-child(2) { animation-delay: 0.1s; }
#post article > *:nth-child(3) { animation-delay: 0.15s; }
#post article > *:nth-child(4) { animation-delay: 0.2s; }
#post article > *:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#post p {
  color: var(--subtext1);
  margin-bottom: 1.2em;
}

/* === Links === */
a {
  color: var(--peach);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

a:hover {
  color: var(--mauve);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* === Code === */
code {
  background: var(--crust);
  color: #d8a389;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.88em;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border);
}

pre {
  position: relative;
  background: var(--crust);
  padding: 20px 20px 20px 22px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-left: 3px solid var(--surface1);
  margin: 1.5em 0;
}

/* language label */
pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 0.7rem;
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.87em;
  color: var(--text);
  line-height: 1.65;
}

/* === Blockquotes === */
blockquote {
  position: relative;
  border-left: 2px solid var(--mauve);
  padding: 12px 18px;
  margin: 1.5em 0;
  background: rgba(203, 166, 247, 0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--subtext0);
  font-style: italic;
}

blockquote::before {
  content: "\201C";
  position: absolute;
  top: -4px;
  left: 10px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2.5rem;
  color: rgba(203, 166, 247, 0.2);
  line-height: 1;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 1.5em 0;
}

th {
  background: var(--mantle);
  color: var(--mauve);
  font-weight: 500;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--subtext1);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* === Divider === */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 2.5em 0;
}

/* === Images === */
img {
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: block;
  margin: 1.5em auto;
}

/* === Callout / Note boxes === */
.note, .warning, .tip {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

.note    { background: rgba(137, 180, 250, 0.06); border-color: rgba(137, 180, 250, 0.25); color: var(--blue); }
.warning { background: rgba(249, 226, 175, 0.06); border-color: rgba(249, 226, 175, 0.25); color: var(--yellow); }
.tip     { background: rgba(166, 227, 161, 0.06); border-color: rgba(166, 227, 161, 0.25); color: var(--green); }

.note::before    { content: "ℹ  NOTE — "; font-weight: 600; }
.warning::before { content: "⚠  WARNING — "; font-weight: 600; }
.tip::before     { content: "✦  TIP — "; font-weight: 600; }

/* === Footer === */
footer {
  display: none;
}

/* === Back link === */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--subtext0);
  font-size: 0.82rem;
  margin-bottom: 24px;
  transition: color 0.15s var(--ease), gap 0.15s var(--ease);
}

.back-link::before { content: "\2190"; }

.back-link:hover {
  color: var(--mauve);
  gap: 10px;
  text-decoration: none;
}

/* === Focused reading mode for post === */
#post article p,
#post article li {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--subtext1);
}

/* code stays monospace in prose */
#post article p code,
#post article li code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84em;
}

/* === Lists === */
ul, ol {
  padding-left: 1.4em;
  margin: 0.8em 0 1.2em;
}

li {
  margin-bottom: 0.35em;
  color: var(--subtext1);
}

ul li::marker { color: var(--mauve); }
ol li::marker { color: var(--peach); font-weight: 600; }

/* === Responsive === */
@media (max-width: 600px) {
  #blog, #post { padding: 18px 16px 48px; }
  h1 { font-size: 1.5rem; }
  header { flex-direction: column; align-items: flex-start; }
}
