/* =========================================================
   IMAGO — Mobile & touch refinements
   Load last so it wins over component styles
   ========================================================= */

/* Safe areas (notch / home indicator) */
@supports (padding: max(0px)) {
  .main-header .header-content {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .main-nav {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .site-footer {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  #divprincipal {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

/* Tablet */
@media (max-width: 991.98px) {
  .header-content {
    padding: 0.7rem 1rem;
  }

  .header-right {
    gap: 8px;
  }

  .countdown-mundial .mundial-partidos {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-item {
    padding: 12px 14px;
    font-size: 0.75rem;
  }
}

/* Phones */
@media (max-width: 767.98px) {
  /* ---- Header: compact brand bar ---- */
  .main-header .d-flex {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .header-content {
    padding: 0.55rem 0.85rem;
  }

  .logo-container {
    gap: 10px;
    min-width: 0;
  }

  .logo-img,
  .logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .logo-full {
    display: none;
  }

  .brand-title {
    font-size: 1.2rem;
    letter-spacing: 0.1em;
  }

  .brand-subtitle {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    margin-top: 2px;
  }

  /* Hide bulky widgets; keep header clean */
  .header-right {
    display: none;
  }

  /* ---- Mobile quick chips (under header) ---- */
  .mobile-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 12px;
    background: var(--imago-header-elevated);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .mobile-chips::-webkit-scrollbar {
    display: none;
  }

  .mobile-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--imago-radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none !important;
    color: #fff !important;
    white-space: nowrap;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  .mobile-chip--mundial {
    background: linear-gradient(135deg, #14532d, #166534);
  }

  .mobile-chip--f1 {
    background: linear-gradient(135deg, #b91c1c, #171717);
  }

  .mobile-chip--gh {
    background: linear-gradient(135deg, #db2777, #9d174d);
  }

  .mobile-chip--tag {
    background: rgba(251, 146, 60, 0.18);
    border-color: rgba(251, 146, 60, 0.4);
    color: #fdba74 !important;
  }

  /* ---- Ticker ---- */
  .news-ticker {
    min-height: 36px;
  }

  .ticker-label {
    padding: 0 8px;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    max-width: 72px;
  }

  .ticker-label svg {
    display: none;
  }

  .ticker-label::after {
    border-width: 4px;
    right: -8px;
  }

  .ticker-content {
    margin-left: 4px;
  }

  .ticker-scroll {
    padding: 8px 0;
    animation-duration: 55s;
  }

  .ticker-item {
    font-size: 0.78rem;
    margin-right: 22px;
  }

  /* ---- Nav: scrollable with edge fade ---- */
  .main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .nav-container {
    justify-content: flex-start;
    padding: 0 8px;
    gap: 0;
    mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 16px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 16px), transparent 100%);
  }

  .nav-item {
    padding: 11px 12px;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    min-height: 44px;
  }

  .nav-item svg {
    display: none;
  }

  /* ---- Main layout ---- */
  .site-main {
    padding-top: 0.75rem;
    padding-bottom: 1.25rem;
  }

  #divprincipal {
    padding-left: 10px;
    padding-right: 10px;
  }

  #divprincipalrow {
    --bs-gutter-x: 0.75rem;
  }

  /* Center column first on mobile */
  #divprincipalrowcol,
  .layout-main {
    order: 1;
  }

  .layout-sidebar--right {
    order: 2;
    margin-top: 0.5rem;
  }

  /* ---- Language switcher ---- */
  .lang-switcher {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 6px 8px;
    margin-bottom: 0.75rem;
  }

  .lang-switcher::-webkit-scrollbar {
    display: none;
  }

  .lang-switcher a {
    padding: 4px;
    min-width: 36px;
    min-height: 36px;
  }

  .lang-switcher img {
    width: 24px;
  }

  /* ---- Article ---- */
  .article-card {
    padding: 1rem 0.9rem 1.35rem;
    border-radius: var(--imago-radius);
  }

  .article-card h1 {
    font-size: 1.35rem;
    letter-spacing: -0.01em;
  }

  .article-meta {
    gap: 0.4rem 0.75rem;
    font-size: 0.8rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.85rem;
  }

  .article-body {
    font-size: 1.05rem;
    line-height: 1.7;
  }

  .article-figure img {
    max-height: 240px;
    border-radius: var(--imago-radius-sm);
  }

  .article-related {
    margin-top: 1.75rem;
    padding-top: 1.15rem;
  }

  /* ---- List cards ---- */
  .news-card {
    margin-bottom: 12px;
    border-radius: 10px;
  }

  .news-card-thumb {
    width: 100%;
    min-height: 160px;
    max-height: 200px;
  }

  .news-card-body {
    padding: 12px 14px;
  }

  .news-card-title {
    font-size: 1rem;
  }

  .news-card-excerpt {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
  }

  .section-page-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.55rem;
  }

  /* ---- Homepage feed ---- */
  #feed section.py-4 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  #pnlHero {
    padding-top: 0 !important;
    padding-bottom: 0.5rem !important;
  }

  #pnlHero .row.g-4 {
    --bs-gutter-y: 0.75rem;
    --bs-gutter-x: 0.75rem;
  }

  #pnlHeroBig-card img.card-img-top {
    height: 200px !important;
  }

  #pnlHeroBig-card-body {
    padding: 0.9rem 1rem !important;
  }

  #pnlHeroBig-card-body h1 {
    font-size: 1.15rem !important;
    margin-bottom: 0.5rem !important;
  }

  #pnlHeroBig-card-body .card-text {
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  #pnlHeroContentSmall1 img.card-img-top {
    height: 140px !important;
  }

  #feed .card-body.p-4 {
    padding: 0.9rem !important;
  }

  #feed h3.card-title {
    font-size: 1.05rem !important;
  }

  #feed h4.card-title {
    font-size: 0.9rem !important;
  }

  #feed .card-text.text-secondary.small {
    -webkit-line-clamp: 3;
  }

  /* Horizontal news rows: keep side-by-side but tighter on mobile */
  #feed .row.g-0 .col-4 img {
    min-height: 96px;
    height: 100%;
    max-height: 120px;
    width: 100%;
    object-fit: cover;
  }

  #feed .row.g-0 .card-body {
    padding: 0.65rem 0.75rem !important;
  }

  #feed .row.g-0 .card-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8rem !important;
  }

  /* 4-col card grids → 1 col on phone */
  #feed .col-lg-3.col-md-4.col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  #feed .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  #feed section > .container > .d-flex.align-items-center {
    margin-bottom: 0.85rem !important;
  }

  #feed section > .container > .d-flex .fw-bold,
  #feed section > .container > .d-flex span.fw-bold {
    font-size: 0.75rem !important;
  }

  /* ---- Side widgets ---- */
  .social-badges {
    gap: 8px;
    margin-bottom: 12px;
  }

  .channel-badge {
    padding: 10px 14px;
    font-size: 0.72rem;
    min-height: 40px;
  }

  .noticias-hoy-container,
  .noticias-leidas-container {
    border-radius: var(--imago-radius);
    margin-bottom: 0.85rem;
  }

  .columnist-card {
    padding: 1rem 0.85rem;
  }

  .columnist-card__photo {
    width: 84px;
    height: 84px;
  }

  /* ---- Ads: no empty placeholder boxes ---- */
  .ad-slot {
    margin: 8px 0;
    min-height: 0;
    padding: 0;
  }

  .ad-slot--sidebar {
    min-height: 0;
    max-width: 100%;
  }

  .ad-slot--in-article {
    min-height: 0;
    margin: 0.85rem 0;
  }

  .ad-slot--banner {
    min-height: 0;
  }

  .footer-ad-wrap {
    margin-bottom: 1rem;
    padding: 0 10px;
  }

  /* ---- Footer ---- */
  .site-footer {
    padding: 2rem 0 1.25rem;
    margin-top: 2rem;
  }

  .site-footer .row > [class*="col-"] {
    margin-bottom: 1.25rem;
  }

  .site-footer__brand {
    font-size: 1.35rem;
  }

  .site-footer__social {
    gap: 8px;
  }

  .site-footer__social-btn {
    padding: 10px 14px;
    min-height: 40px;
  }

  .site-footer__bottom {
    text-align: center;
  }

  .site-footer__legal-links a {
    display: inline-block;
    padding: 6px 4px;
    min-height: 36px;
  }

  /* ---- Pagination ---- */
  .pagination-bar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .pagination-bar .btn {
    width: 100%;
    min-height: 44px;
    text-align: center;
  }

  /* Disable hover lift on touch (less jank) */
  #pnlHero .card:hover,
  .news-card:hover,
  .noticias-leidas-container:hover {
    transform: none;
  }
}

/* Very small phones */
@media (max-width: 379.98px) {
  .brand-subtitle {
    display: none;
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .logo-img,
  .logo-mark {
    width: 36px;
    height: 36px;
  }

  .ticker-label {
    max-width: 56px;
    font-size: 0.55rem;
  }

  .article-card h1 {
    font-size: 1.2rem;
  }

  #pnlHeroBig-card img.card-img-top {
    height: 170px !important;
  }
}

/* Desktop: hide mobile chips row */
@media (min-width: 768px) {
  .mobile-chips {
    display: none !important;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ticker-scroll {
    animation: none;
  }

  .logo-container:hover .logo-img,
  .logo-container:hover .logo-mark,
  .news-card:hover,
  #pnlHero .card:hover {
    transform: none;
  }
}
