/*
 * AI Workflow Toolkit — NPSOA free-tier upgrade modal.
 *
 * Loaded only on the member dashboard page AND only for users whose sole
 * role is aiwftk_npsoa_member (see AIWFTK_Public::enqueue_styles()).
 *
 * The modal itself is rendered by render_dashboard() inside the
 * .aiwftk-dashboard wrapper, with HTML `hidden` attribute set initially.
 * JavaScript (aiwftk-public.js, openUpgradeModal() / closeUpgradeModal())
 * toggles the attribute to show and hide.
 *
 * Divi compatibility — brute-force version:
 *
 * The first iteration of this stylesheet used `body .aiwftk-dashboard` +
 * `!important` on a few key properties, following the project's existing
 * Divi CSS pattern. That wasn't enough — Divi's theme CSS still won on
 * the dialog's background, box-shadow, border-radius, and typography,
 * leaving the modal content floating un-contained over the dashboard
 * with the title rendered in Divi's big all-caps blue h2 treatment.
 *
 * This version takes no chances:
 *
 *   - Every selector is prefixed with `body #aiwftk-npsoa-modal` — an
 *     ID-qualified selector that beats almost anything Divi throws at
 *     structural divs.
 *   - Every visual property carries !important. Background, shadow,
 *     radius, padding, font sizing, text-transform, font-family — if
 *     the theme could plausibly override it, we force it.
 *   - The title explicitly resets text-transform, font-family, letter-
 *     spacing, line-height so Divi's h2 treatment (all-caps, theme font,
 *     wide tracking) can't leak through.
 *   - Both the overlay and the dialog have their backgrounds forced.
 *     Even if one fails, the other provides the visual separation from
 *     the dashboard behind.
 *
 * The cost is ugly-looking CSS. The benefit is the modal reliably looks
 * like a modal on a Divi site without requiring theme-level rule hunts
 * for whichever specific Divi selector is winning on any given property.
 *
 * Z-index policy: the modal sits above Divi's sticky header (z-index
 * 99999 in Divi). 2147483000 leaves room below the 32-bit int ceiling.
 *
 * @package AI_Workflow_Toolkit
 * @subpackage AI_Workflow_Toolkit/assets/css
 * @since 1.24.0
 */

/* ==============================================================
   Root container — full-viewport fixed positioning.
   ============================================================== */

body #aiwftk-npsoa-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2147483000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
    /* Own backdrop — fills the fixed container with a semi-transparent
       dark tint. The separate .aiwftk-npsoa-modal-overlay child is kept
       for the click-to-close target, but the dim itself lives here so
       we're guaranteed a visible backdrop even if the child's background
       gets stripped. */
    background-color: rgba(17, 24, 39, 0.65) !important;

    /*
     * Fade-in / fade-out transitions.
     *
     * The modal's "closed" CSS state is opacity: 0 + visibility: hidden
     * + pointer-events: none — fully invisible, non-interactive, and
     * removed from the accessibility tree (visibility: hidden is the
     * AT-hide signal; we rely on that rather than also juggling
     * aria-hidden to avoid the aria-modal/aria-hidden conflict).
     *
     * Opening adds the .is-open class (see rule below) which transitions
     * opacity from 0 to 1 over 500ms and flips visibility instantly so
     * the fade is visible. Closing removes the class, which reverses
     * the opacity transition over 500ms and — via the `visibility 0s
     * linear 500ms` delay — flips visibility to hidden only AFTER the
     * opacity fade completes. That keeps screen readers from losing the
     * element mid-fade and prevents the element from being click-
     * interceptable after it's visually gone.
     *
     * The transitions carry !important because Divi occasionally sets
     * transition: all 0.3s ease on section/module children and we want
     * the modal's own timing to win.
     */
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.5s ease, visibility 0s linear 0.5s !important;
}

body #aiwftk-npsoa-modal.is-open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    /* Open direction: visibility changes immediately so we can see
       the fade start. Close direction (rule above) delays visibility
       until after the opacity fade ends. */
    transition: opacity 0.5s ease, visibility 0s linear 0s !important;
}

/*
 * No-JS fallback. Keeps the server-rendered modal fully hidden when
 * JavaScript doesn't run. On page load with JS, aiwftk-public.js
 * strips the hidden attribute during init and from then on the
 * .is-open class controls visibility via the transitions above.
 */
