/* TechCiência v3.5.2 — revisão responsiva e de contraste.
 * Carregado depois de todos os temas para corrigir conflitos entre versões. */

/* Menu independente do stacking context do header, inclusive no iOS Safari. */
@media (max-width: 1120px) {
  body > .mobile-menu {
    position: fixed !important;
    inset: var(--header-height, 82px) 0 0 !important;
    z-index: 1000 !important;
    padding: 0 !important;
    width: 100% !important;
    height: calc(100dvh - var(--header-height, 82px)) !important;
    max-height: calc(100dvh - var(--header-height, 82px));
    overflow: hidden !important;
    background: rgba(3, 19, 35, .68) !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
  }
  body > .mobile-menu.is-open:not([hidden]) {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto;
  }
  body > .mobile-menu .mobile-menu__inner {
    display: block;
    height: 100%;
    max-height: 100%;
    width: min(88vw, 390px) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: max(30px, env(safe-area-inset-bottom));
  }
  body.menu-open { overflow: hidden !important; }
  .menu-toggle { position: relative; z-index: 3; touch-action: manipulation; }
  .mobile-menu__head,
  .mobile-menu__footer,
  .mobile-menu__languages { display: flex; }
  .mobile-menu__nav > a { grid-template-columns: minmax(0,1fr) auto !important; line-height: 1.3 !important; }
  .mobile-menu__nav > a span { width: auto; }
}

