/* ==========================================================================
   Video Form Button — Front-end styles
   Divi z-index strategy:
     • The modal overlay is moved to document.body by JS at runtime,
       escaping every Divi stacking context (transform / opacity / filter).
     • z-index: 2147483647 is INT_MAX — nothing beats it.
     • position: fixed references the viewport, not any ancestor.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Trigger button
   -------------------------------------------------------------------------- */
/*
 * Layout-critical properties use !important so the button renders correctly
 * inside arbitrary containers (theme excerpts, The Events Calendar list views,
 * Divi modules) that aggressively reset descendant button styles.
 * Colours come through inline style="" from the shortcode and remain themable.
 */
.vfb-trigger-btn,
button.vfb-trigger-btn {
    display:          inline-block !important;
    padding:          0.75em 1.75em !important;
    margin:           0;
    width:            auto !important;
    height:           auto !important;
    min-height:       0 !important;
    font-size:        1rem !important;
    font-weight:      600 !important;
    font-family:      inherit !important;
    line-height:      1.2 !important;
    letter-spacing:   0.02em !important;
    text-align:       center !important;
    text-decoration:  none !important;
    text-transform:   none !important;
    vertical-align:   middle !important;
    cursor:           pointer !important;
    border:           none !important;
    outline:          none !important;
    box-shadow:       none !important;
    box-sizing:       border-box !important;
    transition:       filter 0.18s ease, transform 0.12s ease;
    /* border-radius and colours supplied inline from shortcode atts */
}

