/**
 * Theme Name: Loom & Logic
 * Description: Tema minimalista para blog de tecnología, inspirado en la interfaz de LinkedIn.
 * Author: techblog
 * Version: 1.0.0
 * License: GNU General Public License v2 or later
 * Text Domain: techblog
 */

/* ============================================================
   Variables y reset
   ============================================================ */

:root {
    --tb-blue: #0a66c2;            /* azul corporativo LinkedIn */
    --tb-blue-hover: #1474d6;
    --tb-dark: #1d2229;            /* texto principal */
    --tb-muted: #666666;           /* texto secundario */
    --tb-faint: #a0afbd;           /* texto muy claro / metadatos */
    --tb-border: #e6e6e6;          /* bordes suaves */
    --tb-bg: #f4f6f8;             /* fondo de página */
    --tb-surface: #ffffff;         /* superficie de tarjetas */
    --tb-code-bg: #f6f7f9;         /* fondo de bloque de código */
    --tb-radius: 10px;
    --tb-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    --tb-max-width: 1120px;
    --tb-content-width: 720px;
    --tb-card-width: 900px;
    --tb-card-padding: 24px;
    --tb-font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --tb-font-code: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html { min-height: 100%; -webkit-text-size-adjust: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    background-color: var(--tb-bg);
    color: var(--tb-dark);
    display: flex;
    flex-direction: column;
    font-family: var(--tb-font-system);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a {
    color: var(--tb-blue);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover { color: var(--tb-blue-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    color: var(--tb-dark);
    line-height: 1.3;
    font-weight: 600;
    margin: 1.4em 0 0.6em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1.1em; }

/* ============================================================
   Contenedor y barra superior (estilo LinkedIn)
   ============================================================ */

.tb-container {
    width: 100%;
    max-width: var(--tb-max-width);
    margin: 0 auto;
    padding: 0 16px;
}

.tb-topbar {
    background: var(--tb-surface);
    border-bottom: 1px solid var(--tb-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.tb-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
}

.tb-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--tb-dark);
    font-weight: 700;
    font-size: 1.1rem;
}
.tb-brand:hover { text-decoration: none; }

.tb-brand-logo,
.tb-brand-in {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
}
.tb-brand-logo { display: block; border-radius: 8px; }
.tb-brand-in {
    display: inline-grid;
    place-items: center;
    background: var(--tb-blue);
    color: #fff;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
}

.tb-nav,
.tb-nav ul,
.tb-nav-items {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tb-nav li { display: flex; margin: 0; padding: 0; list-style: none; }
.tb-nav a {
    color: var(--tb-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.92rem;
}
.tb-nav a:hover { background: var(--tb-bg); text-decoration: none; color: var(--tb-dark); }
.tb-nav a.tb-nav-active { color: var(--tb-blue); }

.tb-main { flex: 1; padding: 32px 0 72px; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--tb-blue);
    color: #fff;
    padding: 8px 12px;
    z-index: 200;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ============================================================
   Feed de entradas (cards estilo LinkedIn)
   ============================================================ */

.tb-featured,
.tb-feed,
.tb-article,
.tb-comments,
.tb-404 {
    width: 100%;
    max-width: var(--tb-card-width);
    margin-right: auto;
    margin-left: auto;
}

.tb-featured {
    margin-bottom: 22px;
    overflow: hidden;
}
.tb-featured-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding: 0 4px;
}
.tb-featured-head h2 { margin: 0; font-size: 1.25rem; }
.tb-featured-head span { color: var(--tb-muted); font-size: 0.9rem; }
.tb-featured-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 2px 4px 12px;
}
.tb-featured-card {
    position: relative;
    flex: 0 0 260px;
    min-height: 148px;
    overflow: hidden;
    scroll-snap-align: start;
    color: #fff;
    background: linear-gradient(135deg, #0a66c2, #1d2229);
    border-radius: var(--tb-radius);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
.tb-featured-card:hover { color: #fff; text-decoration: none; box-shadow: var(--tb-shadow); }
.tb-featured-card img,
.tb-featured-empty {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}
.tb-featured-empty { background: linear-gradient(135deg, #0a66c2, #1d2229); }
.tb-featured-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.08));
}
.tb-featured-title {
    position: absolute;
    right: 14px;
    bottom: 12px;
    left: 14px;
    z-index: 1;
    font-weight: 700;
    line-height: 1.25;
}

.tb-feed { display: flex; flex-direction: column; gap: 16px; }

.tb-card {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.tb-card:hover { border-color: #d6dce2; box-shadow: var(--tb-shadow); }

.tb-card-inner { padding: 18px var(--tb-card-padding) 16px; }

.tb-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--tb-faint);
    font-size: 0.82rem;
}
.tb-card-meta .tb-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.tb-card-meta .tb-author-block { display: flex; flex-direction: column; }
.tb-card-meta .tb-author { font-weight: 600; color: var(--tb-dark); }
.tb-card-meta .tb-role { color: var(--tb-muted); font-size: 0.82rem; }
.tb-card-meta .tb-dot { color: var(--tb-faint); }
.tb-card-meta a { color: var(--tb-blue); font-weight: 600; }
.tb-card-meta a:not(:last-of-type)::after { content: ","; color: var(--tb-faint); }
.tb-card-meta a:last-of-type::after { content: "·"; margin-left: 8px; color: var(--tb-faint); font-weight: 400; }
.tb-card-meta .tb-date { color: var(--tb-faint); font-size: 0.82rem; white-space: nowrap; }

.tb-card-title {
    margin: 0 0 8px;
    font-size: 1.2rem;
    line-height: 1.3;
}
.tb-card-title a { color: var(--tb-dark); }
.tb-card-title a:hover { color: var(--tb-blue); }

.tb-card-image {
    display: block;
    margin: 14px calc(var(--tb-card-padding) * -1) 16px;
    background: var(--tb-code-bg);
    border-top: 1px solid var(--tb-border);
    border-bottom: 1px solid var(--tb-border);
    overflow: hidden;
}
.tb-card-image img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 7;
    object-fit: cover;
}
.tb-card-image-empty { aspect-ratio: 16 / 7; background: linear-gradient(135deg, #eef3f8, #dce8f5); }

.tb-card-excerpt,
.tb-card-excerpt p {
    color: var(--tb-muted);
    font-size: 0.95rem;
    margin: 0 0 12px;
}

.tb-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.tb-reactionbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--tb-border);
}
.tb-readtime { margin-left: auto; color: var(--tb-muted); font-size: 0.85rem; white-space: nowrap; }
.tb-reactionbar button,
.tb-reactionbar a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--tb-muted);
    font-size: 0.85rem;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.tb-reactionbar button:hover,
.tb-reactionbar a:hover { background: var(--tb-bg); color: var(--tb-dark); text-decoration: none; }
.tb-reactionbar .is-active { color: var(--tb-blue); font-weight: 600; }
.tb-reactionbar .is-copied { color: var(--tb-blue); }
.tb-reactionbar .tb-reaction-icon { font-size: 1rem; line-height: 1; }

.tb-archive-header { margin-bottom: 4px; padding: 0 4px 4px; }
.tb-archive-header h1 { font-size: 1.4rem; margin: 0; }
.tb-archive-header p { color: var(--tb-muted); margin: 6px 0 0; }
.tb-archive-header span { color: var(--tb-blue); }
.tb-empty-card { padding: 24px; }
.tb-empty-card p { color: var(--tb-muted); margin: 0; }

/* ============================================================
   Artículo individual (single)
   ============================================================ */

.tb-article {
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
}
.tb-article-inner { padding: var(--tb-card-padding) var(--tb-card-padding) 8px; }

.tb-article-header { padding: 0 0 18px; border-bottom: 1px solid var(--tb-border); margin-bottom: 20px; }

.tb-article-kicker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.tb-article-actions {
    padding-top: 0;
    border-top: 0;
    margin-left: auto;
}

.tb-article-image {
    margin: 0 0 20px;
    overflow: hidden;
    border-radius: var(--tb-radius);
    background: var(--tb-code-bg);
}
.tb-article-image img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 7;
    object-fit: cover;
}

.tb-article-category {
    display: inline-block;
    color: var(--tb-blue);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0;
}
.tb-article-category a { color: var(--tb-blue); }

.tb-article-title { font-size: 2rem; margin: 0 0 16px; line-height: 1.2; }

.tb-article-byline {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--tb-muted);
    font-size: 0.9rem;
}
.tb-article-byline .tb-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.tb-article-byline .tb-author { font-weight: 600; color: var(--tb-dark); display: block; }
.tb-byline-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tb-article-byline .tb-byline-detail:not(:last-child)::after { content: "·"; margin-left: 6px; color: var(--tb-faint); }

.tb-article-body { padding: 8px var(--tb-card-padding) 48px; }

.tb-article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--tb-border);
}

