/* === PDG Manager Frontend Styles === */

.pdg-list-wrap {
    width: 100%;
}

/* ============================================
   Grid Layout
   ============================================ */
.pdg-grid {
    display: grid;
    grid-template-columns: repeat(var(--pdg-columns, 3), 1fr);
    gap: 24px;
}

/* ============================================
   Row Layout
   ============================================ */
.pdg-rows .pdg-card {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid #eee;
}
.pdg-rows .pdg-card:last-child {
    border-bottom: none;
}
.pdg-rows .pdg-photo-container {
    flex: 0 0 180px;
    width: 180px;
}
.pdg-rows .pdg-content {
    flex: 1;
    min-width: 0;
}

/* ============================================
   Card Base
   ============================================ */
.pdg-card {
    background: var(--pdg-card-bg, #fff);
    border-radius: var(--pdg-border-radius, 8px);
    overflow: hidden;
    padding: var(--pdg-card-padding, 16px);
    /* text-align is set by Elementor text_align control and inherited by all children */
}

/* ============================================
   Photo
   ============================================
   HOW ALIGNMENT WORKS:
   - .pdg-card has text-align set by Elementor (e.g. center)
   - .pdg-photo-container inherits that text-align (no override here)
   - .pdg-photo-wrap is display:inline-block so it RESPONDS to text-align
   - When photo width < 100%, the inline-block is narrower than container
     and text-align visually moves it left/center/right
   - Individual photo_align control sets text-align on .pdg-photo-container
     to override the inherited card alignment if needed
   ============================================ */
.pdg-photo-container {
    /* No text-align here — inherits from .pdg-card or prefix_class rules below */
    font-size: 0; /* removes inline-block gap */
}
/* Photo alignment via prefix_class on widget wrapper.
   Only center/right need explicit rules. Left = no rule = inherits from card. */
.pdg-photo-align-center .pdg-photo-container { text-align: center; }
.pdg-photo-align-right  .pdg-photo-container { text-align: right; }
.pdg-photo-wrap {
    display: inline-block;
    vertical-align: top;
    position: relative;
    width: 100%; /* default: fills card; overridden by Elementor photo_width */
    max-width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: #f0f0f0;
}
.pdg-photo-wrap img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.pdg-photo-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    transition: background 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

/* ============================================
   Logo
   ============================================
   HOW ALIGNMENT WORKS:
   - .pdg-logo-container inherits text-align from .pdg-card
   - .pdg-logo-wrap is display:inline-block with width:120px
   - 120px is always narrower than the card, so text-align IMMEDIATELY
     moves it left/center/right — no width change needed
   ============================================ */
.pdg-logo-container {
    /* No text-align here — inherits from .pdg-card or prefix_class rules below */
    margin: 12px 0;
    font-size: 0; /* removes inline-block gap */
}
/* Logo alignment via prefix_class on widget wrapper.
   Only center/right need explicit rules. Left = no rule = inherits from card. */
.pdg-logo-align-center .pdg-logo-container { text-align: center; }
.pdg-logo-align-right  .pdg-logo-container { text-align: right; }
.pdg-logo-wrap {
    display: inline-block;
    vertical-align: top;
    width: 120px; /* explicit width — narrower than card, immediately alignable */
    max-width: 100%;
}
.pdg-logo-wrap {
    cursor: zoom-in;
}
.pdg-logo-wrap img {
    width: 100%;
    height: auto;
    max-height: 120px; /* cap height at container width — prevents portrait logos from over-extending */
    object-fit: contain;
    display: block;
}

/* ============================================
   Lightbox
   ============================================ */
#pdg-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
#pdg-lightbox.is-open {
    display: flex;
}
.pdg-lightbox-inner {
    position: relative;
    background: #fff;
    border-radius: 6px;
    padding: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    max-width: 75vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate;
}
.pdg-lightbox-inner img {
    max-width: calc(75vw - 32px);
    max-height: calc(75vh - 32px);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 2px;
    background-color: #fff; /* ensures PNG transparent areas show white, not the dark overlay */
}
.pdg-lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    background: #fff;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Text Elements
   ============================================ */
