/* ---------- Design tokens ---------- */
:root {
  --bg: #0b0e13;
  --bg-alt: #121722;
  --surface: #161c29;
  --border: #232c3d;
  --text: #e6e9f0;
  --text-dim: #9aa4b8;
  --accent: #2be1ee;
  --accent-rgb: 43, 225, 238;
  --accent-dim: #1d9ca5;
  --danger: #ef6461;
  --radius: 10px;
  --max-width: 960px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- Background symbol ---------- */
.symbol-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  color: var(--accent);
  opacity: 0.16;
  font-family: var(--mono);
  font-size: clamp(6px, 1.35vw, 20px);
  line-height: 1;
  white-space: pre;
  text-shadow: 0 0 60px rgba(var(--accent-rgb), 0.8);
  transform: translate(10vw, -6vh) rotate(-6deg);
}

@media (max-width: 700px) {
  .symbol-bg {
    justify-content: center;
    transform: translate(0, -10vh) rotate(-4deg);
    font-size: clamp(5px, 2.4vw, 12px);
    opacity: 0.13;
  }
}

/* ---------- Header / nav ---------- */
header.site {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 19, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.site::before {
  content: "";
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.8;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
}

.nav .logo {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}
.nav .logo span { color: var(--accent); }
.nav .logo::after {
  content: "▌";
  color: var(--accent);
  margin-left: 3px;
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

.nav a {
  color: var(--text-dim);
  font-size: 0.95rem;
}
.nav a:hover, .nav a.active { color: var(--text); text-decoration: none; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav ul {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    gap: 0;
    display: none;
  }
  .nav ul.open { display: flex; }
  .nav ul li { border-top: 1px solid var(--border); }
  .nav ul a { display: block; padding: 0.85rem 1.5rem; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 5rem 0 3.5rem;
}
.hero .kicker {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0 0 0.75rem;
  line-height: 1.15;
}
.hero p.lede {
  color: var(--text-dim);
  font-size: 1.1rem;
  max-width: 640px;
  margin: 0 0 1.75rem;
}

.btn-row { display: flex; gap: 0.9rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  border: 1px solid var(--border);
}
.btn { transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06201c;
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  box-shadow: 0 8px 24px -8px rgba(var(--accent-rgb), 0.6);
}
.btn.ghost { color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Sections ---------- */
section { padding: 3rem 0; }
section h2 {
  position: relative;
  display: inline-block;
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.55rem;
}
section h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 34px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}
section .section-sub {
  color: var(--text-dim);
  margin-top: 0;
  margin-bottom: 2rem;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ---------- Cards / grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 14px 32px -16px rgba(var(--accent-rgb), 0.45);
}
.card h3 { margin: 0; font-size: 1.05rem; }
.card p { margin: 0; color: var(--text-dim); font-size: 0.95rem; }
.card .tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}
.card .card-link { margin-top: auto; font-size: 0.9rem; font-family: var(--mono); }

/* ---------- Skills list ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.skills-grid h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.skills-grid ul { margin: 0; padding: 0; list-style: none; }
.skills-grid li {
  font-family: var(--mono);
  font-size: 0.92rem;
  padding: 0.2rem 0;
  color: var(--text);
}

/* ---------- Writeup count badge ---------- */
.writeup-count {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  white-space: nowrap;
}

/* ---------- Writeups toolbar (search / sort / tags) ---------- */
.writeups-toolbar { padding-top: 0; padding-bottom: 1.5rem; }
.toolbar-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.search-input, .sort-select {
  font-family: var(--sans);
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.55rem 0.85rem;
}
.search-input { flex: 1 1 220px; min-width: 0; }
.search-input:focus, .sort-select:focus { outline: none; border-color: var(--accent); }
.sort-select { flex: 0 0 auto; }

.tag-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-filter-btn {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.tag-filter-btn:hover { color: var(--text); border-color: var(--accent); }
.tag-filter-btn.active {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.5);
}

.writeup-empty { display: none; color: var(--text-dim); font-family: var(--mono); font-size: 0.9rem; padding: 1rem 0; }

/* ---------- Writeup list ---------- */
.writeup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.writeup-row:first-of-type { border-top: 1px solid var(--border); }
.writeup-row { transition: background-color 0.15s ease, padding-left 0.15s ease; }
.writeup-row:hover { background: rgba(var(--accent-rgb), 0.045); padding-left: 0.5rem; }
.writeup-row .meta { color: var(--text-dim); font-size: 0.85rem; font-family: var(--mono); white-space: nowrap; }
.writeup-row h3 { margin: 0; font-size: 1rem; font-weight: 600; }

.difficulty { font-family: var(--mono); font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 4px; border: 1px solid var(--border); }
.difficulty.easy { color: #7ee787; border-color: #2f6b3a; }
.difficulty.medium { color: #e3b341; border-color: #6b5a2f; }
.difficulty.hard { color: var(--danger); border-color: #6b2f2f; }

/* ---------- Article / writeup page ---------- */
article.post {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}
article.post .post-meta { color: var(--text-dim); font-family: var(--mono); font-size: 0.85rem; margin-bottom: 0.5rem; }
article.post h1 { margin-top: 0; }
article.post h2 { margin-top: 2.2rem; }
article.post pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88rem;
}
article.post code {
  font-family: var(--mono);
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}
article.post pre code { background: none; padding: 0; }
article.post blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.25rem 0;
  padding: 0.25rem 1rem;
  color: var(--text-dim);
}

/* ---------- Contact ---------- */
.contact-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.contact-links a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.contact-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- Footer ---------- */
footer.site {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}
footer.site .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
