/* ============================================
   PIMENTEL - SISTEMA DE DISEÑO
   Estudio de Comunicación, Diseño & Publicidad
   ============================================ */

/* VARIABLES CSS */
:root {
    --white: #ffffff;
    --paper: #F8F8F8;
    --ink: #1a1a1a;
    --ink-light: #666666;
    --ink-lighter: #999999;
    --rule: #e5e5e5;
    --accent: #0066ff;
    --accent-light: #e6f0ff;
    --active: #E73C23;
    
    /* Link States - Fácil de cambiar */
    --link-normal: var(--active);        /* Rojo */
    --link-hover: var(--active);         /* Rojo en hover */
    --link-visited: var(--active);       /* Rojo visitado */
    --link-active: var(--accent);        /* Azul cuando activo */
    --link-external: var(--accent);      /* Azul para externos */
    --link-context: var(--ink-light);    /* Gris para links del sidebar */
    
    /* Variables para search results y componentes adicionales */
    --border-color: #e5e5e5;
    --text-muted: #999999;
    --bg-muted: #f5f5f5;
    
    --max-width: 1280px;
    --grid-gutter: 24px;
    --grid-margin: 48px;
    
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.5rem;
    --text-2xl: 2rem;
    --text-3xl: 2.5rem;
    --text-4xl: 3rem;
    
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-8: 64px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, Helvetica, Arial, sans-serif;
    font-size: var(--text-base);
    line-height: 1.625;
    color: var(--ink);
    background: var(--white);
}

/* ESTILO BASE PARA TODOS LOS ENLACES - link-underline-expand */
a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: #000000;
    text-underline-offset: 3px;
    transition: color 0.3s ease, text-decoration-color 0.3s ease;
}

a:hover {
    color: var(--active);
    text-decoration-color: var(--active);
}

/* ESTILOS BASE PARA TODOS LOS ENCABEZADOS - Solo tipografía */
h1 {
    font-size: var(--text-4xl);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

h2 {
    font-size: var(--text-2xl);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h3 {
    font-size: var(--text-xl);
    font-weight: 500;
    line-height: 1.3;
}

h4 {
    font-size: var(--text-lg);
    font-weight: 500;
    line-height: 1.4;
}

::selection {
    background: var(--accent);
    color: var(--white);
}

/* GRID OVERLAY */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width);
    height: 100%;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gutter);
    padding: 0 var(--grid-margin);
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
}

.grid-overlay.visible { opacity: 1; }
.grid-overlay div { background: var(--accent-light); opacity: 0.4; }

.grid-hint {
    position: fixed;
    bottom: var(--space-3);
    right: var(--space-3);
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    z-index: 10000;
}

/* LAYOUT */
.layout {
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gutter);
    padding: 0 var(--grid-margin);
    min-height: 100vh;
    position: relative;
}

/* Fondo extendido desde el final de col 3 hasta el borde derecho de la página */
.layout::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    /*
       En CSS Grid con gap, el ancho disponible (100% - padding*2) se divide en:
       - 12 columnas de ancho igual
       - 11 gutters entre ellas
       Ancho de 1 columna = (ancho disponible - 11 gutters) / 12
       Posición final de col 3 = padding + (3 * ancho columna) + (2 * gutter)
    */
    left: calc(
        var(--grid-margin) +
        ((100% - var(--grid-margin) * 2 - var(--grid-gutter) * 11) / 12 * 3) +
        (var(--grid-gutter) * 2)
    );
    /* Se extiende hasta el borde derecho de la ventana */
    right: calc(-50vw + 50%);
    background: var(--paper); /* Color de fondo - puedes cambiarlo */
    z-index: -1;
    pointer-events: none;
}

.sidebar {
    grid-column: 1 / 4;
    padding-top: var(--space-6);
    padding-right: var(--grid-gutter);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main {
    grid-column: 4 / 13;
    padding-top: var(--space-6);
    padding-bottom: var(--space-8);
}

/* SIDEBAR - BRAND */
.brand { margin-bottom: var(--space-8); }

.brand-name {
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand-name a {
    color: inherit;
    text-decoration: none;
}

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

.brand-role {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: var(--space-1);
}

/* SIDEBAR - NAVIGATION */
.nav { margin-bottom: var(--space-8); }

.nav-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.nav-list { list-style: none; }
.nav-item { margin-bottom: var(--space-1); }

/* Estilo: link-underline-expand - Línea inferior que transiciona de negro a azul */
.nav-link {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--ink);
    text-decoration: none;
    padding: 2px 0;
    cursor: pointer;
}

.nav-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    min-width: 20px;
    transition: color 0.3s ease;
}

