:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --border: #e5e7eb;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --accent-soft: #ecfdf3;
  --dark: #111827;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(17, 24, 39, .07);
  --max: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

.container {
  width: min(100% - 32px, var(--max));
  margin-inline: auto;
}


/* HEADER */

.site-header {
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
}

.logo-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.main-nav {
  display: none;
  align-items: center;
  gap: 24px;
}

.main-nav a {
  text-decoration: none;
  color: #4b5563;
  font-size: .9rem;
  font-weight: 600;
}

.main-nav a:hover {
  color: var(--accent-dark);
}

.header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 700;
}


/* HERO */

.hero {
  background: var(--dark);
  color: white;
  padding: 64px 0 68px;
}

.hero-label,
.section-label {
  color: var(--accent);
  font-family: "Space Grotesk", sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 780px;
  margin: 14px 0 18px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.1rem, 7vw, 4.2rem);
  line-height: 1.03;
  letter-spacing: -.045em;
}

.hero-text {
  max-width: 650px;
  margin: 0;
  color: #cbd5e1;
  font-size: 1.02rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 17px;
  border-radius: 10px;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 700;
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-secondary {
  border: 1px solid #475569;
  color: white;
}


/* FEATURED */

.featured-section {
  padding: 46px 0 20px;
}

.featured {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.featured-image {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

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

.featured-content {
  padding: 24px;
}

.tag {
  color: var(--accent-dark);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.featured h2 {
  margin: 8px 0 10px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.45rem, 4vw, 2.1rem);
  line-height: 1.15;
}

.featured h2 a,
.tutorial-card h3 a {
  text-decoration: none;
}

.featured p {
  margin: 0;
  color: var(--muted);
}

.article-info,
.small-info {
  color: #98a2b3;
  font-size: .76rem;
}

.article-info {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.read-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--accent-dark);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}


/* TUTORIALS */

.tutorials-section {
  padding: 44px 0 64px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.section-heading h2,
.categories-section h2 {
  margin: 7px 0 5px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.65rem, 4vw, 2.3rem);
  line-height: 1.12;
  letter-spacing: -.025em;
}

.section-heading p {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
}

.view-all {
  color: var(--accent-dark);
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.tutorial-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.tutorial-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(17,24,39,.045);
}

.tutorial-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #e5e7eb;
}

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

.tutorial-content {
  padding: 18px;
}

.tutorial-card h3 {
  margin: 7px 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.08rem;
  line-height: 1.28;
}

.tutorial-card p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}


/* CATEGORIES */

.categories-section {
  padding: 60px 0 70px;
  background: white;
  border-top: 1px solid var(--border);
}

.categories-section h2 {
  margin-bottom: 24px;
}

.categories-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.category {
  min-width: 0;
  padding: 17px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
}

.category:hover {
  border-color: #a7f3d0;
  background: var(--accent-soft);
}

.category strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: .98rem;
}

.category span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .76rem;
}


/* FOOTER */

.site-footer {
  background: var(--dark);
  color: white;
  padding: 42px 0 20px;
}