body #aiwftk-npsoa-modal[hidden] {
    display: none !important;
}

/*
 * Respect prefers-reduced-motion.
 * Users who request reduced motion (OS-level setting) skip the fade
 * and get instant visibility toggles. Accessibility best practice
 * per WCAG 2.1 SC 2.3.3 (Animation from Interactions — AAA) and
 * common sense for vestibular-sensitive users.
 */
@media (prefers-reduced-motion: reduce) {
    body #aiwftk-npsoa-modal,
    body #aiwftk-npsoa-modal.is-open {
        transition: none !important;
    }
}

/* Lock body scroll while the modal is open. JS toggles this class on
   <body> via openUpgradeModal() / closeUpgradeModal(). */
body.aiwftk-npsoa-modal-open {
    overflow: hidden !important;
}

/* ==============================================================
   Overlay — click target that fills the modal behind the dialog.
   Transparent by design because the backdrop now lives on the modal
   itself (above). Kept as a separate element so the click handler has
   a dedicated target that isn't the dialog's own chrome.
   ============================================================== */

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
}

/* ==============================================================
   Dialog — the white card containing title, body, and actions.
   ============================================================== */

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-dialog {
    position: relative !important;
    z-index: 1 !important;              /* stack above the overlay sibling */
    background: #ffffff !important;
    background-color: #ffffff !important;
    border-radius: 10px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    max-width: 480px !important;
    width: 100% !important;
    padding: 36px 32px 28px !important;
    box-sizing: border-box !important;
    max-height: calc(100vh - 32px) !important;
    overflow-y: auto !important;
    text-align: left !important;
}