.nav-text {
    position: relative;
    text-decoration: none;
    transition: color 0.3s ease;
}

.nav-link:hover,
a.nav-link:hover {
    color: var(--active);
    text-decoration: none;
}
.nav-link:hover .nav-number { color: var(--active); }
.nav-link:hover .nav-text {
    color: var(--active);
}

/* Estado activo: color activo, texto bold, sin underline */
.nav-link.active,
a.nav-link.active {
    color: var(--active);
    text-decoration: none;
    cursor: default;
}
.nav-link.active .nav-number {
    color: var(--active);
    font-weight: normal;
}
.nav-link.active .nav-text {
    color: var(--active);
    font-weight: 600;
    text-decoration: none;
}

/* SIDEBAR - BACK LINK */
.back-link { margin-bottom: var(--space-6); }

.back-link a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-sm);
    /* Hereda estilo base de enlaces */
}

/* SIDEBAR - CONTEXT */
.sidebar-context { flex: 1; }

.context-section { 
    display: none; 
    animation: fadeIn 0.4s ease; 
}

.context-section.visible { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.context-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.context-list { list-style: none; }

.context-item { 
    font-size: var(--text-sm); 
    color: var(--ink-light); 
    margin-bottom: var(--space-1); 
}

/* Context links - hover en color activo */
.context-link,
a.context-link {
    color: var(--ink-light);
    text-decoration: underline;
    text-decoration-color: var(--ink-light);
}

.context-link:hover,
a.context-link:hover {
    color: var(--active);
    text-decoration-color: var(--active);
}

/* Context Articles - Lista de artículos en sidebar */
.context-articles {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.context-card {
    display: block;
    text-decoration: none;
}

.context-card-image {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--paper);
    margin-bottom: var(--space-1);
}

.context-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    opacity: 0.85;
    transition: all 0.3s ease;
}

.context-card:hover .context-card-image img {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.02);
}

.context-card-title {
    font-size: var(--text-base);
    font-weight: 400;
    color: var(--ink);
    line-height: 1.4;
    transition: color 0.2s ease;
}

.context-card:hover .context-card-title {
    color: var(--active);
}

.context-card-excerpt {
    font-size: var(--text-sm);
    color: var(--ink-light);
    line-height: 1.5;
    margin-top: var(--space-1);
}

.context-card-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-sm);
    color: var(--ink-lighter);
    margin-top: var(--space-1);
}

/* SIDEBAR - PROJECT DETAILS (proyecto.html) */
.project-details { margin-bottom: var(--space-6); }

.detail-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-1);
}

.detail-value {
    font-size: var(--text-sm);
    color: var(--ink);
    margin-bottom: var(--space-4);
}

/* .detail-value a usa el estilo base global de enlaces */

/* SIDEBAR - TOC (articulo.html) */
.article-toc { margin-bottom: var(--space-6); }

.toc-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.toc-list { list-style: none; }
.toc-item { margin-bottom: var(--space-1); }

.toc-link {
    font-size: var(--text-sm);
    /* Hereda estilo base de enlaces */
}

/* Estado activo: rojo y bold */
.toc-link.active {
    color: #E73C23;
    font-weight: 700;
    text-decoration: none;
}

/* SIDEBAR - FOOTER */
.sidebar-footer { 
    margin-top: auto; 
    padding-bottom: var(--space-4); 
}

.status {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
}

.status::before { 
    content: '●'; 
    color: var(--accent); 
    margin-right: var(--space-1); 
}

.copyright-info {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--rule);
}

.copyright-info p {
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    line-height: 1.6;
    margin-bottom: var(--space-2);
}

.copyright-info p:last-child {
    margin-bottom: 0;
}

/* Enlaces heredan estilo base */

.copyright-info img {
    display: inline-block;
    vertical-align: middle;
}

