/* =============================================
   João Mendes Blog — Custom Styles
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-text: #1e293b;
  --color-text-light: #64748b;
  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-border: #e2e8f0;
  --color-accent: #3b82f6;
  --color-code-bg: #1e293b;
  --color-code-text: #e2e8f0;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  --max-width: 800px;
  --spacing: 2rem;
}

/* Dark mode via data attribute (set by JS toggle) */
[data-theme="dark"] {
  --color-primary: #60a5fa;
  --color-primary-dark: #93bbfc;
  --color-text: #e2e8f0;
  --color-text-light: #94a3b8;
  --color-bg: #0f172a;
  --color-bg-alt: #1e293b;
  --color-border: #334155;
  --color-accent: #60a5fa;
  --color-code-bg: #1a1a2e;
  --color-code-text: #e2e8f0;
}

/* Auto dark mode for users who haven't toggled manually */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #60a5fa;
    --color-primary-dark: #93bbfc;
    --color-text: #e2e8f0;
    --color-text-light: #94a3b8;
    --color-bg: #0f172a;
    --color-bg-alt: #1e293b;
    --color-border: #334155;
    --color-accent: #60a5fa;
    --color-code-bg: #1a1a2e;
    --color-code-text: #e2e8f0;
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- Wrapper --- */
.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
}

/* --- Header --- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem 0;
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: var(--color-primary);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--color-text-light);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s;
}

.site-nav a:hover {
  color: var(--color-primary);
}

/* --- Main Content --- */
.page-content {
  padding: 3rem 0;
  min-height: calc(100vh - 200px);
}

/* --- Home / Post List --- */
.page-heading {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--color-text);
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.post-summary {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border);
}

.post-summary:last-child {
  border-bottom: none;
}

.post-summary h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.post-summary h2 a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s;
}

.post-summary h2 a:hover {
  color: var(--color-primary);
}

.post-meta {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: 0.75rem;
}

.post-category {
  background: var(--color-bg-alt);
  padding: 0.15em 0.5em;
  border-radius: 4px;
  font-size: 0.8rem;
}

.post-excerpt {
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.read-more {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}

.read-more:hover {
  text-decoration: underline;
}

/* --- Single Post --- */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.post-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul, .post-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  border-left: 4px solid var(--color-primary);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--color-bg-alt);
  color: var(--color-text-light);
  font-style: italic;
  border-radius: 0 8px 8px 0;
}

.post-content code {
  font-family: var(--font-mono);
  background: var(--color-bg-alt);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.45;
  font-size: 0.78rem;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.post-content a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.post-content a:hover {
  color: var(--color-primary-dark);
}

/* --- Post Tags --- */
.post-tags {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  background: var(--color-bg-alt);
  color: var(--color-primary);
  padding: 0.25em 0.75em;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* --- Post Navigation --- */
.post-navigation {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
}

.post-navigation a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.post-navigation a:hover {
  text-decoration: underline;
}

/* --- Page --- */
.page-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.page-content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.page-content h2 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.page-content p {
  margin-bottom: 1rem;
}

.page-content ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

/* --- Pagination --- */
.pagination {
  margin-top: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.pagination a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.pagination a:hover {
  text-decoration: underline;
}

.page-number {
  color: var(--color-text-light);
  font-size: 0.9rem;
}

/* --- 404 Error Page --- */
.error-page {
  text-align: center;
  padding: 4rem 0;
}

.error-page h1 {
  font-size: 6rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.error-page h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.error-page p {
  color: var(--color-text-light);
  margin-bottom: 2rem;
}

.btn {
  display: inline-block;
  padding: 0.75em 1.5em;
  background: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--color-primary-dark);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  text-align: center;
}

.site-footer p {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

.site-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  :root {
    --spacing: 1.25rem;
  }

  .site-header .wrapper {
    flex-direction: column;
    gap: 0.75rem;
  }

  .site-nav {
    gap: 1rem;
  }

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

  .page-heading {
    font-size: 1.4rem;
  }

  .post-summary h2 {
    font-size: 1.25rem;
  }

  .error-page h1 {
    font-size: 4rem;
  }

  .hero-content {
    flex-direction: column;
    text-align: center;
  }

  .hero-avatar {
    width: 100px;
    height: 100px;
  }

  .hero-links {
    justify-content: center;
  }

  .about-avatar {
    width: 100px;
    height: 100px;
  }
}

/* --- Hero Section --- */
.hero {
  padding: 2.5rem 0 3rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 3rem;
}

.hero-content {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.hero-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-border);
  flex-shrink: 0;
}

.hero-text {
  flex: 1;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero-tagline {
  font-size: 1.05rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.hero-description {
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: 1rem;
  max-width: 560px;
}

.hero-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero-link {
  display: inline-block;
  padding: 0.4em 1em;
  background: var(--color-bg-alt);
  color: var(--color-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  transition: all 0.2s;
}

.hero-link:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* --- Latest Posts Section --- */
.section-heading {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--color-text);
}

.latest-posts .post-summary h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.latest-posts .post-summary h3 a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s;
}

.latest-posts .post-summary h3 a:hover {
  color: var(--color-primary);
}

/* --- About Page --- */
.about-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.about-avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-border);
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0.4em 0.6em;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--color-text);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--color-bg-alt);
  border-color: var(--color-primary);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Show moon in light mode (click to go dark) */
.theme-toggle .icon-moon {
  display: inline;
}
.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}
[data-theme="dark"] .theme-toggle .icon-sun {
  display: inline;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: inline;
  }
}

/* Smooth theme transition */
body,
.site-header,
.site-footer,
.post-content pre,
.post-content code,
.post-content blockquote,
.hero-link,
.tag,
.post-category,
.btn {
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* Dark mode image adjustments */
[data-theme="dark"] .post-content img {
  opacity: 0.9;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .post-content img {
    opacity: 0.9;
  }
}

/* --- Giscus Comments --- */
.post-comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.post-comments h2 {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  color: var(--color-text);
}
