/* ============================================================
   Pentasquad Events & News — v3.1.0
   ============================================================ */

/*
 * BUG FIX v3.1.4 → v3.1.5:
 * Variables are scoped to .ps-en-wrapper and .ps-en-single instead of :root.
 * Using :root was causing plugin variables to override theme CSS variables
 * globally — breaking menu colors, section backgrounds, and other theme styles.
 * All --ps-* variables are fully isolated inside plugin elements only.
 */
.ps-en-wrapper,
.ps-en-single {
    --ps-accent:          #1a56db;
    --ps-btn-bg:          #1a56db;
    --ps-btn-fg:          #ffffff;
    --ps-chip-date-bg:    #eff4ff;
    --ps-chip-date-fg:    #1a56db;
    --ps-chip-time-bg:    #f0fdf4;
    --ps-chip-time-fg:    #15803d;
    --ps-venue-color:     #dc2626;
    --ps-img-w:           350px;
    --ps-img-h:           233px;
    --ps-grid-img-h:      233px;
    --ps-grid-aspect:     3 / 2;
    --ps-title-size:      17px;
    --ps-title-weight:    700;
    --ps-excerpt-size:    13px;
    --ps-chip-size:       12px;
    --ps-btn-size:        13px;
    --ps-radius-card:     12px;
    --ps-radius-sm:       6px;
    --ps-radius-pill:     50px;
    --ps-shadow:          0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
    --ps-shadow-hover:    0 6px 20px rgba(0,0,0,.10), 0 16px 40px rgba(0,0,0,.10);
    --ps-shadow-glow:     0 0 0 3px rgba(26,86,219,.18), 0 6px 20px rgba(26,86,219,.15);
    --ps-transition:      .22s ease;
    --ps-border:          #e5e7eb;
    --ps-bg-card:         #ffffff;
    --ps-text-title:      #111827;
    --ps-text-body:       #4b5563;
    --ps-text-muted:      #9ca3af;
    --ps-venue-bg:        #fef2f2;
}

/* ── Wrapper ────────────────────────────────────────────────── */
.ps-en-wrapper {
    position: relative;
}

/* ── LIST Grid ──────────────────────────────────────────────── */
.ps-en-grid--list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 0 24px;
}

/* ── GRID Grid ──────────────────────────────────────────────── */
.ps-en-grid--grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 4px 0 24px;
}

/* ── Base Card ──────────────────────────────────────────────── */
.ps-en-card {
    background: var(--ps-bg-card);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius-card);
    overflow: hidden;
    box-shadow: var(--ps-shadow);
    transition: box-shadow var(--ps-transition), transform var(--ps-transition),
                border-color var(--ps-transition);
    position: relative;
}

/* ── Hover Effects ──────────────────────────────────────────── */
.ps-en-card--hover-lift:hover {
    box-shadow: var(--ps-shadow-hover);
    transform: translateY(-4px);
    border-color: #d1d5db;
}
.ps-en-card--hover-glow:hover {
    box-shadow: var(--ps-shadow-glow);
    border-color: var(--ps-accent);
}
.ps-en-card--hover-border { border-width: 1.5px; }
.ps-en-card--hover-border:hover {
    border-color: var(--ps-accent);
    border-width: 2px;
}

/* ── Past event ─────────────────────────────────────────────── */
/* Past events show at full color and brightness — only the Closed badge indicates status */
.ps-en-card--past .ps-en-card__img { filter: none !important; }

/* ── List Card ──────────────────────────────────────────────── */
.ps-en-card--list {
    display: flex;
    align-items: flex-start;
    min-height: var(--ps-img-h);
}

/* ── Grid Card ──────────────────────────────────────────────── */
.ps-en-card--grid {
    display: flex;
    flex-direction: column;
}

