/* Twomey Service Agreements — iPad-first multi-step form */

.twsa-form-root {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 12px 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.4;
    color: #1f2330;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
}

.twsa-form-root *,
.twsa-form-root *::before,
.twsa-form-root *::after {
    box-sizing: border-box;
}

.twsa-form-root h2 {
    font-size: 22px;
    margin: 0 0 4px;
    line-height: 1.2;
}
.twsa-form-root h3 {
    font-size: 17px;
    margin: 0 0 6px;
}
.twsa-lead {
    color: #4a5063;
    margin: 0 0 12px;
    font-size: 16px;
}
.twsa-hint {
    color: #6b7280;
    font-size: 15px;
    margin: 6px 0 0;
}
.twsa-required {
    color: #c53030;
}

/* Form acts as a vertical flex container so the active step fills the viewport */
.twsa-form {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Progress */
.twsa-progress {
    flex: 0 0 auto;
    margin-bottom: 12px;
}
.twsa-progress-label {
    display: block;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 6px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.twsa-progress-bar {
    background: #e6e8ee;
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
}
.twsa-progress-fill {
    background: #1657ff;
    height: 100%;
    width: 0;
    transition: width 200ms ease-out;
}

/* Step container — the visible step fills remaining viewport, scrolls internally only if content overflows */
.twsa-step {
    background: #ffffff;
    border: 1px solid #e6e8ee;
    border-radius: 14px;
    padding: 18px 22px;
    margin-bottom: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.twsa-step:not([hidden]) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.twsa-step[hidden] {
    display: none;
}

/* Inputs */
.twsa-label {
    display: block;
    margin: 12px 0 0;
    font-weight: 600;
    font-size: 15px;
}
.twsa-label--block textarea,
.twsa-label--block input {
    margin-top: 6px;
}
.twsa-form-root input[type="text"],
.twsa-form-root input[type="email"],
.twsa-form-root input[type="tel"],
.twsa-form-root select,
.twsa-form-root textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 11px 14px;
    font-size: 17px;
    line-height: 1.3;
    border: 1px solid #cbd0db;
    border-radius: 9px;
    background: #fbfbfd;
    color: #1f2330;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}
.twsa-form-root textarea {
    min-height: 110px;
    resize: vertical;
}
.twsa-form-root input:focus,
.twsa-form-root textarea:focus,
.twsa-form-root select:focus {
    border-color: #1657ff;
    outline: 2px solid rgba(22, 87, 255, 0.2);
    outline-offset: 0;
    background: #fff;
}

/* Buttons */
.twsa-btn,
.twsa-big-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 10px 22px;
    font-size: 17px;
    font-weight: 600;
    border: 1px solid #cbd0db;
    border-radius: 11px;
    background: #fff;
    color: #1f2330;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform 80ms ease-out, background 120ms ease-out, border-color 120ms ease-out;
}
.twsa-btn:active,
.twsa-big-btn:active {
    transform: scale(0.985);
}
.twsa-btn--primary {
    background: #1657ff;
    border-color: #1657ff;
    color: #fff;
}
.twsa-btn--primary:disabled {
    background: #9aa6c2;
    border-color: #9aa6c2;
    cursor: not-allowed;
}
.twsa-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: #1657ff;
}
.twsa-big-btn {
    width: 100%;
    min-height: 84px;
    font-size: 20px;
    border-width: 2px;
}
.twsa-big-btn--alt {
    background: #f4f6fb;
}

/* Layouts */
.twsa-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.twsa-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
@media (min-width: 640px) {
    .twsa-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

/* Radio cards (device picker) */
.twsa-radio-grid {
    border: 0;
    padding: 0;
    margin: 8px 0 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
@media (min-width: 640px) {
    .twsa-radio-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (min-width: 1024px) {
    .twsa-radio-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
.twsa-radio-grid legend {
    grid-column: 1 / -1;
    font-weight: 600;
    margin-bottom: 2px;
    padding: 0;
    font-size: 15px;
}
.twsa-radio-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 8px;
    text-align: center;
    border: 2px solid #e6e8ee;
    border-radius: 10px;
    background: #fbfbfd;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
}
.twsa-radio-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.twsa-radio-card:has(input:checked) {
    border-color: #1657ff;
    background: #eef3ff;
}

/* Radio pills */
.twsa-radio-row {
    border: 0;
    padding: 0;
    margin: 18px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.twsa-radio-row legend {
    width: 100%;
    font-weight: 600;
    margin-bottom: 6px;
    padding: 0;
}
.twsa-radio-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 8px 18px;
    border: 1.5px solid #cbd0db;
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-weight: 500;
}
.twsa-radio-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.twsa-radio-pill:has(input:checked) {
    background: #eef3ff;
    border-color: #1657ff;
    color: #1657ff;
}

/* Checkbox grid */
.twsa-checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}
@media (min-width: 640px) {
    .twsa-checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1024px) {
    .twsa-checkbox-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
.twsa-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1.5px solid #e6e8ee;
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
    min-height: 46px;
    font-weight: 500;
    font-size: 15px;
}
.twsa-checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.twsa-checkbox:has(input:checked) {
    border-color: #1657ff;
    background: #eef3ff;
}
.twsa-checkbox--block {
    width: 100%;
    margin: 12px 0 0;
}

/* Fieldsets */
.twsa-fieldset {
    border: 1px solid #e6e8ee;
    border-radius: 11px;
    padding: 10px 16px 14px;
    margin: 14px 0 0;
}
.twsa-fieldset legend {
    padding: 0 6px;
    font-weight: 600;
    font-size: 15px;
}

/* Disclaimers */
.twsa-disclaimer {
    border: 1px solid #e6e8ee;
    border-left: 4px solid #1657ff;
    border-radius: 9px;
    padding: 12px 16px;
    margin: 10px 0 0;
    background: #fafbff;
    font-size: 14px;
}
.twsa-disclaimer p {
    margin: 4px 0;
}
.twsa-disclaimer h3 {
    margin-top: 0;
}
.twsa-disclaimer--coverage {
    border-left-color: #6b7280;
    background: #f7f8fb;
}

/* Details (collapsible) */
.twsa-details {
    margin: 18px 0 0;
    border: 1px dashed #cbd0db;
    border-radius: 10px;
    padding: 14px 16px;
}
.twsa-details summary {
    cursor: pointer;
    font-weight: 600;
}

/* Lookup results */
.twsa-lookup-results {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.twsa-lookup-card,
.twsa-confirm-card,
.twsa-prior-list .twsa-prior-card {
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1.5px solid #e6e8ee;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.twsa-lookup-card strong,
.twsa-prior-card strong {
    font-size: 19px;
    display: block;
}
.twsa-lookup-card .twsa-meta,
.twsa-prior-card .twsa-meta {
    color: #6b7280;
    font-size: 15px;
    margin-top: 4px;
}
.twsa-lookup-empty {
    margin-top: 16px;
    padding: 18px;
    border: 1px dashed #cbd0db;
    border-radius: 12px;
    text-align: center;
}

/* Signature pad */
.twsa-sigpad-wrap {
    position: relative;
    border: 2px dashed #cbd0db;
    border-radius: 12px;
    padding: 8px;
    background: #fff;
    margin: 10px 0;
    flex: 1 1 auto;
    min-height: 200px;
    display: flex;
}
.twsa-sigpad {
    width: 100%;
    flex: 1 1 auto;
    min-height: 200px;
    display: block;
    background: #fff;
    border-radius: 8px;
    touch-action: none;
}
.twsa-sigpad-wrap .twsa-btn--ghost {
    position: absolute;
    right: 8px;
    top: 8px;
}

/* Cloudflare Turnstile widget */
.twsa-turnstile {
    margin: 14px 0 4px;
    display: flex;
    justify-content: center;
}

/* Navigation — pinned at the bottom of the viewport */
.twsa-nav {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0 16px;
    background: #ffffff;
    border-top: 1px solid #e6e8ee;
    margin-top: auto;
}
.twsa-nav .twsa-btn--primary,
.twsa-nav [data-twsa-action="submit"] {
    margin-left: auto;
}

/* Status messages */
.twsa-status {
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #fff5f5;
    border: 1px solid #f5c6c6;
    color: #872929;
}
.twsa-status--ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

/* Success */
.twsa-success {
    text-align: center;
    padding: 48px 24px;
    border: 1px solid #a7f3d0;
    background: #ecfdf5;
    border-radius: 16px;
}
.twsa-success h2 {
    color: #065f46;
}
.twsa-reference {
    font-size: 16px;
    color: #374151;
    margin-top: 16px;
}

/* Phone portrait fallback */
@media (max-width: 640px) {
    .twsa-form-root {
        font-size: 16px;
        padding: 10px 12px 0;
    }
    .twsa-step {
        padding: 14px 14px;
    }
    .twsa-form-root h2 {
        font-size: 20px;
    }
}

/* Wider screens — keep readable but use the room */
@media (min-width: 1280px) {
    .twsa-form-root {
        max-width: 1280px;
        padding: 14px 32px 0;
    }
}
