:root {
  --bg: #0B0D10;
  --surface: #161A20;
  --surface-2: #12151A;
  --text: #E9EBEE;
  --text-soft: #9BA3AE;
  --text-faint: #5B6470;
  --accent: #6EE7C7;
  --accent-2: #F2A65A;
  --border: #262B33;
  --code-bg: #0F1216;
  --shadow: 0 20px 45px -28px rgba(0, 0, 0, 0.65);
  --max-w: 740px;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --display: 'Space Grotesk', var(--sans);
  --mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
}

[data-theme="light"] {
  --bg: #F6F3EA;
  --surface: #FFFFFF;
  --surface-2: #FBF9F2;
  --text: #1B1812;
  --text-soft: #5C5546;
  --text-faint: #8B8371;
  --accent: #1C8C73;
  --accent-2: #B5711F;
  --border: #E2DDCC;
  --code-bg: #EFECE1;
  --shadow: 0 20px 45px -30px rgba(27, 24, 18, 0.28);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 4.5rem 1.5rem 4.75rem;
  border-bottom: 1px solid var(--border);
}

.hero--compact { padding: 2rem 1.5rem; }

.hero-dots {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 70% 90% at 15% 0%, black 30%, transparent 80%);
}

.hero-glow {
  position: absolute;
  top: -140px;
  left: -80px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.16;
  filter: blur(10px);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: var(--max-w);
  margin: 0 auto;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-family: var(--mono);
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.hero--compact .site-title { font-size: 1.15rem; }

.cursor {
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.site-subtitle {
  margin: 1.1rem 0 0;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.92rem;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Featured post ---------- */
.featured {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.2rem 2rem;
  margin: 2.5rem 0 3rem;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, border-color 0.22s ease;
}
.featured::before {
  content: "";
  position: absolute;
  left: 0; top: 1.6rem; bottom: 1.6rem;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--accent), var(--accent-2));
}
.featured:hover { transform: translateY(-3px); border-color: var(--accent); }

.featured-date {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.featured-title {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.featured-excerpt { color: var(--text-soft); margin: 0; font-size: 1rem; }
.featured-tags { margin-top: 1.1rem; }

/* ---------- Post list ---------- */
.post-list { display: flex; flex-direction: column; }

.post-entry {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 1.7rem 1rem;
  margin: 0 -1rem;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.5s ease forwards;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.post-entry:hover { background: var(--surface-2); border-left-color: var(--accent); }

@keyframes rise { to { opacity: 1; transform: translateY(0); } }

.post-date {
  font-family: var(--mono);
  color: var(--text-faint);
  font-size: 0.82rem;
  padding-top: 0.35rem;
  white-space: nowrap;
}

.post-title {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-size: 1.32rem;
  font-weight: 600;
  line-height: 1.32;
}

.post-title a {
  color: var(--text);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.25s ease;
}
.post-title a:hover { background-size: 100% 1px; }

.post-excerpt { margin: 0; color: var(--text-soft); font-size: 0.97rem; }

.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

.tag-chip {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
}

.empty-state, .error-state { padding: 3rem 0; color: var(--text-soft); }
.loading { color: var(--text-soft); padding: 2rem 0; }

/* ---------- Single post ---------- */
.back-link {
  display: inline-block;
  margin: 2rem 0;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

#post-article h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.6rem;
  letter-spacing: -0.01em;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.85rem;
  margin: 0 0 2.6rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.post-meta .dot::before { content: "·"; margin: 0 0.15rem; color: var(--text-faint); }

.post-body { font-size: 1.08rem; }
.post-body p { margin: 0 0 1.4rem; }

.post-body h2 { font-family: var(--display); font-size: 1.4rem; font-weight: 600; margin: 2.3rem 0 1rem; }
.post-body h3 { font-family: var(--display); font-size: 1.15rem; font-weight: 600; margin: 1.9rem 0 0.8rem; }
.post-body img { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.post-body a { color: var(--accent); }
.post-body blockquote {
  margin: 1.8rem 0;
  padding-left: 1.3rem;
  border-left: 2px solid var(--accent-2);
  color: var(--text-soft);
  font-style: italic;
}

.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2.2rem 1.1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.88rem;
  position: relative;
  margin: 1.8rem 0;
}
.post-body pre::before {
  content: "";
  position: absolute;
  top: 0.85rem; left: 1.1rem;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 16px 0 0 var(--text-faint), 32px 0 0 var(--text-faint);
  opacity: 0.55;
}
.post-body pre code { background: none; padding: 0; font-size: inherit; }
.post-body code {
  font-family: var(--mono);
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

.post-tags { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--border); }

/* ---------- Reading progress ---------- */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 50;
  transition: width 0.1s linear;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1.5rem 3.5rem;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.to-top { color: var(--accent); text-decoration: none; }
.to-top:hover { text-decoration: underline; }

a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .post-entry { grid-template-columns: 1fr; gap: 0.4rem; }
  .featured { padding: 1.7rem 1.4rem; }
  .hero { padding: 3.25rem 1.25rem 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, .post-entry, .cursor { animation: none !important; transition: none !important; opacity: 1 !important; transform: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Busca ---------- */
.search-box {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-faint);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem 0.7rem 2.5rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-faint); }

#search-input::-webkit-search-cancel-button { cursor: pointer; }

.no-results {
  padding: 2.5rem 0;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.9rem;
}
