/*
Theme Name: Mediguía Código
Theme URI: https://mediguía.com/
Author: Mediguía
Description: Tema editorial de Mediguía hecho íntegramente con código. Portada tipo landing, categorías directas y configuración centralizada.
Version: 2.8
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: mediguia-codigo
*/

:root{
  --mg-bg:#ffffff;
  --mg-surface:#f6f9f8;
  --mg-ink:#17211f;
  --mg-muted:#66736f;
  --mg-line:#e2e9e6;
  --mg-accent:#2f7d70;
  --mg-accent-dark:#235f56;
  --mg-soft:#eaf4f1;
  --mg-radius:22px;
  --mg-shadow:0 16px 48px rgba(31,65,57,.08);
  --mg-max:1180px;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;background:var(--mg-bg);color:var(--mg-ink);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:17px;line-height:1.7;-webkit-font-smoothing:antialiased
}
a{color:inherit;text-decoration:none}
a:hover{color:var(--mg-accent)}
img{max-width:100%;height:auto;display:block}
button,input,textarea,select{font:inherit}
.mg-wrap{width:min(calc(100% - 36px),var(--mg-max));margin-inline:auto}
.mg-narrow{width:min(calc(100% - 36px),860px);margin-inline:auto}
.mg-main{min-height:60vh}

