/* Variables – light (default) */
:root {
  --bg: #fbfbfb;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --link: #0066cc;
  --link-visited: #551a8b;
  --border: rgba(0, 0, 0, 0.08);
  --tag-bg: #e8e8ed;
  --tag-text: #1d1d1f;
  /* Destaque em posts: código, arquivos, termos */
  --code-fg: #0d5a77;
  --code-bg: #e3f0f4;
  --code-border: rgba(13, 90, 119, 0.25);
  --file-fg: #994a00;
  --file-bg: #fef3e6;
  --term-fg: #1a5a1a;
  --term-bg: #e6f0e6;
  /* TL;DR e títulos de tópico em posts */
  --tldr-bg: #e3f0f4;
  --tldr-border: #0d5a77;
  --tldr-fg: #0d5a77;
  --topic-fg: #0d5a77;
  /* Rouge syntax highlight (blocos ```java etc.) */
  --hl-keyword: #0550ae;
  --hl-class: #953800;
  --hl-string: #0a3069;
  --hl-comment: #6e7781;
  --hl-annotation: #8250df;
  --hl-number: #0550ae;
  --hl-method: #953800;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --text: #f5f5f7;
  --text-muted: #a1a1a6;
  --link: #2997ff;
  --link-visited: #b388ff;
  --border: rgba(255, 255, 255, 0.12);
  --tag-bg: #2d2d2d;
  --tag-text: #f5f5f7;
  --code-fg: #7ec8e3;
  --code-bg: #1e2d33;
  --code-border: rgba(126, 200, 227, 0.3);
  --file-fg: #e8a84a;
  --file-bg: #2d2518;
  --term-fg: #7acc7a;
  --term-bg: #1e2d1e;
  --tldr-bg: #1e2d33;
  --tldr-border: #7ec8e3;
  --tldr-fg: #7ec8e3;
  --topic-fg: #7ec8e3;
  --hl-keyword: #79c0ff;
  --hl-class: #ffa657;
  --hl-string: #a5d6ff;
  --hl-comment: #8b949e;
  --hl-annotation: #d2a8ff;
  --hl-number: #79c0ff;
  --hl-method: #ffa657;
}

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

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:visited {
  color: var(--link-visited);
}

/* Layout */
.layout-wrapper {
  min-height: 100vh;
}

.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.header-identity {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}

.profile-img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* desabilita menu de long-press no iOS (salvar/visualizar) */
  -webkit-user-drag: none;
}

.header-social {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.header-linkedin,
.header-github,
.header-email {
  flex-shrink: 0;
  display: inline-flex;
}

.header-linkedin:hover,
.header-github:hover,
.header-email:hover {
  text-decoration: none;
}

.header-linkedin svg,
.header-github svg,
.header-email svg {
  width: 24px;
  height: 24px;
  display: block;
}

.site-name {
  display: inline-flex;
  align-items: center;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}

.site-name:hover,
.site-name:visited,
.site-name:focus {
  color: var(--text);
  text-decoration: none;
}

.site-name:focus {
  outline: none;
}

.site-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
  flex-wrap: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 500;
}

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

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1;
  padding: 0.4rem 0.5rem;
}

.nav-link span {
  line-height: 1.2;
}

.nav-link:hover {
  text-decoration: none;
}

.nav-link:hover span {
  text-decoration: underline;
}

.nav-icon {
  flex-shrink: 0;
  opacity: 0.85;
  display: block;
  vertical-align: middle;
}

.nav-link:hover .nav-icon {
  opacity: 1;
}

/* Toggle switches (language & theme) – sliding thumb */
.header-toggles {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  min-height: 32px;
  min-width: 6.5rem;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  -webkit-tap-highlight-color: transparent;
}

.toggle-switch:focus {
  outline: none;
}

