/*
 * Mermaid Divers Aruba — Formdesk Responsive Theme v6.1
 * Based on the original user-tested v5 stylesheet (25 Oct 2026).
 * Keeps v5 styling, input sizing, date widgets, card fields and textarea fixes.
 * v6 adds narrowly targeted MOBILE stacking for:
 *  - Selected dive experience + its conditional price text
 *  - Number of snorkelers + its conditional price text
 *  - Number of boat-only passengers + its conditional price text
 *  - Wetsuit size + fin size (individual divers and snorkelers)
 * No desktop changes. No changes to form answers, validations or dependencies.
 *
 * IMPORTANT: The live Formdesk-generated HTML could not be inspected.
 * Selectors use the question identifiers visible in this project and
 * the table layout already used successfully in v5; verify on a real iPhone.
 */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iOS Safari should not zoom the page when a visitor focuses a field. */
@media screen and (max-width: 700px) {
  html,
  body {
    max-width: 100%;
  }

  form {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /*
   * Formdesk uses table cells for its side-by-side question layout.
   * Target only the row containing BOTH test name fields, leaving date-picker
   * and other Formdesk internal tables untouched.
   *
   * The fields' Formdesk identifiers are first_name and last_name.
   */
  form tr:has(input:is([name*="first_name"], [id*="first_name"])):has(input:is([name*="last_name"], [id*="last_name"])) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  form tr:has(input:is([name*="first_name"], [id*="first_name"])):has(input:is([name*="last_name"], [id*="last_name"])) > td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important; /* v2: remove extra gap between stacked name fields */
    float: none !important;
  }

  /* Ensure form text fields stay in their available column. */
  form input[type="text"],
  form input[type="email"],
  form input[type="tel"],
  form input[type="number"],
  form input[type="date"],
  form input[type="search"],
  form textarea,
  form select {
    box-sizing: border-box !important;
    max-width: 100% !important;
    font-size: 16px !important;
  }

  /* The name inputs should fill the single column after stacking. */
  form input:is([name*="first_name"], [id*="first_name"],
                [name*="last_name"], [id*="last_name"]) {
    width: 100% !important;
    min-width: 0 !important;
  }
}


/* ================================================================
   v3 – Mermaid Divers visual theme (matching website build v0.5.10)
   Purely visual; the working v2 responsive layout above is unchanged.
   ================================================================ */
:root {
  --mda-navy: #023047;
  --mda-ink: #14313f;
  --mda-muted: #5f7884;
  --mda-border: #aacbd7;
  --mda-yellow: #ffb703;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--mda-ink);
  background-color: #f3fbfe;
}

form {
  color: var(--mda-ink);
}

/* Formdesk may render its form title outside the form element. */
h1, h2, h3 {
  color: var(--mda-navy);
}

/* Change colors and corners only; keep field widths and stacking as in v2. */
form input[type="text"],
form input[type="email"],
form input[type="tel"],
form input[type="number"],
form input[type="date"],
form textarea,
form select {
  font-family: inherit;
  color: var(--mda-ink);
  background-color: #fff;
  border: 1px solid var(--mda-border);
  border-radius: 10px;
}

form input[type="text"]:focus,
form input[type="email"]:focus,
form input[type="tel"]:focus,
form input[type="number"]:focus,
form input[type="date"]:focus,
form textarea:focus,
form select:focus {
  border-color: #0077b6;
  outline: 2px solid rgba(0, 119, 182, .22);
  outline-offset: 1px;
}

/* Only the actual submit action – never date picker or other controls. */
form input[type="submit"],
form button[type="submit"] {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background-color: var(--mda-yellow);
  color: #241900;
  font-family: inherit;
  font-size: 16px;
  font-weight: 750;
  min-height: 48px;
  padding: 11px 24px;
  cursor: pointer;
}

form input[type="submit"]:hover,
form button[type="submit"]:hover {
  background-color: #edab00;
}

@media screen and (max-width: 700px) {
  /* Explicitly retain the iPhone 16px+ field rule introduced in v2. */
  form input[type="text"],
  form input[type="email"],
  form input[type="tel"],
  form input[type="number"],
  form input[type="date"],
  form input[type="search"],
  form textarea,
  form select { font-size: 16px !important; }
}


