/* ==========================================================
   Blog · PHP desde cero hasta experto
   Mismo sistema visual que /libros/catalogo.html y la página del libro
   ========================================================== */

:root {
    --bg: #0a0f1e;
    --surface: #10182e;
    --surface-2: #0d1426;
    --panel: #142a5c;
    --panel-line: rgba(255, 255, 255, 0.14);
    --line: rgba(255, 255, 255, 0.07);
    --text: #e8edf7;
    --body: #cfd7e6;
    --muted: #94a0b8;
    --cyan: #4fd1e0;
    --yellow: #ffc700;
    --red: #ff7a7a;
    --green: #6ee7a8;
    --ink: #0a0f1e;

    --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
    --wrap: 1200px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Cuadrícula técnica muy tenue */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 30% 10%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 80% 60% at 30% 10%, #000 20%, transparent 75%);
}

a {
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 4px;
}

strong {
    font-weight: 600;
    color: #fff;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 24px;
}

.eyebrow {
    display: inline-block;
    margin: 0 0 14px;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--cyan);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 28px;
    border-radius: 4px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink);
    background: var(--yellow);
    transition: background-color .2s ease, transform .2s ease;
}

.btn:hover {
    background: #ffd84d;
    transform: translateY(-2px);
}

.btn-ghost {
    color: var(--text);
    background: transparent;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* ---------- Barra superior ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 28px;
    padding-bottom: 28px;
}

.logo {
    display: inline-block;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.15;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
}

.logo span {
    display: block;
}

.logo span:first-child::after {
    content: "";
    display: inline-block;
    width: 22px;
    height: 3px;
    margin-left: 8px;
    vertical-align: middle;
    background: var(--yellow);
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav .btn {
    padding: 11px 20px;
    font-size: 0.78rem;
}

/* ---------- Hero (listado del blog) ---------- */

.hero {
    position: relative;
    isolation: isolate;
}

.hero::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    width: max(390px, calc(50vw - var(--wrap) / 2 + 390px));
    background-color: var(--panel);
    background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
    background-size: 18px 18px;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px 320px;
    align-items: center;
    min-height: 520px;
    padding-bottom: 72px;
}

.hero-copy {
    padding-right: 40px;
}

.hero-copy h1 {
    margin: 0 0 18px;
    font-size: clamp(2.2rem, 4.6vw, 3.4rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.hero-copy .intro {
    margin: 0 0 32px;
    max-width: 500px;
    color: var(--muted);
    font-size: 1.1rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.terminal {
    margin: 28px 0 0;
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--muted);
}

.terminal .prompt {
    color: var(--cyan);
}

.terminal .out {
    color: var(--text);
}

.cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    margin-left: 4px;
    vertical-align: text-bottom;
    background: var(--yellow);
    animation: parpadeo 1.1s steps(1) infinite;
}

@keyframes parpadeo {
    50% { opacity: 0; }
}

.hero-book {
    display: flex;
    justify-content: flex-end;
    transform: translateX(36px);
}

.hero-book .book {
    width: 240px;
}

.hero-panel {
    padding-left: 72px;
    text-align: center;
}

.hero-panel h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--yellow);
}

.wave {
    display: block;
    width: 96px;
    height: 14px;
    margin: 10px auto 30px;
}

.topics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.topics li {
    padding: 8px 6px;
    border: 1px solid var(--panel-line);
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: #dbe5ff;
}

/* ---------- Libro 3D ---------- */

.book {
    position: relative;
    display: block;
    margin: 0;
    aspect-ratio: 2 / 3;
    transform: perspective(1200px) rotateY(-24deg);
    transform-style: preserve-3d;
    transition: transform .45s ease;
}

a.book:hover,
.book:hover {
    transform: perspective(1200px) rotateY(-8deg);
}

.book img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px 4px 4px 2px;
    box-shadow: -18px 24px 40px -10px rgba(0, 0, 0, 0.7);
}

.book::after {
    content: "";
    position: absolute;
    top: 1.5%;
    left: 100%;
    width: 22px;
    height: 97%;
    transform-origin: left center;
    transform: rotateY(90deg);
    background: repeating-linear-gradient(90deg, #f1f1f1 0 2px, #c9c9c9 2px 3px);
}

.book::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 1;
    width: 10px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent);
    pointer-events: none;
}

/* ---------- Listado de artículos ---------- */

.section {
    padding: 96px 0 0;
}

.section-head {
    margin-bottom: 48px;
    text-align: center;
}

.section-head h2 {
    margin: 0;
    font-size: clamp(1.8rem, 3.6vw, 2.5rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.post-grid {
    display: grid;
    /* 2 columnas: los 10 artículos quedan en 5 filas parejas */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.post-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 30px 30px 28px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--surface), rgba(79, 209, 224, 0.05));
    transition: border-color .2s ease, transform .2s ease;
}

