/* ==========================================================================
 * Dialogs - the shared shell (.ff-dialog) and the quote dialog
 *
 * Two dialogs wear the shell: the quote dialog (#ff-quote-dialog, fixfactor-core
 * includes/core/quote-dialog.php) and "Price too high?" (#negotiate-modal,
 * price-check.css adds its two-column body). Both are native <dialog>
 * elements opened with showModal(): the top layer, the inert page, Esc and the
 * backdrop come from the browser. The scrim and the scroll lock are base.css
 * (dialog::backdrop, html:has(dialog[open])).
 *
 * Phone first: a sheet rising from the bottom edge, the full width, as tall
 * as its content and never taller than the screen less 16px - so the page
 * still shows above it and it reads as a layer, not a new page. The head
 * (title, service, close) stays put; only the body scrolls. From 769px it is
 * a centred panel.
 *
 * Spacing is the v4 scale: title to context 8, context to lead 16, lead to
 * form 24, label to field 8, field to field 20 (24 from 481px), panel padding
 * 16 on a phone and 32 above.
 * ========================================================================== */

.ff-dialog {
    position: fixed;
    inset: auto 0 0;
    /* Only for engines with no <dialog>, where [open] shows it in the page
       instead of the top layer. */
    z-index: 1000;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    color: var(--content-body);
    overflow: hidden;
}

.ff-dialog[open] {
    display: flex;
    animation: ffDialogUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ffDialogUp {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes ffDialogIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: none; }
}

.ff-dialog button,
.ff-dialog input,
.ff-dialog select,
.ff-dialog textarea {
    font-family: inherit;
}

.ff-dialog__head {
    position: relative;
    flex: none;
    padding: 24px 16px 0;
}

.ff-dialog__title {
    margin: 0;
    padding-right: 56px;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--content);
}

/* The service and its price: one quiet line in the action colour. */
.ff-dialog__ctx {
    margin: 8px 0 0;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--action);
}

.ff-dialog__ctx[hidden] {
    display: none;
}

.ff-dialog__close {
    position: absolute;
    top: 16px;
    right: 12px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1.5px solid var(--border-neutral);
    border-radius: 50%;
    background: var(--surface);
    color: var(--content);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

/* 46px to tap, 40px to see. */
.ff-dialog__close::before {
    content: "";
    position: absolute;
    inset: -3px;
}

.ff-dialog__close:hover {
    border-color: var(--action);
}

.ff-dialog__close svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.ff-dialog__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 16px 28px;
    padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
}

.ff-dialog :focus-visible:not(input):not(textarea):not(select) {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

@media (min-width: 769px) {
    .ff-dialog {
        inset: 0;
        width: min(34rem, calc(100% - 40px));
        height: fit-content;
        max-height: calc(100vh - 48px);
        max-height: calc(100dvh - 48px);
        margin: auto;
        border-radius: 16px;
        box-shadow: 0 24px 64px var(--shadow-colour-lg);
    }

    .ff-dialog[open] {
        animation: ffDialogIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .ff-dialog__head { padding: 32px 32px 0; }
    .ff-dialog__close { right: 16px; }
    .ff-dialog__body { padding: 16px 32px 32px; }
}

@media (prefers-reduced-motion: reduce) {
    .ff-dialog[open] { animation: none; }
}

/* --------------------------------------------------------------------------
 * The quote dialog
 *
 * The fields are the site control from wp-integration.css; this only lays
 * the form out. Name and message take the full width; email and phone share
 * a row once there is room for two 48px fields side by side.
 * ------------------------------------------------------------------------ */
#ff-quote-dialog .ffq-lead {
    margin: 0;
    max-width: 52ch;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--content-body);
}

#ff-quote-dialog .ffq-soon {
    margin: 6px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--content-body);
}

#ff-quote-dialog .ffq-soon a {
    color: var(--action);
    font-weight: 600;
    text-underline-offset: 2px;
}

#ff-quote-dialog .wpforms-container {
    margin: 24px 0 0;
}

#ff-quote-dialog .wpforms-field-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 20px;
}

#ff-quote-dialog .wpforms-form .wpforms-field {
    margin: 0;
}

#ff-quote-dialog .wpforms-field textarea {
    height: 120px;
    min-height: 120px;
}

@media (min-width: 481px) {
    #ff-quote-dialog .wpforms-field-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 16px;
        row-gap: 24px;
    }

    #ff-quote-dialog .wpforms-field { grid-column: 1 / -1; }

    #ff-quote-dialog .wpforms-field-email,
    #ff-quote-dialog .wpforms-field-phone { grid-column: auto; }
}

/* The thank-you takes the form's place. */
#ff-quote-dialog .ffq-done {
    display: none;
    padding: 8px 0 0;
    text-align: center;
}

#ff-quote-dialog.is-done .ffq-lead,
#ff-quote-dialog.is-done .ffq-soon,
#ff-quote-dialog.is-done .wpforms-container {
    display: none;
}

#ff-quote-dialog.is-done .ffq-done {
    display: block;
}

#ff-quote-dialog .ffq-done svg {
    color: var(--accent);
    margin-bottom: 12px;
}

#ff-quote-dialog .ffq-done p {
    margin: 0 0 24px;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--content-body);
}

#ff-quote-dialog .ffq-done-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 0 24px;
    border: 2px solid var(--action);
    border-radius: 12px;
    background: var(--surface);
    color: var(--action);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

