/* Boas-vindas mobile (≤ 767px). Fora desse breakpoint nada aqui é exibido. */
#pmMobileHome,
#pmMobileDock,
#pmMhAppLoading {
  display: none;
}

@media (max-width: 767px) {
  :root {
    --pm-mh-blue: #2c77c9;
    --pm-mh-blue-ink: #1f63ad;
    --pm-mh-ink: #172438;
    --pm-mh-muted: #687586;
    --pm-mh-line: #ebe5dd;
    --pm-mh-warm: #f8f4ef;
    --pm-mh-pill: #f2f1f2;
    --pm-mh-dock-h: 72px;
    --pm-mh-safe-top: var(--pm-safe-top, env(safe-area-inset-top, 0px));
    --pm-mh-safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Puxar para baixo recarregaria a página inteira (e o mapa) quando o mapa demora a responder. */
  html,
  body {
    overscroll-behavior-y: none;
  }

  html.pm-mh-home,
  html.pm-mh-home body {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* App instalado no iPhone (iOS 26): com black-translucent, height 100% / 100dvh param antes do fim
     da tela e sobra uma faixa embaixo, pintada com o fundo do documento. 100vh vai até a borda física;
     a cor da barra inferior cobre o que o sistema ainda reservar. */
  @media (display-mode: standalone) {
    html {
      background-color: #fcf9f4;
    }

    html,
    body {
      height: 100vh;
    }

    html .pm-mh-dock::after {
      height: max(64px, env(safe-area-inset-bottom, 0px));
    }
  }

  /* O CSS da boas-vindas desktop nem é aplicado nesta largura (media no <link>). */
  #pmWelcomeOverlay {
    display: none !important;
  }

  html.pm-mh-home #pmMobileHome {
    display: flex;
  }

  html.pm-mh-ready #pmMobileDock {
    display: grid;
  }

  .pm-mh,
  .pm-mh-dock {
    font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    color: var(--pm-mh-ink);
  }

  .pm-mh button:not(.pm-lgpd-notice-btn),
  .pm-mh-dock button {
    font: inherit;
    color: inherit;
    border: 0;
    margin: 0;
    cursor: pointer;
  }

  .pm-mh {
    position: fixed;
    inset: 0;
    z-index: 8500;
    flex-direction: column;
    padding-top: calc(var(--pm-mh-safe-top) + 10px);
    padding-bottom: calc(var(--pm-mh-dock-h) + var(--pm-mh-safe-bottom));
    background:
      radial-gradient(120% 60% at 50% 0%, #f7f9fc 0%, rgba(247, 249, 252, 0) 70%),
      #f2f4f7;
    animation: pmMhIn 0.28s ease both;
  }

  @keyframes pmMhIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }

  /* Cabeçalho */
  .pm-mh__header {
    flex: none;
    padding: 0 16px;
  }

  .pm-mh__top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    min-height: 52px;
  }

  .pm-mh__logo {
    display: block;
    width: auto;
    height: 44px;
  }

  .pm-mh__weather {
    justify-self: center;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 500;
    color: var(--pm-mh-ink);
    white-space: nowrap;
  }

  .pm-mh__weather img {
    width: 22px;
    height: 22px;
    object-fit: contain;
  }

  .pm-mh__user {
    max-width: 140px;
    height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    background: #fff !important;
    color: #4d5a6b !important;
    font-size: 14px !important;
    box-shadow: 0 2px 10px rgba(23, 46, 77, 0.06);
  }

  .pm-mh__user span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pm-mh__search {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: clamp(42px, 5.6dvh, 48px);
    margin-top: clamp(8px, 1.4dvh, 12px) !important;
    padding: 0 18px;
    border-radius: 999px;
    background: #fff !important;
    color: #7a8594 !important;
    font-size: 14px !important;
    text-align: left;
    box-shadow: 0 6px 18px rgba(23, 46, 77, 0.08);
  }

  .pm-mh__search svg {
    flex: none;
    width: 21px;
    height: 21px;
    color: #263243;
  }

  .pm-mh__search span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Carrossel de sistemas */
  .pm-mh__cards {
    flex: none;
    display: flex;
    gap: 10px;
    margin-top: clamp(10px, 1.9dvh, 16px);
    padding: 0 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 12px;
    scrollbar-width: none;
  }

  .pm-mh__cards::-webkit-scrollbar {
    display: none;
  }

  .pm-mh__card {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: 226px;
    height: clamp(80px, 12.5dvh, 106px);
    padding: 12px 14px !important;
    border-radius: 18px;
    overflow: hidden;
    scroll-snap-align: start;
    background: #33475e !important;
    color: #fff !important;
    text-decoration: none;
    text-align: left;
    isolation: isolate;
  }

  .pm-mh__card[hidden] {
    display: none;
  }

  .pm-mh__card > img {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .pm-mh__card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(8, 18, 32, 0) 30%, rgba(8, 18, 32, 0.72) 100%);
  }

  .pm-mh__card strong {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
  }

  .pm-mh__card small {
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.25;
    opacity: 0.95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pm-mh__card-arrow {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    color: var(--pm-mh-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  }

  .pm-mh__card-arrow svg {
    width: 16px;
    height: 16px;
  }

  /* Abas */
  .pm-mh__tabs {
    flex: none;
    display: flex;
    gap: 6px;
    margin: clamp(8px, 1.6dvh, 14px) 12px 0;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    background: #fffcf8;
    box-shadow: 0 4px 14px rgba(23, 46, 77, 0.06);
    position: relative;
    isolation: isolate;
  }

  /* Camadas: fundo e rótulo inativos (0) → gota azul (1) → rótulo ativo (2). */
  .pm-mh__tab {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 36px;
    padding: 0 6px !important;
    border-radius: 999px;
    background: transparent !important;
    color: #6b7584 !important;
    font-size: 14px !important;
    font-weight: 400;
    white-space: nowrap;
  }

  .pm-mh__tab::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: var(--pm-mh-pill);
  }

  .pm-mh__tab > span {
    position: relative;
    z-index: 0;
  }

  .pm-mh__tab.is-active > span {
    z-index: 2;
    color: #fff;
    transition: color 0.24s ease 0.26s;
  }

  .pm-mh__tabs-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 1;
    width: 0;
    height: 36px;
    border-radius: 999px;
    background: linear-gradient(180deg, #3a86d6 0%, var(--pm-mh-blue) 100%);
    box-shadow:
      0 4px 12px rgba(44, 119, 201, 0.3),
      inset 0 1px 1px rgba(255, 255, 255, 0.28);
    pointer-events: none;
    transform-origin: center;
    will-change: left, width, transform;
  }

  /* Folha de conteúdo */
  .pm-mh__sheet {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: clamp(8px, 1.6dvh, 14px);
    border-radius: 28px 28px 0 0;
    background: linear-gradient(180deg, #faf7f3 0%, var(--pm-mh-warm) 100%);
    box-shadow: 0 -4px 20px rgba(23, 46, 77, 0.06);
    overflow: hidden;
  }

  .pm-mh__page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 20px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .pm-mh__page::-webkit-scrollbar {
    display: none;
  }

  /* Início e Turismo cabem na folha sem rolar: o vídeo e o cartão absorvem a sobra ou a falta de altura. */
  .pm-mh__page:is([data-mh-page="inicio"], [data-mh-page="turismo"]) {
    padding-top: clamp(14px, 2.8dvh, 24px);
    padding-bottom: clamp(12px, 2.4dvh, 20px);
    overflow: hidden;
  }

  .pm-mh__page[hidden] {
    display: none;
  }

  .pm-mh__page.is-active {
    animation: pmMhPage 0.22s ease both;
  }

  @keyframes pmMhPage {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }

  .pm-mh__kicker {
    margin: 0 0 clamp(4px, 1dvh, 8px);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--pm-mh-muted);
  }

  .pm-mh__title {
    margin: 0;
    font-size: clamp(20px, 2.8dvh, 23px);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--pm-mh-ink) !important;
  }

  .pm-mh__title--brand {
    font-size: clamp(22px, 3.4dvh, 29px);
    line-height: 1.17;
    color: var(--pm-mh-blue) !important;
  }

  .pm-mh__lead {
    margin: clamp(6px, 1.4dvh, 12px) 0 0;
    font-size: clamp(13.5px, 1.8dvh, 15px);
    line-height: 1.45;
    color: var(--pm-mh-muted);
  }

  .pm-mh__video {
    position: relative;
    flex: 0 1 auto;
    min-height: 0;
    margin-top: clamp(10px, 2.1dvh, 18px);
    aspect-ratio: 1.47;
    border-radius: 20px;
    overflow: hidden;
    background: #efe9e1 url("/assets/video/panorama-tutorial-poster.jpg") center / cover no-repeat;
  }

  .pm-mh__video video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .pm-mh__play {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--pm-mh-blue) !important;
    color: #fff !important;
    transform: translate(-50%, -50%);
    box-shadow: 0 8px 22px rgba(44, 119, 201, 0.4);
  }

  .pm-mh__play svg {
    width: 26px;
    height: 26px;
    margin-left: 3px;
  }

  .pm-mh__video.is-playing .pm-mh__play {
    display: none;
  }

  .pm-mh__footer {
    flex: none;
    margin-top: auto;
    padding-top: clamp(8px, calc(4.4dvh - 18px), 22px);
    font-size: 12px;
    line-height: 1.5;
    color: var(--pm-mh-muted);
  }

  .pm-mh__footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 22px;
    margin-top: 6px;
  }

  .pm-mh__footer-links a,
  .pm-mh__more {
    color: var(--pm-mh-blue);
    font-weight: 500;
    text-decoration: none;
  }

  /* Notícias */
  .pm-mh__feed {
    display: flex;
    flex-direction: column;
    margin-top: 22px;
  }

  .pm-mh__feed + .pm-mh__feed {
    margin-top: 10px;
    padding-top: 22px;
    border-top: 1px solid var(--pm-mh-line);
  }

  .pm-mh__feed-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--pm-mh-ink) !important;
  }

  .pm-mh__feed-title::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 2px;
    background: var(--pm-mh-blue);
  }

  .pm-mh__news {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
  }

  .pm-mh__news li + li {
    border-top: 1px solid var(--pm-mh-line);
  }

  .pm-mh__news a {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 0;
    color: inherit;
    text-decoration: none;
  }

  .pm-mh__news img {
    flex: none;
    width: 84px;
    height: 76px;
    border-radius: 12px;
    object-fit: cover;
    background: #e8eef4;
  }

  .pm-mh__news span {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
  }

  .pm-mh__news small {
    font-size: 11.5px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--pm-mh-blue);
  }

  .pm-mh__news strong {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--pm-mh-ink);
  }

  .pm-mh__news-skeleton {
    height: 76px;
    margin: 16px 0;
    border-radius: 12px;
    background: linear-gradient(90deg, #f0ebe4 0%, #f7f3ee 50%, #f0ebe4 100%);
    background-size: 200% 100%;
    animation: pmMhShimmer 1.2s linear infinite;
  }

  @keyframes pmMhShimmer {
    to { background-position: -200% 0; }
  }

  .pm-mh__empty {
    margin: 16px 0 0;
    font-size: 14px;
    color: var(--pm-mh-muted);
  }

  .pm-mh__more {
    align-self: flex-start;
    margin-top: 8px;
    padding: 8px 0;
    font-size: 14px;
  }

  /* Turismo */
  .pm-mh__tourism {
    position: relative;
    flex: 1 0 auto;
    display: flex;
    margin-top: clamp(10px, 2.1dvh, 18px);
    border: 3px solid #fff;
    border-radius: 22px;
    overflow: hidden;
    background: #16324f url("/assets/img/welcome-hub/turismo-ponte.jpg") center / cover no-repeat;
    box-shadow: 0 6px 18px rgba(13, 41, 66, 0.14);
    color: #fff !important;
    text-decoration: none;
    isolation: isolate;
  }

  .pm-mh__tourism::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(7, 22, 43, 0.78) 0%, rgba(7, 22, 43, 0.4) 45%, rgba(7, 22, 43, 0.1) 100%);
  }

  .pm-mh__tourism-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(8px, 1.6dvh, 14px);
    padding: clamp(14px, 2.6dvh, 22px) 18px;
    font-size: clamp(13px, 1.8dvh, 15px);
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.95);
  }

  .pm-mh__tourism-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: #fff;
    color: #07162b;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
  }

  .pm-mh__tourism-cta svg {
    width: 16px;
    height: 16px;
    color: var(--pm-mh-blue);
  }

  /* Acessos */
  .pm-mh__access {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
  }

  .pm-mh__access button {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 58px;
    padding: 0 16px 0 12px !important;
    border-radius: 16px;
    background: #fff !important;
    color: var(--pm-mh-ink) !important;
    font-size: 15px !important;
    font-weight: 500;
    text-align: left;
    box-shadow: 0 2px 10px rgba(23, 46, 77, 0.04);
  }

  .pm-mh__access button::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-top: 2px solid var(--pm-mh-blue);
    border-right: 2px solid var(--pm-mh-blue);
    transform: rotate(45deg);
  }

  .pm-mh__access-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #e8eff8;
    color: var(--pm-mh-blue-ink);
  }

  .pm-mh__access-icon svg {
    width: 19px;
    height: 19px;
  }

  /* Barra inferior — encosta no fim da tela, inclusive no home indicator do iPhone. */
  .pm-mh-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8600;
    box-sizing: border-box;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 8px;
    width: 100%;
    height: calc(var(--pm-mh-dock-h) + var(--pm-mh-safe-bottom));
    padding: 10px 12px calc(10px + var(--pm-mh-safe-bottom));
    background: #fcf9f4;
    box-shadow: 0 -6px 20px rgba(23, 46, 77, 0.07);
  }

  .pm-mh-dock::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: max(34px, env(safe-area-inset-bottom, 0px));
    background: inherit;
    pointer-events: none;
  }

  /* Mesmas camadas das abas: fundo inativo (0) → gota azul (1) → ícone e rótulo ativos (2). */
  .pm-mh-dock__btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    border-radius: 16px;
    background: transparent !important;
    color: #6b7584 !important;
    font-size: 12px !important;
    font-weight: 500;
  }

  .pm-mh-dock__btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background: #f3efe9;
  }

  .pm-mh-dock__btn > * {
    position: relative;
    z-index: 0;
  }

  .pm-mh-dock__btn[hidden] {
    display: none;
  }

  .pm-mh-dock__btn svg {
    width: 22px;
    height: 22px;
    color: var(--pm-mh-blue);
  }

  .pm-mh-dock__btn.is-active > * {
    z-index: 2;
    color: #fff;
    transition: color 0.24s ease 0.26s;
  }

  .pm-mh-dock__thumb {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 1;
    width: 0;
    height: var(--pm-mh-dock-h);
    border-radius: 16px;
    background: linear-gradient(180deg, #3a86d6 0%, var(--pm-mh-blue) 100%);
    box-shadow:
      0 6px 16px rgba(44, 119, 201, 0.3),
      inset 0 1px 1px rgba(255, 255, 255, 0.28);
    pointer-events: none;
    transform-origin: center;
    will-change: left, width, transform;
  }

  .pm-mh button:focus-visible,
  .pm-mh a:focus-visible,
  .pm-mh-dock button:focus-visible {
    outline: 2px solid var(--pm-mh-blue);
    outline-offset: 2px;
  }

  /* Carregamento do app/mapa depois de sair da boas-vindas */
  html.pm-mh-app-loading #pmMhAppLoading {
    display: flex;
  }

  .pm-mh-loading {
    position: fixed;
    inset: 0 0 calc(var(--pm-mh-dock-h) + var(--pm-mh-safe-bottom));
    z-index: 8495;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #f2f4f7;
    color: var(--pm-mh-muted);
    font: 500 14px/1.3 "Roboto", system-ui, sans-serif;
  }

  .pm-mh-loading__spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(44, 119, 201, 0.18);
    border-top-color: var(--pm-mh-blue);
    border-radius: 50%;
    animation: pmMhSpin 0.8s linear infinite;
  }

  @keyframes pmMhSpin {
    to { transform: rotate(360deg); }
  }

  .pm-mh__user[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
  }

  /*
   * Desfoque de vidro é caro demais para a GPU do celular. Os :not(#…) só elevam a
   * especificidade para vencer regras !important com IDs nos CSS do desktop.
   */
  *:not(#pm-mh-no-blur):not(#pm-mh-no-blur):not(#pm-mh-no-blur),
  *:not(#pm-mh-no-blur):not(#pm-mh-no-blur):not(#pm-mh-no-blur)::before,
  *:not(#pm-mh-no-blur):not(#pm-mh-no-blur):not(#pm-mh-no-blur)::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  /* Drawer fechado fica logo fora da tela e a sombra vazava sobre a borda direita. */
  body.pm-liquid-v2 #drawer.drawer:not(.open),
  .drawer:not(.open) {
    box-shadow: none !important;
  }

  /* Aviso LGPD acima da barra inferior */
  #pmMobileHome .pm-lgpd-notice-embedded {
    position: fixed;
    bottom: calc(var(--pm-mh-dock-h) + var(--pm-mh-safe-bottom));
    z-index: 30;
    padding: 0 12px 10px;
  }

  #pmMobileHome .pm-lgpd-notice-embedded .pm-lgpd-notice-float {
    top: -118px;
  }

  #pmMobileHome .pm-lgpd-notice-embedded .pm-lgpd-notice-float-img {
    width: 140px;
    height: 140px;
  }

  @media (max-width: 359px) {
    .pm-mh__logo { height: 38px; }
    .pm-mh__user { padding: 0 12px; max-width: 110px; }
    .pm-mh__tab { font-size: 13px !important; }
    .pm-mh__title--brand { font-size: 25px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .pm-mh,
    .pm-mh__page.is-active {
      animation: none;
    }

    .pm-mh-loading__spinner {
      animation-duration: 2.4s;
    }
  }
}
