/**
 * Newsletter Modal — Premium Glassmorphism Design
 *
 * Ownership: This module exclusively owns `.newsletter-modal` and its descendants.
 * @layer L3 Components
 */

/* The front page loads this module without the legacy header bundle, so the
 * dialog must own its closed/open shell instead of borrowing `.modal` rules. */
.newsletter-modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 9999;
}

.newsletter-modal.is-open {
    display: flex;
}

/* Keep the bot trap in the submitted form while removing it from layout,
 * keyboard navigation, and the accessibility tree. */
.aiwp-hp-field {
    display: none !important;
}

/* ─────────────────────────────────────
   Custom properties (scoped to modal)
   ───────────────────────────────────── */
.newsletter-modal {
    --nm-bg: rgba(255, 255, 255, 0.82);
    --nm-border: rgba(255, 255, 255, 0.45);
    --nm-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    --nm-text: #0f172a;
    --nm-text-secondary: #475569;
    --nm-accent: 99, 102, 241;  /* indigo-500 */
    --nm-accent-solid: #6366f1;
    --nm-surface: rgba(255, 255, 255, 0.65);
    --nm-surface-hover: rgba(255, 255, 255, 0.85);
    --nm-input-bg: rgba(255, 255, 255, 0.7);
    --nm-input-border: rgba(0, 0, 0, 0.1);
    --nm-success: #10b981;
    --nm-error: #f43f5e;
}

:root[data-theme="dark"] .newsletter-modal {
    --nm-bg: rgba(15, 15, 25, 0.78);
    --nm-border: rgba(255, 255, 255, 0.1);
    --nm-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    --nm-text: #f1f5f9;
    --nm-text-secondary: #94a3b8;
    --nm-surface: rgba(255, 255, 255, 0.06);
    --nm-surface-hover: rgba(255, 255, 255, 0.12);
    --nm-input-bg: rgba(255, 255, 255, 0.08);
    --nm-input-border: rgba(255, 255, 255, 0.12);
}

/* ─────────────────────────────────────
   Overlay
   ───────────────────────────────────── */
.newsletter-modal {
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(var(--nm-accent), 0.15), transparent),
        radial-gradient(ellipse 60% 50% at 85% 80%, rgba(var(--nm-accent), 0.08), transparent),
        rgba(0, 0, 0, 0.50);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    backdrop-filter: blur(16px) saturate(1.2);
}

:root[data-theme="light"] .newsletter-modal {
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(var(--nm-accent), 0.06), transparent),
        rgba(0, 0, 0, 0.32);
}

/* ─────────────────────────────────────
   Modal card (glassmorphism)
   ───────────────────────────────────── */
.newsletter-modal .modal-content,
.newsletter-modal__content {
    max-width: 460px;
    padding: 40px 36px 32px;
    text-align: left;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    background: var(--nm-bg);
    -webkit-backdrop-filter: blur(40px) saturate(1.4);
    backdrop-filter: blur(40px) saturate(1.4);
    border: 1px solid var(--nm-border);
    box-shadow: var(--nm-shadow);
    animation: nmSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes nmSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─────────────────────────────────────
   Decorative glow orbs
   ───────────────────────────────────── */
.newsletter-modal__orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(60px);
    opacity: 0.5;
}

.newsletter-modal__orb--1 {
    width: 200px;
    height: 200px;
    top: -60px;
    right: -40px;
    background: rgba(var(--nm-accent), 0.35);
}

.newsletter-modal__orb--2 {
    width: 160px;
    height: 160px;
    bottom: -40px;
    left: -30px;
    background: rgba(var(--nm-accent), 0.2);
}

/* ─────────────────────────────────────
   Close button
   ───────────────────────────────────── */
.newsletter-modal .modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--nm-surface);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    color: var(--nm-text-secondary);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-size: 0;
    z-index: 2;
}

.newsletter-modal .modal-close:hover {
    background: var(--nm-surface-hover);
    color: var(--nm-text);
    border-color: var(--nm-input-border);
}

.newsletter-modal .modal-close svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

/* ─────────────────────────────────────
   "Exclusive Access" badge
   ───────────────────────────────────── */
.newsletter-modal__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--nm-accent-solid);
    background: rgba(var(--nm-accent), 0.1);
    border: 1px solid rgba(var(--nm-accent), 0.2);
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.newsletter-modal__badge svg {
    width: 13px;
    height: 13px;
    stroke: var(--nm-accent-solid);
}

