/**
 * RSVP Accessibility & "Grandparent-Proof" Overrides
 * 
 * Loaded on all published wedding sites to improve RSVP form usability
 * for older guests, guests with poor eyesight, or guests unfamiliar
 * with web forms. These styles are additive and non-breaking.
 */

/* ──── Larger inputs & labels ──── */
#rsvpForm .input-group input,
#rsvpForm .input-group select,
#rsvpForm .input-group textarea,
#rsvpForm .form-group input,
#rsvpForm .form-group select,
#rsvpForm .form-group textarea {
    font-size: clamp(16px, 1.1rem, 18px); /* Prevents iOS zoom on focus */
    padding: 0.875rem 1rem;
    min-height: 52px; /* WCAG 2.5.8 — 44px minimum touch target */
    border-width: 2px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#rsvpForm .input-group label,
#rsvpForm .form-group label {
    font-size: clamp(14px, 0.95rem, 16px);
    font-weight: 600;
}

/* ──── Focus states — extra obvious ──── */
#rsvpForm input:focus,
#rsvpForm select:focus,
#rsvpForm textarea:focus {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
    border-color: #3b82f6;
}

/* ──── Radio & checkbox — bigger touch targets ──── */
#rsvpForm .radio-option {
    padding: 0.75rem 1rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.15s;
}

#rsvpForm .radio-option:hover,
#rsvpForm .radio-option:focus-within {
    background-color: rgba(0, 0, 0, 0.04);
}

#rsvpForm .radio-option input[type="radio"],
#rsvpForm .radio-option input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
    accent-color: currentColor;
}

#rsvpForm .radio-label {
    font-size: clamp(15px, 1rem, 17px);
}

#rsvpForm .radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ──── Submit button — large and unmissable ──── */
#rsvpForm [data-action="submit-rsvp"],
#rsvpForm button[type="submit"] {
    font-size: clamp(16px, 1.1rem, 20px);
    padding: 1rem 2rem;
    min-height: 56px;
    min-width: 200px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.025em;
    transition: transform 0.1s, background-color 0.2s, box-shadow 0.2s;
}

#rsvpForm [data-action="submit-rsvp"]:active,
#rsvpForm button[type="submit"]:active {
    transform: scale(0.97);
}

/* ──── Inline validation error messages ──── */
.rsvp-field-error {
    display: block;
    color: #dc2626;
    font-size: clamp(13px, 0.875rem, 15px);
    font-weight: 600;
    margin-top: 0.375rem;
    padding-left: 0.25rem;
    animation: rsvp-error-shake 0.4s ease-in-out;
}

/* Top-level form error banner */
.rsvp-error-banner {
    background-color: #fef2f2;
    border: 2px solid #dc2626;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: #dc2626;
    font-size: clamp(14px, 0.95rem, 16px);
    font-weight: 600;
    text-align: center;
    animation: rsvp-error-shake 0.4s ease-in-out;
}

/* Success banner */
.rsvp-success-banner {
    background-color: #f0fdf4;
    border: 2px solid #16a34a;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: #16a34a;
    font-size: clamp(15px, 1rem, 18px);
    font-weight: 700;
    text-align: center;
    animation: rsvp-success-pop 0.3s ease-out;
}

@keyframes rsvp-error-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes rsvp-success-pop {
    0% { transform: scale(0.95); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

/* ──── Invalid field highlight ──── */
#rsvpForm input:invalid:not(:placeholder-shown),
#rsvpForm select:invalid:not(:placeholder-shown),
#rsvpForm textarea:invalid:not(:placeholder-shown),
#rsvpForm .rsvp-field-invalid {
    border-color: #dc2626;
}

/* ──── Disabled/loading state ──── */
#rsvpForm button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ──── Mobile improvements ──── */
@media (max-width: 640px) {
    #rsvpForm .input-group input,
    #rsvpForm .input-group select,
    #rsvpForm .input-group textarea,
    #rsvpForm .form-group input,
    #rsvpForm .form-group select,
    #rsvpForm .form-group textarea {
        font-size: 16px; /* Exactly 16px prevents iOS Safari zoom */
        padding: 1rem;
        min-height: 56px;
    }

    #rsvpForm [data-action="submit-rsvp"],
    #rsvpForm button[type="submit"] {
        width: 100%;
        font-size: 18px;
        padding: 1.25rem;
        min-height: 60px;
    }

    #rsvpForm .radio-option {
        padding: 1rem;
        min-height: 52px;
    }
}

/* ──── High contrast / prefers-contrast ──── */
@media (prefers-contrast: more) {
    #rsvpForm input,
    #rsvpForm select,
    #rsvpForm textarea {
        border-width: 3px;
        border-color: #000;
    }

    #rsvpForm label {
        font-weight: 700;
    }
}

/* ──── Reduced motion ──── */
@media (prefers-reduced-motion: reduce) {
    .rsvp-field-error,
    .rsvp-error-banner,
    .rsvp-success-banner {
        animation: none;
    }

    #rsvpForm [data-action="submit-rsvp"]:active,
    #rsvpForm button[type="submit"]:active {
        transform: none;
    }
}