.pdg-name {
    font-size: var(--pdg-name-size, 1.1em);
    font-weight: bold;
    margin: 10px 0 4px;
}
/* Year highlight — text-only background, enabled via Elementor switcher */
.pdg-year-bg-yes .pdg-year-text {
    display: inline;
}

.pdg-year,
.pdg-theme,
.pdg-club {
    font-size: var(--pdg-meta-size, 0.9em);
    color: #555;
    margin: 2px 0;
}
.pdg-prefix {
    font-size: 0.85em;
    opacity: 0.75;
}
.pdg-ry-prefix,
.pdg-rc-prefix {
    font-size: 0.85em;
    opacity: 0.75;
}
.pdg-deceased {
    margin-left: 6px;
    color: #888;
    font-size: 0.9em;
}

/* ============================================
   Spouse Section
   ============================================ */
.pdg-spouse {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}
.pdg-spouse-photo-wrap {
    display: inline-block;
    vertical-align: top;
    width: 80px;
    max-width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: #f0f0f0;
    position: relative;
}
.pdg-spouse-photo-wrap img {
    width: 100%;
    height: auto;
    display: block;
}
.pdg-spouse-name {
    font-size: 0.85em;
    color: #666;
    margin: 6px 0 0;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .pdg-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .pdg-grid {
        grid-template-columns: 1fr;
    }
    .pdg-rows .pdg-card {
        flex-direction: column;
    }
    .pdg-rows .pdg-photo-container {
        flex: none;
        width: 100%;
    }
    .pdg-horizontal {
        grid-template-columns: 1fr;
    }
    .pdg-card--horizontal {
        flex-direction: column;
    }
    .pdg-photo-col {
        flex: none;
        max-width: 100%;
        width: 100%;
    }
}

/* ============================================
   Horizontal Card Layout
   ============================================ */
.pdg-horizontal {
    display: grid;
    grid-template-columns: repeat(var(--pdg-columns, 1), 1fr);
    gap: 24px;
}

.pdg-card--horizontal {
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: flex-start;
}

/* Left column — PDG photo */
.pdg-photo-col {
    flex: 0 0 25%;
    max-width: 25%;
}