/* ─────────────────────────────────────
   Icon
   ───────────────────────────────────── */
.newsletter-modal__icon {
    width: 52px;
    height: 52px;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--nm-accent-solid), #818cf8);
    border-radius: 14px;
    color: #FFFFFF;
    -webkit-text-fill-color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(var(--nm-accent), 0.25);
    position: relative;
    z-index: 1;
}

.newsletter-modal__icon svg {
    width: 26px;
    height: 26px;
    stroke-width: 1.75;
    stroke: #FFFFFF;
}

/* ─────────────────────────────────────
   Typography
   ───────────────────────────────────── */
.newsletter-modal__content h2,
.newsletter-modal__title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 8px;
    color: var(--nm-text);
    position: relative;
    z-index: 1;
}

/* `.newsletter-modal__content > p` scores 0,0,1,1 and outranked the component
   class `.newsletter-modal__note` (0,0,1,0) further down this file, so that
   note's authored `margin-top:12px` computed to 0 and the privacy line sat
   flush against the form. Wrapping the element half in :where() makes it the
   plain paragraph default it was meant to be, while the explicit
   `.newsletter-modal__subtitle` class keeps its own weight. Same defect family
   as the front-page reset; caught live by skynet_responsive_audit's
   DEAD_SPACING_DECLARATION check. */
.newsletter-modal__subtitle,
:where(.newsletter-modal__content) > :where(p) {
    font-size: 15px;
    color: var(--nm-text-secondary);
    line-height: 1.6;
    margin: 0 0 20px;
    max-width: 48ch;
    position: relative;
    z-index: 1;
}

/* ─────────────────────────────────────
   Benefit bullets (checkmark)
   ───────────────────────────────────── */
.newsletter-modal__bullets {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    display: grid;
    gap: 14px;
    text-align: left;
    position: relative;
    z-index: 1;
}

.newsletter-modal__bullets li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--nm-text);
}

/* Remove old pseudo-element bullets */
.newsletter-modal__bullets li::before {
    content: none;
}

.newsletter-modal__bullet-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--nm-accent), 0.12);
    border-radius: 6px;
    margin-top: 1px;
}

.newsletter-modal__bullet-icon svg {
    width: 13px;
    height: 13px;
    stroke: var(--nm-accent-solid);
}

/* ─────────────────────────────────────
   Form
   ───────────────────────────────────── */
.newsletter-modal__form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.newsletter-modal__input-row {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.newsletter-modal__input-wrapper {
    position: relative;
    flex: 1;
}

.newsletter-modal__input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--nm-text-secondary);
    pointer-events: none;
    opacity: 0.45;
    width: 17px;
    height: 17px;
}

#newsletter-modal .newsletter-modal__form input[type="email"] {
    width: 100%;
    padding: 13px 14px 13px 44px !important;
    font-size: 15px;
    font-family: inherit;
    border: 1.5px solid var(--color-primary, #0066cc) !important;
    border-right: none !important;
    border-radius: 12px 0 0 12px !important;
    background: var(--nm-input-bg);
    color: var(--nm-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    height: 48px;
}

.newsletter-modal__form input[type="email"]::placeholder {
    color: var(--nm-text-secondary);
    opacity: 0.7;
}

.newsletter-modal__form input[type="email"]:focus,
#newsletter-modal .newsletter-modal__form input[type="email"]:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
    border-color: var(--color-primary, #0066cc) !important;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.12);
}

.newsletter-modal__form input[type="email"]:focus::placeholder,
#newsletter-modal .newsletter-modal__form input[type="email"]:focus-visible::placeholder {
    opacity: 0.35;
    transition: opacity 0.2s ease;
}

.newsletter-modal__form input[type="email"][aria-invalid="true"] {
    border-color: rgba(244, 63, 94, 0.7);
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.1);
}

/* ─────────────────────────────────────
   Submit button (gradient + hover lift)
   ───────────────────────────────────── */
.newsletter-modal__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    background: linear-gradient(135deg, var(--nm-accent-solid), #818cf8);
    color: #FFFFFF;
    -webkit-text-fill-color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0;
    border: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px rgba(var(--nm-accent), 0.35);
    height: 48px;
    white-space: nowrap;
    flex-shrink: 0;
}

.newsletter-modal__submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--nm-accent), 0.45);
}

.newsletter-modal__submit:active:not(:disabled) {
    transform: translateY(0);
}

.newsletter-modal__submit span {
    color: #FFFFFF;
    -webkit-text-fill-color: #FFFFFF;
}

