/**
 * contact-form.css - Custom Contact Form
 *
 * Styles for the form rendered by lop_render_contact_form().
 * Designed to match the site palette (green primary, amber accent)
 * with polished focus states, inline error styling, and a clear
 * success state that replaces the form on submit.
 *
 * @package LibrandiOutdoorPower
 * @since   1.2.0
 */


/* ==========================================================
   Form container
   ========================================================== */
.lop-contact-form {
    --lop-cf-border:        var(--color-gray-200);
    --lop-cf-border-hover:  var(--color-gray-300);
    --lop-cf-border-focus:  var(--color-primary-light);
    --lop-cf-focus-ring:    rgba(var(--color-primary-rgb), .15);
    --lop-cf-error:         #c0392b;
    --lop-cf-error-bg:      #fdecea;
    --lop-cf-success:       #1b5e20;
    --lop-cf-success-bg:    #e6f4ea;

    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding: var(--space-8);
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* Success state: hide fields, keep status banner visible */
.lop-contact-form.is-sent > *:not(.lop-contact-form__status):not(noscript) {
    display: none;
}
.lop-contact-form.is-sent .lop-contact-form__status.is-success {
    display: block;
}

/* Honeypot: fully hidden from humans but reachable by naive bots */
.lop-contact-form__hp {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}


/* ==========================================================
   Rows + field wrappers
   Two-column on desktop, single column on mobile.
   ========================================================== */
.lop-contact-form__row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}
@media (min-width: 640px) {
    .lop-contact-form__row {
        grid-template-columns: 1fr 1fr;
    }
}

.lop-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}
.lop-field label {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-gray-800);
    letter-spacing: -0.005em;
}
.lop-field__required {
    color: var(--color-accent);
    margin-left: 2px;
}
.lop-field__hint {
    color: var(--color-gray-400);
    font-weight: 400;
    font-style: italic;
}


/* ==========================================================
   Inputs, selects, textareas
   ========================================================== */
.lop-contact-form input[type="text"],
.lop-contact-form input[type="email"],
.lop-contact-form input[type="tel"],
.lop-contact-form select,
.lop-contact-form textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.4;
    color: var(--color-gray-900);
    background: var(--color-white);
    border: 1.5px solid var(--lop-cf-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--duration) var(--ease),
                box-shadow  var(--duration) var(--ease),
                background  var(--duration) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.lop-contact-form input:hover,
.lop-contact-form select:hover,
.lop-contact-form textarea:hover {
    border-color: var(--lop-cf-border-hover);
}
.lop-contact-form input:focus,
.lop-contact-form select:focus,
.lop-contact-form textarea:focus {
    outline: none;
    border-color: var(--lop-cf-border-focus);
    box-shadow: 0 0 0 4px var(--lop-cf-focus-ring);
}
.lop-contact-form textarea {
    resize: vertical;
    min-height: 140px;
    font-family: var(--font-body);
}

/* Native select dropdown arrow (CSS mask so it adapts to theme color) */
.lop-contact-form select {
    padding-right: calc(var(--space-4) + 20px);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%232d4a22' d='M6 8L0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    background-size: 12px 8px;
}


/* ==========================================================
   Error state
   Red border + red message node. has-error class is toggled
   on .lop-field by the JS when the server returns a per-field
   error for that input.
   ========================================================== */
.lop-field.has-error input,
.lop-field.has-error select,
.lop-field.has-error textarea {
    border-color: var(--lop-cf-error);
    box-shadow: 0 0 0 4px rgba(192, 57, 43, .12);
}
.lop-field__error {
    font-size: var(--text-xs);
    color: var(--lop-cf-error);
    margin: 0;
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height var(--duration) var(--ease),
                opacity var(--duration) var(--ease);
}
.lop-field__error.is-visible {
    max-height: 4em;
    opacity: 1;
    padding-top: 2px;
}


/* ==========================================================
   Submit button + loading spinner
   ========================================================== */
.lop-contact-form__actions {
    display: flex;
    justify-content: flex-start;
    margin-top: var(--space-2);
}
.lop-contact-form__submit {
    position: relative;
    min-width: 180px;
}
.lop-contact-form__submit[disabled] {
    cursor: wait;
    opacity: 0.85;
}
.lop-contact-form__submit.is-loading .lop-contact-form__submit-label {
    visibility: hidden;
}
.lop-contact-form__spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: var(--color-white);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}
.lop-contact-form__submit.is-loading .lop-contact-form__spinner {
    opacity: 1;
    animation: lop-cf-spin 0.75s linear infinite;
}
@keyframes lop-cf-spin {
    to { transform: rotate(360deg); }
}


/* ==========================================================
   Status banner (success or error summary)
   ========================================================== */
.lop-contact-form__status {
    display: none;
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: var(--leading-normal);
    border-left: 3px solid transparent;
}
.lop-contact-form__status.is-visible {
    display: block;
}
.lop-contact-form__status.is-success {
    background: var(--lop-cf-success-bg);
    color: var(--lop-cf-success);
    border-left-color: var(--lop-cf-success);
}
.lop-contact-form__status.is-error {
    background: var(--lop-cf-error-bg);
    color: var(--lop-cf-error);
    border-left-color: var(--lop-cf-error);
}


/* ==========================================================
   Headings, intro, noscript fallback
   ========================================================== */
.lop-contact-form__heading {
    margin: 0;
    font-size: var(--text-2xl);
    color: var(--color-primary);
}
.lop-contact-form__intro {
    margin: 0;
    color: var(--color-gray-600);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
}
.lop-contact-form__noscript {
    padding: var(--space-4);
    background: var(--color-off-white);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}


/* ==========================================================
   Responsive tuning
   ========================================================== */
@media (max-width: 640px) {
    .lop-contact-form {
        padding: var(--space-6);
    }
    .lop-contact-form__submit {
        width: 100%;
    }
}