/* CABECERA */
.mg-header{position:sticky;top:0;z-index:20;background:rgba(255,255,255,.94);backdrop-filter:blur(14px);border-bottom:1px solid rgba(226,233,230,.9)}
.mg-header-inner{min-height:74px;display:flex;align-items:center;justify-content:space-between;gap:22px}
.mg-brand{display:flex;align-items:center;gap:12px;font-weight:850;letter-spacing:-.03em;font-size:1.15rem;white-space:nowrap}
.mg-brand-mark{width:36px;height:36px;border-radius:12px;background:var(--mg-accent);display:grid;place-items:center;color:#fff;font-weight:900}
.mg-brand img{max-height:42px;width:auto}
.mg-nav{display:flex;align-items:center;gap:20px;min-width:0}
.mg-nav ul{display:flex;gap:20px;list-style:none;margin:0;padding:0;align-items:center}
.mg-nav a{color:#34413d;font-weight:650;font-size:.94rem}
.mg-search-link{padding:9px 14px;border:1px solid var(--mg-line);border-radius:999px;background:#fff}

/* HERO */
.mg-hero{padding:78px 0 52px;background:linear-gradient(180deg,#f4faf8 0%,#fff 100%)}
.mg-hero-grid{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(300px,.75fr);gap:52px;align-items:center}
.mg-kicker{display:inline-flex;align-items:center;padding:8px 12px;border-radius:999px;background:var(--mg-soft);color:var(--mg-accent-dark);font-size:.8rem;font-weight:800;text-transform:uppercase;letter-spacing:.08em}
.mg-hero h1{font-size:clamp(2.5rem,6vw,5.1rem);line-height:.98;letter-spacing:-.065em;margin:18px 0 22px;max-width:820px}
.mg-hero p{font-size:clamp(1.05rem,2vw,1.3rem);color:var(--mg-muted);max-width:720px;margin:0 0 28px}
.mg-btn{display:inline-flex;align-items:center;justify-content:center;min-height:48px;padding:0 20px;border-radius:999px;font-weight:800;border:1px solid var(--mg-accent);background:var(--mg-accent);color:#fff}
.mg-btn:hover{background:var(--mg-accent-dark);color:#fff}
.mg-search-card{background:#fff;border:1px solid var(--mg-line);box-shadow:var(--mg-shadow);border-radius:28px;padding:28px}
.mg-search-card h2{font-size:1.25rem;margin:0 0 8px;letter-spacing:-.025em}
.mg-search-card p{margin:0 0 18px;color:var(--mg-muted);font-size:.95rem}
.mg-search-form{display:flex;gap:10px}
.mg-search-form input{width:100%;min-width:0;border:1px solid var(--mg-line);border-radius:14px;padding:13px 14px;outline:none;background:#fff}
.mg-search-form input:focus{border-color:var(--mg-accent);box-shadow:0 0 0 3px rgba(47,125,112,.11)}
.mg-search-form button{border:0;border-radius:14px;background:var(--mg-accent);color:#fff;padding:0 16px;font-weight:800;cursor:pointer}

/* SECCIONES */
.mg-section{padding:64px 0}
.mg-section-soft{background:var(--mg-surface)}
.mg-section-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:28px}
.mg-eyebrow{font-size:.78rem;font-weight:850;letter-spacing:.09em;text-transform:uppercase;color:var(--mg-accent)}
.mg-section h2,.mg-section-head h2{margin:5px 0 0;font-size:clamp(1.8rem,3.5vw,2.7rem);letter-spacing:-.045em;line-height:1.05}
.mg-section-intro{color:var(--mg-muted);max-width:680px;margin:10px 0 0}

/* PORTADA: TARJETAS DE ARTÍCULOS */
.mg-feed{display:grid;gap:18px}
.mg-card{display:grid;grid-template-columns:260px minmax(0,1fr);gap:28px;border:1px solid var(--mg-line);border-radius:var(--mg-radius);padding:18px;background:#fff;transition:transform .2s ease,box-shadow .2s ease,border-color .2s ease}
.mg-card:hover{transform:translateY(-2px);box-shadow:var(--mg-shadow);border-color:#cddbd7}
.mg-card-media{border-radius:16px;overflow:hidden;background:#eaf0ee;aspect-ratio:16/10}
.mg-card-media img{width:100%;height:100%;object-fit:cover}
.mg-card-placeholder{width:100%;height:100%;display:grid;place-items:center;background:linear-gradient(135deg,#eaf4f1,#f7faf9);color:var(--mg-accent);font-weight:900;font-size:2rem}
.mg-card-body{display:flex;flex-direction:column;justify-content:center;min-width:0;padding:6px 8px 6px 0}
.mg-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap;color:var(--mg-muted);font-size:.82rem;font-weight:650}
.mg-badge{color:var(--mg-accent-dark);background:var(--mg-soft);padding:5px 9px;border-radius:999px;font-weight:800}
.mg-card h3{font-size:clamp(1.35rem,2.4vw,2rem);line-height:1.15;letter-spacing:-.035em;margin:10px 0}
.mg-card p{color:var(--mg-muted);margin:0;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.mg-readmore{margin-top:15px;font-weight:850;color:var(--mg-accent-dark)}

/* CATEGORÍAS: ARTÍCULOS COMPLETOS, UNO DETRÁS DE OTRO */
.mg-category-stream{padding:64px 0 80px}
.mg-category-stream-head{max-width:850px;margin-bottom:42px}
.mg-category-stream-head h1{font-size:clamp(2.3rem,5vw,4.2rem);line-height:1.02;letter-spacing:-.055em;margin:7px 0 10px}
.mg-category-articles{display:grid;gap:58px}
.mg-category-article{padding-bottom:58px;border-bottom:1px solid var(--mg-line)}
.mg-category-article:last-child{border-bottom:0;padding-bottom:0}
.mg-category-article-head{max-width:920px;margin-bottom:22px}
.mg-category-article-head h2{font-size:clamp(2rem,4vw,3.5rem);line-height:1.04;letter-spacing:-.05em;margin:12px 0 0}
.mg-category-featured{margin:0 0 30px;border-radius:26px;overflow:hidden;border:1px solid var(--mg-line);background:var(--mg-surface)}
.mg-category-featured img{width:100%;max-height:620px;object-fit:cover}
.mg-category-content{max-width:860px}
.mg-category-article-foot{max-width:860px;margin-top:26px}
.mg-permalink{display:inline-flex;font-weight:800;color:var(--mg-accent-dark);font-size:.92rem}
.mg-permalink:hover{text-decoration:underline;text-underline-offset:3px}

/* CONTENIDO DE ARTÍCULOS */
.mg-content{font-size:1.06rem}
.mg-content h2{font-size:2rem;line-height:1.12;letter-spacing:-.035em;margin:2.2em 0 .7em}
.mg-content h3{font-size:1.45rem;line-height:1.18;letter-spacing:-.025em;margin:1.8em 0 .6em}
.mg-content p{margin:0 0 1.25em}
.mg-content ul,.mg-content ol{padding-left:1.35em;margin:0 0 1.4em}
.mg-content li{margin:.45em 0}
.mg-content blockquote{margin:1.7em 0;padding:18px 22px;border-left:4px solid var(--mg-accent);background:var(--mg-soft);border-radius:0 14px 14px 0}
.mg-content a{text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px;color:var(--mg-accent-dark)}
.mg-content table{width:100%;border-collapse:collapse;margin:1.5em 0;font-size:.95rem}
.mg-content th,.mg-content td{padding:12px;border-bottom:1px solid var(--mg-line);text-align:left;vertical-align:top}
.mg-content figure{margin:1.5em 0}

/* ARTÍCULO INDIVIDUAL */
.mg-article{padding:58px 0 80px}
.mg-article-head{margin-bottom:30px}
.mg-article-head h1{font-size:clamp(2.25rem,5vw,4.4rem);line-height:1.01;letter-spacing:-.055em;margin:14px 0 18px}
.mg-article-lead{font-size:1.18rem;color:var(--mg-muted);margin:0 0 18px}
.mg-featured{margin:30px 0;border-radius:26px;overflow:hidden;border:1px solid var(--mg-line);background:var(--mg-surface)}
.mg-featured img{width:100%;max-height:620px;object-fit:cover}
.mg-author{margin-top:42px;padding:24px;border:1px solid var(--mg-line);border-radius:20px;background:var(--mg-surface)}
.mg-author strong{display:block;font-size:1.05rem;margin-bottom:5px}
.mg-author p{margin:0;color:var(--mg-muted)}

/* AVISOS Y PUBLICIDAD */
.mg-disclaimer{border:1px solid #d7e5e1;background:#f7fbfa;border-radius:18px;padding:20px 22px;color:#4c5c57;font-size:.93rem}
.mg-disclaimer strong{color:var(--mg-ink)}
.mg-ad-slot{max-width:970px;margin:10px auto 58px;text-align:center;min-height:1px}
.mg-ad-placeholder{border:1px dashed #cbd8d4;border-radius:14px;padding:18px;color:var(--mg-muted);font-size:.8rem;background:#fbfcfc}

/* PÁGINAS, BÚSQUEDA Y ARCHIVOS */
.mg-page{padding:58px 0 80px}
.mg-page h1{font-size:clamp(2.2rem,5vw,4rem);letter-spacing:-.05em;line-height:1.02;margin:0 0 28px}
.mg-empty{padding:44px;border:1px dashed #cbd8d4;border-radius:20px;text-align:center;color:var(--mg-muted)}
.mg-back{display:inline-flex;margin-top:28px;font-weight:800;color:var(--mg-accent-dark)}

/* PIE */
.mg-footer{border-top:1px solid var(--mg-line);padding:42px 0 24px;background:#fbfcfc}
.mg-footer-grid{display:grid;grid-template-columns:1.4fr .8fr .8fr;gap:36px}
.mg-footer h3{font-size:1rem;margin:0 0 12px}
.mg-footer p{color:var(--mg-muted);max-width:560px;margin:8px 0}
.mg-footer ul{list-style:none;margin:0;padding:0;display:grid;gap:7px}
.mg-copyright{margin-top:30px;padding-top:18px;border-top:1px solid var(--mg-line);font-size:.84rem;color:var(--mg-muted)}

@media (max-width:900px){
  .mg-nav ul{display:none}
  .mg-hero{padding-top:52px}
  .mg-hero-grid{grid-template-columns:1fr;gap:28px}
  .mg-card{grid-template-columns:190px minmax(0,1fr)}
  .mg-footer-grid{grid-template-columns:1fr 1fr}
}
@media (max-width:640px){
  body{font-size:16px}
  .mg-wrap,.mg-narrow{width:min(calc(100% - 26px),var(--mg-max))}
  .mg-header-inner{min-height:66px}
  .mg-search-link{padding:8px 11px}
  .mg-hero{padding:42px 0 34px}
  .mg-search-form{flex-direction:column}
  .mg-search-form button{min-height:46px}
  .mg-card{grid-template-columns:1fr;padding:13px;gap:16px}
  .mg-card-media{aspect-ratio:16/9}
  .mg-card-body{padding:0 4px 7px}
  .mg-section{padding:48px 0}
  .mg-section-head{align-items:flex-start;flex-direction:column}
  .mg-category-stream{padding-top:44px}
  .mg-category-articles{gap:44px}
  .mg-category-article{padding-bottom:44px}
  .mg-footer-grid{grid-template-columns:1fr}
  .mg-article{padding-top:36px}
}

/* v2.6: categoría Salud limpia, sin cabecera ni mensajes vacíos */
.mg-category-clean{padding-top:32px;}
.mg-category-clean .mg-feed:empty{display:none;}

/* =========================================================
   v2.7 - PORTADA EN 3 COLUMNAS
   Solo afecta a la página principal.
   El resto del tema conserva su diseño anterior.
   ========================================================= */
.mg-home-articles{
  padding:28px 0 72px;
  background:#fff;
}

.mg-home-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:28px;
}

.mg-home-card{
  min-width:0;
  overflow:hidden;
  background:#fff;
  border:1px solid var(--mg-line);
  border-radius:14px;
  box-shadow:0 3px 14px rgba(20,35,31,.06);
  transition:transform .2s ease,box-shadow .2s ease,border-color .2s ease;
}

.mg-home-card:hover{
  transform:translateY(-3px);
  border-color:#d1dcda;
  box-shadow:0 12px 28px rgba(20,35,31,.11);
}

.mg-home-card-media{
  display:block;
  width:100%;
  aspect-ratio:16/6.2;
  overflow:hidden;
  background:#eef3f1;
}

.mg-home-card-media img{
  width:100%;
  height:100%;
  object-fit:cover;
  transition:transform .35s ease;
}

.mg-home-card:hover .mg-home-card-media img{
  transform:scale(1.025);
}

.mg-home-card-placeholder{
  width:100%;
  height:100%;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#edf6f3,#f8fbfa);
  color:var(--mg-accent);
  font-weight:850;
  letter-spacing:-.03em;
}

.mg-home-card-body{
  padding:14px 20px 20px;
}

.mg-home-category{
  display:inline-flex;
  align-items:center;
  padding:4px 9px;
  margin-bottom:10px;
  border-radius:5px;
  background:#2f7d70;
  color:#fff;
  font-size:.72rem;
  line-height:1.2;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.015em;
}

.mg-home-category:hover{color:#fff;filter:brightness(.96)}
.mg-home-category-salud{background:#2fb574}
.mg-home-category-coche{background:#2476f2}
.mg-home-category-hogar{background:#ff8a16}
.mg-home-category-mascotas{background:#ff5d79}
.mg-home-category-autonomos{background:#7757dd}

.mg-home-card-title{
  margin:0 0 8px;
  font-size:clamp(1.2rem,1.75vw,1.55rem);
  line-height:1.18;
  letter-spacing:-.035em;
}

.mg-home-card-title a:hover{color:var(--mg-accent-dark)}

.mg-home-card-excerpt{
  margin:0;
  color:#51605c;
  font-size:.97rem;
  line-height:1.45;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

.mg-home-empty{grid-column:1/-1}

@media (max-width:980px){
  .mg-home-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:22px}
}

@media (max-width:640px){
  .mg-home-articles{padding:18px 0 50px}
  .mg-home-grid{grid-template-columns:1fr;gap:18px}
  .mg-home-card-media{aspect-ratio:16/8.7}
  .mg-home-card-body{padding:14px 16px 18px}
}