.cms-credit {
    font-size: var(--text-xs) !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* SIDEBAR - SOCIALS */
.sidebar-socials {
    margin-top: var(--space-3);
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    text-decoration: none;
    font-size: var(--text-base);
    transition: color 0.3s ease, transform 0.2s ease;
}

.social-icon:hover {
    color: var(--active);
    transform: scale(1.1);
}

.social-icon i {
    font-size: 18px;
}

/* MAIN - SECTIONS (index.html) */
.section { 
    display: none; 
    animation: fadeIn 0.5s ease; 
}

.section.active { display: block; }

/* SECTION HEADER */
.section-header {
    margin-bottom: var(--space-8);
    padding-top: var(--space-1);
    border-top: 3px solid var(--ink);
}

.section-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.section-title {
    font-size: var(--text-4xl);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.section-title .accent { color: var(--accent); }

.section-intro {
    margin-top: var(--space-3);
    max-width: 50ch;
}

/* HOME */
.home-content {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.home-bio { grid-column: 1 / 7; }

.home-bio p {
    margin-bottom: var(--space-3);
    color: var(--ink-light);
}

.home-bio p:first-child {
    font-size: var(--text-lg);
    color: var(--ink);
}

.home-stats {
    grid-column: 7 / 10;
    border-left: 1px solid var(--rule);
    padding-left: var(--grid-gutter);
}

.stat-item { margin-bottom: var(--space-5); }

.stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-3xl);
    font-weight: 500;
    color: var(--accent);
    line-height: 1;
    transition: all 0.3s ease;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--ink-light);
    margin-top: var(--space-1);
}

.home-cta {
    grid-column: 1 / 10;
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--rule);
}

.cta-text { 
    font-size: var(--text-xl); 
    margin-bottom: var(--space-2); 
}

.cta-link {
    font-size: var(--text-lg);
    /* Hereda estilos base de enlaces globales */
}

/* PORTFOLIO */
.portfolio-list { 
    display: flex; 
    flex-direction: column; 
}

/* PORTFOLIO 2 - GRID VISUAL */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gutter);
}

.portfolio-card {
    position: relative;
}

.portfolio-card:hover {
    z-index: 10;
}

.portfolio-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.portfolio-card-image {
    background: var(--paper);
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s ease;
}

.portfolio-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.portfolio-card:hover .portfolio-card-image {
    transform: scale(1.05);
}

.portfolio-card:hover .portfolio-card-title a {
    color: var(--active);
    text-decoration-color: var(--active);
}

.portfolio-card-content {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--rule);
}

.portfolio-card-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
}

.project {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
    align-items: baseline;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    transition: background 0.2s;
}

/* Comentado para evitar línea gris al inicio */
/* .project:first-child { border-top: 1px solid var(--rule); } */

.project:hover .project-title a {
    color: var(--active);
    text-decoration-color: var(--active);
}

.project-info { grid-column: 1 / 6; }

/* Títulos en listados usan h3 base - solo agregar estilos de enlaces */
.project-title a,
.article-title a,
.portfolio-card-title a {
    /* Heredan estilo base de enlaces */
}

.project-description { 
    font-size: var(--text-sm); 
    color: var(--ink-light); 
}

.project-meta {
    grid-column: 6 / 8;
    font-size: var(--text-sm);
    color: var(--ink-light);
}

.project-year {
    grid-column: 8 / 10;
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-sm);
    color: var(--ink-lighter);
    text-align: right;
}

/* Project hover image preview */
.project-image-preview {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    width: 300px;
    height: 225px;
    border-radius: 4px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.project-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project:hover ~ .project-image-preview,
.project-image-preview.visible {
    opacity: 1;
}

/* BLOG */
.blog-list { 
    display: flex; 
    flex-direction: column; 
}

.article {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    transition: background 0.2s;
}

/* Comentado para evitar línea gris al inicio */
/* .article:first-child { border-top: 1px solid var(--rule); } */

.article:hover .article-title a {
    color: var(--active);
    text-decoration-color: var(--active);
}

.article-date {
    grid-column: 1 / 2;
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-sm);
    color: var(--ink-lighter);
}

.article-content { grid-column: 2 / 8; }

.article-excerpt {
    font-size: var(--text-base);
    color: var(--ink-light);
    line-height: 1.7;
}

.article-tags {
    grid-column: 8 / 10;
    text-align: right;
}

