/* =====================================================
   Magazine - Estilos especificos
   Reutiliza las clases base de styles.css (.layout, .sidebar,
   .content, .btn, .crumbs, .pagination, .muted, etc.)
   ===================================================== */

.mag-h1 { margin: 0; font-size: 28px; }
.mag-lead { margin: 8px 0 0; font-size: 15px; max-width: 720px; }
.mag-dot { opacity: .55; margin: 0 4px; }

/* Layout override del magazine: sidebar mas estrecho */
.mag-layout { grid-template-columns: 260px 1fr; }

.mag-sidebar .mag-cat-list {
    list-style: none; padding: 0; margin: 0;
}
.mag-sidebar .mag-cat-list li { padding: 4px 0; }
.mag-sidebar .mag-cat-list a {
    color: var(--text, #222); text-decoration: none; font-size: 14px;
    display: block; padding: 6px 8px; border-radius: 8px;
}
.mag-sidebar .mag-cat-list a:hover { background: var(--soft, #f3f5f8); }
.mag-sidebar .mag-cat-list a.active {
    background: #eaf3ff; color: var(--accent, #1d7fd7); font-weight: 700;
}

/* Grid de tarjetas de posts */
.mag-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.mag-card {
    background: #fff;
    border: 1px solid var(--line, #e6e8ec);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .15s ease, transform .15s ease;
}
.mag-card:hover { border-color: #c6d5ea; transform: translateY(-1px); }

.mag-card-img-link { display: block; aspect-ratio: 16/9; overflow: hidden; background: var(--soft, #f3f5f8); }
.mag-card-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.mag-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.mag-card-cat {
    align-self: flex-start;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    color: var(--accent, #1d7fd7); text-decoration: none;
    padding: 2px 8px; border-radius: 999px; background: #eaf3ff;
}
.mag-card-cat:hover { text-decoration: underline; }

.mag-card-title { margin: 0; font-size: 17px; line-height: 1.3; }
.mag-card-title a { color: var(--text, #222); text-decoration: none; }
.mag-card-title a:hover { color: var(--accent, #1d7fd7); }

.mag-card-excerpt { margin: 0; color: var(--muted, #666); font-size: 13px; line-height: 1.5; }

.mag-card-meta { font-size: 12px; color: var(--muted, #666); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.mag-pagination { margin-top: 24px; }
.mag-empty { background: #fff; border: 1px solid var(--line, #e6e8ec); border-radius: 14px; padding: 30px; text-align: center; }

/* =====================================================
   Articulo individual
   ===================================================== */

.mag-post { max-width: 780px; margin: 16px auto 0; }

.mag-post-header { margin-bottom: 20px; }

/* Variante: header debajo del hero (cuando hay hero overlay) */
.mag-post-header--below {
    margin: 16px 0 24px;
}

.mag-post-cat {
    display: inline-block;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    color: var(--accent, #1d7fd7); text-decoration: none;
    padding: 3px 10px; border-radius: 999px; background: #eaf3ff; margin-bottom: 10px;
}
.mag-post-cat:hover { text-decoration: underline; }

.mag-post-title { font-size: 34px; line-height: 1.2; margin: 6px 0 10px; }
.mag-post-subtitle { font-size: 17px; color: var(--muted, #666); line-height: 1.55; margin: 0 0 14px; }
.mag-post-meta { font-size: 13px; color: var(--muted, #666); display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* =====================================================
   HERO CON OVERLAY (titulo encima de la imagen)
   Reduccion ~73% respecto al hero anterior (380 -> 320px)
   con titulo visible encima gracias a degradado oscuro.
   ===================================================== */
.mag-post-hero-wrap {
    position: relative;
    width: 100%;
    height: 320px;
    border-radius: 16px;
    overflow: hidden;
    margin: 8px 0 0;
    background: #1a1a1a;
}
.mag-post-hero-wrap .mag-post-hero {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
    max-height: none;
}
.mag-post-hero-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px 32px;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,.30) 60%, rgba(0,0,0,.72) 100%);
    color: #fff;
}
.mag-post-hero-cat {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #fff;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(29, 127, 215, .92);
    margin-bottom: 12px;
    backdrop-filter: blur(4px);
}
.mag-post-hero-cat:hover {
    background: rgba(29, 127, 215, 1);
    text-decoration: none;
}
.mag-post-hero-title {
    font-size: 32px;
    line-height: 1.2;
    margin: 0;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0,0,0,.5);
    font-weight: 800;
    max-width: 95%;
}

/* Fallback: hero antiguo si por alguna razon no se usa el wrap */
.mag-post-hero {
    width: 100%;
    max-height: 380px;
    object-fit: cover;
    border-radius: 16px;
    margin: 10px 0 24px;
    display: block;
}

/* Tipografia del cuerpo del articulo */
.mag-post-body { font-size: 17px; line-height: 1.7; color: #222; }
.mag-post-body > * + * { margin-top: 18px; }
.mag-post-body h2 { font-size: 26px; line-height: 1.25; margin-top: 36px; }
.mag-post-body h3 { font-size: 21px; line-height: 1.3; margin-top: 28px; }
.mag-post-body h4 { font-size: 18px; line-height: 1.3; margin-top: 22px; }
.mag-post-body p { margin: 0; }
.mag-post-body a { color: var(--accent, #1d7fd7); text-decoration: underline; text-underline-offset: 2px; }
.mag-post-body a:hover { text-decoration: none; }
.mag-post-body ul, .mag-post-body ol { margin: 0 0 0 24px; padding: 0; }
.mag-post-body li { margin: 6px 0; }
.mag-post-body img { max-width: 100%; height: auto; border-radius: 12px; display: block; margin: 8px auto; }
.mag-post-body blockquote {
    margin: 0; padding: 14px 18px; border-left: 4px solid var(--accent, #1d7fd7);
    background: #eef5ff; border-radius: 0 12px 12px 0; color: #1a3a5a;
}
.mag-post-body code {
    background: #f3f5f8; padding: 1px 6px; border-radius: 4px;
    font-family: 'Consolas','Menlo',monospace; font-size: 15px;
}
.mag-post-body pre {
    background: #0f0f0f; color: #d4d4d4; padding: 14px 16px; border-radius: 12px;
    overflow-x: auto; font-family: 'Consolas','Menlo',monospace; font-size: 14px; line-height: 1.5;
}
.mag-post-body pre code { background: transparent; padding: 0; color: inherit; }
.mag-post-body table { border-collapse: collapse; width: 100%; }
.mag-post-body th, .mag-post-body td { border: 1px solid var(--line, #e6e8ec); padding: 8px 12px; text-align: left; }
.mag-post-body th { background: var(--soft, #f3f5f8); font-weight: 700; }
.mag-post-body hr { border: 0; border-top: 1px solid var(--line, #e6e8ec); margin: 28px 0; }

/* Caja de autor al final del articulo */
.mag-author-box {
    margin-top: 36px; padding: 18px 20px;
    background: var(--soft, #f3f5f8); border-radius: 14px; border: 1px solid var(--line, #e6e8ec);
}
.mag-author-name { font-weight: 800; margin-bottom: 4px; }
.mag-author-bio { color: var(--muted, #666); font-size: 14px; line-height: 1.55; }

.mag-share { margin: 30px 0 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.mag-related { max-width: 1080px; margin: 50px auto 0; }

/* =====================================================
   Shortcodes: tarjeta de producto y tabla comparativa
   ===================================================== */

.mag-product-card {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 16px;
    background: #fff;
    border: 1px solid var(--line, #e6e8ec);
    border-radius: 14px;
    padding: 14px;
    margin: 22px 0;
    align-items: center;
}
.mag-product-img-link { display: block; aspect-ratio: 1/1; overflow: hidden; border-radius: 10px; background: var(--soft, #f3f5f8); }
.mag-product-img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 8px; }
.mag-product-body { display: flex; flex-direction: column; gap: 8px; }
.mag-product-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.mag-product-pill {
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: var(--soft, #f3f5f8); color: var(--muted, #666); font-weight: 600;
}
.mag-product-title { font-size: 17px; font-weight: 800; line-height: 1.3; }
.mag-product-prices { display: flex; align-items: baseline; gap: 10px; }
.mag-product-price { font-size: 22px; font-weight: 900; color: var(--text, #222); }
.mag-prod-old { color: var(--muted, #666); text-decoration: line-through; font-size: 14px; }
.mag-product-ctas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* Tabla comparativa */
.mag-prodtab-wrap { margin: 22px 0; overflow-x: auto; border: 1px solid var(--line, #e6e8ec); border-radius: 14px; background: #fff; }
.mag-prodtab { width: 100%; border-collapse: collapse; font-size: 14px; }
.mag-prodtab th {
    background: var(--soft, #f3f5f8); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--muted, #666); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line, #e6e8ec);
}
.mag-prodtab td { padding: 10px 12px; border-bottom: 1px solid var(--line, #e6e8ec); vertical-align: middle; }
.mag-prodtab tr:last-child td { border-bottom: 0; }
.mag-prodtab-img img { width: 64px; height: 64px; object-fit: contain; background: var(--soft, #f3f5f8); border-radius: 8px; display: block; }
.mag-prodtab-title { font-weight: 800; line-height: 1.3; }
.mag-prodtab-title a { color: inherit; text-decoration: none; }
.mag-prodtab-title a:hover { color: var(--accent, #1d7fd7); }
.mag-prodtab-meta { font-size: 12px; color: var(--muted, #666); margin-top: 2px; }
.mag-prodtab-price { white-space: nowrap; }
.mag-prodtab-ctas { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* =====================================================
   Responsive - Movil
   ===================================================== */

@media (max-width: 860px) {
    .mag-layout { grid-template-columns: 1fr; }
    .mag-sidebar {
        order: 2;
        position: static;
    }
    .mag-content { order: 1; }

    .mag-grid { grid-template-columns: 1fr; gap: 14px; }

    .mag-post-title { font-size: 26px; }
    .mag-post-subtitle { font-size: 15px; }
    .mag-post-body { font-size: 16px; }
    .mag-post-body h2 { font-size: 22px; }
    .mag-post-body h3 { font-size: 18px; }

    /* Hero overlay en movil */
    .mag-post-hero-wrap { height: 200px; border-radius: 12px; }
    .mag-post-hero-overlay { padding: 18px 20px; }
    .mag-post-hero-title { font-size: 22px; }
    .mag-post-hero-cat { font-size: 10px; padding: 3px 10px; margin-bottom: 10px; }

    .mag-product-card { grid-template-columns: 120px 1fr; gap: 12px; padding: 10px; }
    .mag-product-title { font-size: 15px; }
    .mag-product-price { font-size: 18px; }

    .mag-prodtab-img img { width: 48px; height: 48px; }
    .mag-prodtab-ctas { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .mag-h1 { font-size: 22px; }
    .mag-post-title { font-size: 22px; }
    .mag-post-hero-wrap { height: 170px; }
    .mag-post-hero-title { font-size: 19px; }
    .mag-product-card { grid-template-columns: 1fr; }
    .mag-product-img-link { aspect-ratio: 16/9; }
}

/* =====================================================
   Boton CTA ("Mira el precio") - shortcode [boton]
   ===================================================== */

.mag-cta-wrap {
    text-align: center;
    margin: 28px 0;
}

.mag-cta-button {
    display: inline-block;
    background: linear-gradient(180deg, #1d7fd7 0%, #0d63b3 100%);
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.3px;
    padding: 14px 32px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(29, 127, 215, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
    border: 0;
    cursor: pointer;
}

.mag-cta-button:hover {
    background: linear-gradient(180deg, #2a8de0 0%, #146cba 100%);
    box-shadow: 0 6px 18px rgba(29, 127, 215, 0.45);
    transform: translateY(-1px);
    color: #fff !important;
    text-decoration: none !important;
}

.mag-cta-button:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(29, 127, 215, 0.35);
}

@media (max-width: 480px) {
    .mag-cta-button {
        font-size: 15px;
        padding: 12px 24px;
        width: 100%;
        text-align: center;
    }
}

/* =====================================================
   Auto-enlaces de palabras clave
   ===================================================== */

.mag-autolink {
    color: var(--accent, #1d7fd7);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    text-decoration-color: rgba(29, 127, 215, 0.5);
    transition: text-decoration-color 0.12s ease, color 0.12s ease;
}

.mag-autolink:hover {
    text-decoration-style: solid;
    text-decoration-color: var(--accent, #1d7fd7);
    color: #0d63b3;
}

/* =====================================================
   Tarjetas de producto inyectadas por el agente Post Creator
   dentro del cuerpo del post (.mag-post-body .post-products)
   Estilo carrusel: filas con cards estrechas y altura uniforme.
   ===================================================== */

.mag-post-body .post-products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 28px 0;
}

.mag-post-body .post-product-card {
    background: #fff;
    border: 1px solid var(--line, #e6e8ec);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color .15s ease, transform .15s ease;
}
.mag-post-body .post-product-card:hover {
    border-color: #c6d5ea;
    transform: translateY(-1px);
}
.mag-post-body .post-product-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}
.mag-post-body .post-product-card img {
    width: 100%;
    height: 170px;
    object-fit: contain;
    background: var(--soft, #f5f7fa);
    padding: 10px;
    margin: 0;
    border-radius: 0;
    display: block;
}
.mag-post-body .post-product-info {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mag-post-body .post-product-info h3 {
    font-size: 14px;
    line-height: 1.35;
    margin: 0;
    color: var(--text, #222);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mag-post-body .post-product-shop {
    font-size: 11px;
    color: var(--muted, #6b7280);
    margin: 0;
}
.mag-post-body .post-product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent, #1d7fd7);
    margin: 0;
}

/* Disclosure de afiliacion (al final del post) */
.mag-post-body .post-affiliate-disclosure {
    margin-top: 40px;
    padding: 14px 18px;
    background: var(--soft, #f5f7fa);
    border-left: 3px solid var(--accent, #1d7fd7);
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted, #555);
}
.mag-post-body .post-affiliate-disclosure p { margin: 0; }

/* Imagenes inline del body NO escalan a full-width (override del generico) */
.mag-post-body .post-product-card img,
.mag-post-body .post-products img {
    /* las controla la regla especifica de arriba, NO la generica de .mag-post-body img */
    max-width: 100%;
}

/* Movil: cards mas estrechas */
@media (max-width: 720px) {
    .mag-post-body .post-products {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    .mag-post-body .post-product-card img { height: 140px; }
    .mag-post-body .post-product-info h3 { font-size: 13px; }
    .mag-post-body .post-product-price { font-size: 15px; }

    .mag-post-hero { max-height: 240px; }
}

/* =====================================================
   Carrusel "Productos relacionados" al final del post
   (.mag-related-products) - 1 fila con scroll horizontal,
   8 cards estrechas con scroll-snap suave en escritorio
   y desplazamiento natural en movil.
   ===================================================== */
.mag-related-products {
    margin: 40px 0 16px;
}
.mag-related-products .section-title {
    margin: 0 0 14px;
    font-size: 22px;
}

.mag-related-products-carousel {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 1fr);
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 4px 16px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}
.mag-related-products-carousel::-webkit-scrollbar {
    height: 8px;
}
.mag-related-products-carousel::-webkit-scrollbar-thumb {
    background: var(--line, #d3d8e0);
    border-radius: 4px;
}
.mag-related-products-carousel::-webkit-scrollbar-track {
    background: transparent;
}

.mag-rp-card {
    background: #fff;
    border: 1px solid var(--line, #e6e8ec);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    scroll-snap-align: start;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
    display: flex;
    flex-direction: column;
}
.mag-rp-card:hover {
    border-color: #c6d5ea;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(29, 127, 215, .08);
}
.mag-rp-img-wrap {
    background: var(--soft, #f5f7fa);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}
.mag-rp-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.mag-rp-body {
    padding: 10px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.mag-rp-title {
    margin: 0;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
    color: var(--text, #222);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mag-rp-meta {
    font-size: 11px;
    color: var(--muted, #6b7280);
    margin-top: 2px;
}
.mag-rp-price {
    margin-top: auto;
    padding-top: 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent, #1d7fd7);
}

@media (max-width: 720px) {
    .mag-related-products-carousel {
        grid-auto-columns: minmax(140px, 1fr);
        gap: 10px;
    }
    .mag-rp-title { font-size: 12px; }
    .mag-rp-price { font-size: 14px; }
    .mag-related-products .section-title { font-size: 19px; }
}
/* =====================================================
   HERO CON OVERLAY (titulo encima de la imagen)
   ===================================================== */
.mag-post-hero-wrap {
    position: relative;
    width: 100%;
    height: 320px;
    border-radius: 16px;
    overflow: hidden;
    margin: 8px 0 0;
    background: #1a1a1a;
}
.mag-post-hero-wrap .mag-post-hero {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
    max-height: none;
}
.mag-post-hero-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px 32px;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,.30) 60%, rgba(0,0,0,.72) 100%);
    color: #fff;
}
.mag-post-hero-cat {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #fff;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(29, 127, 215, .92);
    margin-bottom: 12px;
}
.mag-post-hero-cat:hover {
    background: rgba(29, 127, 215, 1);
    text-decoration: none;
}
.mag-post-hero-title {
    font-size: 32px;
    line-height: 1.2;
    margin: 0;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0,0,0,.5);
    font-weight: 800;
    max-width: 95%;
}

/* Movil */
@media (max-width: 860px) {
    .mag-post-hero-wrap { height: 200px; border-radius: 12px; }
    .mag-post-hero-overlay { padding: 18px 20px; }
    .mag-post-hero-title { font-size: 22px; }
    .mag-post-hero-cat { font-size: 10px; padding: 3px 10px; margin-bottom: 10px; }
}
@media (max-width: 480px) {
    .mag-post-hero-wrap { height: 170px; }
    .mag-post-hero-title { font-size: 19px; }
}