/* ── Media Block ────────────────────────────────────────────── */
.ps-en-card__media {
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

/* List: fixed width + aspect-ratio driven height — locked box, never stretches with card content. */
.ps-en-card--list .ps-en-card__media {
    width: var(--ps-img-w);
    height: var(--ps-img-h);
    min-height: var(--ps-img-h);
    max-height: var(--ps-img-h);
    aspect-ratio: var(--ps-list-aspect, 3 / 2);
    align-self: stretch;
    flex-shrink: 0;
    border-radius: var(--ps-radius-card) 0 0 var(--ps-radius-card);
    overflow: hidden;
}

/* Grid: full-width image with enforced aspect ratio */
.ps-en-card--grid .ps-en-card__media {
    width: 100%;
    aspect-ratio: var(--ps-grid-aspect);
    /* Fallback for browsers without aspect-ratio (rare) */
    min-height: var(--ps-grid-img-h);
}

/* ── Image Wrap ─────────────────────────────────────────────── */
.ps-en-card__img-wrap {
    width: 100%;
    height: 100%;
    display: block;
}

.ps-en-card__img-wrap a {
    display: block;
    width: 100%;
    height: 100%;
}

/*
 * THE KEY RULE for consistent image display:
 * object-fit: cover fills the fixed container box regardless of the image's
 * natural dimensions (square, portrait, landscape — all render identically).
 * !important on width/height overrides WP's injected inline style/attributes.
 */
.ps-en-card__img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center center;
    display: block;
    transition: transform .45s ease;
    max-width: none !important;
    min-height: 0;
}

/* List: img-wrap and anchor must fill the locked media box */
.ps-en-card--list .ps-en-card__img-wrap,
.ps-en-card--list .ps-en-card__img-wrap a {
    width: 100%;
    height: 100%;
    min-height: unset;
    display: block;
}

.ps-en-card:hover .ps-en-card__img {
    transform: scale(1.05);
}

/* ── No-image Fallback ──────────────────────────────────────── */
.ps-en-card__no-img {
    width: 100%;
    height: 100%;
    min-height: var(--ps-img-h);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
}
.ps-en-card--grid .ps-en-card__no-img {
    aspect-ratio: var(--ps-grid-aspect);
    min-height: var(--ps-grid-img-h);
}
.ps-en-card__no-img--placeholder {
    background: #f1f5f9;
}
.ps-en-card__no-img--color {
    /* background set inline */
}