/* ============================================================
   Tipografía del contenido (optimizada para lectura larga)
   ============================================================ */

.tb-article-body { line-height: 1.7; }
.tb-article-body h1, .tb-article-body h2, .tb-article-body h3, .tb-article-body h4 { scroll-margin-top: 72px; }

.tb-article-body p { font-size: 1.06rem; }

.tb-article-body ul, .tb-article-body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.tb-article-body li { margin-bottom: 0.35em; }

.tb-article-body blockquote {
    margin: 0 0 1.4em;
    padding: 4px 0 4px 20px;
    border-left: 4px solid var(--tb-blue);
    color: var(--tb-dark);
    font-size: 1.06rem;
}
.tb-article-body blockquote p { margin-bottom: 0; }

.tb-article-body code {
    font-family: var(--tb-font-code);
    font-size: 0.88em;
    background: var(--tb-code-bg);
    padding: 2px 5px;
    border-radius: 4px;
    color: #c7254e;
}

.tb-article-body pre {
    background: var(--tb-code-bg);
    border: 1px solid var(--tb-border);
    border-radius: 6px;
    padding: 0;
    overflow: auto;
    margin: 0 0 1.4em;
}
.tb-article-body pre code {
    display: block;
    padding: 14px 16px;
    font-size: 0.85rem;
    line-height: 1.55;
    background: transparent;
    color: inherit;
    white-space: pre;
}