#ff-quote-dialog .ffq-done-close:hover {
    border-color: var(--action-hover);
    color: var(--action-hover);
}

/* ==========================================================================
 * The quote form inside a service panel (quote-dialog.js, data-qm-panel)
 *
 * The panel's own lower zone, edge to edge, not a card inside a card. Inside
 * it the panel's anatomy holds: one line in the weight of the fulfilment
 * question, fields on the grid of the fulfilment cards, then the CTA row.
 * Hover and focus on the fields stay the site's (wp-integration.css).
 *
 * The negative margin undoes the service body's 1.4rem padding.
 * ========================================================================== */
.ff-qslot {
    position: relative;
    margin: 1.75rem -1.4rem -1.4rem;
    padding: 1.4rem;
    border-top: 1px solid var(--wash-warm-strong);
    background: var(--surface-warm);
}

.ff-qslot .ff-qlead {
    margin: 0 0 0.9rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--content);
}

.ff-qslot .wpforms-container.wpforms-container {
    margin: 0;
    padding: 0;
}

.ff-qslot .wpforms-field-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem 0.6rem;
}

.ff-qslot .wpforms-container.wpforms-container .wpforms-form .wpforms-field {
    margin: 0;
    padding: 0;
}

.ff-qslot .wpforms-container.wpforms-container .wpforms-field-label {
    margin: 0 0 6px;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--content);
}

/* Only what is optional gets a mark; required fields stay required. */
.ff-qslot .wpforms-required-label {
    display: none;
}

.ff-qslot .wpforms-field-phone .wpforms-field-label::after {
    content: " (optional)";
    font-weight: 400;
    color: var(--content-secondary);
}

.ff-qslot .ff-qopt {
    font-weight: 400;
    color: var(--content-secondary);
}

.ff-qslot .ff-qhelp {
    display: block;
    margin: -2px 0 6px;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--content-secondary);
}

.ff-qslot .wpforms-container.wpforms-container .wpforms-field textarea {
    display: block;
    height: 96px;
    min-height: 96px;
    padding: 11px var(--space-4);
}

/* [FIX] The model pages' own focus outline stacked a second ring on the site's
   field focus (wp-integration.css). Same selector weight, so it needs the IDs. */
:is(#ff-dm, #ff-dt, #ff-dc) .ff-qslot .wpforms-field :focus-visible {
    outline: none;
}

/* [FIX] The same outline drew a box round the thank-you, which only takes focus
   so a screen reader lands on it. */
:is(#ff-dm, #ff-dt, #ff-dc) .ff-qslot .ff-qdone:focus-visible {
    outline: none;
}

/* One line until there is more to say; two where the model has to be typed. */
@supports (field-sizing: content) {
    .ff-qslot .wpforms-container.wpforms-container .wpforms-field textarea {
        field-sizing: content;
        height: auto;
        min-height: 48px;
        max-height: 15rem;
        resize: none;
    }

    .ff-qslot .wpforms-container.wpforms-container .wpforms-field textarea[aria-describedby] {
        min-height: 76px;
    }
}

/* The same button as "Pay & Reserve", on the same line as "Full details". */
.ff-qslot .wpforms-container.wpforms-container .wpforms-submit-container {
    margin: 1.25rem 0 0;
    padding: 0;
}

.ff-qslot .wpforms-container.wpforms-container .wpforms-submit {
    width: 100%;
    height: 50px;
    min-height: 50px;
    padding: 0 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.ff-qmore {
    display: flex;
    justify-content: center;
}

/* Sent: the whole zone turns green, the one loud moment in the panel. */
.ff-qslot.is-sent {
    border-top-color: var(--border-subtle);
    background: var(--status-success-bg);
}

.ff-qdone {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    outline: none;
    animation: ffQDone 0.25s ease;
}

@keyframes ffQDone {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ff-qdone svg {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
}

.ff-qdone-disc {
    fill: var(--status-success);
}

.ff-qdone-tick {
    fill: none;
    stroke: var(--status-success-bg);
    stroke-width: 2.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The zone's colour makes it loud; the type stays below the service name. */
.ff-qslot .ff-qdone-title {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--content);
}

.ff-qslot .ff-qdone-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--content-body);
    overflow-wrap: anywhere;
}

.ff-qdone-text strong {
    font-weight: 700;
    color: var(--content);
}

/* The row keeps saying it after the panel closes. Same face as the price column. */
.ff-qrequested {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.87em;
    font-weight: 600;
    color: var(--status-success);
    white-space: nowrap;
}

.ff-qrequested svg {
    flex: 0 0 16px;
}

/* Another service after a send: the thank-you's two lines, with "Full details"
   where the CTA row keeps it. */
.ff-qslot.is-note .ff-qlead {
    margin: 0 0 4px;
}

.ff-qslot .ff-qnote-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--content-body);
}

.ff-qslot.is-note .ff-qmore {
    margin-top: 0.25rem;
}

@media (min-width: 769px) {
    .ff-qslot .wpforms-field-container {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ff-qslot .wpforms-field-textarea {
        grid-column: 1 / -1;
    }

    .ff-qslot .wpforms-container.wpforms-container .wpforms-submit {
        width: auto;
    }

    .ff-qmore {
        position: absolute;
        right: 1.4rem;
        bottom: calc(1.4rem + 3px);
    }

    .ff-qslot.is-note {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1.5rem;
    }

    .ff-qslot.is-note .ff-qmore {
        position: static;
        flex: 0 0 auto;
        margin: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ff-qdone { animation: none; }
}

