/* Modo claro y oscuro */
:root,
:root[data-theme="light"],
body,
body[data-theme="light"] {
  --bg-color: #f8f5f1; /* Color papel crema/pergamino suave */
  --text-color: #222;
  --link-color: #1d60a3;
  --link-color-rgb: 29, 96, 163;
  --heading-color: #111;
  --border-color: #e0dcd3; /* Border color more paper-like */
  --accent-color: #1d60a3; /* Mismo que link-color para mantener consistencia */
  --accent-color-rgb: 29, 96, 163;
  --tag-color: #666;
  --tag-color-rgb: 102, 102, 102;
  --border-radius: 6px;
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  --blockquote-bg: rgba(0, 0, 0, 0.03);
  --blockquote-border: var(--accent-color);
}

:root[data-theme="dark"],
body[data-theme="dark"] {
  --bg-color: #222;
  --text-color: #eee;
  --link-color: #5ca8ff;
  --link-color-rgb: 92, 168, 255;
  --heading-color: #fff;
  --border-color: #444;
  --accent-color: #5ca8ff; /* Mismo que link-color para mantener consistencia */
  --accent-color-rgb: 92, 168, 255;
  --tag-color: #aaa;
  --tag-color-rgb: 170, 170, 170;
  --border-radius: 6px;
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  --blockquote-bg: rgba(255, 255, 255, 0.05);
  --blockquote-border: var(--accent-color);
}

body {
  background-color: var(--bg-color) !important;
  color: var(--text-color) !important;
  transition: background-color 0.3s ease, color 0.3s ease;
  text-align: justify;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1em;
  hyphens: auto;
  word-break: break-word;
}

h1 {
  font-family: 'Merriweather', serif;
  font-weight: 200;
  margin-top: 0.5em;
  font-size: 2.2em;
  line-height: 1.2em;
  color: var(--heading-color);
  text-align: left;
}

.title h2 {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  font-size: 1.2em;
  font-weight: 500;
}

/* Estilos de título del blog */
h2 {
  font-family: 'Merriweather', serif;
  font-weight: 700;
  color: var(--heading-color);
  text-align: left;
}

/* Estilo mejorado para blockquotes */
blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 4px solid var(--blockquote-border);
  background-color: var(--blockquote-bg);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-style: italic;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  color: var(--text-color);
  font-size: 1.05em;
  line-height: 1.6;
  overflow: hidden;
}

blockquote::before {
  content: '"';
  position: absolute;
  top: -0.25em;
  left: 0.25em;
  font-family: 'Georgia', serif;
  font-size: 3em;
  opacity: 0.1;
  color: var(--blockquote-border);
}

blockquote p:first-of-type {
  margin-top: 0;
}

blockquote p:last-of-type {
  margin-bottom: 0;
}

blockquote cite {
  display: block;
  text-align: right;
  margin-top: 0.5em;
  font-size: 0.85em;
  font-style: normal;
  opacity: 0.8;
}

blockquote strong, blockquote b {
  color: var(--accent-color);
  font-weight: 500;
  font-family: "Merriweather", serif;
}

/* Estilos para posts recientes con badge */
.recent-posts-list {
  list-style-type: none;
  padding: 0;
  margin-top: 0.5em;
}

.recent-post-item {
  margin-bottom: 0.8em;
  display: flex;
  align-items: baseline;
  transition: transform 0.2s ease;
  padding: 0.5em 0.8em;
  border-radius: var(--border-radius);
  border-left: 3px solid transparent;
}

.recent-post-item:hover {
  background-color: rgba(var(--accent-color-rgb), 0.05);
  transform: translateX(3px);
  border-left-color: var(--accent-color);
}