.post-card:hover,
.post-card:focus-within {
    border-color: rgba(79, 209, 224, 0.35);
    transform: translateY(-4px);
}

.post-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
}

.tag {
    padding: 3px 10px;
    border: 1px solid rgba(79, 209, 224, 0.35);
    border-radius: 999px;
    color: var(--cyan);
}

.post-card h3 {
    margin: 0 0 12px;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.3;
}

.post-card h3 a {
    text-decoration: none;
}

/* toda la tarjeta es clicable */
.post-card h3 a::after {
    content: "";
    position: absolute;
    inset: 0;
}

.post-card p {
    flex: 1;
    margin: 0 0 22px;
    font-size: 0.98rem;
    color: var(--muted);
}

.read-more {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--yellow);
}

/* ---------- CTA (bloque azul) ---------- */

.cta-box {
    position: relative;
    padding: 64px 32px;
    border-radius: 8px;
    text-align: center;
    background-color: var(--panel);
    background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
    background-size: 18px 18px;
}

.cta-box h2,
.cta-box h3 {
    margin: 0 0 16px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    line-height: 1.25;
}

.cta-box p {
    max-width: 600px;
    margin: 0 auto 8px;
    color: #c8d3ee;
}

.cta-box .actions {
    justify-content: center;
    margin-top: 26px;
}

/* ---------- Artículo ---------- */

.post-header {
    padding-top: 24px;
    padding-bottom: 48px;
}

.post-header h1 {
    max-width: 860px;
}

.crumbs {
    margin: 0 0 22px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
}

.crumbs a {
    color: var(--cyan);
    text-decoration: none;
}

.crumbs a:hover {
    text-decoration: underline;
}

.post-header h1 {
    margin: 0 0 20px;
    font-size: clamp(2rem, 4.4vw, 3.1rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.02em;
}

.byline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
}

.byline span::before {
    content: "·";
    margin-right: 18px;
    color: var(--line);
}

.byline span:first-child::before {
    content: none;
}

.post-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 64px;
    align-items: start;
}

.prose {
    max-width: 760px;
    color: var(--body);
    font-size: 1.1rem;
    line-height: 1.8;
}

.prose > * + * {
    margin-top: 1.2em;
}

.prose p {
    margin-bottom: 0;
}

.prose h2 {
    margin: 2.4em 0 0;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--text);
}

.prose h3 {
    margin: 1.8em 0 0;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

.prose a {
    color: var(--cyan);
    text-decoration-color: rgba(79, 209, 224, 0.4);
    text-underline-offset: 3px;
}

.prose a:hover {
    text-decoration-color: var(--cyan);
}

.prose a.btn {
    color: var(--ink);
    text-decoration: none;
}

.prose ul,
.prose ol {
    padding-left: 1.3em;
}

.prose li + li {
    margin-top: 0.45em;
}

.prose ul li::marker {
    color: var(--cyan);
}

.prose ol li::marker {
    font-family: var(--mono);
    font-size: 0.9em;
    color: var(--cyan);
}

/* código en línea */
.prose :not(pre) > code {
    padding: 2px 7px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.86em;
    color: #ffe48a;
    background: var(--surface);
    overflow-wrap: anywhere;   /* los comandos largos no desbordan en móvil */
}

/* TL;DR */
.tldr {
    margin: 0 0 2em;
    padding: 22px 26px;
    border: 1px solid rgba(255, 199, 0, 0.3);
    border-radius: 6px;
    background: rgba(255, 199, 0, 0.05);
}

.tldr strong {
    display: block;
    margin-bottom: 4px;
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--yellow);
}

/* Tabla de contenido */
.toc {
    padding: 22px 26px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
}

.toc p {
    margin: 0 0 10px;
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.toc ol {
    margin: 0;
    padding-left: 1.4em;
    font-size: 1rem;
}

.toc a {
    color: var(--body);
    text-decoration: none;
}

.toc a:hover {
    color: var(--cyan);
}

/* Bloques de código estilo editor */
.code {
    margin: 1.6em 0 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #080d1a;
    overflow: hidden;
}

.code-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
}

