/**
 * Newsletter Frontend Styles
 *
 * Uses CSS custom properties set by the plugin settings:
 * --nl-primary, --nl-secondary, --nl-font-body, --nl-max-width, --nl-radius
 */

/* =========================================================================
   Base / Container
   ========================================================================= */

.nl-newsletter-single,
.nl-archive-page {
    font-family: var(--nl-font-body);
    color: #333;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--nl-primary) 4%, #f0f2f5), #fff);
    padding: 6vw 0;
}

.nl-archive-page {
    padding: 20px;
}

.nl-container {
    max-width: var(--nl-max-width);
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
    padding: 48px 48px 40px;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

@media (max-width: 768px) {
    .nl-newsletter-single,
    .nl-archive-page {
        padding: 16px 8px;
    }
    .nl-container {
        padding: 28px 20px 24px;
        border-radius: 8px;
    }
}

/* =========================================================================
   Header
   ========================================================================= */

.nl-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
}

.nl-logo {
    max-width: 250px;
    height: auto;
    margin-bottom: 16px;
}

.nl-title {
    font-size: 2.2em;
    font-weight: 700;
    color: var(--nl-primary);
    margin: 0 0 6px;
    line-height: 1.2;
}

.nl-date {
    display: inline-block;
    font-size: 0.9em;
    color: #888;
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* =========================================================================
   Intro
   ========================================================================= */

.nl-intro {
    background: var(--nl-primary);
    color: #fff;
    padding: 28px 32px;
    margin-bottom: 32px;
    border-radius: var(--nl-radius);
    font-size: 1em;
    line-height: 1.8;
}

.nl-intro p {
    color: rgba(255, 255, 255, 0.92);
}

.nl-intro p:last-child {
    margin-bottom: 0;
}

/* =========================================================================
   Table of Contents
   ========================================================================= */

.nl-toc {
    background: color-mix(in srgb, var(--nl-primary) 6%, #fff);
    border: 1px solid color-mix(in srgb, var(--nl-primary) 18%, #e0e0e0);
    border-radius: var(--nl-radius);
    padding: 22px 28px;
    margin-bottom: 36px;
}

.nl-toc-title {
    font-weight: 700;
    color: var(--nl-secondary);
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75em;
}

.nl-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2;
    column-gap: 24px;
}

@media (max-width: 600px) {
    .nl-toc-list {
        columns: 1;
    }
}

.nl-toc-list li {
    padding: 5px 0;
    break-inside: avoid;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nl-toc-list a {
    color: var(--nl-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95em;
    transition: color 0.15s ease;
}

.nl-toc-list a:hover {
    color: var(--nl-secondary);
}

.nl-toc-list .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: var(--nl-secondary);
}

/* =========================================================================
   Sections
   ========================================================================= */

.nl-section {
    margin-bottom: 40px;
    padding: 24px;
    background: color-mix(in srgb, var(--nl-primary) 2%, #fafafa);
    border-radius: var(--nl-radius);
    border: 1px solid color-mix(in srgb, var(--nl-primary) 6%, #ebebef);
}

.nl-section-title {
    font-size: 1.25em;
    font-weight: 700;
    color: var(--nl-primary);
    padding-bottom: 10px;
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid var(--nl-primary);
}

.nl-section-title .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: var(--nl-secondary);
}

.nl-section-desc {
    color: #777;
    font-size: 0.9em;
    margin: -12px 0 20px;
    font-style: italic;
}

.nl-back-to-top {
    display: inline-block;
    margin-top: 16px;
    font-size: 0.78em;
    color: #bbb;
    text-decoration: none;
    transition: color 0.15s ease;
}

.nl-back-to-top:hover {
    color: var(--nl-primary);
}

/* =========================================================================
   Item Base
   ========================================================================= */

.nl-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid color-mix(in srgb, var(--nl-primary) 8%, #eee);
}

.nl-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 18px;
}

.nl-item-title {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.3;
    color: #2c3e50;
}

.nl-item-title a {
    color: var(--nl-primary);
    text-decoration: none;
}

.nl-item-title a:hover {
    text-decoration: underline;
}

.nl-item-link {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 24px;
    background: var(--nl-primary);
    color: #fff !important;
    font-weight: 600;
    font-size: 0.9em;
    text-decoration: none !important;
    border-radius: 5px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.nl-item-link:hover {
    background: var(--nl-secondary);
    color: #fff !important;
    transform: translateY(-1px);
}

.nl-item-date {
    display: block;
    font-size: 0.85em;
    color: #888;
    margin-bottom: 6px;
}

.nl-item-excerpt {
    font-size: 0.92em;
    color: #555;
    margin: 6px 0 0;
}

/* =========================================================================
   Flyer Grid
   ========================================================================= */

.nl-newsletter-single .nl-flyer-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    margin-bottom: 24px;
    list-style: none;
    padding: 0;
}

@media (max-width: 768px) {
    .nl-newsletter-single .nl-flyer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
}

@media (max-width: 480px) {
    .nl-newsletter-single .nl-flyer-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
}

.nl-newsletter-single .nl-flyer-grid-item {
    cursor: pointer;
    border-radius: var(--nl-radius);
    overflow: hidden;
    background: #fff;
    border: none;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

.nl-newsletter-single .nl-flyer-grid-item:hover,
.nl-newsletter-single .nl-flyer-grid-item:focus {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    outline: none;
}

.nl-newsletter-single .nl-flyer-thumb {
    position: relative !important;
    overflow: hidden !important;
    aspect-ratio: 3 / 4;
    background: #f6f7f7;
    width: 100% !important;
    display: block !important;
}

.nl-newsletter-single .nl-flyer-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    max-width: 100% !important;
    transition: transform 0.3s ease;
}

.nl-newsletter-single .nl-flyer-grid-item:hover .nl-flyer-thumb img {
    transform: scale(1.03);
}

.nl-newsletter-single .nl-flyer-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease;
    z-index: 2;
    pointer-events: none;
}

.nl-newsletter-single .nl-flyer-grid-item:hover .nl-flyer-overlay {
    background: rgba(0, 0, 0, 0.25);
}

.nl-newsletter-single .nl-flyer-zoom {
    color: #fff !important;
    font-size: 32px !important;
    width: 32px !important;
    height: 32px !important;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nl-newsletter-single .nl-flyer-grid-item:hover .nl-flyer-zoom {
    opacity: 1;
    transform: scale(1);
}

.nl-newsletter-single .nl-flyer-grid-item .nl-flyer-caption {
    padding: 10px 12px;
    margin: 0 !important;
    font-size: 0.82em;
    color: #444;
    line-height: 1.4;
    text-align: center;
    border-top: 1px solid color-mix(in srgb, var(--nl-primary) 10%, #eee);
}

.nl-newsletter-single .nl-flyer-grid-item .nl-flyer-card-link {
    display: block;
    padding: 8px 12px;
    text-align: center;
    font-size: 0.82em;
    font-weight: 600;
    color: var(--nl-secondary);
    text-decoration: none;
    border-top: 1px solid color-mix(in srgb, var(--nl-primary) 10%, #eee);
    transition: background 0.15s ease, color 0.15s ease;
}

.nl-newsletter-single .nl-flyer-grid-item .nl-flyer-card-link:hover {
    background: color-mix(in srgb, var(--nl-secondary) 8%, #fff);
    color: var(--nl-primary);
}

/* =========================================================================
   Featured Flyer (Side by Side)
   ========================================================================= */

.nl-item-featured-flyer {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.nl-featured-side-by-side {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.nl-featured-side-by-side .nl-featured-image {
    flex: 0 0 40%;
    max-width: 40%;
    overflow: hidden;
}

.nl-featured-side-by-side .nl-featured-image img {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block !important;
}

.nl-featured-side-by-side .nl-featured-content {
    flex: 1;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 768px) {
    .nl-featured-side-by-side {
        flex-direction: column;
    }

    .nl-featured-side-by-side .nl-featured-image {
        flex: none;
        max-width: 100%;
    }

    .nl-featured-side-by-side .nl-featured-content {
        padding: 20px;
    }
}

/* =========================================================================
   Featured Flyer (Stacked)
   ========================================================================= */

.nl-featured-stacked {
    display: flex;
    flex-direction: column;
}

.nl-featured-stacked .nl-featured-image {
    width: 100%;
    overflow: hidden;
}

.nl-featured-stacked .nl-featured-image img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    display: block !important;
}

.nl-featured-stacked .nl-featured-content {
    padding: 24px 28px;
}

/* =========================================================================
   Featured Flyer — Shared Content Styles
   ========================================================================= */

.nl-featured-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--nl-primary);
    margin: 0 0 12px;
    line-height: 1.3;
}

.nl-featured-body {
    font-size: 0.93em;
    color: #444;
    line-height: 1.75;
}

.nl-featured-body p:last-child {
    margin-bottom: 0;
}

.nl-featured-link {
    display: inline-block;
    margin-top: 18px;
    padding: 12px 28px;
    background: var(--nl-primary);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: background 0.15s ease, transform 0.15s ease;
    align-self: flex-start;
}

.nl-featured-link:hover {
    background: var(--nl-secondary);
    color: #fff !important;
    transform: translateY(-1px);
}

/* =========================================================================
   Lightbox
   ========================================================================= */

.nl-lightbox {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 999999 !important;
    background: rgba(0, 0, 0, 0.92) !important;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.nl-lightbox.nl-lightbox-open {
    display: flex !important;
}

.nl-lightbox .nl-lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
    position: relative;
}

.nl-lightbox .nl-lightbox-content img {
    max-width: 100% !important;
    max-height: 80vh !important;
    width: auto !important;
    height: auto !important;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    display: block;
    margin: 0 auto;
}

.nl-lightbox .nl-lightbox-caption {
    color: #ddd;
    font-size: 0.95em;
    margin-top: 14px;
    line-height: 1.4;
}

.nl-lightbox .nl-lightbox-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 20px;
    background: var(--nl-primary, #0077b6);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 600;
    transition: background 0.15s ease;
}

.nl-lightbox .nl-lightbox-link:hover {
    background: var(--nl-secondary, #00b4d8);
    color: #fff !important;
}

.nl-lightbox .nl-lightbox-close {
    position: absolute !important;
    top: 16px;
    right: 20px;
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 12px;
    z-index: 10;
    transition: color 0.15s ease;
}

.nl-lightbox .nl-lightbox-close:hover {
    color: var(--nl-secondary, #00b4d8) !important;
}

.nl-lightbox .nl-lightbox-prev,
.nl-lightbox .nl-lightbox-next {
    position: absolute !important;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    color: #fff !important;
    font-size: 48px;
    cursor: pointer;
    padding: 8px 16px;
    line-height: 1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.15s ease;
}

.nl-lightbox .nl-lightbox-prev { left: 16px; }
.nl-lightbox .nl-lightbox-next { right: 16px; }

.nl-lightbox .nl-lightbox-prev:hover,
.nl-lightbox .nl-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}

@media (max-width: 768px) {
    .nl-lightbox .nl-lightbox-prev,
    .nl-lightbox .nl-lightbox-next {
        font-size: 32px;
        padding: 6px 10px;
    }

    .nl-lightbox .nl-lightbox-close {
        font-size: 32px;
        top: 10px;
        right: 12px;
    }
}

/* =========================================================================
   Text Blurb Item
   ========================================================================= */

.nl-item-text-blurb {
    background: #fff;
    padding: 20px 24px;
    border-radius: 6px;
}

.nl-item-text-blurb .nl-item-body {
    font-size: 0.95em;
}

.nl-item-text-blurb .nl-item-body p:last-child {
    margin-bottom: 0;
}

/* =========================================================================
   Resource Card Item
   ========================================================================= */

.nl-item-resource-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: #fff;
    padding: 20px 24px;
    border-radius: 6px;
}

.nl-resource-logo {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: var(--nl-radius);
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--nl-secondary) 20%, #e8e8ec);
}

.nl-resource-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nl-resource-content {
    flex: 1;
}

.nl-resource-desc {
    font-size: 0.9em;
    color: #555;
    margin: 4px 0 0;
}

@media (max-width: 480px) {
    .nl-item-resource-card {
        flex-direction: column;
    }
}

/* =========================================================================
   Announcement Item
   ========================================================================= */

.nl-item-announcement {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #fff;
    padding: 16px 20px;
    border-radius: 6px;
    border-left: 3px solid var(--nl-primary);
}

.nl-announcement-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: var(--nl-secondary);
    margin-top: 2px;
}

.nl-announcement-content {
    flex: 1;
    min-width: 0;
    font-size: 0.95em;
    color: #444;
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: break-word;
}

.nl-announcement-content p:last-child {
    margin-bottom: 0;
}

/* =========================================================================
   Event Item
   ========================================================================= */

.nl-events-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nl-item-event {
    position: relative;
    padding: 14px 18px;
    background: #fff;
    border-radius: 6px;
    border-left: 3px solid var(--nl-primary);
    margin-bottom: 0;
    padding-bottom: 14px;
    border-bottom: none;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.nl-item-event:last-child {
    margin-bottom: 0;
}

.nl-event-body {
    flex: 1;
    min-width: 0;
}

.nl-item-event .nl-item-title {
    margin: 0 0 2px;
    font-size: 0.95em;
}

.nl-item-event .nl-item-date {
    margin-bottom: 0;
    font-size: 0.8em;
}

.nl-item-event .nl-item-excerpt {
    margin: 4px 0 0;
    font-size: 0.85em;
}

/* Event category badges */
.nl-event-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.nl-event-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--nl-secondary);
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-radius: 3px;
    line-height: 1.4;
    white-space: nowrap;
}

/* Event thumbnail */
.nl-event-thumb {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 6px;
    overflow: hidden;
}

.nl-event-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 480px) {
    .nl-event-thumb {
        width: 72px;
        height: 72px;
    }
}

/* =========================================================================
   Footer
   ========================================================================= */

.nl-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 2px solid color-mix(in srgb, var(--nl-primary) 12%, #eee);
    text-align: center;
    font-size: 0.85em;
    color: #999;
}

/* =========================================================================
   Archive Grid
   ========================================================================= */

.nl-archive-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 0;
}

