:root {
  --bg: #0a0a0a;
  --bg-panel: #121212;
  --bg-panel-2: #171717;
  --border: #2a2a2a;
  --red: #ff2c2c;
  --red-dim: #a11c1c;
  --red-glow: rgba(255, 44, 44, 0.35);
  --text: #e6e6e6;
  --text-dim: #9a9a9a;
  --mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.65;
}

body {
  background-image:
    linear-gradient(180deg, rgba(255,44,44,0.04), transparent 300px),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 1px, transparent 1px, transparent 3px);
}

a { color: var(--red); text-decoration: none; }
a:hover { color: #ff5c5c; text-decoration: underline; }

/* ---------- Top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 6vw;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,10,0.9);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(6px);
}

.brand {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .accent { color: var(--red); text-shadow: 0 0 12px var(--red-glow); }
.brand .caret { color: var(--red); animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.nav-right { display: flex; align-items: center; gap: 30px; }

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-links a {
  color: var(--text-dim);
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav-links a:hover { color: var(--red); border-color: var(--red); text-decoration: none; }

/* ---------- Nav search (live, client-side) ---------- */
.nav-search { position: relative; }
.search-toggle {
  background: none;
  border: none;
  padding: 6px;
  margin: 0;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.search-toggle svg { width: 19px; height: 19px; }
.search-toggle:hover { color: var(--red); }

.search-panel {
  display: none;
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  width: 320px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  z-index: 60;
}
.search-panel.open { display: block; }
.search-panel input {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 5px;
  font-family: var(--sans);
  font-size: 0.92rem;
  outline: none;
  transition: border-color .15s;
}
.search-panel input:focus { border-color: var(--red); }
.search-results { margin-top: 8px; max-height: 340px; overflow-y: auto; }
.search-result-item {
  display: block;
  padding: 9px 10px;
  border-radius: 5px;
  color: var(--text);
  transition: background .12s;
}
.search-result-item:hover { background: rgba(255,44,44,0.09); text-decoration: none; }
.search-result-item .srt-title { font-size: 0.92rem; margin-bottom: 3px; }
.search-result-item .srt-date {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--red-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.search-hint, .search-empty {
  padding: 16px 10px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.8rem;
}


/* ---------- Layout wrapper ---------- */
.wrap { width: 92vw; max-width: 1400px; margin: 0 auto; padding: 40px 0 100px; }

.page-title { font-family: var(--mono); font-size: 2.1rem; margin: 10px 0 6px; color: var(--text); }
.page-title .accent { color: var(--red); }
.page-subtitle { color: var(--text-dim); margin-bottom: 40px; font-size: 1rem; }

/* ---------- Post list (index) ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 26px; }

.post-card {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel-2));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.post-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--red-dim); transition: background .15s;
}
.post-card:hover { border-color: var(--red-dim); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,44,44,0.08); }
.post-card:hover::before { background: var(--red); }
.post-card .date { font-family: var(--mono); font-size: 0.78rem; color: var(--red-dim); text-transform: uppercase; letter-spacing: 1px; }
.post-card h2 { font-size: 1.3rem; margin: 10px 0 10px; color: var(--text); }
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--red); text-decoration: none; }
.post-card p { color: var(--text-dim); font-size: 0.95rem; margin: 0 0 14px; }
.post-card .read-more { font-family: var(--mono); font-size: 0.85rem; }

.empty-state {
  color: var(--text-dim); font-family: var(--mono); padding: 60px 0; text-align: center;
  border: 1px dashed var(--border); border-radius: 8px;
}

/* ---------- Single post ---------- */
.post-full { width: 100%; }
.post-full .date { font-family: var(--mono); color: var(--red-dim); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }
.post-full h1 { font-size: 2.4rem; margin: 12px 0 30px; border-bottom: 1px solid var(--border); padding-bottom: 24px; }

.post-body { font-size: 1.08rem; color: #ddd; max-width: 900px; }
.post-body img { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); margin: 20px 0; }
.post-body img.broken-img { display: none; }
.post-body pre {
  background: #050505; border: 1px solid var(--red-dim); border-radius: 6px; padding: 18px;
  overflow-x: auto; font-family: var(--mono); font-size: 0.92rem; color: #ff8080; margin: 20px 0;
}
.post-body code { font-family: var(--mono); background: #050505; padding: 2px 6px; border-radius: 4px; color: #ff8080; font-size: 0.92em; }
.post-body pre code { background: none; padding: 0; color: inherit; }
.post-body blockquote { border-left: 3px solid var(--red); margin: 20px 0; padding: 4px 20px; color: var(--text-dim); font-style: italic; }
.post-body h1, .post-body h2, .post-body h3 { color: var(--text); margin-top: 34px; }
.post-body a { border-bottom: 1px solid var(--red-dim); }
.post-body ul, .post-body ol { padding-left: 26px; }
.post-body p { margin: 0 0 1em 0; }
.post-body p:last-child { margin-bottom: 0; }

.image-note {
  border: 1px dashed var(--red-dim);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 20px 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  background: rgba(255,44,44,0.04);
}

.back-link { display: inline-block; margin-bottom: 30px; font-family: var(--mono); font-size: 0.9rem; color: var(--text-dim); }
.back-link:hover { color: var(--red); }

/* ---------- About / portfolio page ---------- */
.about-wrap { max-width: 900px; }
.about-header { display: flex; align-items: center; gap: 26px; margin-bottom: 40px; }
.avatar-circle {
  flex-shrink: 0; width: 120px; height: 120px; border-radius: 50%;
  border: 2px solid var(--red); box-shadow: 0 0 24px var(--red-glow);
  background: var(--bg-panel); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder-icon { width: 56%; height: 56%; fill: var(--red-dim); }
.about-heading .page-title { margin: 0 0 6px; }
.about-body { font-size: 1.05rem; color: #ddd; max-width: 760px; }
.about-body p { margin-bottom: 18px; }
.social-row { display: flex; gap: 18px; margin-top: 50px; padding-top: 30px; border-top: 1px solid var(--border); }
.social-icon {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-dim);
  transition: color .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.social-icon svg { width: 20px; height: 20px; }
.social-icon:hover { color: var(--red); border-color: var(--red); transform: translateY(-2px); box-shadow: 0 4px 16px var(--red-glow); text-decoration: none; }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 30px 0 50px; color: #555; font-family: var(--mono); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* ---------- 404 ---------- */
.page-404 {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--mono); color: var(--text-dim); gap: 12px;
}
.page-404 h1 { font-size: 5rem; color: var(--red); margin: 0; text-shadow: 0 0 30px var(--red-glow); }

@media (max-width: 700px) {
  .nav-links { display: none; }
  .post-full h1 { font-size: 1.7rem; }
  .search-panel { width: 260px; right: -30px; }
}
@media (max-width: 600px) {
  .about-header { flex-direction: column; align-items: flex-start; }
}
