/* =============================================
   MOBILE — max-width: 767px
   Reglas exclusivas para teléfonos
   ============================================= */

@media (max-width: 767px) {

  :root {
    --header-height: 56px;
    --gutter: 24px;
  }

  body { font-size: 0.9375rem; line-height: 1.65; }

  a, button { -webkit-tap-highlight-color: rgba(38, 208, 124, 0.15); }

  .container {
    max-width: 100%;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
  }

  /* ── HEADER ── */
  .site-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-height);
    width: 100%;
    background: #fff;
    border-bottom: 1px solid var(--color-border-light);
  }

  .site-header__inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
  }

  .site-logo__img { height: 26px; width: auto; }

  .nav-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px; height: 44px;
    padding: 10px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
  }

  .nav-toggle span {
    display: block; width: 100%; height: 2px;
    background: var(--color-primary); border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem var(--gutter) 1rem;
    box-shadow: var(--shadow-md);
    z-index: 200;
  }

  .site-nav.is-open { display: flex; }

  .site-nav a {
    display: block;
    padding: 0.875rem 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    min-height: 44px;
  }

  /* ── HOME HERO ── */
  .hero {
    background: linear-gradient(160deg, var(--color-bg-dark) 0%, var(--color-primary-light) 100%);
    color: #fff;
    text-align: center;
    padding: 2rem var(--gutter);
    width: 100%;
  }

  .hero__badge {
    display: inline-block;
    background: rgba(38,208,124,0.2);
    border: 1px solid rgba(38,208,124,0.4);
    color: var(--color-accent);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1rem;
  }

  .hero__title {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.22;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
  }

  .hero__subtitle {
    font-size: 0.9375rem;
    line-height: 1.55;
    opacity: 0.9;
  }

  /* ── POSTS GRID ── */
  .posts-section { padding: 2rem 0; }

  .section-header { margin-bottom: 1.5rem; }

  .section-header__label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent-dark);
    margin-bottom: 0.375rem;
  }

  .section-header__title { font-size: 1.3125rem; font-weight: 700; }

  .posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .post-card {
    display: flex; flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg);
  }

  .post-card__image { aspect-ratio: 16/9; overflow: hidden; }

  .post-card__image img {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: center 25%;
  }

  .post-card__body { padding: 1rem; display: flex; flex-direction: column; flex: 1; }

  .post-card__category {
    font-size: 0.6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--color-accent-dark); margin-bottom: 0.375rem;
  }

  .post-card__title { font-size: 1rem; font-weight: 700; line-height: 1.35; margin-bottom: 0.375rem; }
  .post-card__excerpt { font-size: 0.875rem; color: var(--color-text-muted); line-height: 1.55; flex: 1; margin-bottom: 0.75rem; }
  .post-card__meta { font-size: 0.75rem; color: var(--color-text-light); padding-top: 0.75rem; border-top: 1px solid var(--color-border-light); display: flex; gap: 0.75rem; }
  .post-card__read-more { font-size: 0.875rem; font-weight: 600; color: var(--color-primary); margin-top: 0.5rem; }

  /* ── ARTICLE HERO (sin imagen de fondo — banners klap tienen texto incrustado) ── */
  .article-hero {
    width: 100%;
    min-height: auto;
    background: var(--color-bg-dark);
    color: #fff;
    border-bottom: 4px solid var(--color-accent);
    overflow: hidden;
  }

  .article-hero__image { display: none !important; }
  .article-hero::after { display: none !important; }

  /* Imagen destacada debajo del hero (placeholders locales) */
  .article-featured-image {
    display: block !important;
    width: 100%;
    margin: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--color-bg-dark);
  }

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

  .article-hero .container {
    max-width: 100%;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
  }

  .article-hero__overlay { padding: 1.125rem 0 1rem; }

  .breadcrumb {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem;
    font-size: 0.75rem; margin-bottom: 0.75rem; opacity: 0.8;
  }

  .breadcrumb a { color: #fff; }
  .breadcrumb [aria-current="page"],
  .breadcrumb__sep:last-of-type { display: none; }

  .article-hero__category {
    display: inline-block;
    background: var(--color-accent);
    color: var(--color-primary-dark);
    font-size: 0.625rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 0.3rem 0.625rem;
    border-radius: var(--radius-full);
    margin-bottom: 0.625rem;
  }

  .article-hero__title {
    font-size: 1.3125rem;
    font-weight: 800;
    line-height: 1.28;
    letter-spacing: -0.02em;
    margin-bottom: 0.625rem;
    max-width: none;
  }

  .article-hero__meta {
    display: flex; flex-wrap: wrap; gap: 0.625rem;
    font-size: 0.8125rem; opacity: 0.85;
  }

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

  /* ── ARTICLE LAYOUT ── */
  .article-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.125rem 0 2rem;
    width: 100%;
  }

  /* ── TOC acordeón ── */
  .toc {
    order: -1;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    padding: 0;
  }

  .toc__toggle {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--color-bg-alt);
    border: none;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-primary);
    min-height: 48px;
  }

  .toc.is-open .toc__toggle { border-bottom: 1px solid var(--color-border); }

  .toc__panel { display: none; padding: 0.75rem 1rem 1rem; }
  .toc.is-open .toc__panel { display: block; }
  .toc.is-open .toc__toggle-icon { transform: rotate(180deg); }
  .toc__title { display: none; }

  .toc ol li { margin-bottom: 0.375rem; }
  .toc ol li a {
    font-size: 0.875rem;
    line-height: 1.45;
    padding: 0.375rem 0 0.375rem 0.625rem;
  }

  /* ── PROSE ── */
  .prose { font-size: 0.9375rem; line-height: 1.65; max-width: none; }
  .prose > * + * { margin-top: 0.875rem; }

  .prose h2 {
    font-size: 1.1875rem; font-weight: 700; line-height: 1.3;
    margin-top: 1.75rem; padding-bottom: 0.375rem;
    border-bottom: 2px solid var(--color-border-light);
    scroll-margin-top: calc(var(--header-height) + 1rem);
  }

  .prose h3 { font-size: 1.0625rem; font-weight: 700; margin-top: 1.25rem; }
  .prose h4 { font-size: 0.9375rem; font-weight: 700; margin-top: 1rem; }

  .prose .lead {
    font-size: 0.9375rem; line-height: 1.6;
    color: var(--color-text-muted);
    border-left: 3px solid var(--color-primary);
    padding-left: 0.875rem;
    margin-bottom: 1rem;
  }

  /* ── TABLAS → tarjetas apiladas (sin scroll horizontal) ── */
  .table-wrapper {
    position: relative;
    overflow: visible;
    margin: 1.25rem 0;
    width: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .table-wrapper::after { display: none; }

  .prose table {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 0.875rem;
    border-collapse: separate;
    border-spacing: 0;
  }

  .prose thead { display: none; }

  .prose tbody { display: block; }

  .prose tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg);
    box-shadow: 0 1px 4px rgba(0, 43, 73, 0.06);
  }

  .prose tbody tr:last-child { margin-bottom: 0; }

  /* Anula zebra striping de base — cada fila es una tarjeta */
  .prose tbody tr:nth-child(even) { background: var(--color-bg); }

  .prose tbody td {
    display: block;
    padding: 0;
    border-bottom: none;
    text-align: left;
  }

  /* Primera columna = título de la tarjeta */
  .prose tbody td:first-child {
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.35;
    padding: 0.75rem 1rem;
  }

  /* Resto de columnas = etiqueta + valor */
  .prose tbody td:not(:first-child) {
    display: grid;
    grid-template-columns: minmax(0, 44%) 1fr;
    gap: 0.625rem;
    align-items: start;
    padding: 0.625rem 1rem;
    border-top: 1px solid var(--color-border-light);
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--color-text);
  }

  .prose tbody td:not(:first-child)::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
  }

  /* Celdas con ✓ o — */
  .prose tbody td.table-cell--yes {
    color: var(--color-accent-dark);
    font-weight: 700;
  }

  .prose tbody td.table-cell--no {
    color: var(--color-text-light);
  }

  /* ── REASON CARDS ── */
  .reason-cards { display: grid; gap: 0.75rem; margin: 1.25rem 0; }

  .reason-card {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .reason-card__number {
    width: 32px; height: 32px;
    background: var(--color-accent); color: var(--color-primary-dark);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.875rem;
  }

  .reason-card__title { font-size: 0.9375rem; font-weight: 700; margin-bottom: 0.25rem; line-height: 1.3; }
  .reason-card__text { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.55; }

  /* ── STEPS ── */
  .steps { margin: 1.25rem 0; }

  .step {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    position: relative;
  }

  .step:not(:last-child)::before {
    content: ''; position: absolute;
    left: 17px; top: 36px; bottom: 0; width: 2px;
    background: var(--color-border);
  }

  .step__marker {
    width: 36px; height: 36px;
    background: var(--color-accent); color: var(--color-primary-dark);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.8125rem;
  }

  .step__title { font-size: 0.9375rem; font-weight: 700; margin-bottom: 0.25rem; }
  .step__text { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.55; }

  /* ── GRIDS ── */
  .actors-grid,
  .payment-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.625rem;
    margin: 1.25rem 0;
  }

  .actor-card,
  .payment-item {
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-alt);
  }

  .actor-card { text-align: center; }

  .actor-card__icon {
    width: 44px; height: 44px;
    background: var(--color-primary); color: #fff;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.125rem;
    margin: 0 auto 0.625rem;
  }

  .actor-card__name { font-size: 0.875rem; font-weight: 700; margin-bottom: 0.25rem; }
  .actor-card__desc { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.5; }

  .payment-item { display: flex; gap: 0.75rem; background: var(--color-bg); }

  .payment-item__icon {
    width: 40px; height: 40px;
    background: var(--color-bg-alt);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; flex-shrink: 0;
  }

  .payment-item__title { font-size: 0.875rem; font-weight: 700; }
  .payment-item__desc { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.5; }

  /* ── CALLOUTS ── */
  .callout {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: var(--radius-md);
    border-left: 4px solid;
  }

  .callout--info { background: #eef4f8; border-color: var(--color-primary); }
  .callout--tip { background: var(--color-accent-light); border-color: var(--color-accent); }
  .callout__title { font-size: 0.875rem; font-weight: 700; margin-bottom: 0.375rem; }
  .callout p { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.55; margin: 0; }

  /* ── TAGS ── */
  .tags {
    display: flex; flex-wrap: wrap; gap: 0.375rem;
    margin-top: 1.5rem; padding-top: 1rem;
    border-top: 1px solid var(--color-border);
  }

  .tag {
    font-size: 0.75rem;
    padding: 0.3rem 0.625rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
  }

  /* ── RELATED POSTS ── */
  .related-posts {
    background: var(--color-bg-alt);
    padding: 2rem 0;
    border-top: 4px solid var(--color-accent);
    width: 100%;
  }

  .related-posts__header { text-align: center; margin-bottom: 1.5rem; padding: 0 var(--gutter); }
  .related-posts__label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-accent-dark); margin-bottom: 0.375rem; }
  .related-posts__title { font-size: 1.25rem; font-weight: 800; color: var(--color-primary); margin-bottom: 0.375rem; }
  .related-posts__subtitle { font-size: 0.875rem; color: var(--color-text-muted); line-height: 1.5; }
  .related-posts__grid { margin-bottom: 1.25rem; }
  .related-posts__footer { padding: 0 var(--gutter); }
  .btn { width: 100%; min-height: 48px; }

  /* ── FOOTER ── */
  .site-footer {
    background: var(--color-bg-dark);
    color: rgba(255,255,255,0.7);
    padding: 1.5rem 0 1.25rem;
    width: 100%;
  }

  .site-footer__inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .site-footer__logo { height: 26px; filter: brightness(0) invert(1); }

  .site-footer__links {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .site-footer__links a {
    display: block;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: rgba(255,255,255,0.7);
    min-height: 40px;
  }

  .site-footer__copy {
    font-size: 0.75rem;
    opacity: 0.5;
    text-align: left;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
}

/* ── Pantallas muy pequeñas (320px) ── */
@media (max-width: 389px) {
  :root { --gutter: 16px; }

  .hero__title { font-size: 1.375rem; }
  .article-hero__title { font-size: 1.1875rem; }
  .prose { font-size: 0.875rem; }
  .prose h2 { font-size: 1.0625rem; }
  .prose table { font-size: 0.8125rem; }
}

/* Safe area iPhone */
@media (max-width: 767px) {
  @supports (padding: max(0px)) {
    .container {
      padding-left: max(var(--gutter), env(safe-area-inset-left));
      padding-right: max(var(--gutter), env(safe-area-inset-right));
    }
  }
}
