/* Insight — camada global de responsividade, header e footer unificados.
   Carregada em todas as páginas via nav-links.js. Não altera identidade visual:
   apenas organiza, refina e corrige layout (sobretudo mobile). */

/* ---------- 0. Fluxo do documento ---------- 
   O runtime injeta `html,body{height:100%}` e `#dc-root{height:100%}`, o que
   prende a página à altura da janela: tudo que vem depois do conteúdo (footer,
   CTA final) era posicionado a partir do fim da 1ª tela e aparecia sobreposto
   no meio da página. A altura passa a ser sempre governada pelo conteúdo. */
html, body { height: auto !important; }
body { min-height: 100vh; }
#dc-root, #dc-root > .sc-host { height: auto !important; min-height: 0 !important; }

/* ---------- 1. Base fluida ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { -webkit-text-size-adjust: 100%; }
img, video, canvas, svg, iframe { max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, h5, h6, p, span, a, div, li, td, th, label, strong, em, button {
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}
h1, h2, h3, h4, p, li { text-wrap: pretty; }

/* Altura sempre governada pelo conteúdo: nada de corte por altura fixa (mobile). */
@media (max-width: 900px) {
  section, article, main, footer, header { height: auto !important; max-height: none !important; }
  [style*="height:100vh"], [style*="height: 100vh"] { height: auto !important; }
}
/* palavra animada / destaque dentro de títulos: nunca quebra no meio */
h1 span, h2 span, h3 span { overflow-wrap: normal; }
h1 span[style*="inline-block"], h2 span[style*="inline-block"], h3 span[style*="inline-block"] { white-space: nowrap; }
.ih-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.ih-scroll > table { min-width: 520px; }

/* Escala tipográfica fluida (sobrepõe os tokens em telas pequenas) */
@media (max-width: 900px) {
  :root {
    --text-5xl: clamp(2rem, 7.5vw, 3.75rem);
    --text-4xl: clamp(1.85rem, 6.5vw, 3rem);
    --text-3xl: clamp(1.6rem, 5.4vw, 2.375rem);
    --text-2xl: clamp(1.4rem, 4.6vw, 1.875rem);
    --text-xl: clamp(1.2rem, 3.8vw, 1.5rem);
    --text-lg: clamp(1.08rem, 3.2vw, 1.25rem);
  }
}

/* ---------- 2. Grades, flex e espaçamentos ---------- */
@media (max-width: 900px) {
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  [style*="display: flex"] > *, [style*="display:flex"] > * { min-width: 0; }
  [style*="display: grid"] > *, [style*="display:grid"] > * { min-width: 0; }
}