/* Scoped to avoid inheriting grid card's inline-block rules. */
.pdg-photo-col .pdg-photo-wrap {
    display: block;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.pdg-photo-col .pdg-photo-wrap img {
    width: 100%;
    height: auto;
    display: block;
}

/* Right column — all content */
.pdg-content-col {
    flex: 1;
    min-width: 0;
}

.pdg-card--horizontal .pdg-name {
    margin-top: 0;
}

.pdg-theme-year {
    font-style: italic;
    margin-bottom: 8px;
}

/* Media thumbnails + details row */
.pdg-meta-row {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: flex-start;
    margin-top: 8px;
}

.pdg-media-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.pdg-details-col {
    flex: 1;
}

.pdg-ri-president {
    margin-top: 4px;
}

/* ============================================
   Marquee Shortcode
   ============================================ */
.pdg-marquee-wrap {
    overflow-x: clip;
    width: 100%;
    padding-top: 48px;
    position: relative;
    isolation: isolate;
    min-height: var(--pdg-strip-height, 0);
    background-color: var(--pdg-bg-color, transparent);
}

.pdg-marquee-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    width: max-content;
    animation-name: pdg-scroll-ltr;
    animation-duration: var(--pdg-marquee-speed, 30s);
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.pdg-marquee-row--rtl {
    animation-name: pdg-scroll-rtl;
}

.pdg-marquee-pause-hover:hover .pdg-marquee-row {
    animation-play-state: paused;
}

@keyframes pdg-scroll-ltr {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

@keyframes pdg-scroll-rtl {
    from { transform: translateX(-50%); }
    to   { transform: translateX(0); }
}

.pdg-marquee-item {
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.pdg-marquee-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: inherit;
}

.pdg-marquee-photo {
    width: var(--pdg-marquee-size, 80px);
    height: var(--pdg-marquee-size, 80px);
    overflow: hidden;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pdg-marquee-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.pdg-marquee-item:hover .pdg-marquee-photo img {
    opacity: 1 !important;
}

.pdg-marquee-hover-zoom .pdg-marquee-item:hover .pdg-marquee-photo img {
    transform: scale(1.08);
}

.pdg-marquee-photo--circle {
    border-radius: 50%;
}

.pdg-marquee-initials {
    font-size: calc(var(--pdg-marquee-size, 80px) * 0.35);
    font-weight: bold;
    color: #9ca3af;
    line-height: 1;
}

.pdg-marquee-name {
    font-size: 0.75em;
    text-align: center;
    white-space: nowrap;
    max-width: var(--pdg-marquee-size, 80px);
    overflow: hidden;
    text-overflow: ellipsis;
    color: #555;
}

.pdg-marquee-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 0.78em;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    text-align: center;
    line-height: 1.5;
}

.pdg-marquee-item:hover .pdg-marquee-tooltip {
    opacity: 1;
}

.pdg-marquee-wrap .pdg-marquee-row + .pdg-marquee-row {
    margin-top: 16px;
}

/* Edge fade — left and right gradient overlays */
.pdg-marquee-fade::before,
.pdg-marquee-fade::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: var(--pdg-fade-width, 80px);
    z-index: 2;
    pointer-events: none;
}
.pdg-marquee-fade::before {
    left: 0;
    background: linear-gradient(to right, var(--pdg-fade-color, #fff), transparent);
}
.pdg-marquee-fade::after {
    right: 0;
    background: linear-gradient(to left, var(--pdg-fade-color, #fff), transparent);
}

/* ============================================
   Card Modal Trigger
   ============================================ */
.pdg-card[data-pdg-modal] {
    cursor: pointer;
}

/* ============================================
   Modal Overlay
   ============================================ */
#pdg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
#pdg-modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Modal Box
   ============================================ */
.pdg-modal-box {
    background: #fff;
    border-radius: 12px;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}
#pdg-modal-overlay.is-open .pdg-modal-box {
    transform: scale(1);
}

/* ============================================
   Modal Close Button
   ============================================ */
.pdg-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
}
.pdg-modal-close:hover {
    color: #111;
    background: #f0f0f0;
}

/* ============================================
   Modal Header (two-column)
   ============================================ */
.pdg-modal-header {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}
.pdg-modal-photo-col img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    object-fit: cover;
    display: block;
}
.pdg-modal-details-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ============================================
   Modal Detail Elements
   ============================================ */
.pdg-modal-name {
    font-size: 1.15em;
    font-weight: 700;
    line-height: 1.3;
    color: #111;
    margin-bottom: 2px;
}
.pdg-modal-year {
    font-size: 0.9em;
    color: #555;
    font-weight: 600;
}
.pdg-modal-theme {
    font-style: italic;
    color: #333;
    font-size: 0.92em;
}
.pdg-modal-logo-wrap {
    margin-top: 4px;
}
.pdg-modal-logo {
    max-width: 100px;
    max-height: 80px;
    object-fit: contain;
    display: block;
}
.pdg-modal-club {
    font-size: 0.88em;
    color: #444;
}
.pdg-modal-spouse {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}
.pdg-modal-spouse-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.pdg-modal-spouse-name {
    font-size: 0.85em;
    color: #555;
}

/* ============================================
   Modal RI President Section
   ============================================ */
.pdg-modal-ri-section {
    border-top: 1px solid #e5e5e5;
    padding-top: 18px;
    margin-top: 4px;
}
.pdg-modal-ri-label {
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin-bottom: 6px;
}
.pdg-modal-ri-name {
    font-weight: 600;
    color: #222;
    font-size: 0.95em;
}
.pdg-modal-ri-body {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.pdg-modal-ri-photo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%;
    flex-shrink: 0;
    display: block;
}
.pdg-modal-ri-info {
    flex: 1;
    min-width: 0;
}
.pdg-modal-ri-detail {
    font-size: 0.85em;
    color: #555;
    margin-top: 2px;
}

/* ============================================
   Modal Responsive
   ============================================ */
@media (max-width: 640px) {
    #pdg-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .pdg-modal-box {
        padding: 20px;
        max-height: 92vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        width: 100%;
        max-width: 100%;
    }
    .pdg-modal-header {
        grid-template-columns: 1fr;
    }
    .pdg-modal-photo-col img {
        max-height: 240px;
        object-fit: cover;
        width: 100%;
    }
}