.footer-top {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.footer-logo {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
}

.footer-top p {
  max-width: 420px;
  margin: 8px 0 0;
  color: #94a3b8;
  font-size: .85rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.footer-links a {
  color: #cbd5e1;
  font-size: .8rem;
  text-decoration: none;
}

.ad-container {
  width: 100%;
  min-height: 90px;
  margin: 35px 0;
}

.footer-bottom {
  padding-top: 20px;
  border-top: 1px solid #293241;
  color: #64748b;
  font-size: .75rem;
}


/* TABLET */

@media (min-width: 620px) {

  .container {
    width: min(100% - 48px, var(--max));
  }

  .tutorial-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }

}


/* DESKTOP */

@media (min-width: 900px) {

  .main-nav {
    display: flex;
  }

  .header-button {
    display: none;
  }

  .hero {
    padding: 90px 0 96px;
  }

  .featured {
    display: grid;
    grid-template-columns: 1.08fr .92fr;
  }

  .featured-image {
    aspect-ratio: auto;
    min-height: 360px;
  }

  .featured-content {
    padding: 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .tutorial-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .footer-top {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

}

/* =========================================================
   HAPPYTUTOS — MEJORA GENERAL DE LECTURA DE ARTÍCULOS
   ========================================================= */

/* Estructura general */
.content-layout {
    max-width: 1120px;
    margin-inline: auto;
}

.content-layout > div {
    min-width: 0;
}

.content-layout article {
    max-width: 820px;
    margin: 0 auto;
}

/* Cabecera del artículo */
.article-hero {
    padding-top: 24px;
    margin-bottom: 34px;
}

.article-hero h1 {
    margin: 12px 0 22px;
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.12;
    letter-spacing: -0.035em;
}

/* Categoría */
.article-hero .card-category {
    display: inline-block;
    margin-bottom: 4px;
}

/* Información del artículo */
.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 18px;
    line-height: 1.5;
}

/* Imagen principal */
.article-main-image {
    margin: 0 0 42px;
}

.article-main-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 18px;
}

/* Cuerpo */
.article-body {
    font-size: 1.08rem;
    line-height: 1.85;
    color: inherit;
}

/* Párrafos */
.article-body p {
    margin: 0 0 1.45em;
}

/* Primer párrafo / introducción */
.article-body .intro-lead {
    font-size: 1.2rem;
    line-height: 1.75;
    margin-bottom: 2rem;
}

/* Subtítulos */
.article-body h2 {
    margin: 3rem 0 1.1rem;
    font-size: clamp(1.55rem, 4vw, 2.15rem);
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.article-body h3 {
    margin: 2.3rem 0 0.9rem;
    font-size: clamp(1.25rem, 3vw, 1.55rem);
    line-height: 1.3;
}

/* Listas */
.article-body ul,
.article-body ol {
    margin: 1.2rem 0 2rem;
    padding-left: 1.6rem;
}

.article-body li {
    margin-bottom: 0.85rem;
    padding-left: 0.25rem;
}

.article-body li:last-child {
    margin-bottom: 0;
}

/* Enlaces */
.article-body a {
    text-underline-offset: 3px;
}

/* Imágenes dentro del contenido */
.article-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2.2rem auto;
    border-radius: 14px;
}

/* Citas */
.article-body blockquote {
    margin: 2.2rem 0;
    padding: 1.2rem 1.4rem;
    border-left: 4px solid currentColor;
    border-radius: 0 12px 12px 0;
}

/* Código */
.article-body pre {
    overflow-x: auto;
    margin: 2rem 0;
    padding: 1.2rem;
    border-radius: 12px;
}

.article-body code {
    overflow-wrap: anywhere;
}

/* Tablas */
.article-body table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
}

.article-body th,
.article-body td {
    padding: 0.8rem;
    text-align: left;
}

/* Separadores */
.article-body hr {
    margin: 3rem 0;
}

/* Espacio antes del footer */
.content-layout {
    padding-bottom: 70px;
}

/* =========================================================
   MÓVIL
   ========================================================= */