.code-bar i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.code-bar i:nth-child(1) { background: #ff5f57; }
.code-bar i:nth-child(2) { background: #febc2e; }
.code-bar i:nth-child(3) { background: #28c840; }

.code-bar span {
    margin-left: 8px;
}

.code pre {
    margin: 0;
    padding: 20px 22px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.86rem;
    line-height: 1.7;
    color: #dbe5ff;
    tab-size: 4;
}

/* Sin ligaduras en el código: "=>" y "===" deben verse tal como se escriben */
code,
pre {
    font-variant-ligatures: none;
}

.code pre code {
    font-family: inherit;
}

/* comentarios dentro del código */
.code .c {
    color: #6b7a99;
}

/* Avisos */
.note {
    padding: 18px 22px;
    border-left: 3px solid var(--cyan);
    border-radius: 0 6px 6px 0;
    background: var(--surface);
    font-size: 1rem;
}

.note.warn {
    border-left-color: var(--red);
}

.note.ok {
    border-left-color: var(--green);
}

/* Tablas */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.prose th,
.prose td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.prose th {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cyan);
    background: var(--surface);
}

.prose tr:last-child td {
    border-bottom: 0;
}

/* Bloque del libro dentro del artículo */
.book-callout {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 26px;
    align-items: center;
    margin-top: 2.4em;
    padding: 26px;
    border: 1px solid rgba(255, 199, 0, 0.25);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(20, 42, 92, 0.6), var(--surface));
}

.book-callout .book {
    width: 96px;
    transform: perspective(800px) rotateY(-18deg);
}

.book-callout h3 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.book-callout p {
    margin: 0 0 14px;
    font-size: 1rem;
}

.book-callout .btn {
    padding: 11px 20px;
    font-size: 0.75rem;
}

/* Lateral fijo */
.aside {
    position: sticky;
    top: 24px;
}

.aside-card {
    padding: 30px 26px;
    border-radius: 8px;
    text-align: center;
    background-color: var(--panel);
    background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
    background-size: 18px 18px;
}

.aside-card .book {
    width: 150px;
    margin: 0 auto 26px;
}

.aside-card h2 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.aside-card p {
    margin: 0 0 20px;
    font-size: 0.95rem;
    color: #c8d3ee;
}

.aside-card .btn {
    width: 100%;
    justify-content: center;
    padding: 13px 16px;
    font-size: 0.75rem;
}

.aside-card .btn + .btn {
    margin-top: 10px;
}

.aside-links {
    margin-top: 20px;
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
}

.aside-links p {
    margin: 0 0 10px;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.aside-links ol {
    margin: 0;
    padding-left: 1.4em;
    font-size: 0.92rem;
    line-height: 1.5;
}

.aside-links li + li {
    margin-top: 8px;
}

.aside-links a {
    color: var(--body);
    text-decoration: none;
}

.aside-links a:hover,
.aside-links a[aria-current] {
    color: var(--cyan);
}

/* Navegación anterior / siguiente */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 3em;
}

.post-nav a {
    display: block;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    transition: border-color .2s ease;
}

.post-nav a:hover {
    border-color: rgba(79, 209, 224, 0.35);
}

.post-nav small {
    display: block;
    margin-bottom: 4px;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--cyan);
}

.post-nav .next {
    text-align: right;
}

/* ---------- Footer ---------- */

footer {
    margin-top: 96px;
    padding: 32px 0 48px;
    border-top: 1px solid var(--line);
    text-align: center;
    font-size: 0.95rem;
    color: var(--muted);
}

footer p {
    margin: 0 0 6px;
}

footer a {
    color: var(--text);
    text-decoration-color: var(--yellow);
    text-underline-offset: 4px;
}

footer .mono {
    display: block;
    margin-bottom: 8px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--cyan);
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .hero-grid {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .hero-panel {
        display: none;
    }

    .hero::after {
        width: 220px;
    }

    .hero-book {
        transform: none;
    }

    .post-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 48px;
    }

    .aside {
        position: static;
        max-width: 760px;
    }

    .aside-card {
        display: grid;
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 28px;
        align-items: center;
        text-align: left;
    }

    .aside-card .book {
        width: 120px;
        margin: 0;
    }

    .aside-card .btn {
        width: auto;
    }

    .aside-card .btn + .btn {
        margin: 10px 0 0;
    }
}

@media (max-width: 760px) {
    body {
        font-size: 1rem;
    }

    .hero::after {
        display: none;
    }

    .hero-grid {
        grid-template-columns: 1fr;
        min-height: 0;
        padding-top: 8px;
        padding-bottom: 32px;
        text-align: center;
    }

    .hero-copy {
        padding-right: 0;
    }

    .hero-copy .intro {
        margin-left: auto;
        margin-right: auto;
    }

    .actions {
        justify-content: center;
    }

    .terminal {
        font-size: 0.72rem;
    }

    .hero-book {
        order: -1;
        justify-content: center;
        margin-bottom: 40px;
    }

    .hero-book .book {
        width: 170px;
    }

    .nav .btn-ghost {
        display: none;
    }

    .section {
        padding-top: 64px;
    }

    .post-grid {
        grid-template-columns: 1fr;
    }

    .post-card {
        padding: 24px 22px;
    }

    .prose {
        font-size: 1.02rem;
    }

    .prose h2 {
        font-size: 1.45rem;
    }

    .code pre {
        padding: 16px;
        font-size: 0.8rem;
    }

    .book-callout,
    .aside-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .book-callout .book,
    .aside-card .book {
        margin: 0 auto;
    }

    .post-nav {
        grid-template-columns: 1fr;
    }

    .post-nav .next {
        text-align: left;
    }

    .cta-box {
        padding: 48px 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .cursor { animation: none; }
    .book, .btn, .post-card { transition: none; }
}
