@import url("https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;0,800;0,900;1,400;1,700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap");

@font-face {
  font-family: "PP Editorial New";
  font-weight: 400;
  src: url("/fonts/pp-editorial-new/PPEditorialNew-Regular.woff2")
      format("woff2"),
    url("/fonts/pp-editorial-new/PPEditorialNew-Regular.woff") format("woff");
}

@font-face {
  font-family: "PP Editorial New";
  font-weight: 700;
  src: url("/fonts/pp-editorial-new/PPEditorialNew-Bold.woff2") format("woff2"),
    url("/fonts/pp-editorial-new/PPEditorialNew-Bold.woff") format("woff");
}

/* ============================================
   Keleshev-Inspired Minimalist Design
   + Chirpy-Style TOC (Popup Mobile + Panel Desktop)
   ============================================ */

/* Separadores decorativos con ornamentos tipográficos */
hr {
    border: none;
    color: #000;
    text-align: center;
}

hr:after {
    content: "⁂"; /* Asterismo */
    display: inline-block;
    position: relative;
    font-size: 1.5em;
    padding: 0 0.25em;
    background: white;
    margin: 1em;
}

hr.fleuron:after {
    content: "❦"; /* Fleuron */
    display: inline-block;
    position: relative;
    font-size: 1.5em;
    padding: 0 0.25em;
    background: white;
    margin: 1em;
}

/* Reset y configuración base */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body, h1, h2, h3, h4, p {
    margin: 0;
    padding: 0;
}

body {
    margin: auto;
    padding: 0 25px;
    width: 700px;
    max-width: 100%;
    font-size: 19px;
    /* font-family: Georgia, 'Times New Roman', Times, serif; */
    line-height: 1.5em;
    -webkit-text-size-adjust: 100%;
    text-align: left;
    background-color: white;
    color: #333;
}

/* Header centrado y espacioso */
header {
    margin: 6rem 0;
    padding-top: 0.001rem;
    text-align: center;
}

header h1 {
    font-weight: 100;
    margin-bottom: 0.5em;
}

/* Navegación simple y centrada */
nav {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

nav a {
    color: #045591;
    text-decoration: none;
    border-bottom: 0;
}

nav a:visited {
    color: #921b51;
    border-bottom: 1px solid #921b51;
}

nav a:hover {
    border-bottom: 1px solid black;
}

/* Sistema de enlaces con indicadores visuales */
a {
    color: #045591;
    text-decoration: none;
}

a:visited {
    color: #921b51;
    border-bottom: 1px solid #921b51;
}

a:hover {
    border-bottom: 1px solid black;
}

/* Indicador de enlaces externos */
a[href^="http"]:after {
    content: '⤴';
    font-size: 0.8em;
    margin-left: 0.2em;
}

/* Excepciones para enlaces internos */
nav a:after,
header a:after {
    content: '' !important;
}

/* Tipografía y jerarquía */
h1, h2, h3, h4 {
    font-weight: 100;
    line-height: 1em;
}

h1 {
    text-align: center;
    font-size: 2em;
    margin: 1em 0;
}

h2, h3 {
    font-style: italic;
}

h2 {
    text-align: center;
    margin-top: 2em;
    padding-top: 1em;
    font-size: 1.5em;
}

h3 {
    margin-top: 1.5em;
    font-size: 1.25em;
}

/* Bloques de código con borde izquierdo */
pre {
    border-left: 2.5px solid black;
    padding-left: 1.20em;
    margin-left: 0;
    font-family: Courier, monospace;
    line-height: 150%;
    overflow-x: auto;
}

code {
    font-family: Courier, monospace;
}

pre em {
    color: #000;
    font-weight: 100;
}

/* Citas con borde completo */
blockquote {
    border: 2.5px solid black;
    margin-left: 0;
    margin-right: 0;
    padding: 1.5em;
    font-style: italic;
}

/* Tablas estilo LaTeX */
table {
    border-collapse: collapse;
    border-top: 2px solid;
    border-bottom: 2px solid;
    margin: 2em auto;
    width: 100%;
}

thead {
    border-bottom: 1px solid;
}

thead th {
    font-weight: normal;
    padding: 0.5em;
    text-align: left;
}

tbody td {
    padding: 0.5em;
}

table pre {
    border-left: none;
    padding-left: 0;
}

/* Imágenes centradas y responsivas */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2em auto;
}

/* Figuras con caption */
figure {
    text-align: center;
    display: table;
    width: 100%;
    margin: 2em 0;
    padding: 0;
}

figcaption {
    display: table-caption;
    caption-side: bottom;
    margin-top: 1em;
    font-style: italic;
    font-size: 0.9em;
}

/* Listas */
ol, ul {
    margin: 1em 0;
    padding-left: 2em;
}