/* ================================================================
   v4 – all CURRENT two-column Formdesk question rows on mobile

   The original v3 iPhone fix for the name row remains intact above.
   The rules below also stack side-by-side dates, contact details,
   accommodation/transport, card placeholders, and Diver 1–8 fields.

   Scope: @media max-width 767px and only rows having actual form
   controls in TWO distinct direct table cells. Formdesk date-picker
   icons, help text and plain-text separators are not targeted.

   Safeguard: two adjacent SELECT controls are not stacked by the
   general rule. This preserves a possible month/year two-selector
   date control. Diver 1–8 selector pairs are explicitly included.

   NOTE: Formdesk generates its own table markup. These selectors
   are a tested layout strategy, not a verified live DOM contract.
   ================================================================ */

@media screen and (max-width: 767px) {
  html, body { max-width: 100% !important; }

  body, form, form > table {
    box-sizing: border-box !important;
    max-width: 100% !important;
  }

  /* A pair of answer controls arranged in two table cells.
   * Exclude SELECT+SELECT except for clearly named individual-diver
   * questions to preserve the expiration month/year pair. */
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type :is(input:not([type="hidden"]), textarea)):has(> td:nth-of-type(2) :is(input:not([type="hidden"]), select, textarea)),
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type select):has(> td:nth-of-type(2) :is(input:not([type="hidden"]), textarea)),
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type [name*="diver_"]):has(> td:nth-of-type(2) [name*="diver_"]),
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type [id*="diver_"]):has(> td:nth-of-type(2) [id*="diver_"]) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Corresponding cells only. Avoid changing cell display on every
   * internal date-picker or layout table. */
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type :is(input:not([type="hidden"]), textarea)):has(> td:nth-of-type(2) :is(input:not([type="hidden"]), select, textarea)) > td:not([hidden]):not([style*="display:none"]):not([style*="display: none"]),
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type select):has(> td:nth-of-type(2) :is(input:not([type="hidden"]), textarea)) > td:not([hidden]):not([style*="display:none"]):not([style*="display: none"]),
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type [name*="diver_"]):has(> td:nth-of-type(2) [name*="diver_"]) > td:not([hidden]):not([style*="display:none"]):not([style*="display: none"]),
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type [id*="diver_"]):has(> td:nth-of-type(2) [id*="diver_"]) > td:not([hidden]):not([style*="display:none"]):not([style*="display: none"]) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    float: none !important;
    box-sizing: border-box !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
  }

  /* iOS text zoom fix – retain at >=16px even for new fields.
     Keep original desktop sizes and default Formdesk control logic. */
  form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
  form select, form textarea {
    font-size: 16px !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    min-width: 0;
  }

  /* Text fields get usable width on mobile; date widgets and their
     paired month/year dropdowns keep their native control widths. */
  form input[type="text"]:not([name*="date"]):not([id*="date"]):not([name*="last_dive"]):not([id*="last_dive"]),
  form input[type="email"], form input[type="tel"], form input[type="search"],
  form textarea {
    width: 100% !important;
  }

  /* Allow date placeholders to be read on small iPhones. */
  form input:is([name*="date"], [id*="date"], [name*="last_dive"], [id*="last_dive"]) {
    min-width: min(136px, 100%) !important;
    max-width: 100% !important;
  }

  /* Prevent titles, separator notes and hyperlinks from stretching
     the viewport on a long mobile form. */
  form :is(h1, h2, h3, p, label, legend) {
    overflow-wrap: anywhere;
  }
  form img { max-width: 100% !important; height: auto !important; }

  /* Control pairs in a single field, such as the expiration month
     and year, are left untouched – no blanket table/tr/td rule. */
}

/* 320px supplementary accommodation; desktop unaffected. */
@media screen and (max-width: 360px) {
  form { margin-left: auto; margin-right: auto; }
  form input[type="date"] { max-width: 100% !important; }
}


/* ================================================================
   v5 — MOBILE TEXT-AREA FIT (the three long-answer questions)

   These rules are additive to the user-tested v4 layout. They ONLY
   affect small screens and do not alter the desktop layout, diver
   dependencies, date pickers, menus or booking fields.

   Formdesk can assign an intrinsic size through textarea cols/width
   or through a containing table cell. In Safari this can cause the
   page to shift/zoom horizontally when a long-answer field is focused.
   ================================================================ */