.tag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding: var(--space-4) 0;
    border-top: 1px solid var(--border-color);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    height: 3rem;
    padding: 0 var(--space-3);
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink);
    text-decoration: none;
    background: transparent;
    border: 2px solid var(--ink);
    border-radius: 0;
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.pagination span {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

/* CV */
.cv-content {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.cv-main { grid-column: 1 / 6; }
.cv-aside { grid-column: 7 / 10; }
.cv-block { margin-bottom: var(--space-6); }

.cv-block-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--rule);
}

.cv-entry { margin-bottom: var(--space-4); }

.cv-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.cv-entry-title { 
    font-size: var(--text-base); 
    font-weight: 500; 
}

.cv-entry-period {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
}

.cv-entry-org { 
    font-size: var(--text-sm); 
    color: var(--ink-light); 
    margin-bottom: 4px; 
}

.cv-entry-description { 
    font-size: var(--text-sm); 
    color: var(--ink-light); 
}

.cv-skills { 
    font-size: var(--text-sm); 
    color: var(--ink-light); 
    line-height: 1.8; 
}

.cv-download { margin-top: var(--space-3); }

/* Enlaces heredan estilo base */

/* CONTACT */
.contact-content {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.contact-main { grid-column: 1 / 5; }
.contact-form-area { grid-column: 6 / 10; }

.contact-title-large {
    font-size: var(--text-2xl);
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: var(--space-5);
}

.contact-methods { list-style: none; }

.contact-method {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--rule);
}

.contact-method:first-child { border-top: 1px solid var(--rule); }

.contact-method-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.contact-method-value { font-size: var(--text-base); }

/* Enlaces heredan estilo base */

.form-intro {
    font-size: var(--text-sm);
    color: var(--ink-light);
    margin-bottom: var(--space-4);
}

.form-group { margin-bottom: var(--space-3); }

.form-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-1);
}

.form-input, .form-textarea {
    width: 100%;
    padding: var(--space-2);
    font-family: inherit;
    font-size: var(--text-base);
    color: var(--ink);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--rule);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus { 
    border-color: var(--accent); 
}

.form-textarea { 
    min-height: 100px; 
    resize: vertical; 
}

.form-submit {
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-4);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--white);
    background: var(--ink);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.form-submit:hover { background: var(--active); }

/* PROJECT DETAIL PAGE (proyecto.html) */
.project-header {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-5);
    border-bottom: 5px solid var(--ink);
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.project-header > * {
    grid-column: 1 / 7;
}

.project-header h1 {
    margin-bottom: var(--space-3);
}

.project-category {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.intro-text {
    font-size: var(--text-lg);
    color: var(--ink-light);
    line-height: 1.7;
}

.project-content {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.project-image-full {
    grid-column: 1 / 10;
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-lighter);
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
    overflow: hidden;
}

.project-image-full img {
    width: 100%;
    height: auto;
    display: block;
}

.project-image-half {
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-lighter);
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-sm);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.project-image-half:hover {
    transform: scale(1.05);
}

.project-image-half img {
    width: 100%;
    height: auto;
    display: block;
}

/* Patrón de 2 columnas para todas las imágenes de galería */
.project-content > .project-image-half:nth-child(odd) { grid-column: 1 / 5; }
.project-content > .project-image-half:nth-child(even) { grid-column: 5 / 9; }

/* Layout de detalle de proyecto - similar a artículos */
.project-detail-content {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
    grid-column: 1 / 10;
}

.project-main {
    grid-column: 1 / 7;
}

.project-main p {
    margin-bottom: var(--space-3);
    line-height: 1.8;
}

.project-aside {
    grid-column: 7 / 10;
}

.project-text {
    grid-column: 1 / 7;
    margin: var(--space-6) 0;
}

.project-text h2 {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--space-3);
    letter-spacing: -0.02em;
}

.project-text p {
    color: var(--ink-light);
    margin-bottom: var(--space-3);
    line-height: 1.8;
}

.project-text p:last-child { margin-bottom: 0; }

.project-credits {
    grid-column: 7 / 10;
    margin: var(--space-6) 0;
}

.credits-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.credits-list { list-style: none; }

.credits-item {
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
}

.credits-role { color: var(--ink-lighter); }
.credits-name { color: var(--ink); }

.project-nav {
    grid-column: 1 / 10;
    margin-top: var(--space-8);
    padding-top: var(--space-5);
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
}

.project-nav-item {
    flex: 1;
    max-width: 45%;
}