li {
    margin: 0.5em 0;
}

/* Párrafos */
p {
    margin: 1em 0;
}

/* Artículos en la página principal */
article {
    margin-bottom: 3em;
    padding-bottom: 2em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

article:last-child {
    border-bottom: none;
}

article h2 {
    margin-top: 0;
    margin-bottom: 0.25em;
    font-size: 1.3em;
}

article h2 a {
    color: #333;
    text-decoration: none;
    border-bottom: 0;
}

article h2 a:visited {
    color: #333;
    border-bottom: 0;
}

article h2 a:hover {
    color: #045591;
    border-bottom: 1px solid #045591;
}

/* Fechas de posts */
.post-date {
    display: block;
    color: #666;
    font-size: 0.85em;
    margin-top: 0.25em;
    margin-bottom: 1em;
    font-style: italic;
}

/* Layout de posts con imagen */
.post-item {
    display: flex;
    gap: 2em;
    align-items: flex-start;
}

.post-content {
    flex: 1;
    min-width: 0;
}

.post-thumbnail {
    flex-shrink: 0;
    width: 150px;
}

.post-thumbnail a {
    display: block;
    border-bottom: 0 !important;
}

.post-thumbnail a:after {
    content: '' !important;
}

.post-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 3px;
    transition: opacity 0.2s ease;
}

.post-thumbnail img:hover {
    opacity: 0.8;
}

/* Estilos para los tags del post */
.post-categories {
  font-size: 0.875rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  font-weight: 500;
  line-height: 1.5;
  font-family: Manrope, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  .post-categories {
    color: #999;
  }
}

/* Footer minimalista */
footer {
    margin-top: 4em;
    padding: 2em 0;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85em;
    color: #666;
}

footer a {
    color: #045591;
}

/* Mejoras de legibilidad */
::selection {
    background: rgba(4, 85, 145, 0.2);
}

::-moz-selection {
    background: rgba(4, 85, 145, 0.2);
}

/* Espaciado para contenido principal */
main {
    margin: 2em 0;
}


/* ============================================
   TOC ESTILO CHIRPY
   Mobile: Popup Modal
   Desktop: Panel Lateral Sticky
   ============================================ */

/* Contenedor principal */
.article-with-sidebar {
    position: relative;
}

/* ============================================
   MOBILE: Botón Flotante + Popup
   ============================================ */

/* Botón flotante que aparece al hacer scroll */
#toc-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3rem;
    margin: 0 -25px 1em -25px;
    padding: 0 1rem;
    background: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    transition: top 0.2s ease-in-out;
}

#toc-bar.invisible {
    top: -3rem;
}

#toc-bar .label {
    font-size: 0.9em;
    color: #333;
    font-weight: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Botón estático en la página */
#toc-solo-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em 1em;
    margin-bottom: 2em;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.5em;
    background: white;
    color: #666;
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

#toc-solo-trigger:hover {
    border-color: #045591;
    color: #045591;
}

#toc-solo-trigger .label {
    font-size: 1em;
}

/* Botones trigger genéricos */
.toc-trigger {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5em;
    font-size: 1em;
    transition: color 0.2s ease;
}

.toc-trigger:hover {
    color: #045591;
}

/* Popup Modal (dialog) */
#toc-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.5em;
    background: white;
    color: #333;
    min-width: 20rem;
    max-width: 90vw;
    max-height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Animaciones del popup */
@keyframes slide-in {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes slide-out {
    from {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
}

#toc-popup[open] {
    animation: slide-in 0.3s ease-out;
}

#toc-popup[closing] {
    animation: slide-out 0.3s ease-out;
}

/* Backdrop del popup */
#toc-popup::backdrop {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Header del popup */
#toc-popup .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1em 1.5em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: white;
    position: sticky;
    top: 0;
    z-index: 1;
}

#toc-popup .header .label {
    font-size: 1em;
    font-weight: normal;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

#toc-popup-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5em;
    font-size: 1.2em;
    line-height: 1;
    transition: color 0.2s ease;
}

#toc-popup-close:hover {
    color: #000;
}

/* Contenido del popup */
#toc-popup-content {
    padding: 1.5em;
    overflow-y: auto;
    max-height: calc(80vh - 4rem);
}

/* Gradiente inferior para indicar scroll */
#toc-popup::after {
    content: '';
    position: sticky;
    bottom: 0;
    display: block;
    height: 2rem;
    background: linear-gradient(transparent, white 70%);
    pointer-events: none;
}

/* Listas del TOC */
#toc-popup-content ol,
#toc-popup-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc-popup-content li {
    margin: 0.25em 0;
}

#toc-popup-content a {
    display: block;
    padding: 0.5em 0;
    color: #666;
    text-decoration: none;
    border-bottom: none;
    line-height: 1.4;
    transition: color 0.2s ease;
}