@media screen and (max-width: 767px) {
  /* Keep every long-answer field inside the visible form/viewport,
     even when Formdesk supplies a large cols, width or min-width. */
  html body form textarea,
  html body form textarea[cols] {
    display: block !important;
    width: min(100%, calc(100vw - 40px)) !important;
    max-width: min(100%, calc(100vw - 40px)) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    font-size: 16px !important; /* Prevent iPhone's focus-zoom */
    line-height: 1.4 !important;
    overflow-wrap: anywhere !important;
    resize: vertical;
  }

  /* Prevent a Formdesk table cell containing a large text area from
     reserving a wider minimum width than the mobile form. */
  html body form td:has(textarea),
  html body form th:has(textarea) {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}


/* ======================================================================
   v6 — CORRECT THE TWO REMAINING MOBILE TWO-COLUMN PATTERNS

   Formdesk places some questions + price TEXT in two adjacent table
   cells. v5's stacking selectors deliberately excluded that pattern.
   It also left Wetsuit + Fin SELECT/SELECT pairs side-by-side.

   Scope is intentionally narrow: recognized identifiers and mobile
   only. In particular, do NOT turn every table row into a block:
   expiration-month/year, date widgets and other nested tables must
   retain their native layout.
   ====================================================================== */
@media screen and (max-width: 767px) {

  /* CASE A — A participant/experience dropdown followed by plain price
     text in the next cell, with no second answer control.
     Handles the main experience price and both US$40 passenger prices.

     CASE B — The wetsuit dropdown in the first cell and fin dropdown
     in the second. The identifier matching deliberately works for
     Diver 1..N and Snorkeler 1..N alike.

     :not([style*=...]) protects Formdesk's hidden Dependency rows.
     The extra no-control check in case A avoids affecting any other
     two-question row. */
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):is(
      :has(> td:first-of-type select:is(
          [name*="selected_dive_experience" i], [id*="selected_dive_experience" i],
          [name*="number_of_snorkelers" i], [id*="number_of_snorkelers" i],
          [name*="number_of_boat_passengers" i], [id*="number_of_boat_passengers" i]
        )):not(:has(> td:nth-of-type(2) :is(input, select, textarea))),
      :has(> td:first-of-type select:is([name*="wetsuit" i], [id*="wetsuit" i])):has(> td:nth-of-type(2) select:is([name*="fin" i], [id*="fin" i]))
    ) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Only cells inside the above identified rows become full-width.
     Never force hidden Dependency cells to display! */
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):is(
      :has(> td:first-of-type select:is(
          [name*="selected_dive_experience" i], [id*="selected_dive_experience" i],
          [name*="number_of_snorkelers" i], [id*="number_of_snorkelers" i],
          [name*="number_of_boat_passengers" i], [id*="number_of_boat_passengers" i]
        )):not(:has(> td:nth-of-type(2) :is(input, select, textarea))),
      :has(> td:first-of-type select:is([name*="wetsuit" i], [id*="wetsuit" i])):has(> td:nth-of-type(2) select:is([name*="fin" i], [id*="fin" i]))
    ) > td:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    float: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Compact, readable spacing below an experience/participant dropdown.
     This additional padding is for PRICE TEXT ONLY. Wetsuit/Fin is
     handled independently by the v6.1 adjustment below. */
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:nth-of-type(2)):has(> td:first-of-type select:is(
      [name*="selected_dive_experience" i], [id*="selected_dive_experience" i],
      [name*="number_of_snorkelers" i], [id*="number_of_snorkelers" i],
      [name*="number_of_boat_passengers" i], [id*="number_of_boat_passengers" i]
    )):not(:has(> td:nth-of-type(2) :is(input, select, textarea))) > td:nth-of-type(2):not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden) {
    padding-top: 6px !important;
    padding-bottom: 8px !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
}


/* ======================================================================
   v6.1 — SMALL MOBILE SPACING REFINEMENT FOR WETSUIT / FIN

   v6 gave the second column (Fin size) 6px of extra top padding,
   originally shared with the price-text rows. Formdesk already has
   its own normal question spacing, so this makes Fin size sit a
   little farther below Wetsuit size than other consecutive fields.

   Restore normal stacked-field spacing ONLY for Wetsuit/Fin rows.
   Leave all three price-text row spacings unchanged.
   ====================================================================== */
@media screen and (max-width: 767px) {
  form tr:not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden):has(> td:first-of-type select:is([name*="wetsuit" i], [id*="wetsuit" i])):has(> td:nth-of-type(2) select:is([name*="fin" i], [id*="fin" i])) > td:nth-of-type(2):not([hidden]):not([style*="display:none"]):not([style*="display: none"]):not([aria-hidden="true"]):not(.hidden):not(.is-hidden) {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
}