.toggle-switch:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--link);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] .toggle-thumb {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Thumb position: right option active */
.lang-toggle.is-right .toggle-thumb,
[data-theme="dark"] .theme-toggle .toggle-thumb {
  left: calc(50% + 1px);
}

.toggle-option {
  position: relative;
  z-index: 1;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 999px;
  color: var(--text-muted);
  line-height: 1.3;
  transition: color 0.2s ease;
  user-select: none;
  text-decoration: none;
}

.toggle-option:visited {
  color: var(--text-muted);
}

a.toggle-option:hover {
  color: var(--text);
  text-decoration: none;
}

.toggle-option.is-active {
  color: var(--bg);
}

a.toggle-option.is-active:hover,
a.toggle-option.is-active:visited {
  color: var(--bg);
  text-decoration: none;
}

/* Theme toggle options: same track size as language toggle */
.theme-toggle .toggle-option {
  min-width: 2.5rem;
  padding: 0.35rem;
}

/* Theme toggle: which icon is “on” (light on thumb) */
[data-theme="light"] .theme-option-light,
:root:not([data-theme]) .theme-option-light {
  color: var(--bg);
}

[data-theme="dark"] .theme-option-dark {
  color: var(--bg);
}

/* Contact icons (About) */
.contact-icons {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 0;
}

.contact-icon {
  display: inline-flex;
  color: var(--text);
  transition: opacity 0.2s;
}

.contact-icon:hover {
  opacity: 0.7;
}

.contact-icon svg {
  width: 28px;
  height: 28px;
}

/* Page (About / index) */
.page {
  padding: 1rem 0;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.about-role {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.about-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.about-links a {
  font-weight: 500;
}

.page-content {
  max-width: 65ch;
}

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

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

.page-content a {
  word-break: break-word;
}

.page-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

/* Blog list */
.blog-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.blog-list li {
  padding: 0.6rem 0;
}

.blog-list li:first-child {
  padding-top: 0.25rem;
}

.blog-list a {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
}

.blog-list a:hover {
  color: var(--link);
}

.blog-meta {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.blog-meta-date {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.blog-meta-icon {
  flex-shrink: 0;
  opacity: 0.85;
  vertical-align: middle;
}

.blog-meta time {
  margin-right: 0.5rem;
}

.post-tags-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 4px;
}

/* Post (single) – largura de leitura + centralizado na área de conteúdo */
.post {
  padding: 1rem 0;
  max-width: 72ch;
  margin-left: auto;
  margin-right: auto;
}

.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  line-height: 1.3;
}

.post-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.post-meta time {
  margin-right: 0.75rem;
}

.post-content {
  width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Imagens responsivas no post */
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Tabelas: limitar largura; para tabelas muito largas use um wrapper com overflow-x: auto no Markdown */
.post-content table {
  max-width: 100%;
}

.post-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.post-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post-content p {
  margin: 0 0 1rem;
}

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

.post-content pre,
.post-content code {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Mono", monospace;
  font-size: 0.9em;
}

.post-content pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--tag-bg);
  border-radius: 8px;
  margin: 1rem 0;
}

/* Inline code: comandos, nomes de arquivos, termos técnicos (backticks no Markdown) */
.post-content code {
  padding: 0.2rem 0.4rem;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 4px;
  border: 1px solid var(--code-border);
  font-weight: 500;
}

.post-content pre code {
  padding: 0;
  background: none;
  color: var(--text);
  border: none;
  font-weight: inherit;
}

/* Rouge syntax highlight (blocos ```java, ```js, etc.) */
.post-content pre code .k,
.post-content pre code .kd { color: var(--hl-keyword); }
.post-content pre code .nc,
.post-content pre code .nf { color: var(--hl-class); }
.post-content pre code .na { color: var(--hl-annotation); }
.post-content pre code .s,
.post-content pre code .s1,
.post-content pre code .s2 { color: var(--hl-string); }
.post-content pre code .c,
.post-content pre code .c1,
.post-content pre code .cm { color: var(--hl-comment); font-style: italic; }
.post-content pre code .mi,
.post-content pre code .mf { color: var(--hl-number); }

/* Opcional: destaque extra para caminhos de arquivo (usar <code class="file-path">…</code>) */
.post-content code.file-path {
  background: var(--file-bg);
  color: var(--file-fg);
  border-color: rgba(153, 74, 0, 0.25);
}

[data-theme="dark"] .post-content code.file-path {
  border-color: rgba(232, 168, 74, 0.35);
}

/* Opcional: termo em destaque (usar <span class="term">…</span>) */
.post-content .term {
  padding: 0.1rem 0.35rem;
  background: var(--term-bg);
  color: var(--term-fg);
  border-radius: 3px;
  font-weight: 500;
}

/* Primeiro parágrafo (TL;DR) com marcador `TL;DR:` – destaque por estrutura */
.post-content > p:first-of-type {
  padding: 0.75rem 1rem;
  background: var(--tldr-bg);
  border-left: 4px solid var(--tldr-border);
  border-radius: 0 6px 6px 0;
}

.post-content blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-content a {
  word-break: break-word;
}

/* Mermaid: diagramas pré-renderizados (jekyll-mermaid-prebuild) */
.post-content img.mermaid-diagram {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Mermaid: container responsivo (lib in-browser) — visível no mobile */
.post-content pre:has(> code.language-mermaid),
.post-content .mermaid {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.post-content .mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Mermaid: loading no lugar do diagrama até a lib carregar */
body.mermaid-loading .post-content pre:has(> code.language-mermaid) {
  position: relative;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.mermaid-loading .post-content pre:has(> code.language-mermaid) > code {
  visibility: hidden;
  position: absolute;
}
body.mermaid-loading .post-content pre:has(> code.language-mermaid)::before {
  content: "";
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: mermaid-spin 0.7s linear infinite;
  flex-shrink: 0;
}
body.mermaid-loading .post-content pre:has(> code.language-mermaid)::after {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  color: var(--fg-muted, var(--fg));
  opacity: 0.8;
}
@keyframes mermaid-spin {
  to { transform: rotate(360deg); }
}

/* Desktop: sidebar */
@media (min-width: 641px) {
  .layout-wrapper {
    display: block;
  }

  .site-header {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    border-bottom: none;
    border-right: 1px solid var(--border);
    background: var(--bg);
    overflow-y: auto;
  }

  .header-inner {
    max-width: none;
    margin: 0;
    padding: 1.5rem 1.25rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem 0;
  }

  .header-identity {
    width: 100%;
    align-items: center;
    text-align: center;
  }

  .profile-img {
    margin-bottom: 0.25rem;
  }

  .header-social {
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
  }

  .header-actions {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.25rem;
  }

  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .header-toggles {
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    width: 100%;
    flex-wrap: wrap;
  }

  .main-content {
    margin-left: 280px;
    max-width: none;
  }
}

/* Mobile: header on top */
@media (max-width: 640px) {
  .main-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: center;
  }

  .header-identity {
    width: 100%;
    align-items: center;
    text-align: center;
  }

  .header-actions {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  .site-nav {
    justify-content: center;
    flex-wrap: wrap;
  }

  .header-toggles {
    justify-content: center;
  }
}
