*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

main { flex: 1; }

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  width: 100%;
}

/* ── Nav ─────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  background: rgba(249, 249, 249, 0.93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e5e5e5;
  z-index: 100;
}

nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

nav .site-title {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  white-space: nowrap;
}

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

nav ul li::before { content: none; }

nav ul a {
  display: block;
  padding: 0.3rem 0.65rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.9rem;
  color: #555;
  transition: background 0.15s, color 0.15s;
}

nav ul a:hover  { background: #f0f0f0; color: #111; }
nav ul a.active { background: #111; color: #fff !important; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0.3rem 0.65rem;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }

  nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: #f9f9f9;
    border-bottom: 1px solid #e5e5e5;
    padding: 0.75rem 2rem;
    gap: 0.2rem;
  }

  nav.open ul { display: flex; }
  header { position: relative; }
}

/* ── Hero ────────────────────────────────────────── */

.hero {
  position: relative;
  background: #f8fafc;
  padding: 9rem 2rem 8rem;
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid #e2e8f0;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.6;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 3rem;
}

.hero h1 {
  color: #0f172a;
  font-size: clamp(2.2rem, 6vw, 4rem);
  margin-bottom: 1rem;
  line-height: 1.15;
}

.hero .tagline {
  color: #64748b;
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
}

.btn {
  display: inline-block;
  padding: 0.8rem 2.2rem;
  background: #0f172a;
  color: #fff !important;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:hover {
  background: #1e293b;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2);
}

/* Corner brackets */

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  animation: cornerPulse 4s ease-in-out infinite;
}

.corner.tl { top: 0; left: 0; border-top: 2px solid #94a3b8; border-left: 2px solid #94a3b8; }

@keyframes cornerPulse {
  0%, 100% { width: 24px; height: 24px; opacity: 0.4; }
  50%       { width: 40px; height: 40px; opacity: 0.9; }
}

/* ── Tags ────────────────────────────────────────── */

.tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  background: #f0f0f0;
  color: #555;
  border-radius: 4px;
  text-decoration: none;
  margin-left: 0.25rem;
  transition: background 0.15s;
}

.tag:hover { background: #e0e0e0; color: #222; }

/* ── Posts ───────────────────────────────────────── */

article + article {
  border-top: 1px solid #eee;
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

/* ── Mermaid ─────────────────────────────────────── */

.mermaid-wrapper {
  margin: 2rem 0;
  text-align: center;
}

.mermaid-wrapper .mermaid {
  display: inline-block;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 100%;
  overflow-x: auto;
}

/* ── Download ────────────────────────────────────── */

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  background: #f1f5f9;
  color: #0f172a !important;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  margin: 1rem 0;
}

.download-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.download-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* ── Code ────────────────────────────────────────── */

/* inline code */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85em;
  background: #1e1e1e;
  color: #e0e0e0;
  padding: 0.15em 0.45em;
  border-radius: 4px;
}

/* block code — Chroma wraps in div.highlight > pre */
.highlight {
  position: relative;
  margin: 1.75rem 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #333;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.highlight pre {
  margin: 0;
  padding: 1.5rem 1.75rem;
  overflow-x: auto;
  background: #272822 !important;
  font-size: 0.875rem;
  line-height: 1.65;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* language label top-right */
.highlight code[data-lang]::after {
  content: attr(data-lang);
  position: absolute;
  top: 0.55rem;
  right: 1rem;
  font-size: 0.68rem;
  font-family: monospace;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  pointer-events: none;
}

/* strip Sakura's pre styles inside highlight */
.highlight pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

/* ── Search ──────────────────────────────────────── */

.search-wrapper {
  position: relative;
  margin-bottom: 2rem;
}

.search-wrapper::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center;
  pointer-events: none;
}

#search-input {
  width: 100%;
  font-size: 1rem;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.07);
}

.search-card {
  display: block;
  padding: 1.25rem 1.5rem;
  border: 1.5px solid #e5e5e5;
  border-radius: 10px;
  margin-bottom: 0.85rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.search-card:hover {
  border-color: #bbb;
  box-shadow: 0 4px 14px rgba(0,0,0,0.07);
  transform: translateY(-1px);
}

.search-card h3 { margin: 0.4rem 0 0.5rem; font-size: 1.05rem; }
.search-card p  { margin: 0; font-size: 0.9rem; color: #666; line-height: 1.5; }
.search-card-meta { margin-bottom: 0.25rem; }
.search-card-meta .tag { margin-left: 0; margin-right: 0.25rem; }
.search-empty { color: #888; font-style: italic; }

/* ── Footer ──────────────────────────────────────── */

footer {
  background: #f8f8f8;
  border-top: 1px solid #e5e5e5;
}

footer .container {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  text-align: center;
  font-size: 0.88rem;
  color: #999;
}
