/* Phone and tablet layout for the static Palm Street Boat Yard copy.
   Desktop (1024 px and wider) is untouched: every rule sits inside the media query,
   and .mobile-call is hidden there. Replaces the old separate jQuery Mobile pages. */
.mobile-call { display: none; }

@media (max-width: 1023px) {
  html, body { overflow-x: hidden; }
  body { background: #fff; -webkit-text-size-adjust: 100%; }

  /* Banner: the logo sits in the middle of bg_top.png (2480 x 336); keep it centred and scale it to the screen */
  #bg_top { display: block; background-size: min(2480px, 477vw) auto; }
  #banner { width: 100%; height: min(251px, 48.3vw); }

  .mobile-call { display: block; height: 24px; text-align: center; margin: 4px 16px 10px; font: 18px/24px 'oswaldbold', Arial, Helvetica, sans-serif; }
  .mobile-call a, .mobile-call a:visited { color: #073569; text-decoration: none; }

  /* Menu: wrap the six tabs into pills; the Helpful Links drop-down shows under Contact Us on tap.
     The menu starts below the banner image's navy stripe (image rows 305-320 of 336, scaled by the
     background-size above), never on it: the navy tab text on the navy stripe read as cut off.
     Target top = image bottom + a little (min(66vw, 342px)), minus banner height and the call line (24px + 4px top margin; its 10px bottom margin collapses into this one). */
  #menu_field { margin-top: max(10px, calc(min(66vw, 342px) - min(251px, 48.3vw) - 28px)); }
  #menu_field, #menu { width: auto; height: auto; padding: 0 8px; }
  #menu ul.nav { float: none; white-space: normal !important; display: flex !important; flex-wrap: wrap; justify-content: center; gap: 6px; }
  #menu ul.nav > li { width: auto !important; float: none; position: relative; }
  .nav .top, .nav li li.sfhover { padding: 8px 12px; font-size: 16px; border-radius: 12px; }
  .nav .selected .top { border-radius: 12px; }
  .nav li:hover { border-radius: 12px; }
  .nav li ul { right: 0; }
  .nav ul li { width: 170px; }

  /* Slideshow: 1024 x 433 scaled to the screen width */
  #frame { width: 100%; height: auto; aspect-ratio: 1024 / 433; overflow: hidden; margin-top: 10px; }
  #frame div { width: 100% !important; height: 100% !important; }
  #frame img { width: 100%; height: auto; display: block; }

  /* Page body: one column, Latest News after the content */
  #bg_y, #bg_y_bottom { display: block; background: #fff; }
  #container { width: auto; }
  /* #column_right and #content are both children of #header: content first, Latest News after */
  #header { display: flex; flex-direction: column; }
  #header > * { order: 0; }
  #header > #content { order: 1; margin: 0 0 20px 0; }
  #header > #column_right { order: 2; float: none; width: auto; margin: 0 16px; clear: none; }
  .box { margin-bottom: 30px; }
  #content .top h1, .heading { padding: 10px 16px 0 16px; }
  #content h1, .heading { font-size: 36px; }
  #content .middle { padding: 0 16px 1px 16px; overflow-wrap: anywhere; }
  #content .middle img { max-width: 100%; height: auto; }
  #content .middle iframe { float: none !important; display: block; width: 100%; margin: 0 0 12px; }
  #content .middle table { max-width: 100%; }
  /* Gallery: the 4-across thumbnail table becomes a two-column grid */
  #content .middle table[width="100%"] { display: block; width: 100%; }
  #content .middle table[width="100%"] > tbody { display: flex; flex-wrap: wrap; }
  #content .middle table[width="100%"] > tbody > tr { display: contents; }
  #content .middle table[width="100%"] > tbody > tr > td { display: block; width: 50% !important; box-sizing: border-box; text-align: center; padding: 4px 4px 12px !important; margin: 0 !important; }
  #content .middle table[width="100%"] > tbody > tr > td:empty { display: none; }
  /* Contact page: the blank paragraphs that cleared the floated map on desktop only leave a gap here */
  #content .middle:has(#contact) table[cellpadding="2"] ~ p { display: none; }
  /* Contact form: full-width fields, 16px so iOS does not zoom on focus */
  #content .middle #contact table[width="100%"] > tbody { display: block; }
  #content .middle #contact table[width="100%"] > tbody > tr > td { width: 100% !important; text-align: left; padding: 2px 0; }
  #contact input[type="text"] { width: 100%; box-sizing: border-box; font-size: 16px; padding: 6px; }
  #contact textarea { width: 100% !important; box-sizing: border-box; font-size: 16px; }

  /* Footer: blue curve scaled, links wrap */
  #bg_bottom { display: block; background: #073569; }
  #footer { width: auto; height: auto; padding: 24px 16px 30px; }
  #footer, #footer a, #footer a:visited { color: #fff; }
  #footermenu { margin: 0; line-height: 2.4; }
  #footermenu a, #footermenu a:visited { display: inline-block; margin: 2px; color: #fff; background: #042244; }
}
