/* SP Compliance Gate — Frontend Styles
 * Extracted from inline_styles() for browser caching.
 */

/* Stage 1 Gate: Scoped styles - CACHE-SAFE IMPLEMENTATION */

/*
 * Stage 1 is rendered before the site header. Give it a true top-layer
 * stacking value so later theme/header markup cannot sit above the gate.
 * The PHP-rendered inline style mirrors these values for first-paint safety.
 */
#sp-ruo-stage1-overlay {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2147483001;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(12px, 2vw, 24px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* ONLY show when html has required class */
html.sp-ruo-stage1-required.sp-gate-show-s1 #sp-ruo-stage1-overlay {
    display: flex;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Scroll lock ONLY when gate required (NO !important to avoid theme conflicts) */
html.sp-ruo-stage1-required.sp-gate-show-s1,
html.sp-ruo-stage1-required.sp-gate-show-s1 body {
    overflow: hidden;
}

/*
 * Universal containment for Stage 1 only. This prevents broad site rules such
 * as button/input width + padding from making the gate wider than its modal.
 */
#sp-ruo-stage1-overlay,
#sp-ruo-stage1-overlay *,
#sp-ruo-stage1-overlay *::before,
#sp-ruo-stage1-overlay *::after {
    box-sizing: border-box !important;
}

/*
 * Auto vertical margins center the modal when it fits. When it is taller than
 * the viewport, the margins collapse and the overlay itself remains scrollable
 * from the very top—no hidden header/logo or unreachable bottom button.
 */
#sp-ruo-stage1-overlay #sp-ruo-stage1-modal {
    position: relative !important;
    flex: 0 1 500px !important;
    width: min(100%, 500px) !important;
    max-width: 500px !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: auto 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5) !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    isolation: isolate !important;
}

/* All other styles MUST be scoped under #sp-ruo-stage1-overlay or #sp-ruo-stage1-modal */
#sp-ruo-stage1-overlay .sp-ruo-gate-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 24px !important;
    overflow-x: hidden !important;
}

#sp-ruo-stage1-overlay .sp-ruo-gate-content > *,
#sp-ruo-stage1-overlay .sp-ruo-gate-section,
#sp-ruo-stage1-overlay .sp-ruo-agreement-box,
#sp-ruo-stage1-overlay label,
#sp-ruo-stage1-overlay label > span,
#sp-ruo-stage1-overlay p,
#sp-ruo-stage1-overlay h2,
#sp-ruo-stage1-overlay h3 {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: anywhere !important;
}

#sp-ruo-stage1-overlay .sp-ruo-gate-section {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 2px solid #E2E8F0;
}

#sp-ruo-stage1-overlay .sp-ruo-gate-section:last-of-type {
    border-bottom: none;
}

#sp-ruo-stage1-overlay .sp-ruo-agreement-box {
    width: 100% !important;
    background: #F8FAFC;
    border-left: 4px solid #002868;
    padding: 12px;
    border-radius: 4px;
    max-height: 200px;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
}

/* Keep checkbox controls from inheriting site-wide full-width form styling. */
#sp-ruo-stage1-overlay input[type="checkbox"] {
    display: inline-block !important;
    flex: 0 0 18px !important;
    width: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    height: 18px !important;
    min-height: 18px !important;
    max-height: 18px !important;
    margin: 3px 0 0 !important;
    padding: 0 !important;
    border-radius: 2px !important;
    box-shadow: none !important;
}

/* Birthday/email inputs stay contained without changing their intended widths. */
#sp-ruo-stage1-overlay input:not([type="checkbox"]),
#sp-ruo-stage1-overlay select,
#sp-ruo-stage1-overlay textarea {
    max-width: 100% !important;
}

/* Hard override broad theme/global button rules. */
#sp-ruo-stage1-overlay #sp-ruo-gate-submit,
#sp-ruo-stage1-overlay #sp-ruo-gate-submit:hover,
#sp-ruo-stage1-overlay #sp-ruo-gate-submit:focus,
#sp-ruo-stage1-overlay #sp-ruo-gate-submit:active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    margin: 0 !important;
    padding: 13px 16px !important;
    border: 0 !important;
    border-radius: 6px !important;
    background: #002868 !important;
    color: #ffffff !important;
    font-size: 15px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
    text-align: center !important;
    box-shadow: none !important;
    transform: none !important;
}

#sp-ruo-stage1-overlay #sp-ruo-gate-submit:hover,
#sp-ruo-stage1-overlay #sp-ruo-gate-submit:focus {
    background: #BF0A30 !important;
    box-shadow: 0 4px 12px rgba(191, 10, 48, 0.3) !important;
}

#sp-ruo-stage1-overlay img {
    display: block !important;
    width: auto !important;
    max-width: min(200px, 100%) !important;
    height: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

@media (max-width: 600px) {
    #sp-ruo-stage1-overlay {
        padding: 10px !important;
    }

    #sp-ruo-stage1-overlay #sp-ruo-stage1-modal {
        width: 100% !important;
        max-width: 500px !important;
        border-radius: 8px !important;
    }

    #sp-ruo-stage1-overlay .sp-ruo-gate-content {
        padding: 20px 16px !important;
    }
}

@media (max-width: 380px) {
    #sp-ruo-stage1-overlay {
        padding: 6px !important;
    }

    #sp-ruo-stage1-overlay .sp-ruo-gate-content {
        padding: 18px 13px !important;
    }

    #sp-ruo-stage1-overlay #sp-ruo-gate-heading {
        font-size: 20px !important;
    }
}

/* Legacy Stage 2 and other gate styles below */

#sp-ruo-gate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#sp-ruo-gate-modal {
    background: white;
    max-width: 700px;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.sp-ruo-gate-stripe {
    background: linear-gradient(90deg, #BF0A30 0%, #E8E8E8 50%, #002868 100%);
    height: 4px;
    border-radius: 8px 8px 0 0;
}

.sp-ruo-gate-content {
    padding: 30px;
}

.sp-ruo-gate-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 2px solid #E2E8F0;
}

.sp-ruo-gate-section:last-of-type {
    border-bottom: none;
}

.sp-ruo-agreement-box {
    background: #F8FAFC;
    border-left: 4px solid #002868;
    padding: 15px;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
}

#sp-ruo-gate-submit:hover {
    background: #BF0A30;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(191, 10, 48, 0.3);
}

.sp-ruo-disclaimer {
    background: #F9FAFB;
    border-left: 3px solid #CBD5E1;
    padding: 15px 20px;
    margin: 20px 0;
    font-size: 13px;
    line-height: 1.6;
    color: #475569;
}

.sp-ruo-disclaimer strong {
    color: #64748B;
    display: inline;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
}

.sp-ruo-checkout-checkbox {
    margin: 15px 0;
}

.sp-ruo-checkout-checkbox label {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
    cursor: pointer !important;
    font-weight: 400 !important;
    color: #475569 !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sp-ruo-checkout-checkbox label span {
    margin-top: 1px !important;
    line-height: 1.2 !important;
    display: inline !important;
}

.sp-ruo-checkout-checkbox input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    margin: 1px 0 0 0 !important;
}