.date-badge {
  display: inline-block;
  background-color: rgba(var(--tag-color-rgb), 0.03);
  color: var(--tag-color);
  font-size: 0.65em;
  padding: 0.08em 0.28em;
  border-radius: 4px;
  margin-right: 0.5em;
  white-space: nowrap;
  transition: all 0.3s ease;
  border: 1px solid rgba(var(--tag-color-rgb), 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.date-num {
  font-weight: 500;
}

.date-sep {
  color: rgba(var(--tag-color-rgb), 0.5);
  font-weight: 300;
  margin: 0 -0.05em;
}

.date-badge:hover {
  background-color: rgba(var(--link-color-rgb), 0.08);
  color: var(--link-color);
  border-color: rgba(var(--link-color-rgb), 0.15);
  transform: translateY(-1px);
}

.date-badge:hover .date-sep {
  color: rgba(var(--link-color-rgb), 0.5);
}

.post-link {
  flex: 1;
  line-height: 1.4;
  transition: color 0.2s ease;
}

@media (max-width: 480px) {
  .recent-post-item {
    flex-wrap: wrap;
  }
  
  .date-badge {
    margin-bottom: 0.3em;
  }
  
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  nav {
    margin-top: 0.5em;
    width: 100%;
    justify-content: space-between;
  }
  
  .theme-toggle {
    position: absolute;
    top: 15px;
    right: 0;
  }
}

/* Enlaces */
a {
  color: var(--link-color);
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}

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

a:not(.title a, .contact-link, nav a, .post-link, .theme-toggle)::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--link-color), rgba(var(--link-color-rgb), 0.6));
  opacity: 0;
  transform-origin: bottom right;
  transform: scaleX(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
  border-radius: 1px;
}

a:not(.title a, .contact-link, nav a, .post-link, .theme-toggle):hover::after {
  transform-origin: bottom left;
  transform: scaleX(1);
  opacity: 1;
}

/* Estilos para la fecha simple */
.date-simple {
  display: inline-block;
  color: var(--tag-color);
  font-size: 0.7em;
  line-height: 1.2em;
  margin-right: 0.8em;
  white-space: nowrap;
  font-family: monospace;
  cursor: help;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  border: 1px solid rgba(var(--tag-color-rgb), 0.1);
  padding: 2px 4px;
  border-radius: 6px;
  background-color: rgba(var(--tag-color-rgb), 0.03);
  vertical-align: middle;
  position: relative;
  top: -2px;
}

.date-simple:hover {
  opacity: 1;
  color: var(--link-color);
}

.date-separator {
  opacity: 0.4;
  color: var(--tag-color);
}

.date-simple:hover .date-separator {
  opacity: 0.5;
  color: var(--link-color);
}

/* Estilos específicos para las listas de blog */
ul.blog-posts li {
  display: flex;
  align-items: baseline;
  flex-wrap: nowrap;
}

ul.blog-posts li .date-simple {
  flex: 0 0 auto;
  margin-top: 0;
  margin-bottom: 0;
}

ul.blog-posts li span i {
  font-style: normal;
}

a:hover {
  text-decoration: none;
  cursor: pointer;
}

/* Etiquetas */
.tag-cloud {
  margin-top: 2em;
}

