/**
 * Custom Soft Paywall Styles
 */

/* ============================================
   CSS Variables - Murphy's Law Branding
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Murphy's Law Brand Colors */
    --endrn-teal: #1B7C7C;
    --endrn-teal-hover: #156565;
    --endrn-teal-light: rgba(27, 124, 124, 0.1);
    --endrn-orange: #F5A550;
    --endrn-orange-hover: #E89440;
    --endrn-dark-navy: #2C3E50;
    --endrn-light-grey: #F5F5F5;
    --endrn-medium-grey: #999999;
    --endrn-white: #FFFFFF;

    /* Paywall Specific Variables */
    --endrn-spw-overlay-bg: rgba(44, 62, 80, 0.75);
    --endrn-spw-sheet-bg: var(--endrn-white);
    --endrn-spw-sheet-shadow: 0 -12px 48px rgba(44, 62, 80, 0.2), 0 -4px 16px rgba(44, 62, 80, 0.1);
    --endrn-spw-border-radius: 20px;
    --endrn-spw-accent: var(--endrn-orange);
    --endrn-spw-accent-hover: var(--endrn-orange-hover);
    --endrn-spw-text: var(--endrn-dark-navy);
    --endrn-spw-text-muted: var(--endrn-medium-grey);
    --endrn-spw-input-border: #E0E0E0;
    --endrn-spw-input-focus: var(--endrn-teal);
    --endrn-spw-error: #E74C3C;
    --endrn-spw-fade-start: rgba(255, 255, 255, 0);
    --endrn-spw-fade-end: rgba(255, 255, 255, 0.98);
}

/* ============================================
   Scroll Lock
   ============================================ */
html.endrn-spw-locked,
html.endrn-spw-locked body {
    overflow: hidden !important;
    height: 100% !important;
    position: relative !important;
}

/* iOS Safari fix for scroll lock */
html.endrn-spw-locked body {
    position: fixed !important;
    width: 100% !important;
    touch-action: none;
}

/* ============================================
   Content Wrapper
   ============================================ */
.endrn-spw-content {
    position: relative;
}

.endrn-spw-content--locked {
    overflow: hidden !important;
    position: relative;
}

/* Graduated Blur Overlay - increases toward bottom */
.endrn-spw-content--locked::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60vh;
    min-height: 300px;
    max-height: 800px;
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    pointer-events: none;
    z-index: 99;
}

/* Create graduated blur effect using multiple pseudo-elements via mask */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .endrn-spw-content--locked::before {
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        mask-image: linear-gradient(to bottom,
            rgba(0,0,0,0) 0%,
            rgba(0,0,0,0.02) 10%,
            rgba(0,0,0,0.08) 20%,
            rgba(0,0,0,0.18) 30%,
            rgba(0,0,0,0.32) 40%,
            rgba(0,0,0,0.48) 50%,
            rgba(0,0,0,0.64) 60%,
            rgba(0,0,0,0.78) 70%,
            rgba(0,0,0,0.88) 80%,
            rgba(0,0,0,0.95) 90%,
            rgba(0,0,0,1) 100%
        );
        -webkit-mask-image: linear-gradient(to bottom,
            rgba(0,0,0,0) 0%,
            rgba(0,0,0,0.02) 10%,
            rgba(0,0,0,0.08) 20%,
            rgba(0,0,0,0.18) 30%,
            rgba(0,0,0,0.32) 40%,
            rgba(0,0,0,0.48) 50%,
            rgba(0,0,0,0.64) 60%,
            rgba(0,0,0,0.78) 70%,
            rgba(0,0,0,0.88) 80%,
            rgba(0,0,0,0.95) 90%,
            rgba(0,0,0,1) 100%
        );
    }
}

/* Gradient Fade Overlay on Content */
.endrn-spw-content--locked::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 60vh;
    min-height: 300px;
    max-height: 800px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.02) 10%,
        rgba(255, 255, 255, 0.08) 20%,
        rgba(255, 255, 255, 0.18) 30%,
        rgba(255, 255, 255, 0.35) 40%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0.72) 60%,
        rgba(255, 255, 255, 0.85) 70%,
        rgba(255, 255, 255, 0.93) 80%,
        rgba(255, 255, 255, 0.97) 90%,
        var(--endrn-spw-fade-end) 100%
    );
    pointer-events: none;
    z-index: 100;
}