.tb-article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1.4em;
    font-size: 0.95rem;
}
.tb-article-body th, .tb-article-body td {
    padding: 8px 12px;
    border: 1px solid var(--tb-border);
    text-align: left;
}
.tb-article-body th { background: var(--tb-code-bg); font-weight: 600; }

.tb-article-body img { border-radius: 6px; margin: 0 0 1.4em; }

.tb-article-body hr { border: none; border-top: 1px solid var(--tb-border); margin: 2em 0; }

.tb-comments {
    margin-top: 16px;
    padding: 0;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
    overflow: hidden;
}
.tb-comments-section { padding: 20px var(--tb-card-padding) var(--tb-card-padding); }
.tb-comments-header {
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--tb-border);
}
.tb-comments-header h2,
.comment-reply-title { margin: 0 0 4px; font-size: 1.2rem; }
.tb-comments-header p { margin: 0; color: var(--tb-muted); font-size: 0.95rem; }
.tb-comment-list,
.tb-comment-list .children {
    margin: 0;
    padding: 0;
    list-style: none;
}
.tb-comment-list .children { margin: 12px 0 0 52px; }
.tb-comment-list .comment-body {
    position: relative;
    margin-bottom: 12px;
    padding: 14px 16px 14px 68px;
    background: var(--tb-bg);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius);
}
.tb-comment-list .avatar {
    position: absolute;
    top: 14px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
}
.tb-comment-list .comment-author { font-weight: 600; line-height: 1.3; }
.tb-comment-list .comment-author .says { display: none; }
.tb-comment-list .comment-metadata,
.tb-comment-list .reply { font-size: 0.82rem; }
.tb-comment-list .comment-metadata a { color: var(--tb-faint); }
.tb-comment-list .comment-content { color: var(--tb-muted); font-size: 0.95rem; }
.tb-comment-list .comment-content p { margin: 8px 0 0; }
.tb-comment-list .reply a { color: var(--tb-blue); font-weight: 600; }
.tb-comments .navigation { margin: 16px 0; }
.tb-comment-form { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--tb-border); }
.tb-comment-form p { margin: 0 0 12px; }
.tb-comment-form label { display: block; margin-bottom: 6px; color: var(--tb-muted); font-size: 0.9rem; font-weight: 600; }
.tb-comment-form input,
.tb-comment-form textarea {
    width: 100%;
    border: 1px solid var(--tb-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--tb-dark);
    font: inherit;
}
.tb-comment-form input:focus,
.tb-comment-form textarea:focus {
    outline: none;
    border-color: var(--tb-blue);
    box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}