.project-nav-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-1);
}

.project-nav-item a {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
}

.project-nav-item a:hover {
    color: var(--accent);
}

.project-nav-item.next {
    text-align: right;
}

/* ARTICLE DETAIL PAGE (articulo.html) */
.article-header {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-5);
    border-bottom: 5px solid var(--ink);
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.article-header > * {
    grid-column: 1 / 7;
}

.article-header h1 {
    margin-bottom: var(--space-3);
}

.article-meta {
    display: flex;
    gap: var(--space-3);
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
}

/* Imagen destacada del artículo */
.article-featured-image {
    margin: var(--space-6) 0;
}

.article-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

.article-featured-image figcaption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    margin-top: var(--space-2);
}

/* Grid para el contenido del artículo detallado */
.article-detail-content {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: var(--grid-gutter);
}

.article-body { 
    grid-column: 1 / 7;
}

/* Espaciado específico para encabezados dentro del contenido de artículos */
.article-body h2 {
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
}
.article-body h2#heading-0 {margin-top:0 !important}

.article-body h3 {
    margin-top: var(--space-5);
    margin-bottom: var(--space-2);
}

.article-body p {
    margin-bottom: var(--space-3);
    line-height: 1.8;
}

.article-body a {
    color: var(--link-normal);
    text-decoration: none;
}

.article-body a:hover { 
    color: var(--link-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

/* Icono para enlaces externos */
.article-body a[target="_blank"]::after,
.home-bio p a[target="_blank"]::after{
    content: '\2197'; /* ↗ */
    font-size: 0.8em;
    margin-left: 2px;
    vertical-align: super;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}
.article-body a[target="_blank"]:hover::after,
.home-bio p a[target="_blank"]:hover::after{
    opacity: 1;
}
.article-body a[target="_blank"]:not(:has(img))::after

.article-body blockquote {
    margin: var(--space-5) 0;
    padding-left: var(--space-4);
    border-left: 2px solid var(--accent);
    font-size: var(--text-lg);
    color: var(--ink-light);
    font-style: italic;
}

.article-body ul, .article-body ol {
    margin-bottom: var(--space-3);
    padding-left: var(--space-4);
}

.article-body li { margin-bottom: var(--space-1); }

.article-body figure { margin: var(--space-6) 0; }

.article-body figure img {
    width: 100%;
    height: auto;
    background: var(--paper);
}

.article-body figcaption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    margin-top: var(--space-2);
}

/* Imágenes en el cuerpo del artículo */
.article-body img,
.blog-imagenes img {
    max-width: 100%;
    height: auto;
    display: block;
}

.blog-imagenes {
    margin: var(--space-6) 0;
}

.blog-imagenes .image-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    margin-top: var(--space-2);
}

.article-aside { 
    grid-column: 7 / 10;
    position: sticky;
    bottom: 0;
    align-self: end;
    padding-bottom: var(--space-4);
}

.aside-block { margin-bottom: var(--space-6); }

.aside-block:last-child { margin-bottom: 0; }

.aside-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.aside-content {
    font-size: var(--text-sm);
    color: var(--ink-light);
    line-height: 1.7;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.tag, .aside-content .tag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-light);
    padding: 4px 8px;
    background: var(--paper);
}

.article-footer {
    grid-column: 1 / 7;
    margin-top: var(--space-8);
    padding-top: var(--space-5);
    border-top: 1px solid var(--rule);
}

.related-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-3);
}

.related-list { list-style: none; }

.related-item {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--rule);
}

.related-item:first-child { border-top: 1px solid var(--rule); }

.related-link {
    font-size: var(--text-base);
    font-weight: 500;
    /* Hereda estilos base de enlaces globales */
}

/* Scroll to top button */
.scroll-to-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
    background: none;
    border: none;
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, color 0.2s;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    color: var(--ink);
}

.scroll-to-top:hover .scroll-to-top-button {
    background: var(--ink);
    color: var(--paper);
}

.scroll-to-top-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background: transparent;
    border: 2px solid var(--ink);
    border-radius: 0;
    color: var(--ink);
    transition: all 0.2s ease;
}

