/* ============================================================
   P & D Plumbing — Book Online scheduler (v24)
   Shared across all pages. Matches site tokens defined per-page.
   ============================================================ */

.bk-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: none;
    background: rgba(4, 25, 48, 0.62);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    padding: 2.5rem 1rem;
    overflow-y: auto;
}
.bk-overlay.bk-open { display: flex; align-items: flex-start; justify-content: center; }

.bk-modal {
    background: #fff;
    width: 100%;
    max-width: 620px;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(2, 20, 40, 0.5);
    display: flex;
    flex-direction: column;
    margin: auto 0;
    overflow: hidden;
}

/* Header */
.bk-head {
    background: linear-gradient(120deg, var(--navy, #072D52) 0%, var(--navy-2, #0B3E70) 100%);
    color: #fff;
    padding: 1.15rem 1.4rem 1rem;
    position: relative;
    flex-shrink: 0;
}
.bk-head h2 {
    color: #fff;
    font-size: 1.25rem;
    margin: 0 2.2rem 0.15rem 0;
    line-height: 1.25;
}
.bk-head .bk-sub { color: rgba(255, 255, 255, 0.82); font-size: 0.85rem; margin: 0; }
.bk-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}
.bk-close:hover, .bk-close:focus-visible { background: rgba(255, 255, 255, 0.25); }

/* Progress */
.bk-progress { display: flex; gap: 6px; padding: 0.9rem 1.4rem 0; flex-shrink: 0; }
.bk-progress span {
    flex: 1;
    height: 5px;
    border-radius: 999px;
    background: var(--line, #E3EAF2);
    transition: background 0.25s ease;
}
.bk-progress span.bk-done { background: var(--action, #0A6FE8); }
.bk-step-label {
    padding: 0.55rem 1.4rem 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted, #5B6B7B);
    flex-shrink: 0;
}

/* Body */
.bk-body { padding: 0.9rem 1.4rem 1.2rem; }
.bk-step { display: none; }
.bk-step.bk-active { display: block; }
.bk-step h3 { font-size: 1.12rem; margin: 0 0 0.9rem; }

/* Service choice cards */
.bk-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.bk-choice { position: relative; }
.bk-choice input { position: absolute; opacity: 0; inset: 0; }
.bk-choice label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: 1.5px solid var(--line, #E3EAF2);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink, #16232F);
    cursor: pointer;
    min-height: 52px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.bk-choice label:hover { border-color: var(--action, #0A6FE8); }
.bk-choice input:focus-visible + label { outline: 2px solid var(--action, #0A6FE8); outline-offset: 2px; }
.bk-choice input:checked + label {
    border-color: var(--action, #0A6FE8);
    background: #EDF5FF;
    color: var(--navy, #072D52);
}
.bk-choice.bk-choice-emg input:checked + label { border-color: var(--red, #D93025); background: #FDF1F0; }

/* Fields */
.bk-field { margin-bottom: 0.85rem; }
.bk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.bk-grid3 { display: grid; grid-template-columns: 1.4fr 0.8fr 0.8fr; gap: 0.7rem; }
.bk-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--navy, #072D52);
    margin-bottom: 0.3rem;
}
.bk-label .bk-opt { font-weight: 500; color: var(--muted, #5B6B7B); }
.bk-body input[type="text"],
.bk-body input[type="tel"],
.bk-body input[type="email"],
.bk-body input[type="date"],
.bk-body select,
.bk-body textarea {
    width: 100%;
    border: 1.5px solid var(--line, #E3EAF2);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    font-size: 16px; /* prevents iOS zoom */
    font-family: inherit;
    color: var(--ink, #16232F);
    background: #fff;
    min-height: 48px;
}
.bk-body textarea { min-height: 96px; resize: vertical; }
.bk-body input:focus, .bk-body select:focus, .bk-body textarea:focus {
    outline: 2px solid var(--action, #0A6FE8);
    outline-offset: 1px;
    border-color: var(--action, #0A6FE8);
}
.bk-body input.bk-invalid, .bk-body select.bk-invalid, .bk-body textarea.bk-invalid { border-color: var(--red, #D93025); }
.bk-choice.bk-invalid label {
    border-color: var(--red, #D93025);
    background: #FDF1F0;
}
.bk-consent.bk-invalid {
    outline: 2px solid var(--red, #D93025);
    outline-offset: 4px;
    border-radius: 4px;
}
.bk-file-wrap.bk-invalid {
    border-color: var(--red, #D93025);
    background: #FDF1F0;
}
.bk-error {
    display: none;
    color: var(--red, #D93025);
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 0.55rem;
}
.bk-error.bk-show { display: block; }

/* Photo upload */
.bk-file-wrap { border: 1.5px dashed var(--line, #E3EAF2); border-radius: 12px; padding: 0.8rem 0.9rem; }
.bk-file-wrap input[type="file"] { font-size: 0.88rem; width: 100%; }
.bk-file-note { font-size: 0.78rem; color: var(--muted, #5B6B7B); margin-top: 0.35rem; }

/* Radio rows (contact method) */
.bk-radio-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.bk-radio-row .bk-choice label { min-height: 44px; padding: 0.55rem 0.9rem; }

/* Consent */
.bk-consent { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.86rem; color: var(--ink, #16232F); }
.bk-consent input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--action, #0A6FE8); }

/* Emergency callout */
.bk-emg {
    display: none;
    background: #FDF1F0;
    border: 1.5px solid var(--red, #D93025);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.9rem;
}
.bk-emg.bk-show { display: block; }
.bk-emg strong { color: var(--red, #D93025); display: block; margin-bottom: 0.25rem; font-size: 0.95rem; }
.bk-emg p { margin: 0 0 0.6rem; font-size: 0.86rem; color: var(--ink, #16232F); line-height: 1.5; }
.bk-emg-call {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--red, #D93025);
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.05rem;
    padding: 0.65rem 1.2rem;
    border-radius: 10px;
    min-height: 48px;
}
.bk-emg-call:hover { background: #B7271D; color: #fff; }

/* Footer nav */
.bk-foot {
    display: flex;
    gap: 0.7rem;
    padding: 0.9rem 1.4rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line, #E3EAF2);
    background: #FBFDFF;
    flex-shrink: 0;
}
.bk-btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    padding: 0.85rem 1rem;
    min-height: 52px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}
.bk-btn-next { background: var(--action, #0A6FE8); color: #fff; }
.bk-btn-next:hover { background: var(--action-dark, #0857BC); }
.bk-btn-back {
    background: #fff;
    color: var(--navy, #072D52);
    border: 1.5px solid var(--line, #E3EAF2);
    flex: 0 0 auto;
    min-width: 96px;
}
.bk-btn-back:hover { border-color: var(--navy, #072D52); }
.bk-btn:disabled { opacity: 0.65; cursor: default; transform: none; }
.bk-fine { font-size: 0.78rem; color: var(--muted, #5B6B7B); margin-top: 0.7rem; line-height: 1.5; }

/* Scroll lock while open */
body.bk-lock { overflow: hidden; }

/* Mobile: full-screen sheet */
@media (max-width: 640px) {
    .bk-overlay {
        padding: 0;
        height: 100%;
        height: 100dvh;
        overflow: hidden;
    }
    .bk-modal {
        max-width: none;
        height: 100%;
        height: 100dvh;
        min-height: 0;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }
    .bk-head {
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    }
    .bk-choices {
        grid-template-columns: 1fr;
    }
    .bk-grid2,
    .bk-grid3 {
        grid-template-columns: 1fr;
    }
    .bk-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bk-overlay, .bk-modal, .bk-progress span, .bk-choice label, .bk-btn { transition: none !important; }
}

/* Visually hidden (screen-reader accessible) helpers */
.netlify-honeypot {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   v25 — Mobile submission repair layer
   (booking.css loads after each page's inline <style>, so these
   equal-specificity rules win the cascade without redesigning
   the desktop styles above them.)
   ============================================================ */

/* ---------- Visible validation message for standard forms ---------- */
.nf-error {
    display: none;
    margin: 0 0 0.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    background: #FDECEA;
    border: 1px solid #F5C6C0;
    color: #B3261E;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.45;
}
.nf-error.nf-show { display: block; }
/* quick-contact forms sit on dark navy panels — keep the message readable */
.qc-form .nf-error { background: #FFF3F2; }

/* Highlight fields the browser reports as invalid after a blocked attempt
   (standard forms only — the booking modal has its own .bk-invalid styles) */
form.netlify-form:not(#bkForm) input[aria-invalid="true"]:not([type="radio"]):not([type="checkbox"]),
form.netlify-form:not(#bkForm) select[aria-invalid="true"],
form.netlify-form:not(#bkForm) textarea[aria-invalid="true"] {
    border-color: #D93025 !important;
    outline: 2px solid rgba(217, 48, 37, 0.35);
    outline-offset: 1px;
}

/* ---------- Submit controls: reliable tap targets everywhere ---------- */
form.netlify-form button[type="submit"],
form.netlify-form input[type="submit"],
form.netlify-form button:not([type]),
.bk-btn {
    touch-action: manipulation;          /* no 300ms delay / double-tap zoom */
    pointer-events: auto;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
}

/* Clear pressed / focus / disabled / sending states */
form.netlify-form button[type="submit"]:active,
form.netlify-form input[type="submit"]:active,
.bk-btn:active {
    transform: translateY(1px);
    filter: brightness(0.94);
}
form.netlify-form button[type="submit"]:focus-visible,
form.netlify-form input[type="submit"]:focus-visible,
.bk-btn:focus-visible {
    outline: 3px solid #7CBBFF;
    outline-offset: 2px;
}
form.netlify-form button[type="submit"]:disabled,
form.netlify-form input[type="submit"]:disabled,
form.netlify-form [aria-busy="true"],
.bk-btn:disabled,
.bk-btn[aria-busy="true"] {
    opacity: 0.65;
    cursor: default;
    transform: none;
}

/* Keep fields and buttons clear of the sticky header / bottom bar when
   JS scrolls the first invalid control into view */
form.netlify-form input,
form.netlify-form select,
form.netlify-form textarea,
form.netlify-form button[type="submit"],
form.netlify-form input[type="submit"] {
    scroll-margin-top: 90px;
    scroll-margin-bottom: 110px;
}

@media (max-width: 968px) {
    /* ≥52px touch height and full width on phones for every submit control */
    form.netlify-form button[type="submit"],
    form.netlify-form input[type="submit"] {
        min-height: 52px;
        width: 100%;
        align-self: stretch;   /* careers form centers its button on desktop */
    }
    .bk-btn { min-height: 52px; }
}

/* ---------- Fixed mobile Call Now / Book Online bar ---------- */
/* The empty container never intercepts taps; only the two links do. */
.mobile-call-bar {
    pointer-events: none;
}
.mobile-call-bar .mcb-row {
    pointer-events: none;
    /* extend the bar's background through the iPhone home-indicator area */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #041F3A;
}
.mobile-call-bar a {
    pointer-events: auto;
    min-height: 52px;
    touch-action: manipulation;
}
.mobile-call-bar a:active { filter: brightness(0.9); }

@media (max-width: 968px) {
    /* Enough scrolling space for every submit button to clear the fixed
       bar completely (bar ≈56px + breathing room + safe area). Overrides
       the inline 56–60px page padding via cascade order. */
    body {
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    }
}

/* ============================================================
   v26 — Safari repair layer
   ============================================================ */

/* Booking form shell: the <form> now wraps both the scrollable .bk-body
   and the .bk-foot, so the footer submit button is physically inside the
   form. Flexbox keeps the header and footer visible while only .bk-body
   scrolls (matters on the mobile full-screen sheet). */
.bk-form-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.bk-form-shell > .bk-body {
    flex: 1 1 auto;
    min-height: 0;
}
@media (max-width: 640px) {
    .bk-form-shell > .bk-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Explicit-JS invalid marking for standard forms (class-based; no
   dependence on the :invalid pseudo-class) */
form.netlify-form:not(#bkForm) input.nf-invalid:not([type="radio"]):not([type="checkbox"]),
form.netlify-form:not(#bkForm) select.nf-invalid,
form.netlify-form:not(#bkForm) textarea.nf-invalid {
    border-color: #D93025 !important;
    outline: 2px solid rgba(217, 48, 37, 0.35);
    outline-offset: 1px;
}
/* required checkbox / radio rows: outline the clickable label row */
form.netlify-form:not(#bkForm) input.nf-invalid[type="checkbox"],
form.netlify-form:not(#bkForm) input.nf-invalid[type="radio"] {
    outline: 2px solid rgba(217, 48, 37, 0.6);
    outline-offset: 2px;
}
