/* =========================================
   Pedro Mendes — Blog pessoal
   Estilo base, light/dark via variáveis
   ========================================= */

:root {
  --bg: #fdfdfb;
  --bg-elevated: #ffffff;
  --text: #1b1b1b;
  --text-muted: #5c5c5c;
  --accent: #2b6cb0;
  --accent-hover: #1e4e82;
  --border: #e5e2da;
  --code-bg: #f2f0ea;
  --max-width: 760px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --bg-elevated: #1c1f23;
  --text: #e8e6e1;
  --text-muted: #9a9890;
  --accent: #6fa8dc;
  --accent-hover: #8fc0ea;
  --border: #2d2f33;
  --code-bg: #1f2226;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --bg-elevated: #1c1f23;
    --text: #e8e6e1;
    --text-muted: #9a9890;
    --accent: #6fa8dc;
    --accent-hover: #8fc0ea;
    --border: #2d2f33;
    --code-bg: #1f2226;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */

header.site-header {
  border-bottom: 1px solid var(--border);
  padding: 28px 0 20px;
  margin-bottom: 40px;
}

.site-header .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--text);
}

.brand .name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand .tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
}

nav.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

nav.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

nav.site-nav a:hover,
nav.site-nav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

#theme-toggle:hover {
  border-color: var(--accent);
}

/* ---------- Main content ---------- */

main {
  min-height: 60vh;
}

.page-title {
  font-size: 2rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 36px;
  font-size: 1.05rem;
}

/* ---------- Home: largura maior para o grid de cards ---------- */

body.home .wrapper {
  max-width: 1080px;
}

/* ---------- Filtro de categorias ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 36px;
}

.filter-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Post grid (index, estilo "Medium") ---------- */

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.post-card.is-hidden {
  display: none;
}

.post-card a.card-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-cover {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--code-bg);
}

/* Capa gerada automaticamente quando o post não tem imagem própria */
.card-cover-placeholder {
  aspect-ratio: 16 / 9;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-serif);
  background: linear-gradient(135deg, var(--cover-a, #2b6cb0), var(--cover-b, #7c3aed));
}

.card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.card-body h2 {
  margin: 8px 0 8px;
  font-size: 1.2rem;
  line-height: 1.35;
  color: var(--text);
}

.card-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  flex: 1;
}

.card-body .tags {
  margin-top: 14px;
}

.no-results {
  display: none;
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
}

.no-results.visible {
  display: block;
}

/* ---------- Tags ---------- */

.tag {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 3px 10px;
  margin-right: 6px;
  text-decoration: none;
}

/* ---------- Single post ---------- */

article.post {
  margin-bottom: 60px;
}

article.post .post-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

article.post h1 {
  font-size: 2.1rem;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

article.post h2 {
  font-size: 1.5rem;
  margin: 2em 0 0.6em;
}

article.post h3 {
  font-size: 1.2rem;
  margin: 1.8em 0 0.6em;
}

article.post p {
  margin: 0 0 1.2em;
}

article.post a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

article.post a:hover {
  color: var(--accent-hover);
}

article.post img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.5em 0;
}

article.post blockquote {
  margin: 1.5em 0;
  padding: 2px 20px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

article.post code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

article.post pre {
  background: var(--code-bg);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
}

article.post pre code {
  background: none;
  padding: 0;
}

article.post ul,
article.post ol {
  padding-left: 1.4em;
  margin: 0 0 1.2em;
}

hr.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  font-size: 0.95rem;
}

.post-nav a {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- About page ---------- */

.about-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.social-links {
  display: flex;
  gap: 14px;
  margin-top: 20px;
}

.social-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
}

.social-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Footer ---------- */

footer.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 24px 0 50px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

footer.site-footer a {
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .site-header .wrapper {
    flex-wrap: wrap;
  }

  nav.site-nav {
    gap: 12px;
  }

  .page-title {
    font-size: 1.6rem;
  }

  article.post h1 {
    font-size: 1.7rem;
  }
}