.scroll-to-top-button svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 991px) {
    :root {
        --grid-margin: 32px;
        --grid-gutter: 20px;
    }

    .sidebar { grid-column: 1 / 4; }
    .main { grid-column: 4 / 13; }

    /* El fondo se recalcula automáticamente con las nuevas variables */
    
    .section-title { font-size: var(--text-3xl); }
    .project-title { font-size: var(--text-3xl); }
    .article-title { font-size: var(--text-3xl); }
    
    .cv-content, .contact-content { 
        grid-template-columns: 1fr; 
    }
    
    .cv-main, .cv-aside, .contact-main, .contact-form-area { 
        grid-column: 1 / -1; 
    }
    
    .cv-aside, .contact-form-area {
        margin-top: var(--space-4);
        padding-top: var(--space-4);
        border-top: 1px solid var(--rule);
    }
    
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .project-text { grid-column: 1 / 10; }
    .project-credits { 
        grid-column: 1 / 10; 
        margin-top: 0; 
    }
    
    .article-body { grid-column: 1 / 10; }
    .article-aside { display: none; }
    .article-footer { grid-column: 1 / 10; }
}

@media (max-width: 767px) {
    :root {
        --grid-margin: 24px;
        --grid-gutter: 16px;
    }

    .layout { display: block; }

    /* Ocultar fondo extendido en móvil */
    .layout::after {
        display: none;
    }
    
    .sidebar {
        position: relative;
        height: auto;
        padding-bottom: var(--space-4);
        margin-bottom: var(--space-4);
        border-bottom: 1px solid var(--rule);
    }
    
    .sidebar-context, .sidebar-footer { display: none; }
    .project-details, .article-toc { display: none; }
    
    .nav-list { 
        display: flex; 
        flex-wrap: wrap; 
        gap: var(--space-1) var(--space-3); 
    }
    
    .nav-item { margin-bottom: 0; }
    
    .main { padding-top: 0; }
    
    .section-title { font-size: var(--text-2xl); }
    .project-title { font-size: var(--text-2xl); }
    .article-title { font-size: var(--text-2xl); }
    
    .home-content, .portfolio-list .project, .blog-list .article {
        display: block;
    }
    
    .home-stats {
        border-left: none;
        padding-left: 0;
        margin-top: var(--space-5);
        padding-top: var(--space-5);
        border-top: 1px solid var(--rule);
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
    }
    
    .stat-item { margin-bottom: 0; }
    
    .project-meta, .project-year { 
        margin-top: var(--space-1); 
        font-size: var(--text-xs); 
    }
    
    .project-year { text-align: left; }
    
    .article-date { margin-bottom: var(--space-1); }
    .article-tags { 
        text-align: left; 
        margin-top: var(--space-2); 
    }
    
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    
    .grid-hint { display: none; }
    
    .project-content { display: block; }
    
    .project-image-full, .project-image-half {
        margin-bottom: var(--space-3);
    }
    
    .project-text, .project-credits {
        margin: var(--space-4) 0;
    }
    
    .project-nav {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .project-nav-item { max-width: 100%; }
    .project-nav-item.next { text-align: left; }
    
    .article-content { display: block; }
    
    .project-header {
        display: block;
    }
    
    .article-header {
        display: block;
    }
    
    .project-detail-content {
        display: block;
    }
    
    .project-main {
        grid-column: 1 / -1;
    }
    
    .project-aside {
        grid-column: 1 / -1;
        margin-top: var(--space-4);
        padding-top: var(--space-4);
        border-top: 1px solid var(--rule);
    }
    
    .section-intro {
        max-width: none;
    }
    
    .article-header > * {
        grid-column: 1 / -1;
    }
    
    .article-detail-content {
        display: block;
    }
    
    .article-body,
    .article-footer {
        grid-column: 1 / -1;
    }
}

@media (max-width: 575px) {
    :root { 
        --grid-margin: 16px; 
        --text-4xl: 2rem; 
        --text-3xl: 1.75rem; 
        --text-2xl: 1.5rem; 
    }
    
    .brand-name { font-size: var(--text-lg); }
    .nav-number { display: none; }
    .home-stats { grid-template-columns: 1fr; }
    .stat-value { font-size: var(--text-2xl); }
}

/* SEARCH BOX */
.box-search {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.95);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.box-search.active {
    opacity: 1;
    visibility: visible;
}

.box-search .table {
    display: table;
    width: 100%;
    height: 100%;
}

.box-search .table-cell {
    display: table-cell;
    vertical-align: middle;
}

.box-search .container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.search-form {
    position: relative;
}

.search-field {
    width: 100%;
    padding: var(--space-3) 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--white);
    color: var(--white);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: var(--text-2xl);
    outline: none;
}