/* Etiquetas sobre painéis escuros: fundo branco exige texto escuro. */
body:not(.page-home) .page-hero .pill-row > span {
  color: #103a56 !important;
  background: #f2fbfd !important;
  border: 1px solid #a3d9df !important;
  font-size: clamp(.78rem, 3.5vw, .92rem);
  font-weight: 750;
  line-height: 1.35;
  max-width: 100%;
  overflow-wrap: anywhere;
}
body:not(.page-home) .page-hero .pill-row { gap: 9px; }
/* Color guardrails for surface-vs-text combinations. */
body:not(.page-home) .page-hero .page-hero__lead { color: #d9edf5 !important; }
body:not(.page-home) .post-card__body { min-width: 0; }
body:not(.page-home) .post-card__body :is(h2,h3,a) { overflow-wrap: anywhere; }
body:not(.page-home) .post-card__category { color: #087a85 !important; }
body:not(.page-home) .post-card p { color: #50667a !important; }
body:not(.page-home) .post-card :is(h2,h3) a { color: #0b6e80 !important; }

@media (max-width: 760px) {
  html { overflow-x: clip; }
  .container { width: min(calc(100% - 32px), var(--container, 1240px)); }
  .page-hero__grid,
  .split-story__grid,
  .news-grid { min-width: 0; }
  .page-hero__grid > *, .split-story__grid > * { min-width: 0; }
  .page-hero :is(h1,h2),
  .split-story :is(h2,h3),
  .post-card :is(h2,h3) { overflow-wrap: break-word; text-wrap: pretty; }
  .page-hero { padding-block: 46px 52px !important; }
  .page-hero__grid { gap: 28px !important; }
  .page-hero__media { width: 100%; margin: 0; }
  .page-hero__media img { width: 100%; height: auto; max-height: 390px; object-fit: cover; }
  .news-grid { grid-template-columns: minmax(0,1fr) !important; gap: 22px; }
  .news-grid .post-card { min-width: 0; overflow: hidden; }
  .news-grid .post-card__image { display: block; width: 100%; }
  .news-grid .post-card__image img { display: block; width: 100%; height: clamp(185px,55vw,240px); object-fit: cover; }
  .news-grid .post-card__body { padding: 20px 19px 22px; }
  .news-grid .post-card h2 { font-size: clamp(1.28rem,6vw,1.8rem); line-height: 1.2; letter-spacing: -.025em; }
  .news-grid .post-card p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    font-size: .96rem;
    line-height: 1.6;
  }
  .news-grid .post-card__category { font-size: .72rem; line-height: 1.45; letter-spacing: 0; }
  /* All Brazil/Timor bridge variants: flow layout, never intersect content. */
  .country-bridge,
  .page-home .country-bridge,
  .country-bridge--about {
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    gap: 14px;
    min-height: 0 !important;
    height: auto !important;
    padding: 20px 16px !important;
    isolation: isolate;
    border-radius: 22px;
  }
  .country-bridge__card,
  .page-home .country-bridge__card,
  .country-bridge--about .country-bridge__card {
    position: relative !important;
    inset: auto !important;
    flex: none;
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 54px minmax(0,1fr) !important;
    grid-template-rows: auto auto !important;
    align-content: center;
    align-items: center;
    gap: 3px 12px !important;
    padding: 17px 15px !important;
    border-radius: 16px;
    animation: none !important;
    transform: none !important;
    backdrop-filter: none;
  }
  .country-bridge__flag-wrap,
  .page-home .country-bridge__flag-wrap {
    grid-column: 1 !important;
    grid-row: 1 / 3 !important;
    width: 50px !important;
    height: 44px !important;
    border-radius: 11px;
  }
  .country-bridge__flag-wrap img { max-width: 44px; }
  .country-bridge__card strong,
  .page-home .country-bridge__card strong {
    grid-column: 2 !important;
    grid-row: 1 !important;
    font-size: clamp(.95rem,4.1vw,1.06rem) !important;
    line-height: 1.25;
  }
  .country-bridge__card small,
  .page-home .country-bridge__card small {
    grid-column: 2 !important;
    grid-row: 2 !important;
    max-width: none;
    font-size: clamp(.78rem,3.25vw,.88rem) !important;
    line-height: 1.45;
    overflow-wrap: break-word;
  }
  .country-bridge__hub,
  .page-home .country-bridge__hub {
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    flex: none;
    align-self: center;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: min(210px, 80%) !important;
    height: auto !important;
    min-height: 92px !important;
    padding: 19px 20px !important;
    border-radius: 52px;
  }
  .country-bridge__hub strong,
  .page-home .country-bridge__hub strong { font-size: .94rem !important; line-height: 1.3; }
  .country-bridge__hub small,
  .page-home .country-bridge__hub small { display: block !important; font-size: .73rem; line-height: 1.4; }
  .country-bridge__hub-ring,
  .country-bridge__hub-dot,
  .country-bridge__orbit,
  .country-bridge__stream,
  .country-bridge__node,
  .country-bridge__signal { pointer-events: none; }
  .country-bridge__hub-dot { display: none; }
  .country-bridge__hub-ring { inset: 8px; }
  .country-bridge__orbit { opacity: .23; }
  /* No mid-hub overlap and no absolutely positioned text in the small cards. */
  .split-story__media--bridge { width: 100%; min-width: 0; }
  .split-story__grid { gap: 26px; }
  /* Floating chat must not obscure long lines or feature carousels. */
  .contact-chat { right: max(10px, env(safe-area-inset-right)) !important; bottom: max(12px, env(safe-area-inset-bottom)) !important; }
  .contact-chat__launcher { width: 52px !important; height: 52px !important; }
  .contact-chat__launcher svg { width: 23px; height: 23px; }
  .contact-chat__panel { max-width: calc(100vw - 24px); max-height: min(76dvh, 680px); }
}
@media (max-width: 380px) {
  .container { width: min(calc(100% - 28px),var(--container,1240px)); }
  .page-hero__grid { gap: 22px !important; }
  .pill-row span { padding: 9px 12px; }
  .country-bridge { padding: 16px 12px !important; }
  .country-bridge__card { padding: 13px 12px !important; }
}
@media (prefers-reduced-motion: reduce) {
  body > .mobile-menu,
  body > .mobile-menu .mobile-menu__inner { transition: none !important; }
}

/* Destaques do hero: cards suficientemente largos para leitura no celular.
   O auto-scroll e o avanço automático permanecem controlados pelo JS 3.5.1. */
@media (max-width: 760px) {
  .page-home .spotlight-hero__bottom-inner {
    display: grid !important;
    grid-template-columns: 69px minmax(0,1fr) !important;
    gap: 10px !important;
    min-height: 116px;
  }
  .page-home .spotlight-hero__bottom { min-height: 116px; }
  .page-home .spotlight-hero__meta { min-width: 0; }
  .page-home .spotlight-hero__meta-label { font-size: .58rem; line-height: 1.4; }
  .page-home .spotlight-hero__meta-row { white-space: nowrap; }
  .page-home .spotlight-hero__chapters-wrap { min-width: 0; }
  .page-home .spotlight-chapter {
    box-sizing: border-box;
    flex: 0 0 138px !important;
    min-width: 138px !important;
    padding: 14px 13px !important;
  }
  .page-home .spotlight-chapter__title {
    font-size: .74rem !important;
    line-height: 1.4;
    overflow-wrap: break-word;
  }
  .page-home .spotlight-hero__arrows { bottom: calc(100% + 14px); }
}
@media (max-width: 380px) {
  .page-home .spotlight-hero__bottom-inner { grid-template-columns: 62px minmax(0,1fr) !important; gap: 7px !important; }
  .page-home .spotlight-chapter { min-width: 128px !important; flex-basis: 128px !important; }
}
