/* ==========================================================================
   Content Gate — Frontend Styles
   ========================================================================== */

/* ── Teaser / Fade ─────────────────────────────────────────────────────────── */

.cg-teaser-wrap {
    position: relative;
    overflow: hidden;
    /* Max height for the teaser before it fades — tweak as needed */
    max-height: 340px;
}

.cg-teaser-content {
    position: relative;
    z-index: 1;
}

/* The gradient fade that sits over the truncated text */
.cg-fade-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 160px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.85) 50%,
        rgba(255, 255, 255, 1) 100%
    );
    z-index: 2;
    pointer-events: none;
}

/* Dark-mode safe: override the gradient colour if the theme uses a dark bg.
   Themes should expose --cg-bg or we fall back to transparent. */
@media (prefers-color-scheme: dark) {
    .cg-fade-overlay {
        background: linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.85) 50%,
            rgba(0, 0, 0, 1) 100%
        );
    }
}

/* Lock body scroll when the overlay is open */
body.cg-overlay-open {
    overflow: hidden;
}

/* ── Overlay ───────────────────────────────────────────────────────────────── */

.cg-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-end;   /* Mobile: slide up from bottom */
    justify-content: center;
    padding: 0;
}

@media (min-width: 640px) {
    .cg-overlay {
        align-items: center;   /* Desktop: centred */
        padding: 24px;
    }
}

/* Semi-transparent backdrop — NOT click-to-close */
.cg-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* The white card */
.cg-overlay__modal {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 36px 28px 40px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 -4px 40px rgba(0, 0, 0, .18);

    /* Animate in */
    animation: cgSlideUp 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

@media (min-width: 640px) {
    .cg-overlay__modal {
        border-radius: 16px;
        max-width: 480px;
        width: 100%;
        max-height: 90vh;
        box-shadow: 0 12px 48px rgba(0, 0, 0, .18);
        animation: cgFadeScale 0.22s ease-out both;
    }
}

@keyframes cgSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

@keyframes cgFadeScale {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ── Step visibility ───────────────────────────────────────────────────────── */

.cg-step { display: none; }
.cg-step--active { display: block; }

/* ── Icon ──────────────────────────────────────────────────────────────────── */

.cg-overlay__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #eff6ff;
    color: #1a73e8;
    margin: 0 auto 20px;
}

/* ── Typography ────────────────────────────────────────────────────────────── */

.cg-overlay__headline {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    text-align: center;
    line-height: 1.25;
    margin: 0 0 10px;
}

.cg-overlay__subheadline {
    font-size: 15px;
    color: #555;
    text-align: center;
    line-height: 1.55;
    margin: 0 0 24px;
}

.cg-email-display {
    font-size: 14px;
    color: #555;
    text-align: center;
    font-weight: 500;
    margin-bottom: 20px;
}

.cg-email-confirm {
    font-size: 15px;
    color: #1a73e8;
    font-weight: 600;
}

/* ── Form elements ─────────────────────────────────────────────────────────── */

.cg-form-group {
    margin-bottom: 16px;
}

.cg-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
}

.cg-input-wrap {
    position: relative;
}

.cg-input {
    display: block;
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    color: #111;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
}

.cg-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .18);
}

.cg-input-wrap .cg-input {
    padding-right: 44px;
}

.cg-toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    padding: 4px;
    line-height: 0;
    transition: color .15s;
}

.cg-toggle-password:hover { color: #555; }

.cg-field-error {
    font-size: 13px;
    color: #dc2626;
    margin-top: 5px;
}

.cg-server-error {
    font-size: 14px;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 10px 14px;
    margin-top: 12px;
    text-align: center;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.cg-btn {
    display: block;
    width: 100%;
    padding: 13px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, opacity .15s, transform .1s;
    line-height: 1;
}

.cg-btn:active { transform: scale(0.985); }

.cg-btn--primary {
    background: #1a73e8;
    color: #fff;
}

.cg-btn--primary:hover { background: #1557b0; }
.cg-btn--primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Loading state */
.cg-btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.cg-btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cgSpin .6s linear infinite;
}

@keyframes cgSpin {
    to { transform: rotate(360deg); }
}

/* Back button */
.cg-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #555;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 20px;
    transition: color .15s;
}

.cg-back-btn:hover { color: #111; }

/* Link-style button */
.cg-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: #1a73e8;
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
}

.cg-link-btn:hover { color: #1557b0; }

/* ── Divider ───────────────────────────────────────────────────────────────── */

.cg-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: #9ca3af;
    font-size: 13px;
}

.cg-divider::before,
.cg-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

/* ── Social login area (Nextend) ───────────────────────────────────────────── */

.cg-social {
    margin-bottom: 4px;
}

/* Override Nextend's default button styles to match our design */
.cg-social .nsl-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
}

.cg-social .nsl-container-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cg-social .nsl-button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 12px 16px !important;
    border: 1.5px solid #d1d5db !important;
    border-radius: 8px !important;
    background: #fff !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #333 !important;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.cg-social .nsl-button:hover {
    background: #f9fafb !important;
    border-color: #9ca3af !important;
}

/* ── Legal text ────────────────────────────────────────────────────────────── */

.cg-legal {
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
    line-height: 1.5;
    margin-top: 14px;
}

.cg-legal a {
    color: #555;
    text-decoration: underline;
}

.cg-legal a:hover { color: #111; }

.cg-form-footer {
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
    margin-top: 12px;
}

.cg-form-footer .cg-link {
    color: #555;
    text-decoration: none;
}

.cg-form-footer .cg-link:hover { color: #111; }

/* ── Privacy note ──────────────────────────────────────────────────────────── */

.cg-privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 20px;
}

/* ── Turnstile ─────────────────────────────────────────────────────────────── */

.cg-turnstile-wrap {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}

/* ── Success screen ────────────────────────────────────────────────────────── */

.cg-success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #eff6ff;
    color: #1a73e8;
    margin: 0 auto 24px;
}

/* ── Close button ──────────────────────────────────────────────────────────── */

.cg-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--cg-text-muted, #9ca3af);
    padding: 0;
    transition: background .15s, color .15s;
    z-index: 10;
    flex-shrink: 0;
}

.cg-close-btn:hover {
    background: #f3f4f6;
    color: var(--cg-text-primary, #111);
}

/* Ensure modal has relative positioning for the absolute close btn */
.cg-overlay__modal {
    position: relative;
}

/* Backdrop is now clickable — show pointer cursor */
.cg-overlay__backdrop {
    cursor: pointer;
}
