/* CANDIDO ADVENTURE — V14.57 — Ajustes restritos a menus mobile horizontal.
   Não alterar posicionamento de cenário, sprites, colisões, hitboxes, multiplayer,
   regras de jogo, Firestore, recompensas, inventário ou imagens oficiais. */

/* Só em paisagem touch (incluindo emulação de celulares baixos em navegador). */
@media (orientation: landscape) and (pointer: coarse),
       (orientation: landscape) and (max-width: 900px) and (max-height: 520px) {
  /* A barra oficial deve caber em uma linha, sem encolher a arte de estrelas. */
  html body > .wrap {min-width:0!important;max-width:100%!important;box-sizing:border-box!important}
  html body > .wrap > header.top {
    width:100%!important;max-width:100%!important;min-width:0!important;
    flex-wrap:nowrap!important;gap:clamp(3px,.65vw,8px)!important;
    padding-left:max(4px,env(safe-area-inset-left))!important;
    padding-right:max(4px,env(safe-area-inset-right))!important;
  }
  html body > .wrap > header.top > .brand {min-width:0!important;flex:1 1 auto!important}
  html body > .wrap > header.top > .flex {min-width:0!important;max-width:calc(100% - 62px)!important;gap:4px!important}
  html body > .wrap > header.top .brand-logo {max-width:92px!important;max-height:39px!important;object-fit:contain!important}
  html body > .wrap > header.top .ca-stars-counter {
    flex:0 0 110px!important;width:110px!important;min-width:110px!important;max-width:110px!important;
    height:40px!important;min-height:40px!important;max-height:40px!important;
  }

  /* Login: campo de senha e Entrar permanecem alcançáveis mesmo em 360px de altura. */
  html body #login {max-width:100%!important;min-width:0!important}
  html body #login .hero.landing {max-height:clamp(26px,8dvh,45px)!important;min-height:0!important;margin:2px 0!important}
  html body #login > .panel {
    box-sizing:border-box!important;width:min(700px,100%)!important;
    max-height:calc(100dvh - 95px)!important;min-height:0!important;
    padding:8px 14px!important;overflow-y:auto!important;overflow-x:hidden!important;
    overscroll-behavior:contain!important;
  }
  html body #login #loginFields :is(input,select) {font-size:16px!important;min-height:36px!important}

  /* Início: seis menus em 3 × 2, sem quadrados que invadem a altura do celular. */
  html body #student .student-hero-row.ca-home-six {
    box-sizing:border-box!important;display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    grid-auto-rows:auto!important;gap:clamp(5px,.9vw,11px)!important;
    margin:5px 0 9px!important;width:100%!important;max-width:100%!important;
  }
  html body #student .student-hero-row.ca-home-six > * {
    box-sizing:border-box!important;min-width:0!important;width:100%!important;max-width:100%!important;
    aspect-ratio:auto!important;
    height:clamp(126px,36dvh,172px)!important;
    min-height:clamp(126px,36dvh,172px)!important;
    max-height:clamp(126px,36dvh,172px)!important;
    overflow:hidden!important;margin:0!important;
  }
  html body #student .ca-home-six :is(.welcome-card,.postcard-trigger,.v299-feature-button) {
    aspect-ratio:auto!important;min-height:0!important;height:100%!important;max-height:100%!important;
    gap:3px!important;padding:5px!important;justify-content:center!important;
    overflow:hidden!important;
  }
  html body #student .ca-home-six :is(.v299-feature-icon,.postcard-icon-shell,#ca-hello-avatar) {
    width:auto!important;height:auto!important;max-width:min(35%,78px)!important;
    max-height:clamp(48px,16dvh,74px)!important;object-fit:contain!important;flex-shrink:1!important;
  }
  html body #student .ca-home-six :is(.postcard-trigger-label,.v299-feature-button > span,#welcome) {
    font-size:clamp(11px,1.7vw,15px)!important;line-height:1.17!important;
    white-space:normal!important;overflow-wrap:anywhere!important;
  }
  html body #student .ca-home-six .ca-library-menu-label small {display:none!important}
  html body #student .panel {max-width:100%!important;box-sizing:border-box!important}

  /* Área do professor: não perder abas/ferramentas quando a tela fica baixa. */
  html body #teacher .teacher-workspace.ca-professor-2 {
    width:100%!important;max-width:100%!important;
    height:calc(100dvh - 54px)!important;max-height:calc(100dvh - 54px)!important;
    min-height:0!important;grid-template-rows:44px minmax(0,1fr)!important;
  }
  html body #teacher .teacher-sidebar.ca-professor-nav {
    height:44px!important;min-height:44px!important;max-height:44px!important;
    padding:3px max(7px,env(safe-area-inset-left))!important;
    overflow-x:auto!important;overflow-y:hidden!important;
    scroll-padding-inline:8px!important;-webkit-overflow-scrolling:touch!important;
  }
  html body #teacher .teacher-sidebar.ca-professor-nav > button.btn {height:36px!important;min-height:36px!important}
  html body #teacher .teacher-content {min-height:0!important;overflow-y:auto!important;overscroll-behavior:contain!important}

  /* Central do Aventureiro: manter a arte 1670×942 e rolagem apenas no texto. */
  html body #ca-center-backdrop.ca-open.ca-v1411-art-open:not(.ca-library-only) {
    max-height:100dvh!important;overflow:auto!important;
    padding:max(2px,env(safe-area-inset-top)) max(2px,env(safe-area-inset-right))
      max(2px,env(safe-area-inset-bottom)) max(2px,env(safe-area-inset-left))!important;
  }
  html body #ca-center-backdrop.ca-v1411-art-open #ca-center > .ca-pane:not([hidden]) {
    min-width:0!important;min-height:0!important;overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }
  html body #ca-center-backdrop.ca-v1411-art-open #ca-center .ca-pane :is(p,li) {
    font-size:clamp(11px,1.45cqw,15px)!important;line-height:1.35!important;
    overflow-wrap:anywhere!important;
  }

  /* Postcards: dois cartões por faixa no celular horizontal, deslizando na mesma revista. */
  html body #postcardOverlay.ca-pc60-active .ca-pc60-track {
    --pc60-gap:2%!important;overscroll-behavior-x:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }
  html body #postcardOverlay.ca-pc60-active .ca-pc60-track > .ca-pc60-card {
    flex:0 0 calc((100% - var(--pc60-gap))/2)!important;
    scroll-snap-align:start!important;min-width:0!important;
    overflow-x:hidden!important;overflow-y:auto!important;
  }
  html body #postcardOverlay.ca-pc60-active .ca-pc60-card strong {font-size:clamp(10px,1.35cqw,14px)!important}
  html body #postcardOverlay.ca-pc60-active .ca-pc60-condition {font-size:clamp(9px,1.16cqw,12px)!important}
  html body #postcardOverlay.ca-pc60-active .ca-pc60-card .ca-pc60-date {font-size:clamp(8px,1.02cqw,11px)!important}

  /* Catálogo em formato revista: compras legíveis sem deslocar a arte. */
  html body #ca-shop-modal.ca-magazine-mode #ca-magazine-ui .ca-mag-sheet {
    overflow-x:hidden!important;overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;overscroll-behavior:contain!important;
  }
  html body #ca-shop-modal.ca-magazine-mode #ca-magazine-ui .ca-mag-sheet .ca-mag-item-title {
    font-size:clamp(10px,1.12vw,12px)!important;max-height:none!important;
    -webkit-line-clamp:unset!important;line-clamp:unset!important;
    white-space:normal!important;overflow-wrap:anywhere!important;
  }
  html body #ca-shop-modal.ca-magazine-mode #ca-magazine-ui .ca-mag-sheet .ca-mag-item-status {font-size:clamp(9px,1vw,11px)!important}
  html body #ca-shop-modal.ca-magazine-mode #ca-magazine-ui .ca-mag-sheet button.ca-mag-buy {
    min-height:28px!important;font-size:clamp(10px,1.04vw,12px)!important;
    white-space:normal!important;line-height:1.18!important;
  }

  /* Menu Meu Aventureiro: os controles do cabeçalho permanecem acessíveis. */
  html body #avatarModal .avatar-modal-head {min-width:0!important;overflow:hidden!important}
  html body #avatarModal .avatar-head-actions {
    min-width:0!important;max-width:100%!important;flex-wrap:nowrap!important;
    overflow-x:auto!important;overflow-y:hidden!important;scrollbar-width:thin!important;
    overscroll-behavior-x:contain!important;-webkit-overflow-scrolling:touch!important;
  }
  html body #avatarModal .avatar-head-actions > * {flex-shrink:0!important}
}

/* Paisagem muito baixa: facilitar acesso ao formulário sem deformar painéis. */
@media (orientation: landscape) and (max-height: 390px) and (max-width: 850px) {
  html body #login > .panel {max-height:calc(100dvh - 85px)!important}
  html body #student .student-hero-row.ca-home-six > * {
    height:126px!important;min-height:126px!important;max-height:126px!important;
  }
  html body #teacher .teacher-workspace.ca-professor-2 {
    height:calc(100dvh - 50px)!important;max-height:calc(100dvh - 50px)!important;
  }
}