/* Fallback for browsers without backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .endrn-spw-content--locked::after {
        background: linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.1) 10%,
            rgba(255, 255, 255, 0.25) 20%,
            rgba(255, 255, 255, 0.4) 30%,
            rgba(255, 255, 255, 0.55) 40%,
            rgba(255, 255, 255, 0.7) 50%,
            rgba(255, 255, 255, 0.82) 60%,
            rgba(255, 255, 255, 0.9) 70%,
            rgba(255, 255, 255, 0.95) 80%,
            rgba(255, 255, 255, 0.98) 90%,
            var(--endrn-spw-fade-end) 100%
        );
    }
}

/* ============================================
   Overlay - Subtle gradient (no solid overlay for bottom sheet)
   ============================================ */
.endrn-spw-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 50%,
        rgba(44, 62, 80, 0.15) 75%,
        rgba(44, 62, 80, 0.3) 100%
    );
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.endrn-spw-overlay--visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Bottom Sheet
   ============================================ */
.endrn-spw-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    pointer-events: none;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s ease;
}

.endrn-spw-sheet--visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.endrn-spw-sheet__inner {
    width: 100%;
    max-width: 100%;
    background: var(--endrn-spw-sheet-bg);
    border-radius: var(--endrn-spw-border-radius) var(--endrn-spw-border-radius) 0 0;
    box-shadow: var(--endrn-spw-sheet-shadow);
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 16px));
    max-height: 40vh;
    overflow: hidden;
    border-top: 4px solid var(--endrn-teal);
    position: relative;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .endrn-spw-sheet__inner {
        padding: 28px 40px;
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 16px));
        border-top: 5px solid var(--endrn-teal);
        max-width: 800px;
        margin: 0 auto;
    }
}

@media (min-width: 1024px) {
    .endrn-spw-sheet__inner {
        max-width: 900px;
        padding: 32px 50px;
        padding-bottom: calc(32px + env(safe-area-inset-bottom, 16px));
    }
}

/* ============================================
   Sheet Content
   ============================================ */

/* Remove lock icon - too much vertical space */
.endrn-spw-sheet__inner::before {
    display: none;
}

.endrn-spw-copy {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .endrn-spw-copy {
        margin-bottom: 24px;
    }
}

#endrn-spw-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--endrn-spw-text);
    margin: 0 0 12px 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

@media (min-width: 768px) {
    #endrn-spw-title {
        font-size: 1.5rem;
        margin-bottom: 14px;
    }
}

@media (min-width: 1024px) {
    #endrn-spw-title {
        font-size: 1.625rem;
    }
}

.endrn-spw-message {
    color: var(--endrn-spw-text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 600px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .endrn-spw-message {
        font-size: 0.9375rem;
        line-height: 1.55;
    }
}

.endrn-spw-message p {
    margin: 0 0 10px 0;
}

.endrn-spw-message p:last-child {
    margin-bottom: 0;
}

.endrn-spw-message strong {
    color: var(--endrn-spw-text);
    font-weight: 600;
}

/* ============================================
   Form
   ============================================ */
.endrn-spw-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .endrn-spw-form {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
}

@media (min-width: 768px) {
    .endrn-spw-form {
        gap: 16px;
    }
}

.endrn-spw-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    min-width: 0;
    width: 100%;
}

.endrn-spw-label span {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--endrn-spw-text);
    letter-spacing: -0.01em;
}

@media (min-width: 768px) {
    .endrn-spw-label span {
        font-size: 0.875rem;
    }
}

.endrn-spw-form input[type="text"],
.endrn-spw-form input[type="email"] {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    font-size: 0.9375rem;
    border: 2px solid var(--endrn-spw-input-border);
    border-radius: 8px;
    background: var(--endrn-light-grey);
    color: var(--endrn-spw-text);
    transition: all 0.25s ease;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .endrn-spw-form input[type="text"],
    .endrn-spw-form input[type="email"] {
        padding: 13px 16px;
        font-size: 1rem;
    }
}

.endrn-spw-form input[type="text"]:focus,
.endrn-spw-form input[type="email"]:focus {
    outline: none;
    border-color: var(--endrn-spw-input-focus);
    background: #fff;
    box-shadow: 0 0 0 4px var(--endrn-teal-light), 0 2px 8px rgba(27, 124, 124, 0.1);
    transform: translateY(-1px);
}