@media (max-width: 700px) {

    .content-layout {
        padding-inline: 18px;
        padding-bottom: 55px;
    }

    .content-layout article {
        max-width: none;
    }

    .article-hero {
        padding-top: 18px;
        margin-bottom: 28px;
    }

    .article-hero h1 {
        font-size: clamp(1.85rem, 8vw, 2.45rem);
        line-height: 1.14;
        margin-top: 10px;
        margin-bottom: 20px;
    }

    .article-meta {
        gap: 7px 9px;
        font-size: 0.88rem;
    }

    .article-main-image {
        margin-bottom: 34px;
    }

    .article-main-image img {
        border-radius: 14px;
    }

    .article-body {
        font-size: 1.04rem;
        line-height: 1.82;
    }

    .article-body p {
        margin-bottom: 1.5em;
    }

    .article-body .intro-lead {
        font-size: 1.12rem;
        line-height: 1.75;
        margin-bottom: 1.8rem;
    }

    .article-body h2 {
        margin-top: 2.8rem;
        margin-bottom: 1rem;
    }

    .article-body h3 {
        margin-top: 2.2rem;
        margin-bottom: 0.85rem;
    }

    .article-body ul,
    .article-body ol {
        padding-left: 1.35rem;
        margin-top: 1rem;
        margin-bottom: 1.8rem;
    }

    .article-body li {
        margin-bottom: 0.9rem;
    }

    .article-body img {
        margin: 2rem auto;
        border-radius: 12px;
    }

    .article-body blockquote {
        margin: 2rem 0;
        padding: 1rem 1.1rem;
    }
}

/* =========================================================
   IMÁGENES DENTRO DE LOS ARTÍCULOS
   ========================================================= */

.article-body img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 520px;
    height: auto;
    object-fit: contain;
    margin: 2.8rem auto;
    border-radius: 14px;
}

/* En pantallas grandes, mantenerlas contenidas */
@media (min-width: 701px) {
    .article-body img {
        max-width: 650px;
    }
}

/* En móviles */
@media (max-width: 700px) {
    .article-body img {
        width: 100%;
        max-width: 100%;
        max-height: 420px;
        margin: 2.2rem auto;
        border-radius: 12px;
    }
}

/* =========================================================
   HAPPYTUTOS — MISMO DISEÑO PARA TODAS LAS IMÁGENES
   ========================================================= */

/* Imagen principal + imágenes internas */
.article-main-image img,
.article-body img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: 18px;
    object-fit: cover;
}

/* Imágenes internas: mismo ancho visual que la principal */
.article-body img {
    margin: 2.8rem auto;
}

/* Móvil: exactamente el mismo comportamiento */
@media (max-width: 700px) {

    .article-main-image img,
    .article-body img {
        width: 100%;
        max-width: 100%;
        height: auto;
        border-radius: 14px;
        object-fit: cover;
    }

    .article-body img {
        margin: 2.2rem auto;
    }
}

/* =========================================================
   NUEVOS ARTÍCULOS - PORTADA
   ========================================================= */

.article-slot {
  margin: 0;
}

.new-article-card {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr);
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
}

.new-article-image {
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.9rem;
}

