/**
 * Paywall Modal (Phase 3, Dashboard V1)
 *
 * Shown when a non-unlocked user tries to use a Wave 3 action (doc/step/note)
 * or hits the "Start drafting" CTA on a tracking-stage application.
 *
 * Primary CTA: $19 Playbook unlock (sienna-accented, recommended path).
 * Secondary CTA: $29/mo Premium subscription (forest-outlined, workaround).
 *
 * All class names use pw- prefix to keep this file self-contained.
 */

.pw-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 24, 20, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.pw-modal-overlay.open {
    display: flex;
    animation: pwFadeIn 200ms ease-out;
}
@keyframes pwFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pw-modal {
    background: #FFFDFA;
    border-radius: 14px;
    max-width: 560px;
    width: 100%;
    padding: 32px 36px 26px;
    box-shadow:
        0 18px 48px rgba(26, 24, 20, 0.24),
        0 2px 8px rgba(26, 24, 20, 0.08);
    position: relative;
    animation: pwSlideIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
@keyframes pwSlideIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pw-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    color: #6B6458;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
.pw-modal__close:hover,
.pw-modal__close:focus-visible {
    background: #F4EEDF;
    color: #1A1814;
    outline: none;
}
.pw-modal__close:focus-visible {
    box-shadow: 0 0 0 2px #C4532B;
}

.pw-modal__kicker {
    font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #9F4121;
    font-weight: 700;
    margin-bottom: 10px;
}

.pw-modal__title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: #1A1814;
    margin: 0 0 10px;
}
.pw-modal__title em {
    font-style: italic;
    color: #1F4A37;
}

.pw-modal__desc {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: #3A362E;
    line-height: 1.55;
    margin: 0 0 22px;
    max-width: 56ch;
}
.pw-modal__desc strong {
    color: #1A1814;
    font-weight: 600;
}

.pw-modal__options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* V1.2 cap-reached variant: single primary option (full width) + secondary
   text button for "Remove a grant" escape hatch. */
.pw-modal__options--single {
    grid-template-columns: 1fr;
}
.pw-option__secondary {
    background: transparent;
    border: none;
    color: #6B6458;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 13px;
    padding: 12px 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: #C7BFAE;
    transition: color 120ms ease, text-decoration-color 120ms ease;
    min-height: 44px;
}
.pw-option__secondary:hover,
.pw-option__secondary:focus-visible {
    color: #1A1814;
    text-decoration-color: #1A1814;
    outline: none;
}
.pw-option__secondary:focus-visible {
    box-shadow: 0 0 0 2px #C4532B;
    border-radius: 4px;
}

.pw-option {
    display: flex;
    flex-direction: column;
    padding: 18px 20px 16px;
    border: 1px solid #E8E1D4;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
    background: #FFFDFA;
    text-decoration: none;
    color: inherit;
    position: relative;
}
.pw-option:hover,
.pw-option:focus-visible {
    border-color: #1A1814;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26, 24, 20, 0.08);
    outline: none;
    text-decoration: none;
}

.pw-option--primary {
    border-color: #C4532B;
    border-width: 2px;
    padding: 17px 19px 15px; /* offset 1px extra border */
    background: linear-gradient(180deg, #FFFDFA 0%, #FDF4EC 100%);
}
.pw-option--primary:hover,
.pw-option--primary:focus-visible {
    border-color: #9F4121;
    box-shadow: 0 6px 18px rgba(196, 83, 43, 0.16);
}

.pw-option__label {
    font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #6B6458;
    font-weight: 700;
    margin-bottom: 6px;
    display: block;
}
.pw-option--primary .pw-option__label {
    color: #9F4121;
}

.pw-option__price {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 26px;
    font-weight: 500;
    color: #1A1814;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 8px;
    display: block;
}
.pw-option__price-note {
    font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
    font-size: 10px;
    color: #6B6458;
    letter-spacing: 0.04em;
    font-weight: 500;
    display: inline-block;
    margin-left: 4px;
    text-transform: lowercase;
}

.pw-option__desc {
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 13px;
    color: #3A362E;
    line-height: 1.45;
    margin: 0 0 14px;
    flex: 1;
}
.pw-option__desc strong {
    color: #1A1814;
    font-weight: 600;
}

.pw-option__btn {
    align-self: flex-start;
    padding: 8px 14px;
    border-radius: 6px;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: 0.005em;
    border: none;
    cursor: pointer;
    background: #1F4A37;
    color: #FFFDFA;
    transition: background 150ms ease;
    pointer-events: none; /* parent <a> handles click */
}
.pw-option:hover .pw-option__btn {
    background: #143229;
}
.pw-option--primary .pw-option__btn {
    background: #C4532B;
}
.pw-option--primary:hover .pw-option__btn {
    background: #9F4121;
}

.pw-modal__footer {
    text-align: center;
    padding-top: 16px;
    margin-top: 2px;
    border-top: 1px solid #F0EBE0;
    font-family: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: #6B6458;
}
.pw-modal__footer a {
    color: #1F4A37;
    text-decoration: none;
    font-weight: 600;
}
.pw-modal__footer a:hover,
.pw-modal__footer a:focus-visible {
    text-decoration: underline;
    outline: none;
}

/* Cap-reached footnote variant — slightly lighter, no top border, smaller. */
.pw-modal__footer--footnote {
    border-top: none;
    padding-top: 8px;
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: none;
    color: #8A8378;
    line-height: 1.5;
}

/* Tablet + small desktop — slightly tighter */
@media (max-width: 700px) {
    .pw-modal {
        padding: 28px 24px 22px;
    }
    .pw-modal__title {
        font-size: 21px;
    }
}

/* Mobile — stack options */
@media (max-width: 560px) {
    .pw-modal {
        padding: 24px 20px 20px;
        border-radius: 12px;
    }
    .pw-modal__options {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .pw-modal__title {
        font-size: 20px;
    }
    .pw-modal__kicker {
        font-size: 9.5px;
    }
    .pw-option {
        padding: 16px 18px 14px;
    }
    .pw-option--primary {
        padding: 15px 17px 13px;
    }
}

/* Reduced motion — disable entrance animations */
@media (prefers-reduced-motion: reduce) {
    .pw-modal-overlay.open { animation: none; }
    .pw-modal { animation: none; }
    .pw-option { transition: none; }
}