.search-field::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.kd-close {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    cursor: pointer;
}

.kd-close::before,
.kd-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 2px;
    background: var(--white);
}

.kd-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.kd-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.kd-close:hover::before,
.kd-close:hover::after {
    background: var(--accent);
}

/* SEARCH RESULTS */
.search-results-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.search-result-item {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-color);
    align-items: start;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.search-result-section {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.search-result-content {
    flex: 1;
}

.search-result-title {
    font-size: var(--text-lg);
    font-weight: 500;
    margin-bottom: var(--space-1);
}

.search-result-title a {
    color: var(--ink);
    text-decoration: none;
}

.search-result-title a:hover {
    color: var(--accent);
}

.search-result-excerpt {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.5;
}

.search-result-meta {
    display: flex;
    gap: var(--space-2);
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.search-result-category {
    background: var(--bg-muted);
    padding: var(--space-1) var(--space-2);
    border-radius: 2px;
}

.no-results {
    text-align: center;
    padding: var(--space-8) 0;
    color: var(--text-muted);
}

.no-results p {
    margin-bottom: var(--space-4);
}

.no-results .back-link {
    color: var(--accent);
    text-decoration: none;
}

.no-results .back-link:hover {
    text-decoration: underline;
}

.search-term-display {
    font-style: italic;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

@media (max-width: 767px) {
    .search-result-item {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .search-result-meta {
        order: -1;
    }
}

/* LIGHTBOX */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90vh;
    position: relative;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--ink);
    font-size: 3rem;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10001;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.lightbox-close:hover {
    transform: scale(1.1);
}

@media print {
    .sidebar { display: none; }
    .main { grid-column: 1 / -1; }
    .section { 
        display: block !important; 
        page-break-before: always; 
    }
    .socials, .box-search, .site-footer { display: none; }
}

.status.no {
    color: #bbb !important;
}
.status.no::before {
    color: #bbb !important;
}

.imagen-rob {
    width: 100%;
    margin-bottom: var(--space-3);
    display: block;
}

/* ============================================
   TABLAS - Estilo minimalista editorial
   ============================================ */
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-5) 0;
    font-size: var(--text-sm);
}

.article-body thead {
    border-bottom: 2px solid var(--ink);
}

.article-body th {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink);
    text-align: left;
    padding: var(--space-2) var(--space-3) var(--space-2) 0;
}

.article-body td {
    padding: var(--space-2) var(--space-3) var(--space-2) 0;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-light);
    vertical-align: top;
    line-height: 1.5;
}

.article-body tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   HR - Separador con linea accent
   ============================================ */
.article-body hr {
    border: none;
    border-top: 2px solid var(--accent);
    margin: var(--space-8) 0;
    width: 80px;
}

.home-main {
    grid-column: 1 / 7;
}

/* Latest Article Box */
.latest-article-box {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--rule);
}

.latest-article-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.latest-article-title {
    font-size: var(--text-base);
    font-weight: 500;
    margin-bottom: var(--space-1);
}

.latest-article-title a {
    color: var(--ink);
    text-decoration: none;
}

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

.latest-article-excerpt {
    font-size: var(--text-sm);
    color: var(--ink-light);
    line-height: 1.6;
}

/* Latest Project Box */
.latest-project-box {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--rule);
}

.latest-project-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.latest-project-card {
    display: block;
    text-decoration: none;
}

.latest-project-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--paper);
    margin-bottom: var(--space-2);
    transition: transform 0.3s ease;
}

.latest-project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    opacity: 0.85;
    transition: all 0.3s ease;
}

.latest-project-card:hover .latest-project-image {
    transform: scale(1.05);
}

.latest-project-card:hover .latest-project-image img {
    filter: grayscale(0%);
    opacity: 1;
}

.latest-project-title {
    font-size: var(--text-base);
    font-weight: 400;
    color: var(--ink);
    margin-bottom: var(--space-1);
    transition: color 0.2s ease;
}

.latest-project-card:hover .latest-project-title {
    color: var(--active);
}

.latest-project-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: var(--text-xs);
    color: var(--ink-lighter);
}