.nl-archive-card {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #eef0f2;
    border-radius: var(--nl-radius);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.nl-archive-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.nl-archive-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 6px;
    overflow: hidden;
}

.nl-archive-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nl-archive-card-content {
    flex: 1;
}

.nl-archive-card-title {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--nl-primary);
    margin: 0 0 4px;
}

.nl-archive-card-date {
    display: block;
    font-size: 0.85em;
    color: #999;
    margin-bottom: 8px;
}

.nl-archive-card-excerpt {
    font-size: 0.9em;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .nl-archive-card {
        flex-direction: column;
    }

    .nl-archive-thumb {
        width: 100%;
        height: 180px;
    }
}

/* =========================================================================
   Archive Shortcode Grid (columns variant)
   ========================================================================= */

.nl-archive-grid.nl-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.nl-archive-grid.nl-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .nl-archive-grid.nl-columns-2,
    .nl-archive-grid.nl-columns-3 {
        grid-template-columns: 1fr;
    }
}

/* Pagination */
.nl-pagination {
    margin-top: 32px;
    text-align: center;
}

.nl-pagination .nav-links a,
.nl-pagination .nav-links span {
    padding: 8px 14px;
    margin: 0 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.nl-pagination .nav-links a {
    background: var(--nl-primary);
    color: #fff;
    text-decoration: none;
}

.nl-pagination .nav-links a:hover {
    background: var(--nl-secondary);
}

.nl-pagination .nav-links .current {
    background: #f0f0f0;
    color: #333;
}

.nl-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.1em;
}

/* =========================================================================
   Print Styles
   ========================================================================= */

@media print {
    .nl-container {
        max-width: 100%;
        padding: 0;
    }

    .nl-back-to-top,
    .nl-item-link {
        display: none;
    }

    .nl-section {
        page-break-inside: avoid;
    }
}