.vfb-trigger-btn:hover {
    filter:    brightness(1.12);
    transform: translateY(-1px);
}
.vfb-trigger-btn:active {
    transform: translateY(0);
    filter:    brightness(0.95);
}
.vfb-trigger-btn:focus-visible {
    outline:        3px solid currentColor;
    outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Modal overlay
   Appended to <body> by JS — completely outside Divi stacking contexts.
   -------------------------------------------------------------------------- */
.vfb-modal-overlay {
    /* Position against viewport, not any ancestor */
    position:   fixed !important;
    inset:      0 !important;          /* top/right/bottom/left: 0 */
    width:      100vw !important;
    height:     100vh !important;

    /*
     * INT_MAX z-index. Divi uses 9999-1000000; this beats everything.
     * The !important ensures Divi's specificity tricks can't override it.
     */
    z-index:    2147483647 !important;

    /* Semi-transparent dark backdrop */
    background: rgba(0, 0, 0, 0.62);

    /* Flex-centre the dialog box */
    display:          flex !important;
    align-items:      center;
    justify-content:  center;
    padding:          1rem;
    box-sizing:       border-box;

    /* Smooth fade-in */
    opacity:    0;
    transition: opacity 0.22s ease;

    /* Prevent backdrop from generating its own stacking context
       (no transform, no filter, no opacity < 1 until animation). */
}

.vfb-modal-overlay.vfb-modal--visible {
    opacity: 1;
}

/* Hidden state — drives visibility for all .vfb-* hideable elements */
.vfb-hidden {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Modal box
   -------------------------------------------------------------------------- */
.vfb-modal-box {
    position:         relative;
    background:       #ffffff;          /* overridden by JS per-instance */
    border:           2px solid #a22025; /* overridden by JS per-instance */
    border-radius:    12px;
    padding:          2rem 2.25rem 1.75rem;
    width:            100%;
    max-width:        540px;
    max-height:       90vh;
    overflow-y:       auto;
    box-shadow:       0 8px 40px rgba(0,0,0,0.25);
    box-sizing:       border-box;

    /* Slide-up entrance */
    transform:        translateY(18px);
    transition:       transform 0.25s cubic-bezier(0.34,1.28,0.64,1);
}

.vfb-modal--visible .vfb-modal-box {
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Close button
   -------------------------------------------------------------------------- */
.vfb-modal-close {
    position:    absolute;
    top:         0.75rem;
    right:       1rem;
    background:  transparent;
    border:      none;
    font-size:   1.6rem;
    line-height: 1;
    color:       #555;
    cursor:      pointer;
    padding:     0.2em 0.3em;
    border-radius: 4px;
    transition:  color 0.15s, background 0.15s;
}
.vfb-modal-close:hover {
    color:       #a22025;
    background:  rgba(162,32,37,0.08);
}
.vfb-modal-close:focus-visible {
    outline: 2px solid #a22025;
}

/* --------------------------------------------------------------------------
   Form title
   -------------------------------------------------------------------------- */
.vfb-modal-title {
    margin:       0 2rem 1.4rem 0;
    font-size:    1.3rem;
    font-weight:  700;
    color:        #1a1a1a;
    line-height:  1.3;
}

/* --------------------------------------------------------------------------
   Form layout
   -------------------------------------------------------------------------- */
.vfb-form {
    display:        flex;
    flex-direction: column;
    gap:            0.9rem;
}

.vfb-row--2 {
    display: grid;
    gap:     0.9rem;
    grid-template-columns: 1fr 1fr;
}

/* --------------------------------------------------------------------------
   Fields
   -------------------------------------------------------------------------- */
.vfb-field {
    display:        flex;
    flex-direction: column;
    gap:            0.3rem;
}

.vfb-field label {
    font-size:   0.82rem;
    font-weight: 600;
    color:       #444;
    letter-spacing: 0.01em;
}

.vfb-req {
    color: #a22025;
}

.vfb-field input {
    padding:       0.55em 0.8em;
    font-size:     0.95rem;
    border:        1.5px solid #d0d0d0;
    border-radius: 6px;
    background:    #fafafa;
    color:         #1a1a1a;
    width:         100%;
    box-sizing:    border-box;
    outline:       none;
    transition:    border-color 0.18s, box-shadow 0.18s;
    -webkit-appearance: none;
    appearance:    none;
}

.vfb-field input:focus {
    border-color: #a22025;
    background:   #fff;
    box-shadow:   0 0 0 3px rgba(162,32,37,0.12);
}

.vfb-field input::placeholder {
    color: #aaa;
}

/* Invalid state after attempted submit */
.vfb-field input.vfb-invalid {
    border-color: #c0392b;
    box-shadow:   0 0 0 3px rgba(192,57,43,0.15);
}

/* --------------------------------------------------------------------------
   Error message
   -------------------------------------------------------------------------- */
.vfb-msg {
    padding:       0.65em 0.9em;
    border-radius: 6px;
    font-size:     0.88rem;
    font-weight:   500;
}
.vfb-msg--error {
    background:  #fdf0f0;
    border:      1px solid #e8a0a2;
    color:       #8b1a1e;
}

/* --------------------------------------------------------------------------
   Submit button — colours applied by JS per-instance
   -------------------------------------------------------------------------- */
.vfb-submit-btn {
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             0.5em;
    width:           100%;
    padding:         0.75em 1.5em;
    margin-top:      0.25rem;
    font-size:       1rem;
    font-weight:     700;
    letter-spacing:  0.02em;
    border:          none;
    border-radius:   6px;      /* overridden by JS */
    cursor:          pointer;
    background:      #a22025;  /* overridden by JS */
    color:           #ffffff;  /* overridden by JS */
    transition:      filter 0.18s, transform 0.12s;
}
.vfb-submit-btn:hover:not(:disabled) {
    filter:    brightness(1.1);
    transform: translateY(-1px);
}
.vfb-submit-btn:active {
    transform: translateY(0);
}
.vfb-submit-btn:disabled {
    opacity: 0.7;
    cursor:  not-allowed;
}

/* Spinner */
.vfb-btn-spinner {
    width:            18px;
    height:           18px;
    border:           2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius:    50%;
    animation:        vfb-spin 0.7s linear infinite;
    flex-shrink:      0;
}
@keyframes vfb-spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Privacy note
   -------------------------------------------------------------------------- */
.vfb-privacy {
    font-size:   0.75rem;
    color:       #888;
    text-align:  center;
    margin:      0.3rem 0 0;
}
.vfb-privacy a {
    color: #a22025;
}

/* --------------------------------------------------------------------------
   Body scroll-lock (applied by JS)
   -------------------------------------------------------------------------- */
body.vfb-scroll-locked {
    overflow: hidden !important;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .vfb-modal-box {
        padding:       1.5rem 1.25rem 1.25rem;
        border-radius: 10px;
        max-height:    95vh;
    }
    .vfb-row--2 {
        grid-template-columns: 1fr;
    }
    .vfb-modal-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 360px) {
    .vfb-modal-box {
        padding: 1.2rem 1rem 1rem;
    }
}