/* Close button — circular X in the top-right corner of the dialog. */
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    background: transparent !important;
    background-color: transparent !important;
    border: 0 !important;
    color: #6b7280 !important;
    font-size: 26px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    transition: color 0.15s ease, background-color 0.15s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-close:hover,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-close:focus {
    color: #111827 !important;
    background: #f3f4f6 !important;
    background-color: #f3f4f6 !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-close:focus-visible {
    outline: 2px solid var(--aiwftk-primary, #2271b1) !important;
    outline-offset: 2px !important;
}

/* Kill Divi's ::after arrow on buttonish elements — the close button is
   a <button>, not an <a>, but Divi's selectors sometimes catch both. */
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-close::after,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-close::before {
    display: none !important;
    content: none !important;
}

/* ==============================================================
   Title — aggressively reset so Divi's h2 treatment doesn't leak
   through (all-caps, theme font, wide letter-spacing, large size).
   ============================================================== */

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-title {
    display: block !important;
    margin: 0 0 12px 0 !important;
    padding: 0 40px 0 0 !important;   /* room for the close button */
    font-family: inherit !important;   /* use theme body font, not heading font */
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: #111827 !important;
    text-transform: none !important;   /* defeat any theme uppercase rule */
    letter-spacing: normal !important;
    text-align: left !important;
    /* Divi often styles the heading color and :before/:after — strip it. */
    background: none !important;
    border: 0 !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-title::before,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-title::after {
    display: none !important;
    content: none !important;
}

/* ==============================================================
   Body paragraphs.
   ============================================================== */

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-body {
    margin: 0 0 22px 0 !important;
    padding: 0 !important;
    color: #374151 !important;
    font-family: inherit !important;
    font-size: 16px !important;
    line-height: 1.55 !important;
    text-align: left !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-body p {
    margin: 0 0 10px 0 !important;
    padding: 0 !important;
    color: #374151 !important;
    font-family: inherit !important;
    font-size: 16px !important;
    line-height: 1.55 !important;
    text-align: left !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-body p:last-child {
    margin-bottom: 0 !important;
}

/* ==============================================================
   Actions — primary CTA + secondary text link stacked vertically.
   ============================================================== */

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
    margin: 0 !important;
    padding: 0 !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-cta-primary {
    display: inline-block !important;
    text-align: center !important;
    background: var(--aiwftk-cta, #f36f21) !important;
    background-color: var(--aiwftk-cta, #f36f21) !important;
    color: #ffffff !important;
    text-decoration: none !important;
    font-family: inherit !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    line-height: 1.2 !important;
    padding: 13px 20px !important;
    border-radius: 6px !important;
    border: 1px solid var(--aiwftk-cta-hover, #d85f18) !important;
    min-height: 44px !important;
    box-sizing: border-box !important;
    transition: background-color 0.15s ease !important;
    cursor: pointer !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-cta-primary:hover,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-cta-primary:focus {
    background: var(--aiwftk-cta-hover, #d85f18) !important;
    background-color: var(--aiwftk-cta-hover, #d85f18) !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-cta-primary:focus-visible {
    outline: 2px solid var(--aiwftk-primary, #2271b1) !important;
    outline-offset: 2px !important;
}

/* Kill Divi's ::after arrow on the primary CTA.
   See Patterns-and-Solutions.md "Gravity Forms Styling Inside Plugin
   Shortcodes" for the same pattern. */
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-cta-primary::after,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-cta-primary::before {
    display: none !important;
    content: none !important;
}

/* Secondary action — plain-text link treatment, centered, no background. */
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-secondary {
    display: inline-block !important;
    text-align: center !important;
    background: transparent !important;
    background-color: transparent !important;
    color: var(--aiwftk-primary, #2271b1) !important;
    border: 0 !important;
    text-decoration: underline !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
    padding: 8px 12px !important;
    margin: 0 !important;
    min-height: auto !important;    /* secondary action doesn't need 44px — optional emphasis */
    cursor: pointer !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-secondary:hover,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-secondary:focus {
    color: var(--aiwftk-primary-hover, #135e96) !important;
    background: transparent !important;
    background-color: transparent !important;
    text-decoration: underline !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-secondary:focus-visible {
    outline: 2px solid var(--aiwftk-primary, #2271b1) !important;
    outline-offset: 2px !important;
    border-radius: 4px !important;
}

body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-secondary::after,
body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-secondary::before {
    display: none !important;
    content: none !important;
}

/* ==============================================================
   Responsive — mobile adjustments.
   ============================================================== */

@media (max-width: 480px) {
    body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-dialog {
        padding: 28px 20px 20px !important;
    }

    body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-title {
        font-size: 20px !important;
    }

    body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-body,
    body #aiwftk-npsoa-modal .aiwftk-npsoa-modal-body p {
        font-size: 15px !important;
    }
}

/* ==============================================================
   Roundtable section treatment for NPSOA free-tier users.

   Two visual states sit alongside the existing full-member Roundtable
   rendering (which we leave untouched):

     .aiwftk-npsoa-roundtable-comp
       Complimentary-access framing line — small italic note rendered
       under the join link reminding NPSOA users that their Roundtable
       access is a complimentary benefit of NPSOA membership. Muted
       grey so it reads as context, not a primary CTA.

     .aiwftk-npsoa-roundtable-upgrade
       Upgrade nudge rendered in place of the join link when the
       admin-configured npsoa_roundtable_expires date has passed. The
       Roundtable date is still shown (so NPSOA users see the
       Roundtable is ongoing) but the join link is replaced with a
       brief "become a member" pitch.

   Neither rule uses ID-scoped specificity because these elements live
   in the normal dashboard flow, not inside the modal. The
   body .aiwftk-dashboard prefix + !important is sufficient for Divi
   compatibility here per the established project pattern.
   ============================================================== */

body .aiwftk-dashboard .aiwftk-npsoa-roundtable-comp {
    margin-top: 4px !important;
    font-size: 13px !important;
    color: #6b7280 !important;
    line-height: 1.4 !important;
}

body .aiwftk-dashboard .aiwftk-npsoa-roundtable-comp em {
    font-style: italic !important;
    color: #6b7280 !important;
}

body .aiwftk-dashboard .aiwftk-npsoa-roundtable-upgrade {
    display: inline-block;
    /* v1.24.5: the upgrade nudge now lives in its own centered
       .aiwftk-roundtable-action line (stacked column layout), so the
       old margin-left: 12px — which was the gap from the date/label
       inline siblings — no longer applies. */
    margin-left: 0 !important;
    color: #6b7280 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

body .aiwftk-dashboard .aiwftk-npsoa-roundtable-upgrade a {
    color: var(--aiwftk-cta, #f36f21) !important;
    font-weight: 600 !important;
    text-decoration: underline !important;
}

body .aiwftk-dashboard .aiwftk-npsoa-roundtable-upgrade a:hover,
body .aiwftk-dashboard .aiwftk-npsoa-roundtable-upgrade a:focus {
    color: var(--aiwftk-cta-hover, #d85f18) !important;
    text-decoration: underline !important;
}

/* =====================================================
   /npsoa-mag page — standalone "Copy the Upgraded Prompt"
   button + section content (v1.66.0).

   Public magazine page on a Divi site, so visual properties
   carry !important to beat the theme's button and list
   styling (per the project's Divi-override keep-list). The
   button is self-contained — it does NOT inherit the
   delivery-page overlay control's absolute positioning, so
   it degrades to a plain in-flow button if CSS is missing
   rather than breaking. Styled to match the plugin's
   standard copy button (the one on /workflow).
   ===================================================== */
body .aiwftk-npsoa-prompt-copy {
    margin: 0 0 8px 0 !important;
    /* Center the inline-block button within its own (full-width) wrapper, so
       it centers regardless of the host Divi module's own text-align. */
    text-align: center !important;
}
/* Belt-and-suspenders with the <pre>'s HTML hidden attribute. */
body .aiwftk-npsoa-prompt-copy .aiwftk-prompt-upgrade-text {
    display: none !important;
}
/* Matches the orange "Copy This Workflow" CTA on /workflow
   (.aiwftk-featured-workflow-wrap .aiwftk-copy-btn) — the button Dave prefers.
   Same brand-CTA orange, uppercase, 700 weight, 6px radius, darker-orange
   hover with an orange outline. white-space:normal + max-width so the longer
   "Copy the Upgraded Prompt" label wraps gracefully instead of overflowing. */
body button.aiwftk-npsoa-copy-btn {
    display: inline-block !important;
    position: static !important;
    padding: 20px 56px !important;
    min-height: 44px !important;
    max-width: 100% !important;
    background: #f37024 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    font-family: inherit !important;
    line-height: 1.3 !important;
    text-align: center !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-decoration: none !important;
    white-space: normal !important;
    box-shadow: none !important;
    outline: none !important;
    box-sizing: border-box !important;
    transition: background 0.2s ease, transform 0.05s ease !important;
}
body button.aiwftk-npsoa-copy-btn:hover,
body button.aiwftk-npsoa-copy-btn:focus {
    background: #d95e1a !important;
    color: #ffffff !important;
    outline: 2px solid #f37024 !important;
    outline-offset: 2px !important;
}
/* Copied/error states also recolor the focus outline (it comes after the
   :hover/:focus rule at equal specificity, so it wins when the button is both
   focused and copied) — otherwise the orange focus ring lingers around the
   green "Copied!" button. v1.66.3. */
body button.aiwftk-npsoa-copy-btn.aiwftk-prompt-upgrade-copied {
    background: #46b450 !important;
    color: #ffffff !important;
    outline: 2px solid #2e7d32 !important;
    outline-offset: 2px !important;
}
body button.aiwftk-npsoa-copy-btn.aiwftk-prompt-upgrade-error {
    background: #be1e2d !important;
    color: #ffffff !important;
    outline: 2px solid #7f141d !important;
    outline-offset: 2px !important;
}

/* Prompt-intro sentences (key="prompt_intro") — a tight, deliberate gap between
   the lines instead of a full blank line, and no trailing margin. v1.66.3.
   text-align:center reasserts the page's centering: wrapping the sentences in
   <p> (to control the gap) pulled them under Divi's default left-aligned
   paragraph styling, which the inline <br> version never hit. v1.66.4. */
body .aiwftk-npsoa-prompt-intro {
    text-align: center !important;
}
body .aiwftk-npsoa-prompt-intro p {
    margin: 0 0 10px 0 !important;
    line-height: 1.6 !important;
    text-align: center !important;
}
body .aiwftk-npsoa-prompt-intro p:last-child {
    margin-bottom: 0 !important;
}

/* Section content rendered by [aiwftk_npsoa_field key="above_video"/"below_video"].
   The intro is a plain block; the bullets are a plugin-owned <ul> so bullet
   markup and styling live here, not in each episode's copy. */
body .aiwftk-npsoa-section-intro {
    margin: 0 0 12px 0 !important;
    line-height: 1.6 !important;
}
body ul.aiwftk-npsoa-section-list {
    margin: 0 0 12px 1.35em !important;
    padding: 0 !important;
    list-style: disc outside !important;
}
body ul.aiwftk-npsoa-section-list li {
    margin: 0 0 6px 0 !important;
    line-height: 1.6 !important;
    list-style: disc outside !important;
}
