/* ==========================================================================
   Quinta do Cume — versão mobile e tablet (18-11-2026)
   Só atua em ecrãs com menos de 1000px de largura (telemóvel e iPad
   vertical), exceto as correções para ecrãs táteis no primeiro bloco.
   Em desktop o site fica exatamente igual.
   Carregado depois de todos os outros estilos de cada página.
   ========================================================================== */

/* ---------- Ecrãs táteis (iPhone, iPad, também na horizontal) ---------- */
@media (hover: none), (pointer: coarse), (max-width: 999px) {
  /* o slideshow da homepage (maximage) põe overflow:hidden no html/body a cada
     "resize" — no iOS isso acontece durante o scroll e o scroll prende ou salta */
  html.mc-hide-scrolls, body.mc-hide-scrolls, .mc-hide-scrolls { overflow: visible !important; }

  /* slideshow estático: a altura deixa de acompanhar a barra de endereço do
     iOS (que muda durante o scroll e fazia a fotografia "aproximar") */
  body .mc-cycle, #maximage.mc-cycle, #maximage .mc-image {
    height: 100vh !important; height: 100lvh !important;
  }
}

@media (max-width: 999px) {

  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  html, body { height: auto; }
  body { overflow-x: hidden; min-height: 100vh; background-repeat: no-repeat; background-position: center center; }
  img { max-width: 100%; height: auto; }
  iframe { max-width: 100%; }
  a { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }

  /* ---------- Cabeçalho: logótipo em cima, menu centrado por baixo ---------- */
  #header { height: auto; padding: 0; }
  #header table { width: 100% !important; }
  #header td { display: block; width: auto !important; height: auto !important; text-align: center; padding: 0 !important; }
  #header td img { display: block; width: 108px; height: auto !important; margin: 26px auto 14px; }
  #header ul {
    float: none; display: flex; flex-wrap: wrap; justify-content: center;
    gap: 0 4px; padding: 0 16px 18px; margin: 0; width: auto !important;
  }
  #header ul li { float: none; margin: 0 !important; }
  #header ul li a,
  #header ul li a:hover,
  html[lang="de"] #header ul li a,
  html[lang="de"] #header ul li a:hover {
    height: auto; font-size: 14px; letter-spacing: 0.6px;
    padding: 7px 8px 8px; line-height: 1.1;
  }

  /* ---------- Conteúdo ---------- */
  #body { width: auto; box-sizing: border-box; padding: 0 24px 48px; }
  #body table { width: 100% !important; }
  #body td { box-sizing: border-box; }
  #body h2 { font-size: 26px; line-height: 1.15; }
  #body h3 { font-size: 21px; line-height: 1.2; }
  #body p { line-height: 1.5; }
  /* palavras longas (sobretudo em alemão) partem em vez de alargar a página */
  #body h2, #body h3, #body h4, #body h6, #body p, #body td { overflow-wrap: anywhere; word-break: normal; -webkit-hyphens: auto; hyphens: auto; }
  #body iframe, .video-container iframe {
    width: 100% !important; height: auto !important; aspect-ratio: 16 / 9; display: block;
  }
  .video-container { padding: 0 24px !important; height: auto !important; overflow: visible !important; background: none !important; }
  .video-container iframe { position: static !important; }
  /* homepage: deixa ver o slideshow de fotografias entre o vídeo e o footer */
  .video-container, #container > iframe { margin-bottom: 55vh; }
  #maximage .mc-image { background-position: center center !important; }

  /* faixas de imagem (vinhos, enoturismo, contactos) */
  #body_alt { height: 220px !important; background-position: center center; }
  #body_alt td { height: 220px !important; }
  #body_alt_hover a { padding: 12px 20px; display: inline-block; width: auto; margin: 0; border: 0; }
  #body_alt_hover { font-size: 26px; }

  /* faixas com texto por cima (contactos, enoturismo, concurso): altura cresce com o texto */
  #body_alt:not(:has(#body_alt_hover)) {
    height: auto !important; min-height: 220px; padding: 28px 0 24px; box-sizing: border-box;
    background-size: cover !important;
  }
  #body_alt:not(:has(#body_alt_hover)) td { height: auto !important; }

  /* banners do concurso (texto desenhado na imagem, 3:1): mostrar inteiros */
  #body_alt[style*="/Banner"]:not(:has(#body_alt_hover)) {
    height: auto !important; min-height: 0 !important; padding: 0 !important; aspect-ratio: 3 / 1;
    background-size: contain !important; background-position: center center !important; background-repeat: no-repeat !important;
  }

  /* em ecrãs táteis não há "hover": o nome do vinho fica sempre visível */
  @media (hover: none) {
    #body_alt_hover { opacity: 0.62; background-color: #000; }
  }

  /* ---------- Notícias e prémios: cada notícia separada por uma linha ---------- */
  #body td#news_principal, #body td#news_secundaria { padding: 22px 0 26px !important; }
  #body td#news_principal h3, #body td#news_secundaria h3 { font-size: 22px; line-height: 1.15; margin: 0 0 8px; }
  #body td#news_principal h6, #body td#news_secundaria h6 { margin: 0 0 12px; line-height: 1.2; color: #7a6c64; letter-spacing: 0.08em; }
  #body td#news_principal p, #body td#news_secundaria p { margin: 0 0 12px; }

  /* ---------- Enoturismo: bloco de marcação ---------- */
  .qdc-cta { margin: 32px 0 8px; padding: 32px 0 0; }
  .qdc-cta .qdc-btn { padding: 14px 26px; }

  /* ---------- Footer ---------- */
  #footer_alt { height: auto !important; padding: 32px 0 20px; box-sizing: border-box; }
  #footer_alt table { width: 100% !important; }
  #footer_alt td { height: auto !important; box-sizing: border-box; padding: 0 24px; vertical-align: top; }
  #footer_alt td[width="1%"] { display: none; }
  #footer_alt a[href^="tel:"], #footer_alt a[href^="mailto:"] { display: inline-block; padding: 2px 0; }

  /* ---------- Formulário de contactos ---------- */
  .form td { height: auto !important; padding-bottom: 10px; }
  #field, .form textarea { box-sizing: border-box; width: 100% !important; font-size: 16px; }
  #body .form textarea { font-family: 'Roboto Condensed', sans-serif; line-height: 1.4; -webkit-hyphens: manual; hyphens: manual; overflow-wrap: break-word; }
  .form #submit { width: 140px !important; height: 44px !important; }
}