.newsletter-modal__submit svg {
    width: 15px;
    height: 15px;
    stroke: #FFFFFF;
    transition: transform 0.2s ease;
}

.newsletter-modal__submit:hover:not(:disabled) svg {
    transform: translateX(3px);
}

.newsletter-modal__submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.newsletter-modal__submit.is-loading svg {
    display: none;
}

.newsletter-modal__submit.is-loading::after {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: rgba(255, 255, 255, 0.95);
    animation: nmSpin 0.8s linear infinite;
}

@keyframes nmSpin {
    to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────
   Response messages
   ───────────────────────────────────── */
.newsletter-modal__response {
    display: none;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.45;
    text-align: left;
    border: 1px solid var(--nm-input-border);
    background: var(--nm-surface);
    color: var(--nm-text);
}

.newsletter-modal__response.is-success {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
    color: var(--nm-text);
}

.newsletter-modal__response.is-error {
    border-color: rgba(244, 63, 94, 0.3);
    background: rgba(244, 63, 94, 0.1);
    color: var(--nm-text);
}

/* ─────────────────────────────────────
   Privacy note
   ───────────────────────────────────── */
.newsletter-modal__note {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--nm-text-secondary);
    margin-top: 12px;
    opacity: 0.85;
    position: relative;
    z-index: 1;
}

.newsletter-modal__note svg {
    width: 13px;
    height: 13px;
    color: var(--nm-success);
    opacity: 0.9;
    flex-shrink: 0;
}

/* ─────────────────────────────────────
   Social proof
   ───────────────────────────────────── */
.newsletter-modal__social {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--nm-input-border);
    text-align: center;
    position: relative;
    z-index: 1;
}

.newsletter-modal__social-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--nm-text-secondary);
    letter-spacing: 0.02em;
    opacity: 0.75;
}

/* ─────────────────────────────────────
   Dark mode refinements
   ───────────────────────────────────── */

/* Badge: indigo-500 (#6366f1) on dark card rgba(15,15,25) is low-contrast.
   Use indigo-300 (#a5b4fc) for the label text and lift the pill background. */
:root[data-theme="dark"] .newsletter-modal__badge {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.35);
}

:root[data-theme="dark"] .newsletter-modal__badge svg {
    stroke: #a5b4fc;
}

:root[data-theme="dark"] .newsletter-modal__icon {
    box-shadow: 0 3px 10px rgba(var(--nm-accent), 0.18);
}

:root[data-theme="dark"] .newsletter-modal__submit {
    box-shadow: 0 3px 10px rgba(var(--nm-accent), 0.18);
}

:root[data-theme="dark"] .newsletter-modal__orb {
    opacity: 0.3;
}

:root[data-theme="dark"] .newsletter-modal__input-icon {
    color: rgba(255, 255, 255, 0.65);
    opacity: 0.7;
}