.new-article-content {
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.new-article-content h2 {
  margin: 0.8rem 0 1rem;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  line-height: 1.15;
}

.new-article-content p {
  margin: 0 0 1.8rem;
  color: var(--muted);
  line-height: 1.7;
}

.new-article-link {
  width: fit-content;
  font-weight: 700;
  text-decoration: none;
}

.new-article-link:hover {
  text-decoration: underline;
}

@media (max-width: 700px) {

  .new-article-card {
    grid-template-columns: 1fr;
    border-radius: 16px;
  }

  .new-article-image {
    min-height: 240px;
  }

  .new-article-content {
    padding: 1.8rem;
  }

  .new-article-content h2 {
    font-size: 1.65rem;
  }

}


/* =========================================================
   ALINEACIÓN GLOBAL DE CONTENIDO
   Mantiene márgenes consistentes en todas las páginas
========================================================= */

main {
  width: 100%;
  overflow-x: hidden;
}

/* Contenedor general consistente */
main > .container,
main > section > .container {
  width: min(100% - 48px, 1180px);
  margin-inline: auto;
}

/* Evita que bloques internos se salgan horizontalmente */
main section,
main article,
.content-layout,
.article-body,
.new-article-card {
  max-width: 100%;
}

/* Imágenes y contenido multimedia nunca exceden el contenedor */
.article-body img,
.article-main-image img,
.new-article-image img,
main img {
  max-width: 100%;
  height: auto;
}

/* Mantener grids dentro del área visible */
.card-grid,
.tutorial-grid,
.categories-grid {
  max-width: 100%;
}

/* MÓVIL */
@media (max-width: 700px) {

  main > .container,
  main > section > .container {
    width: calc(100% - 36px);
  }

  main section {
    max-width: 100%;
  }

}

/* =========================================================
   MARGEN INTERNO UNIFORME EN BLOQUES DE CONTENIDO
========================================================= */

main section > .container {
  padding-inline: 24px;
  box-sizing: border-box;
}

main section > .container > * {
  box-sizing: border-box;
}

/* El contenido nunca debe tocar los bordes */
main section .section-head,
main section .card-grid,
main section .new-article-card,
main section .content-layout {
  width: 100%;
  box-sizing: border-box;
}

/* Textos dentro de tarjetas y bloques */
main section .card-body,
main section .new-article-content {
  box-sizing: border-box;
}

/* Móvil */
@media (max-width: 700px) {
  main section > .container {
    padding-inline: 18px;
  }
}


/* ===== ESPACIO PARA ADSENSE ENTRE CONTENIDOS ===== */
.ad-between-content {
  margin: 64px auto;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

@media (max-width: 700px) {
  .ad-between-content {
    margin: 44px auto;
    min-height: 140px;
  }
}

/* ===== TEXTO JUSTIFICADO EN ARTÍCULOS ===== */
.article-body p {
  text-align: justify;
}

/* ===== ADSENSE SUPERIOR ===== */
.ad-top-content {
  margin: 28px auto 48px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

@media (max-width: 700px) {
  .ad-top-content {
    margin: 22px auto 36px;
    min-height: 140px;
  }
}

/* ===== ESPACIADO ALTERNADO DE LOS BLOQUES ADSENSE ===== */

/* BLOQUE 1 — CABECERA: ESPACIO GRANDE */
.ad-top-content {
  margin: 80px auto;
}

/* BLOQUE 2 — BODY: ESPACIO NORMAL */
.ad-body-content {
  margin: 40px auto;
}

/* BLOQUE 3 — IN-ARTICLE: ESPACIO GRANDE */
.ad-between-content {
  margin: 80px auto;
}

/* BLOQUE 4 — FOOTER: ESPACIO NORMAL */
.ad-footer-content {
  margin: 40px auto;
}

@media (max-width: 700px) {

  /* BLOQUE 1 */
  .ad-top-content {
    margin: 55px auto;
  }

  /* BLOQUE 2 */
  .ad-body-content {
    margin: 28px auto;
  }

  /* BLOQUE 3 */
  .ad-between-content {
    margin: 55px auto;
  }

  /* BLOQUE 4 */
  .ad-footer-content {
    margin: 28px auto;
  }

}

/* ===== ESPACIO ENTRE CONTENIDO Y ANUNCIOS ===== */

.ad-top-content {
  min-height: 0;
  margin: 80px auto;
}

.ad-body-content {
  min-height: 0;
  margin: 40px auto;
}

.ad-between-content {
  min-height: 0;
  margin: 80px auto;
}

.ad-footer-content {
  min-height: 0;
  margin: 40px auto;
}

@media (max-width: 700px) {
  .ad-top-content {
    min-height: 0;
    margin: 55px auto;
  }

  .ad-body-content {
    min-height: 0;
    margin: 28px auto;
  }

  .ad-between-content {
    min-height: 0;
    margin: 55px auto;
  }

  .ad-footer-content {
    min-height: 0;
    margin: 28px auto;
  }
}

/* ===== ELIMINAR ESPACIOS EXTRA DE ADS ===== */

.ad-top-content,
.ad-body-content,
.ad-between-content,
.ad-footer-content {
  margin: 0 auto;
  min-height: 0;
}

@media (max-width: 700px) {
  .ad-top-content,
  .ad-body-content,
  .ad-between-content,
  .ad-footer-content {
    margin: 0 auto;
    min-height: 0;
  }
}