.tag-cloud a, .post-tags a, a[href^="/tags/"] {
  display: inline-block;
  margin-right: 0.5em;
  margin-bottom: 0.5em;
  padding: 0.2em 0.6em;
  font-size: 0.8em;
  color: var(--tag-color);
  background-color: var(--border-color);
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.tag-cloud a:hover, .post-tags a:hover, a[href^="/tags/"]:hover {
  background-color: var(--link-color);
  color: var(--bg-color);
  text-decoration: none;
}

.post-tags {
  margin-top: 2em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
}

/* Navegación entre posts */
.post-navigation {
  margin-top: 3em;
  display: flex;
  justify-content: space-between;
  padding-top: 0.5em;
  gap: 1em;
}

.prev-post, .next-post {
  max-width: 48%;
  transition: all 0.3s ease;
  cursor: pointer;
}

.prev-post {
  text-align: left;
}

.next-post {
  text-align: right;
  margin-left: auto;
}

.post-navigation a {
  display: block;
  padding: 0.6em;
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  background-color: rgba(var(--tag-color-rgb), 0.03);
  border: 1px solid rgba(var(--border-color), 0.2);
  cursor: pointer;
}

.prev-post a {
  padding-left: 1em;
}

.next-post a {
  padding-right: 1em;
}

.prev-post:hover {
  transform: translateX(3px);
  border-left-color: var(--accent-color);
}

.next-post:hover {
  transform: translateX(-3px);
  border-right-color: var(--accent-color);
}

.post-navigation a:hover {
  background-color: rgba(var(--accent-color-rgb), 0.05);
  border-color: rgba(var(--accent-color-rgb), 0.1);
}

.nav-label {
  display: block;
  font-size: 0.65em;
  font-weight: 500;
  color: var(--tag-color);
  margin-bottom: 0.3em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.8;
  transition: all 0.3s ease;
}

.nav-title {
  display: block;
  font-size: 0.75em;
  font-weight: 500;
  font-family: 'Merriweather', serif;
  color: var(--link-color);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
}

.post-navigation a:hover .nav-label {
  color: var(--accent-color);
  opacity: 1;
}

.post-navigation a:hover .nav-title {
  color: var(--accent-color);
}

@media (max-width: 600px) {
  .post-navigation {
    flex-direction: column;
    gap: 1em;
  }
  
  .prev-post, .next-post {
    max-width: 100%;
    width: 100%;
  }
  
  .next-post {
    text-align: left;
    border-right: none;
    border-left: 3px solid transparent;
  }
  
  .next-post:hover {
    transform: translateX(3px);
    border-left-color: var(--accent-color);
  }
}

/* Estilo para fecha del post */
.post-date {
  color: var(--tag-color);
  margin-top: -0.5em;
  margin-bottom: 0.8em;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

/* Enlace permanente y botón de compartir */
.permalink, .share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tag-color);
  opacity: 0.6;
  transition: opacity 0.2s ease;
  margin-right: 8px;
}

.permalink:hover, .share-button:hover {
  opacity: 1;
  color: var(--link-color);
  text-decoration: none;
  cursor: pointer;
}

.permalink-icon, .share-icon {
  width: 16px;
  height: 16px;
  transition: filter 0.2s ease;
}

/* Aplicar filtros para el icono tanto en modo claro como oscuro */
:root[data-theme="light"] .permalink-icon, :root[data-theme="light"] .share-icon,
body[data-theme="light"] .permalink-icon, body[data-theme="light"] .share-icon {
  filter: brightness(0) invert(0.3) opacity(0.6);
}

:root[data-theme="dark"] .permalink-icon, :root[data-theme="dark"] .share-icon,
body[data-theme="dark"] .permalink-icon, body[data-theme="dark"] .share-icon {
  filter: brightness(0) invert(0.9) opacity(0.6);
}

:root[data-theme="light"] .permalink:hover .permalink-icon, :root[data-theme="light"] .share-button:hover .share-icon,
body[data-theme="light"] .permalink:hover .permalink-icon, body[data-theme="light"] .share-button:hover .share-icon {
  filter: brightness(0) invert(0.3) opacity(1);
}

:root[data-theme="dark"] .permalink:hover .permalink-icon, :root[data-theme="dark"] .share-button:hover .share-icon,
body[data-theme="dark"] .permalink:hover .permalink-icon, body[data-theme="dark"] .share-button:hover .share-icon {
  filter: brightness(0) invert(0.9) opacity(1);
}

/* Encabezados */
h1, h2, h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  color: var(--heading-color);
  font-family: 'Merriweather', serif;
}

/* Toast notification */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-color);
  color: var(--text-color);
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin: 0 auto;
  text-align: center;
  pointer-events: none;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  border: 1px solid var(--border-color);
  max-width: 80%;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Contenido principal */
content {
  line-height: 1.5;
  text-align: justify;
  margin-top: 0.5em;
  text-align: justify;
  hyphens: auto;
  word-break: break-word;
}

/* Justificar párrafos */
p {
  text-align: justify;
  margin-bottom: 1.2em;
  hyphens: auto;
  word-break: break-word;
}

