/* mobile responsive overlay for welfare.hkflu.org.hk mirror */
img { max-width: 100%; height: auto; }

/* medium screens (981-1023px): let the 980px frame shrink to fit */
@media screen and (min-width: 981px) and (max-width: 1023px) {
  table[width="980"] { width: 100% !important; }
  .m-page { width: 100% !important; }
  .m-page img[width="760"] { width: 100%; height: auto; }
  .m-page table[width="760"] { width: 100% !important; }
}

@media screen and (max-width: 980px) {
  body { margin: 0; padding: 0; }

  /* neutralize HTML width/height attributes so images never force table min-width */
  img[width], img[height] { width: auto !important; height: auto !important; max-width: 100%; }
  .m-page table { width: 100% !important; table-layout: fixed !important; }
  .m-page td { min-width: 0 !important; overflow-wrap: break-word; }
  .m-page img { max-width: 100% !important; }
  .m-page iframe { max-width: 100% !important; }
  .m-logo img { width: 220px !important; max-width: 60% !important; }
  .m-toppic img { width: 100% !important; }

  /* ---- inner pages: stack the 980px table layout ---- */
  .m-page { width: 100% !important; border: 0 !important; }
  .m-page, .m-page tbody, .m-page tr, .m-page td, .m-page th { display: block !important; width: auto !important; height: auto !important; }
  .m-page a img { display: inline-block; }
  .m-head, .m-cols, .m-foot { width: 100% !important; }

  /* header: logo hidden on mobile */
  .m-page .m-logo { display: none !important; }
  .m-toppic img { display: block; }
  .m-titlebar { padding: 6px 10px; }
  .m-rightbg { display: none !important; }

  /* top nav becomes a wrapping menu */
  .m-nav, .m-nav > tbody, .m-nav > tbody > tr { display: block !important; width: 100% !important;
           text-align: center; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }
  .m-nav > tbody > tr > td { display: inline-block !important; width: auto !important;
           height: auto !important; padding: 7px 8px; }
  .m-nav .m-slash { display: none !important; }
  .m-nav a { font-size: 15px; }

  /* columns stack: sidebar, content, (hide spacer + facebook) */
  .m-side { background: #f5f5f5 !important; border-bottom: 1px solid #ddd; padding: 8px 12px 12px; }
  .m-side table { width: 100% !important; }
  .m-side table td { height: auto !important; padding: 4px 0; }
  .m-side a.list { display: inline-block; line-height: 1.5; padding: 5px 0; }
  .m-side img[src*="left_bottom"] { display: none; }
  .m-main { padding: 10px 8px; overflow-x: auto; }
  /* keep content-area tables as real tables for readability */
  .m-main table { display: table !important; width: 100% !important; height: auto !important; }
  .m-main tbody { display: table-row-group !important; }
  .m-main tr { display: table-row !important; height: auto !important; }
  .m-main td { display: table-cell !important; width: auto !important; height: auto !important; }
  .m-page .m-spacer, .m-page .m-right { display: none !important; }

  /* footer disclaimer */
  .m-foot td { white-space: normal !important; padding: 8px !important; line-height: 1.6; }

  /* leaflet card grids: single column on mobile (desktop keeps 2 columns) */
  .m-main .m-cards { display: grid !important; width: 100% !important; grid-template-columns: 1fr; }
  .m-main .m-cards > tbody, .m-main .m-cards > tbody > tr { display: contents !important; }
  .m-main .m-cards > tbody > tr > td { display: block !important; width: auto !important;
           height: auto !important; text-align: center; }
  .m-main .m-cards > tbody > tr:nth-child(1) > td:nth-child(1) { grid-row: 1; }
  .m-main .m-cards > tbody > tr:nth-child(2) > td:nth-child(1) { grid-row: 2; }
  .m-main .m-cards > tbody > tr:nth-child(1) > td:nth-child(2) { grid-row: 3; }
  .m-main .m-cards > tbody > tr:nth-child(2) > td:nth-child(2) { grid-row: 4; }
  .m-main .m-cards td table { width: 100% !important; margin: 4px auto 12px; }
  .m-main .m-cards td table td { width: auto !important; height: auto !important; }
  .m-main .m-cards img { width: 100% !important; max-width: 100% !important; display: block; }

  pre { white-space: pre-wrap; word-break: break-all; }

  /* ---- index.html home page ---- */
  .m-idx, .m-idx > tbody, .m-idx > tbody > tr,
  .m-idx > tbody > tr > td { display: block !important; width: auto !important; }
  .m-idx-nav, .m-idx-nav > tbody, .m-idx-nav > tbody > tr { display: block !important;
           width: 100% !important; text-align: center; }
  .m-idx-nav > tbody > tr > td { display: inline-block !important; width: auto !important;
           height: auto !important; padding: 9px 10px; }
  .m-idx-nav .m-slash, .m-idx-nav .m-idx-pad { display: none !important; }
  .m-idx-banner, .m-idx-banner td { display: block !important; width: auto !important; }
  .m-idx-banner img { display: block; margin: 0 auto; }
}