@media (max-width: 680px) {
  /* uma coluna — exceto grades de ícone + texto (primeira faixa pequena/auto) */
  [style*="grid-template-columns"]:not([style*="columns: auto"]):not([style*="columns:auto"]):not([style*="columns: 16px"]):not([style*="columns:16px"]):not([style*="columns: 18px"]):not([style*="columns:18px"]):not([style*="columns: 20px"]):not([style*="columns:20px"]):not([style*="columns: 22px"]):not([style*="columns:22px"]):not([style*="columns: 24px"]):not([style*="columns:24px"]):not([style*="columns: 28px"]):not([style*="columns:28px"]):not([style*="columns: 32px"]):not([style*="columns:32px"]):not([style*="columns: 36px"]):not([style*="columns:36px"]):not([style*="columns: 40px"]):not([style*="columns:40px"]):not([style*="columns: 44px"]):not([style*="columns:44px"]):not([style*="columns: 48px"]):not([style*="columns:48px"]):not(.ih-keep-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  [style*="display: flex"]:not(.ih-nowrap), [style*="display:flex"]:not(.ih-nowrap) { flex-wrap: wrap; }
  /* respiro lateral consistente */
  [style*="padding:"][style*="px 32px"], [style*="padding:"][style*="px 40px"],
  [style*="padding:"][style*="px 28px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  [style*="white-space: nowrap"]:not(.ih-nowrap):not(.anchor-nav):not(.anchor-nav *):not(.footer-marquee-track):not(.footer-marquee-item):not(.ie-footer-marquee-track):not(.ie-footer-marquee-item),
  [style*="white-space:nowrap"]:not(.ih-nowrap):not(.anchor-nav):not(.anchor-nav *):not(.footer-marquee-track):not(.footer-marquee-item):not(.ie-footer-marquee-track):not(.ie-footer-marquee-item) {
    white-space: normal !important;
  }
  .anchor-nav a, .anchor-nav button { white-space: nowrap !important; }
  /* nada com largura mínima maior que a tela */
  [style*="min-width: 3"], [style*="min-width:3"],
  [style*="min-width: 4"], [style*="min-width:4"],
  [style*="min-width: 5"], [style*="min-width:5"],
  [style*="min-width: 6"], [style*="min-width:6"],
  [style*="min-width: 7"], [style*="min-width:7"],
  [style*="min-width: 8"], [style*="min-width:8"] { min-width: 0 !important; }
  /* botões e campos nunca cortados */
  button, a[style*="border-radius"], input, select, textarea { max-width: 100% !important; }
  button, input, select, textarea { min-height: 44px; }
  a[style*="display: inline-flex"], a[style*="display:inline-flex"],
  button[style*="display: inline-flex"], button[style*="display:inline-flex"] { justify-content: center; }
  /* tabelas */
  table { width: 100% !important; }
}

@media (max-width: 420px) {
  [style*="padding:"][style*="px 32px"], [style*="padding:"][style*="px 40px"] {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* ---------- 3. Header global unificado ---------- */
.ih { background: #fff; border-bottom: 1px solid var(--ink-100); font-family: var(--font-body); position: relative; z-index: 60; }
.ih-bar { max-width: var(--container-max); margin: 0 auto; padding: 12px 32px; display: flex; align-items: center; gap: 20px; }
.ih-logo { display: flex; align-items: center; flex-shrink: 0; }
.ih-logo img { height: 48px; width: auto; object-fit: contain; }
.ih-links { display: flex; align-items: center; gap: 20px; margin-left: auto; flex-wrap: nowrap; }
.ih-links a { color: var(--text-secondary); text-decoration: none; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; padding: 6px 0; border-bottom: 2px solid transparent; }
.ih-links a:hover { color: var(--brand-primary); }
.ih-links a[aria-current="page"] { color: var(--brand-primary); font-weight: 700; border-bottom-color: var(--brand-primary); }
.ih-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.ih-cta { background: var(--brand-accent); color: #fff; border: none; border-radius: var(--radius-pill); padding: 11px 20px; font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.ih-cta:hover { filter: brightness(.94); }
.ih-burger { display: none; margin-left: auto; width: 46px; height: 46px; border: 1px solid var(--ink-100); border-radius: var(--radius-md); background: #fff; cursor: pointer; align-items: center; justify-content: center; flex-direction: column; gap: 5px; flex-shrink: 0; }
.ih-burger span { display: block; width: 20px; height: 2px; background: var(--ink-900); border-radius: 2px; transition: transform .18s cubic-bezier(.4,0,.2,1), opacity .18s; }
.ih-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ih-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.ih-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.ih-burger:focus-visible, .ih-links a:focus-visible, .ih-cta:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.ih-drawer { display: none; border-top: 1px solid var(--ink-100); background: #fff; padding: 12px 20px 20px; }
.ih-drawer[data-open="true"] { display: block; }
.ih-drawer nav { display: flex; flex-direction: column; }
.ih-drawer a { display: block; padding: 14px 4px; font-size: var(--text-base); font-weight: 600; color: var(--text-primary); text-decoration: none; border-bottom: 1px solid var(--ink-50); }
.ih-drawer a[aria-current="page"] { color: var(--brand-primary); }
.ih-drawer .ih-cta { width: 100%; justify-content: center; margin-top: 16px; padding: 14px 20px; }
.ih-badge { flex-shrink: 0; }

@media (max-width: 1080px) {
  .ih-links, .ih-actions, .ih-badge { display: none !important; }
  .ih-burger { display: flex; }
  .ih-bar { padding: 10px 20px; gap: 12px; }
  .ih-logo img { height: 40px; }
}
@media (max-width: 360px) { .ih-logo img { height: 34px; } }

/* ---------- 4. Barra âncora interna do curso ---------- */
.anchor-nav { overflow-x: auto !important; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.anchor-nav::-webkit-scrollbar { display: none; }
.ih-anchor-toggle { display: none; }

/* No mobile a barra âncora vira menu vertical: nenhum link fica fora da tela. */
@media (max-width: 900px) {
  .anchor-nav { overflow: visible !important; white-space: normal !important; }
  .anchor-nav .ih-anchor-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; min-height: 48px; padding: 12px 20px;
    background: #fff; border: none; border-bottom: 1px solid var(--ink-50);
    font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm);
    color: var(--brand-primary); cursor: pointer; text-align: left;
  }
  .anchor-nav .ih-anchor-caret { transition: transform .18s cubic-bezier(.4,0,.2,1); }
  .anchor-nav[data-ih-anchor="open"] .ih-anchor-caret { transform: rotate(180deg); }
  .anchor-nav > div {
    display: none !important; flex-direction: column !important; align-items: stretch !important;
    padding: 4px 20px 12px !important; gap: 0 !important;
    max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .anchor-nav[data-ih-anchor="open"] > div { display: flex !important; }
  .anchor-nav a {
    padding: 13px 4px !important; font-size: var(--text-sm) !important;
    border-bottom: 1px solid var(--ink-50); white-space: normal !important;
  }
  .anchor-nav a:last-child { border-bottom: none; }
}

/* ---------- 4b. Estado de erro de carregamento ---------- */
.ih-boot-error { max-width: 640px; margin: 0 auto; padding: 72px 24px; text-align: center; font-family: var(--font-body); }
.ih-boot-error h1 { font-family: var(--font-display); font-size: 24px; color: var(--ink-900); margin: 0 0 10px; }
.ih-boot-error p { font-size: 15px; line-height: 1.6; color: var(--text-secondary); margin: 0 0 24px; }
.ih-boot-error-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.ih-boot-error-actions a { text-decoration: none; font-weight: 700; font-size: 14px; padding: 12px 22px; border-radius: 999px; background: var(--brand-accent); color: #fff; min-height: 44px; display: inline-flex; align-items: center; }
.ih-boot-error-actions a + a { background: transparent; color: var(--brand-primary); border: 1.5px solid var(--brand-primary); }

/* ---------- 4c. Skeleton de carregamento ---------- */
.ih-skeleton { max-width: var(--container-max); margin: 0 auto; padding: 28px 20px 64px; }
.ih-skeleton-bar { height: 56px; border-bottom: 1px solid var(--ink-100); margin: -28px -20px 28px; background: #fff; }
.ih-skeleton-line, .ih-skeleton-card { background: linear-gradient(90deg, var(--ink-50) 25%, #fff 50%, var(--ink-50) 75%); background-size: 200% 100%; animation: ihShimmer 1.4s linear infinite; border-radius: 12px; }
.ih-skeleton-line { height: 22px; margin-bottom: 14px; }
.ih-skeleton-line.w-60 { width: 60%; }
.ih-skeleton-line.w-40 { width: 40%; }
.ih-skeleton-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 20px; margin-top: 28px; }
.ih-skeleton-card { height: 260px; }
@keyframes ihShimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ih-skeleton-line, .ih-skeleton-card { animation: none; } }

/* ---------- 5. Footer ---------- */
@media (max-width: 900px) {
  .footer-nav-grid, .ie-footer-nav-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 680px) {
  .footer-nav-grid, .ie-footer-nav-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
  .footer-bottom-bar, .ie-footer-bottom-bar { flex-direction: column; align-items: flex-start !important; }
  .footer-cta-buttons, .ie-footer-cta-buttons { flex-direction: column; width: 100%; }
  .footer-cta-buttons > a, .ie-footer-cta-buttons > a { width: 100%; justify-content: center; }
  footer form { flex-direction: column !important; align-items: stretch !important; }
  footer input[type="email"], footer input[type="text"] { width: 100% !important; }
  footer button[type="submit"] { width: 100%; justify-content: center; }
  footer label { display: flex; align-items: flex-start; gap: 8px; }
  footer a[href^="mailto:"], footer a[href^="tel:"] { overflow-wrap: anywhere; }
}