#toc-popup-content a:visited {
    color: #666;
    border-bottom: none;
}

#toc-popup-content a:hover {
    color: #333;
    border-bottom: none;
}

#toc-popup-content a:after {
    content: '' !important;
}

/* Enlace activo */
#toc-popup-content a.active {
    color: #045591;
    font-weight: normal;
}

/* Jerarquía de encabezados */
#toc-popup-content ol ol {
    padding-left: 1.5em;
    margin-top: 0.25em;
}

#toc-popup-content ol ol a {
    font-size: 0.95em;
    color: #888;
}

/* Scrollbar del popup */
#toc-popup-content::-webkit-scrollbar {
    width: 4px;
}

#toc-popup-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

#toc-popup-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Lock scroll del body cuando popup está abierto */
body.overflow-hidden,
html.overflow-hidden {
    overflow: hidden !important;
}


/* ============================================
   DESKTOP: Panel Lateral Sticky (≥1200px)
   ============================================ */

@media (min-width: 1200px) {
    /* Ocultar elementos mobile */
    #toc-bar,
    #toc-solo-trigger,
    #toc-popup {
        display: none !important;
    }
    
    /* Mostrar panel lateral */
    #toc-wrapper {
        display: block;
        position: fixed;
        right: calc((100vw - 700px) / 2 - 250px);
        top: 150px;
        width: 220px;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        padding-right: 20px;
    }
    
    #toc-wrapper h2 {
        font-size: 0.85em;
        font-weight: 100;
        font-style: normal;
        margin: 0 0 1em 0;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    /* Lista del TOC */
    #toc-wrapper ol,
    #toc-wrapper ul {
        list-style: none;
        padding: 0;
        margin: 0;
        border-left: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    #toc-wrapper li {
        margin: 0;
    }
    
    /* Enlaces del TOC */
    #toc-wrapper a {
        display: block;
        padding: 0.4em 0 0.4em 1em;
        font-size: 0.85em;
        color: #666;
        text-decoration: none;
        border-bottom: none;
        border-left: 2px solid transparent;
        margin-left: -1px;
        line-height: 1.4;
        transition: all 0.2s ease;
    }
    
    #toc-wrapper a:visited {
        color: #666;
        border-bottom: none;
    }
    
    #toc-wrapper a:hover {
        color: #333;
        border-left-color: #333;
        border-bottom: none;
    }
    
    #toc-wrapper a:after {
        content: '' !important;
    }
    
    /* Enlace activo */
    #toc-wrapper a.active {
        color: #045591;
        border-left-color: #045591;
    }
    
    /* Jerarquía de encabezados */
    #toc-wrapper ol ol,
    #toc-wrapper ul ul {
        border-left: none;
        padding-left: 1em;
        margin-top: 0.25em;
    }
    
    #toc-wrapper ol ol a,
    #toc-wrapper ul ul a {
        font-size: 0.8em;
        padding: 0.3em 0 0.3em 1em;
        border-left: none;
    }
    
    /* Scrollbar minimalista */
    #toc-wrapper::-webkit-scrollbar {
        width: 3px;
    }
    
    #toc-wrapper::-webkit-scrollbar-track {
        background: transparent;
    }
    
    #toc-wrapper::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
    }
}

/* Pantallas muy grandes */
@media (min-width: 1400px) {
    #toc-wrapper {
        right: calc((100vw - 700px) / 2 - 280px);
        width: 250px;
    }
}


/* ============================================
   RESPONSIVE: Mobile y Tablet
   ============================================ */

/* Responsive: Mobile */
@media (max-width: 768px) {
    body {
        font-size: 17px;
        padding: 0 15px;
        width: 100%;
    }
    
    header {
        margin: 3rem 0;
    }
    
    h1 {
        font-size: 1.75em;
    }
    
    h2 {
        font-size: 1.35em;
    }
    
    .post-item {
        flex-direction: column;
        gap: 1em;
    }
    
    .post-thumbnail {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    
    blockquote {
        padding: 1em;
    }
    
    pre {
        padding-left: 0.8em;
        font-size: 0.85em;
    }
    
    /* Ajustes del TOC bar en mobile */
    #toc-bar {
        margin: 0 -15px 1em -15px;
    }
    
    /* Popup más pequeño en mobile */
    #toc-popup {
        min-width: auto;
        width: 90vw;
    }

    /* Ocultar elemento */
    #toc-solo-trigger,
    #toc-wrapper {
        display: none !important;
    }

}

/* Responsive: Tablet */
@media (min-width: 769px) and (max-width: 1199px) {
    body {
        width: 90%;
        max-width: 700px;
    }

    /* Ocultar elemento */
    #toc-solo-trigger,
    #toc-wrapper {
        display: none !important;
    }
}