/* ── Type Badge ─────────────────────────────────────────────── */
.ps-en-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--ps-radius-pill);
    line-height: 1;
    pointer-events: none;
    backdrop-filter: blur(4px);
    z-index: 2;
}
.ps-en-badge--event { background: var(--ps-btn-bg); }
.ps-en-badge--news  { background: #0891b2; }

/* ── Status Badge ───────────────────────────────────────────── */
.ps-en-status {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: var(--ps-radius-pill);
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}
.ps-en-status--upcoming { background: rgba(255,255,255,.92); color: #15803d; border: 1px solid #bbf7d0; }
.ps-en-status--today    { background: #fef08a; color: #92400e; border: 1px solid #fde047; }
.ps-en-status--closed   { background: rgba(255,255,255,.88); color: #6b7280; border: 1px solid #e5e7eb; }

/* ── Card Body ──────────────────────────────────────────────── */
.ps-en-card__body {
    flex: 1;
    min-width: 0;
    padding: 18px 22px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}
.ps-en-card--grid .ps-en-card__body { justify-content: flex-start; }

/* ── Chips ──────────────────────────────────────────────────── */
.ps-en-card__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.ps-en-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--ps-chip-size);
    font-weight: 600;
    padding: 5px 12px 5px 9px;
    border-radius: var(--ps-radius-pill);
    white-space: nowrap;
    line-height: 1;
}
.ps-en-chip svg { flex-shrink: 0; opacity: .85; }
.ps-en-chip--date { background: var(--ps-chip-date-bg); color: var(--ps-chip-date-fg); }
.ps-en-chip--time { background: var(--ps-chip-time-bg); color: var(--ps-chip-time-fg); }

/* Audience chip — employee only */
.ps-en-chip--audience {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
/* Audience chip — open to all */
.ps-en-chip--audience-open {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Venue chip — used on single pages */
.ps-en-chip--venue {
    background: #fef2f2;
    color: var(--ps-venue-color);
    border: 1px solid #fecaca;
}

/* ── Title ──────────────────────────────────────────────────── */
.ps-en-card__title {
    font-size: var(--ps-title-size);
    font-weight: var(--ps-title-weight);
    color: var(--ps-text-title);
    margin: 0;
    line-height: 1.35;
    letter-spacing: -.015em;
}
.ps-en-card__title a { color: inherit; text-decoration: none; transition: color var(--ps-transition); }
.ps-en-card__title a:hover { color: var(--ps-accent); }

/* ── Venue ──────────────────────────────────────────────────── */
.ps-en-card__venue {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ps-venue-color);
    background: var(--ps-venue-bg);
    padding: 4px 11px 4px 8px;
    border-radius: var(--ps-radius-pill);
    margin: 0;
    width: fit-content;
}

/* ── Excerpt ────────────────────────────────────────────────── */
.ps-en-card__excerpt {
    font-size: var(--ps-excerpt-size);
    color: var(--ps-text-body);
    line-height: 1.65;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Footer ─────────────────────────────────────────────────── */
.ps-en-card__footer { margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────── */
.ps-en-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    font-size: var(--ps-btn-size);
    font-weight: 600;
    border-radius: var(--ps-radius-sm);
    text-decoration: none !important;
    line-height: 1;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background var(--ps-transition), color var(--ps-transition),
                border-color var(--ps-transition), transform var(--ps-transition),
                opacity var(--ps-transition);
    background: none;
}
.ps-en-btn svg { flex-shrink: 0; transition: transform var(--ps-transition); }
.ps-en-btn:hover svg { transform: translateX(3px); }

.ps-en-btn--filled { background: var(--ps-btn-bg); color: var(--ps-btn-fg) !important; border-color: var(--ps-btn-bg); }
.ps-en-btn--filled:hover { filter: brightness(.9); transform: translateX(2px); }

.ps-en-btn--outline { background: transparent; color: var(--ps-accent) !important; border-color: var(--ps-accent); }
.ps-en-btn--outline:hover { background: var(--ps-chip-date-bg); transform: translateX(2px); }

.ps-en-btn--closed {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; font-size: var(--ps-btn-size); font-weight: 600;
    border-radius: var(--ps-radius-sm); border: 1.5px solid #e5e7eb;
    background: #f3f4f6; color: #9ca3af !important;
    cursor: default; pointer-events: none; line-height: 1;
}

/* ── AJAX Pagination Controls ───────────────────────────────── */
.ps-en-pagination-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0 24px;
    gap: 12px;
}

/* Numbered prev/next */
.ps-en-pagination {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ps-en-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 16px;
    font-weight: 600;
    border: 1.5px solid var(--ps-border);
    border-radius: var(--ps-radius-sm);
    background: #fff;
    color: var(--ps-text-body);
    cursor: pointer;
    transition: all var(--ps-transition);
    line-height: 1;
}
.ps-en-page-btn:hover:not([disabled]) {
    background: var(--ps-btn-bg);
    color: var(--ps-btn-fg);
    border-color: var(--ps-btn-bg);
}
.ps-en-page-btn[disabled] {
    opacity: .35;
    cursor: not-allowed;
}

.ps-en-page-info {
    font-size: 13px;
    color: var(--ps-text-body);
    white-space: nowrap;
}
.ps-en-page-info strong {
    color: var(--ps-text-title);
}

/* Load More button */
.ps-en-load-more {
    min-width: 160px;
    justify-content: center;
}

/* ── Spinner ────────────────────────────────────────────────── */
.ps-en-spinner {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 24px 0;
}
.ps-en-spinner span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ps-accent);
    animation: ps-bounce 1.2s infinite ease-in-out both;
}
.ps-en-spinner span:nth-child(1) { animation-delay: -0.32s; }
.ps-en-spinner span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ps-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: .3; }
    40%           { transform: scale(1); opacity: 1;  }
}

/* ── Empty ──────────────────────────────────────────────────── */
.ps-en-empty {
    color: var(--ps-text-muted);
    font-size: 14px;
    text-align: center;
    padding: 40px 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ps-en-grid--grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .ps-en-card--list { flex-direction: column; min-height: unset; }

    .ps-en-card--list .ps-en-card__media {
        width: 100%;
        height: auto;
        min-height: unset;
        max-height: unset;
        aspect-ratio: var(--ps-list-aspect, 16 / 7);
        border-radius: var(--ps-radius-card) var(--ps-radius-card) 0 0;
    }

    .ps-en-card--list .ps-en-card__img-wrap,
    .ps-en-card--list .ps-en-card__img-wrap a {
        width: 100%;
        height: 100%;
        min-height: unset;
    }

    .ps-en-card__body { padding: 16px; }
    .ps-en-card__title { font-size: 15px; }
}

/* ── Single Event / News Detail Block ───────────────────────── */

/* Outer wrapper */
.ps-en-single {
    margin-bottom: 32px;
    font-family: inherit;
}

