/* Smart Article Pagination Pro — Frontend CSS
   Target: < 20KB minified | Mobile-first | No CLS */

/* ── Variables (overridden by inline CSS from PHP) ── */
:root {
    --sap-btn-color: #1a7a4a;
    --sap-btn-text:  #ffffff;
    --sap-radius:    4px;
}

/* ── Page Wrapper ── */
.sap-page {
    /* No visual styles — just a semantic wrapper */
}

/* ── NEXT Section ── */
.sap-next-section {
    margin: 32px 0;
    text-align: center;
}

/* ── Continue Text ── */
.sap-continue-text {
    font-style: italic;
    color: #666666;
    margin: 0 0 12px;
    font-size: 15px;
    line-height: 1.4;
}

/* ── Nav row: Back + Next side by side ── */
.sap-nav-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.sap-nav-row .sap-next-button {
    flex: 1 1 auto;
}

.sap-nav-row .sap-prev-button {
    flex: 0 0 auto;
    min-width: 110px;
}

/* ── NEXT / BACK Buttons (shared base) ── */
.sap-next-button,
.sap-prev-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 60px;
    padding: 16px 24px;
    background: var(--sap-btn-color, #1a7a4a);
    color: var(--sap-btn-text, #ffffff);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    border-radius: var(--sap-radius, 4px);
    border: 2px solid transparent;
    cursor: pointer;
    box-sizing: border-box;
    contain: layout; /* reserve space to prevent CLS */
    transition: filter 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.sap-prev-button {
    font-size: 18px;
    background: #eeeeee;
    color: #333333;
}

.sap-next-button:hover,
.sap-next-button:active,
.sap-prev-button:hover,
.sap-prev-button:active {
    filter: brightness(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.sap-next-button:focus-visible,
.sap-prev-button:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 3px;
}

.sap-arrow { font-size: 1.1em; line-height: 1; }

/* ── Button skins ── */

/* Outline: transparent fill, colored border + text */
.sap-next-button.sap-skin-outline {
    background: transparent;
    color: var(--sap-btn-color, #1a7a4a);
    border-color: var(--sap-btn-color, #1a7a4a);
}
.sap-prev-button.sap-skin-outline {
    background: transparent;
    color: #666666;
    border-color: #cccccc;
}

/* Pill: fully rounded regardless of the border-radius setting */
.sap-next-button.sap-skin-pill,
.sap-prev-button.sap-skin-pill {
    border-radius: 999px;
}

/* Gradient: subtle glossy overlay on top of the chosen color */
.sap-next-button.sap-skin-gradient {
    background-image: linear-gradient(135deg, rgba(255,255,255,.22), rgba(0,0,0,.10)), linear-gradient(var(--sap-btn-color, #1a7a4a), var(--sap-btn-color, #1a7a4a));
}
.sap-prev-button.sap-skin-gradient {
    background-image: linear-gradient(135deg, rgba(255,255,255,.5), rgba(0,0,0,.04)), linear-gradient(#eeeeee, #eeeeee);
}

/* Minimal link: no button box, just a bold colored text link */
.sap-next-button.sap-skin-minimal-link,
.sap-prev-button.sap-skin-minimal-link {
    background: transparent;
    border: none;
    color: var(--sap-btn-color, #1a7a4a);
    min-height: auto;
    padding: 8px 4px;
    text-decoration: underline;
    box-shadow: none !important;
}
.sap-prev-button.sap-skin-minimal-link { color: #666666; flex: 0 0 auto; }

/* ── Archive ("After Posts") nav ── */
.sap-archive-nav-row {
    margin: 32px 0;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}
.sap-archive-nav { flex: 1; }

/* ── Progress Bar ── */
.sap-progress {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin: 0 0 24px;
    position: relative;
}

.sap-progress-bar {
    height: 100%;
    background: var(--sap-btn-color, #1a7a4a);
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 4px;
}

.sap-progress-label {
    position: absolute;
    right: 0;
    top: 10px;
    font-size: 12px;
    color: #888888;
    white-space: nowrap;
}

/* ── Ad Zones ── */
.sap-ad-zone {
    margin: 16px 0;
    text-align: center;
    min-height: 10px; /* prevent CLS — real height set by ad */
}

/* ── Sticky/Anchor Ad (Pro) ──
   Height-capped and always closable, matching Google's anchor/overlay ad
   policy requirements — never covers more than a small strip of the
   viewport and the reader can always dismiss it. */
.sap-sticky-ad {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    max-height: 100px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    padding: 4px 36px 4px 4px;
    box-sizing: border-box;
}

.sap-sticky-ad-inner {
    max-width: 100%;
    max-height: 92px;
    overflow: hidden;
}

.sap-sticky-ad-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    line-height: 26px;
    text-align: center;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
}

.sap-sticky-ad-close:hover,
.sap-sticky-ad-close:focus-visible {
    background: rgba(0, 0, 0, 0.8);
}

@media (min-width: 783px) {
    .sap-sticky-ad {
        left: auto;
        right: 16px;
        bottom: 16px;
        max-width: 468px;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }
}

/* ── AJAX Loading State ── */
.sap-loading {
    text-align: center;
    padding: 32px 16px;
    color: #888888;
    font-size: 15px;
}

.sap-loading-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--sap-btn-color, #1a7a4a);
    border-radius: 50%;
    animation: sap-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* ── ARIA live region for AJAX ── */
.sap-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .sap-next-button,
    .sap-prev-button {
        min-height: 56px;
        font-size: 18px;
        padding: 14px 16px;
    }

    .sap-prev-button { min-width: 90px; font-size: 15px; }

    .sap-continue-text {
        font-size: 14px;
    }
}

/* ── Dark mode support ── */
@media (prefers-color-scheme: dark) {
    .sap-continue-text {
        color: #aaaaaa;
    }
    .sap-loading {
        color: #aaaaaa;
    }
    .sap-prev-button {
        background: #333333;
        color: #eeeeee;
    }
    .sap-prev-button.sap-skin-outline {
        border-color: #555555;
        color: #cccccc;
    }
}