.tb-comment-submit {
    border: 0;
    border-radius: 18px;
    background: var(--tb-blue);
    color: #fff;
    padding: 9px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.tb-comment-submit:hover { background: var(--tb-blue-hover); }
.comment-notes,
.logged-in-as,
.comment-form-cookies-consent,
.form-allowed-tags { color: var(--tb-muted); font-size: 0.85rem; }

/* ============================================================
   Notas al pie y referencias
   ============================================================ */

.techblog-footnote-ref {
    display: inline-block;
    min-width: 1.2em;
    text-align: center;
    color: var(--tb-blue);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    vertical-align: super;
    line-height: 1;
}
.techblog-footnote-ref:hover { text-decoration: underline; }

.techblog-references {
    margin-top: 3em;
    padding: 20px;
    background: var(--tb-code-bg);
    border: 1px solid var(--tb-border);
    border-radius: 6px;
}
.techblog-references-title { font-size: 1.2rem; margin: 0 0 12px; }
.techblog-references-list { margin: 0; padding-left: 1.4em; }
.techblog-references-list li {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--tb-muted);
    scroll-margin-top: 72px;
}
.techblog-footnote-num {
    display: inline-grid;
    place-items: center;
    min-width: 1.4em;
    height: 1.4em;
    border-radius: 50%;
    background: var(--tb-blue);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
}

/* ============================================================
   Paginación, sidebar y utilidades
   ============================================================ */

.tb-pagination { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.tb-pagination a, .tb-pagination span {
    padding: 6px 12px;
    border: 1px solid var(--tb-border);
    border-radius: 6px;
    color: var(--tb-blue);
    background: var(--tb-surface);
}
.tb-pagination .current { background: var(--tb-blue); color: #fff; border-color: var(--tb-blue); }

.tb-404 { text-align: center; padding: 64px 16px; }
.tb-404 h1 { font-size: 3rem; margin-bottom: 8px; }
.tb-404 p { color: var(--tb-muted); margin-bottom: 24px; }

.tb-btn {
    display: inline-block;
    background: var(--tb-blue);
    color: #fff;
    padding: 10px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 600;
}
.tb-btn:hover { background: var(--tb-blue-hover); text-decoration: none; color: #fff; }

.tb-footer {
    margin-top: auto;
    background: var(--tb-surface);
    border-top: 1px solid var(--tb-border);
}
.tb-footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
}
.tb-footer-copy {
    color: var(--tb-faint);
    font-size: 0.82rem;
    border-top: 1px solid var(--tb-border);
    padding: 14px 16px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
    :root { --tb-card-padding: 14px; }
    .tb-main { padding-top: 18px; }
    .tb-container { padding: 0 10px; }
    .tb-card-inner { padding-top: 16px; padding-bottom: 14px; }
    .tb-card-image img { aspect-ratio: 16 / 9; }
    .tb-featured-card { flex-basis: 78vw; }
    .tb-article-image img { aspect-ratio: 16 / 9; }
    .tb-reactionbar { flex-wrap: wrap; }
    .tb-readtime { width: 100%; margin-left: 0; padding: 2px 10px 4px; }
    .tb-article-title { font-size: 1.6rem; }
    .tb-article-inner, .tb-article-body { padding-left: 16px; padding-right: 16px; }
    .tb-article-kicker { align-items: flex-start; flex-direction: column; gap: 10px; }
    .tb-article-byline { flex-wrap: wrap; }
    .tb-article-actions { margin-left: 0; }
    .tb-comments-section { padding-top: 16px; padding-bottom: 18px; }
    .tb-comment-list .children { margin-left: 18px; }
    .tb-comment-list .comment-body { padding-left: 62px; }
}