/* ---------- Telemóvel: colunas passam a uma só ---------- */
@media (max-width: 640px) {

  #header td img { width: 96px; margin: 22px auto 12px; }
  #header ul { padding: 0 10px 16px; }
  #header ul li a,
  #header ul li a:hover,
  html[lang="de"] #header ul li a,
  html[lang="de"] #header ul li a:hover { font-size: 13px; padding: 7px 7px 8px; }

  #body { padding: 0 20px 40px; }
  .video-container { padding: 0 20px; }
  #body td { display: block; width: auto !important; height: auto !important; padding-left: 0; padding-right: 0; }
  #body td[width="1%"], #body td[width="2%"] { display: none; }
  #body td:empty { display: none; }
  #body h2 { font-size: 24px; }
  #body img { margin-left: auto; margin-right: auto; }

  /* fichas de vinho: medalhas lado a lado, garrafa centrada */
  #body td[width="20%"] { text-align: center; padding: 12px 0; }
  #body td[width="20%"] br { display: none; }
  #body td[width="20%"] img { display: inline-block; margin: 4px; }
  #body img[src*="garrafa_"] { width: auto !important; max-height: 340px; }

  /* notícias e prémios: imagem e "ver notícia" deixam de flutuar ao lado do título seguinte */
  #body td#news_principal a, #body td#news_secundaria a { float: none; display: inline-block; margin: 4px 0 0; }
  #body td#news_principal img, #body td#news_secundaria img { display: block; margin: 4px 0 6px; }

  /* prémios e galerias: imagens centradas */
  #body td[align="center"], #body td img[width="200"] { text-align: center; }

  #body_alt:has(#body_alt_hover), #body_alt:has(#body_alt_hover) td { height: 180px !important; }
  #body_alt:not(:has(#body_alt_hover)) td { display: block; width: auto !important; padding: 0 20px 10px; }
  #body_alt_hover { font-size: 22px; }

  #footer_alt td { display: block; width: auto !important; padding: 0 20px 18px; }
  #footer_alt td[align="right"] { text-align: left; padding-top: 4px; }

  .form #submit { width: 100% !important; }
  #body .qdc-cta a.qdc-btn { display: block; text-align: center; }

  /* concurso: cada título fica por cima do seu texto (no desktop estão lado a lado) */
  #body table:has(> tbody > tr:first-child > td[width="960px"] + td[width="960px"]) > tbody { display: flex; flex-direction: column; }
  #body table:has(> tbody > tr:first-child > td[width="960px"] + td[width="960px"]) > tbody > tr { display: contents; }
  #body table:has(> tbody > tr:first-child > td[width="960px"] + td[width="960px"]) > tbody > tr:nth-child(1) > td:nth-child(1) { order: 1; }
  #body table:has(> tbody > tr:first-child > td[width="960px"] + td[width="960px"]) > tbody > tr:nth-child(2) > td:nth-child(1) { order: 2; padding-bottom: 24px; }
  #body table:has(> tbody > tr:first-child > td[width="960px"] + td[width="960px"]) > tbody > tr:nth-child(1) > td:nth-child(2) { order: 3; }
  #body table:has(> tbody > tr:first-child > td[width="960px"] + td[width="960px"]) > tbody > tr:nth-child(2) > td:nth-child(3) { order: 4; }
}