:root[data-theme="dark"] .newsletter-modal__form input[type="email"]::placeholder {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

:root[data-theme="dark"] .newsletter-modal__form input[type="email"] {
    border-color: var(--color-primary, #0066cc);
}

:root[data-theme="dark"] .newsletter-modal__form input[type="email"]:focus,
:root[data-theme="dark"] #newsletter-modal .newsletter-modal__form input[type="email"]:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
    border-color: var(--color-primary, #0066cc) !important;
}

:root[data-theme="dark"] .newsletter-modal__note svg {
    color: #34d399;
    opacity: 1;
}

/* ─────────────────────────────────────
   Mobile (≤ 480px)
   ───────────────────────────────────── */
@media (max-width: 480px) {
    .newsletter-modal .modal-content,
    .newsletter-modal__content {
        max-width: calc(100vw - 28px);
        padding: 32px 22px 26px;
        margin: 14px;
        border-radius: 20px;
    }

    .newsletter-modal__icon {
        width: 44px;
        height: 44px;
        margin-bottom: 14px;
        border-radius: 12px;
    }

    .newsletter-modal__icon svg {
        width: 22px;
        height: 22px;
    }

    .newsletter-modal__content h2,
    .newsletter-modal__title {
        font-size: 24px;
    }

    .newsletter-modal__subtitle,
    .newsletter-modal__content > p {
        font-size: 14px;
    }

    .newsletter-modal__input-row {
        flex-direction: column;
        gap: 10px;
    }

    .newsletter-modal__form input[type="email"] {
        border-right: 1.5px solid var(--color-primary, #0066cc);
        border-radius: 12px;
        font-size: 16px;
    }

    .newsletter-modal__submit {
        width: 100%;
        border-radius: 12px;
    }

    .newsletter-modal__orb--1 {
        width: 140px;
        height: 140px;
    }

    .newsletter-modal__orb--2 {
        width: 110px;
        height: 110px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .newsletter-modal .modal-content,
    .newsletter-modal__content {
        animation: none;
    }

    .newsletter-modal__submit,
    .newsletter-modal__submit svg {
        transition: none;
    }
}

/* ========================================
   Footer Newsletter CTA Strip
   Compact inline signup bar above the compact footer.
   Hidden on front-page (which has its own newsletter section).
   ======================================== */

.footer-newsletter {
    padding: 40px 0;
    background: var(--color-surface-dark, #111116);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Override guardrails overflow-x:hidden on .container and the
   <section> so the email focus ring (outline + box-shadow) is not
   clipped.  The parent <body> still prevents page-level X-overflow. */
.footer-newsletter,
.footer-newsletter > .container {
    overflow: visible;
}

:root[data-theme="light"] .footer-newsletter {
    background: var(--color-surface, #f8f8fa);
    border-top-color: rgba(0, 0, 0, 0.06);
}

.footer-newsletter__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    max-width: 960px;
    margin: 0 auto;
    padding: 28px 32px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
}

:root[data-theme="light"] .footer-newsletter__inner {
    border-color: var(--color-border, rgba(0, 0, 0, 0.1));
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.footer-newsletter__title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0 0 4px;
    color: #fff;
}

:root[data-theme="light"] .footer-newsletter__title {
    color: var(--color-text, #111);
}

.footer-newsletter__desc {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
    line-height: 1.5;
}

:root[data-theme="light"] .footer-newsletter__desc {
    color: var(--color-text-muted, #666);
}

.footer-newsletter__form {
    flex-shrink: 0;
}

.footer-newsletter__input-group {
    display: flex;
    gap: 0;
}

.footer-newsletter__input-group input[type="email"] {
    width: 260px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    border: 1.5px solid rgba(255, 255, 255, 0.15) !important;
    border-right: none !important;
    border-radius: 10px 0 0 10px !important;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

:root[data-theme="light"] .footer-newsletter__input-group input[type="email"] {
    border: 1.5px solid var(--color-border, #ddd) !important;
    border-right: none !important;
    background: var(--color-bg, #f8f8fa);
    color: var(--color-text, #111);
}

.footer-newsletter__input-group input[type="email"]::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

:root[data-theme="light"] .footer-newsletter__input-group input[type="email"]::placeholder {
    color: var(--color-text-muted, #999);
    opacity: 0.7;
}

.footer-newsletter__input-group input[type="email"]:focus {
    outline: none;
    border-color: rgba(var(--color-primary-rgb, 59, 130, 246), 0.6);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 59, 130, 246), 0.15);
    position: relative;
    z-index: 1;
}

.footer-newsletter__input-group button {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none !important;
    border-radius: 0 10px 10px 0 !important;
    background: var(--color-primary, #0066cc);
    color: #fff;
    -webkit-text-fill-color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.footer-newsletter__input-group button:hover {
    background: var(--color-primary-hover, #0052a3);
    box-shadow: 0 4px 14px rgba(var(--color-primary-rgb, 0, 102, 204), 0.35);
}

/* Honeypot — visually hidden, still accessible to bots */
.footer-newsletter .aiwp-hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    pointer-events: none;
}

@media (max-width: 640px) {
    .footer-newsletter {
        padding: 32px 0;
    }

    .footer-newsletter__inner {
        flex-direction: column;
        text-align: center;
        gap: 20px;
        padding: 24px 20px;
    }

    .footer-newsletter__input-group {
        width: 100%;
    }

    .footer-newsletter__input-group input[type="email"] {
        width: 100%;
        min-width: 0;
    }
}

/* ─────────────────────────────────────
   Specificity boost: beat late-cascade overrides
   (dark mode guardrails, generic button resets)
   ───────────────────────────────────── */
.newsletter-modal .newsletter-modal__form input[type="email"] {
    border: 1.5px solid var(--color-primary, #0066cc) !important;
    border-right: none !important;
    border-radius: 12px 0 0 12px !important;
}

.footer-newsletter .footer-newsletter__input-group input[type="email"] {
    border-right: none !important;
    border-radius: 10px 0 0 10px !important;
}