/* Encabezado */
header {
  padding: 10px 0 0;
  margin-bottom: 0.5em;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.title {
  flex: 1;
}

.title h2 {
  font-weight: 700;
  color: var(--heading-color);
  letter-spacing: -0.02em;
  transition: transform 0.3s ease;
  margin-bottom: 0.2rem;
}

.title:hover h2 {
  transform: translateX(3px);
}

.subtitle {
  margin-top: -5px;
  font-size: 0.8rem;
  opacity: 0.8;
  font-weight: normal;
  margin-bottom: 0.8rem;
  color: var(--text-color);
  text-align: left;
}

/* Navegación */
nav {
  display: flex;
  align-items: center;
}

nav a {
  margin-right: 1em;
  font-family: 'Merriweather', serif;
  position: relative;
  padding: 5px 0;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: width 0.3s ease;
}

nav a:hover::after {
  width: 100%;
}

/* Botón de modo oscuro */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2em 0.5em;
  color: var(--text-color);
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  transform: rotate(15deg);
}

/* Sección de contacto */
.contact-section {
  margin-top: 1em;
  padding: 0.5em 0;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5em;
  justify-content: center;
}

.contact-link {
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
  text-decoration: none;
  background: none;
  padding: 0.5em;
  border-radius: 50%;
  position: relative;
}

.contact-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--accent-color);
  opacity: 0;
  transform: scale(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: -1;
}

/* Estilos para modo claro */
:root[data-theme="light"] .contact-link .contact-icon,
body[data-theme="light"] .contact-link .contact-icon {
  filter: brightness(0) invert(0.5);
  opacity: 0.6;
}

/* Estilos para modo oscuro */
:root[data-theme="dark"] .contact-link .contact-icon,
body[data-theme="dark"] .contact-link .contact-icon {
  filter: brightness(0) invert(0.7);
  opacity: 0.6;
}

.contact-link:hover {
  transform: translateY(-3px) scale(1.15);
  text-decoration: none;
}

.contact-link:hover::before {
  opacity: 0.1;
  transform: scale(1);
}

:root[data-theme="light"] .contact-link:hover .contact-icon,
body[data-theme="light"] .contact-link:hover .contact-icon {
  filter: brightness(0) invert(0.3);
  opacity: 1;
}

:root[data-theme="dark"] .contact-link:hover .contact-icon,
body[data-theme="dark"] .contact-link:hover .contact-icon {
  filter: brightness(0) invert(0.9);
  opacity: 1;
}

.contact-link .contact-icon {
  width: 16px;
  height: 16px;
  transition: all 0.3s ease;
}

/* Estilos para imágenes en posts */
.post-image-container {
  text-align: center;
  margin: 30px 0;
}

.post-image {
  border-radius: 12px;
  border: 2px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 90%;
  padding: 4px;
  background-color: var(--bg-color);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-image:hover {
  transform: scale(1.01);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

/* Etiqueta de imagen (caption) */
.image-caption {
  font-size: 0.85em;
  color: var(--tag-color);
  margin-top: 8px;
  font-style: italic;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

/* Mejoras para bloques de código de varias líneas */
pre code, .highlight, .code {
  display: block;
  padding: 1rem;
  margin: 1rem 0;
  background-color: #1e1e1e !important; /* Fondo oscuro tipo VSCode */
  color: #d4d4d4 !important; /* Color claro para el texto */
  border-radius: 8px !important;
  overflow-x: auto;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 0.9em;
  line-height: 1.5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* Estilos para diferentes modos */
:root[data-theme="light"] pre code, 
:root[data-theme="light"] .highlight, 
:root[data-theme="light"] .code,
body[data-theme="light"] pre code,
body[data-theme="light"] .highlight,
body[data-theme="light"] .code {
  background-color: #1e1e1e !important; /* Mantener fondo oscuro incluso en modo claro */
  color: #d4d4d4 !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] pre code,
:root[data-theme="dark"] .highlight,
:root[data-theme="dark"] .code,
body[data-theme="dark"] pre code,
body[data-theme="dark"] .highlight,
body[data-theme="dark"] .code {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Para código en línea, mantenemos los colores */
:root[data-theme="light"] code:not(pre code),
body[data-theme="light"] code:not(pre code) {
  background-color: var(--code-background-color);
  color: var(--code-color);
}

:root[data-theme="dark"] code:not(pre code),
body[data-theme="dark"] code:not(pre code) {
  background-color: var(--code-background-color);
  color: var(--code-color);
}