.endrn-spw-form input[type="text"]:hover:not(:focus),
.endrn-spw-form input[type="email"]:hover:not(:focus) {
    border-color: #C0C0C0;
}

.endrn-spw-form input[type="text"]::placeholder,
.endrn-spw-form input[type="email"]::placeholder {
    color: var(--endrn-medium-grey);
    opacity: 0.7;
}

/* Honeypot - hidden from users */
.endrn-spw-hp {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* Submit Button - Primary Orange CTA */
.endrn-spw-submit {
    width: 100%;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--endrn-white);
    background: var(--endrn-spw-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 4px;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 12px rgba(245, 165, 80, 0.25);
}

@media (min-width: 640px) {
    .endrn-spw-submit {
        grid-column: 1 / -1;
    }
}

@media (min-width: 768px) {
    .endrn-spw-submit {
        padding: 15px 32px;
        font-size: 1.0625rem;
        margin-top: 8px;
    }
}

.endrn-spw-submit:hover {
    background: var(--endrn-spw-accent-hover);
    box-shadow: 0 6px 20px rgba(245, 165, 80, 0.4);
    transform: translateY(-2px);
}

.endrn-spw-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(245, 165, 80, 0.3);
}

.endrn-spw-submit:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(245, 165, 80, 0.3), 0 6px 20px rgba(245, 165, 80, 0.4);
}

.endrn-spw-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Loading state */
.endrn-spw-submit--loading {
    position: relative;
    color: transparent !important;
}

.endrn-spw-submit--loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: endrn-spw-spin 0.8s linear infinite;
}

@keyframes endrn-spw-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Privacy Note */
.endrn-spw-privacy {
    font-size: 0.75rem;
    color: var(--endrn-spw-text-muted);
    text-align: center;
    line-height: 1.5;
    margin-top: 12px;
    flex-shrink: 0;
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .endrn-spw-privacy {
        font-size: 0.8125rem;
        margin-top: 14px;
    }
}

.endrn-spw-privacy a {
    color: var(--endrn-teal);
    text-decoration: none;
    transition: color 0.2s ease;
}

.endrn-spw-privacy a:hover {
    color: var(--endrn-teal-hover);
    text-decoration: underline;
}

/* Error Message */
.endrn-spw-error {
    font-size: 0.8125rem;
    color: var(--endrn-spw-error);
    text-align: center;
    margin-top: 8px;
    font-weight: 500;
    padding: 6px 10px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--endrn-spw-error);
    flex-shrink: 0;
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .endrn-spw-error {
        font-size: 0.875rem;
        padding: 8px 12px;
        margin-top: 10px;
    }
}

.endrn-spw-error:empty {
    display: none;
}

/* ============================================
   Animations
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .endrn-spw-overlay,
    .endrn-spw-sheet,
    .endrn-spw-submit {
        transition: none;
    }
    
    .endrn-spw-submit--loading::after {
        animation: none;
    }
}

/* ============================================
   Focus visible for keyboard navigation
   ============================================ */
.endrn-spw-form input:focus-visible,
.endrn-spw-submit:focus-visible {
    outline: 3px solid var(--endrn-teal);
    outline-offset: 2px;
}


/* Improved mobile spacing */
@media (max-width: 480px) {
    .endrn-spw-sheet__inner {
        padding: 20px 18px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 16px));
    }

    #endrn-spw-title {
        font-size: 1.25rem;
        margin-bottom: 10px;
    }

    .endrn-spw-message {
        font-size: 0.8125rem;
    }

    .endrn-spw-copy {
        margin-bottom: 16px;
    }

    .endrn-spw-form {
        gap: 10px;
    }

    .endrn-spw-form input[type="text"],
    .endrn-spw-form input[type="email"] {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 11px 12px;
    }

    .endrn-spw-submit {
        padding: 13px 24px;
        font-size: 0.9375rem;
    }
}

/* High contrast for better readability */
@media (prefers-contrast: high) {
    .endrn-spw-form input[type="text"],
    .endrn-spw-form input[type="email"] {
        border-width: 3px;
    }

    .endrn-spw-submit {
        font-weight: 700;
    }
}