/* ── Hero Image ─────────────────────────────────────────────── */
.ps-en-single__hero {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    background: #f1f5f9;
    aspect-ratio: var(--ps-single-aspect, 16 / 7);
    max-height: 600px;
}

.ps-en-single__hero-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
    display: block;
    max-width: none !important;
}

/* Status badge overlaid on hero */
.ps-en-single__status {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 50px;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}
.ps-en-single__status--upcoming { background: rgba(255,255,255,.92); color: #15803d; border: 1px solid #bbf7d0; }
.ps-en-single__status--today    { background: #fef08a; color: #92400e; border: 1px solid #fde047; }
.ps-en-single__status--closed   { background: rgba(255,255,255,.88); color: #6b7280; border: 1px solid #e5e7eb; }

/* Audience badge overlaid bottom-left on hero */
.ps-en-single__audience-badge {
    position: absolute;
    bottom: 14px;
    left: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 5px 12px 5px 9px;
    border-radius: 50px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    pointer-events: none;
    z-index: 2;
    backdrop-filter: blur(4px);
}

/* ── Meta row — chips left, CTA right ──────────────────────── */
.ps-en-single__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.ps-en-single__meta--news {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 16px;
}

.ps-en-single__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ps-en-single__cta {
    flex-shrink: 0;
}

/* ── Details WYSIWYG ────────────────────────────────────────── */
.ps-en-wysiwyg {
    font-size: 15px;
    line-height: 1.8;
    color: #374151;
}

.ps-en-wysiwyg > *:first-child { margin-top: 0; }
.ps-en-wysiwyg > *:last-child  { margin-bottom: 0; }

.ps-en-wysiwyg h1,
.ps-en-wysiwyg h2,
.ps-en-wysiwyg h3,
.ps-en-wysiwyg h4,
.ps-en-wysiwyg h5,
.ps-en-wysiwyg h6 {
    color: #111827;
    font-weight: 700;
    line-height: 1.3;
    margin: 1.6em 0 .6em;
}
.ps-en-wysiwyg h2 { font-size: 1.4em; }
.ps-en-wysiwyg h3 { font-size: 1.2em; }
.ps-en-wysiwyg h4 { font-size: 1.05em; }

.ps-en-wysiwyg p { margin: 0 0 1.1em; }

.ps-en-wysiwyg ul,
.ps-en-wysiwyg ol {
    margin: 0 0 1.1em 1.5em;
    padding: 0;
}
.ps-en-wysiwyg li { margin-bottom: .4em; }

.ps-en-wysiwyg a {
    color: var(--ps-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity .2s;
}
.ps-en-wysiwyg a:hover { opacity: .75; }

.ps-en-wysiwyg strong,
.ps-en-wysiwyg b { font-weight: 700; color: #111827; }

.ps-en-wysiwyg em,
.ps-en-wysiwyg i { font-style: italic; }

.ps-en-wysiwyg blockquote {
    border-left: 3px solid var(--ps-accent);
    margin: 1.4em 0;
    padding: .75em 1.4em;
    background: #f8fafc;
    border-radius: 0 8px 8px 0;
    color: #4b5563;
    font-style: italic;
}
.ps-en-wysiwyg blockquote p { margin: 0; }

.ps-en-wysiwyg hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 2em 0;
}

.ps-en-wysiwyg img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: .6em 0;
    display: block;
}

.ps-en-wysiwyg table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2em;
    font-size: .93em;
    border-radius: 8px;
    overflow: hidden;
}
.ps-en-wysiwyg th,
.ps-en-wysiwyg td {
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    text-align: left;
}
.ps-en-wysiwyg th {
    background: #f9fafb;
    font-weight: 600;
    color: #111827;
}
.ps-en-wysiwyg tr:nth-child(even) td { background: #fafafa; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    .ps-en-single__hero { aspect-ratio: var(--ps-single-aspect, 16 / 7); max-height: 280px; }
    .ps-en-single__meta { flex-direction: column; align-items: flex-start; }
    .ps-en-single__cta  { width: 100%; }
    .ps-en-single__cta .ps-en-btn { width: 100%; justify-content: center; }
    .ps-en-wysiwyg { font-size: 14px; }
    .ps-en-wysiwyg h2 { font-size: 1.25em; }
    .ps-en-wysiwyg h3 { font-size: 1.1em; }
}
