/*
 * PIFster Shared Utility Styles
 * For grid layout, buttons, reveal/accordion, video icons, and universal helpers.
 * Only use these classes for true shared UI patterns.
 * Author: PIFster Team
 */

/* Shared typography styles for charity components */
.monthly-charity-subtitle,
.past-winner-subtitle {
    font-size: 1.08rem;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 1.2em;
    margin-top: -0.2em;
    line-height: 1.3;
    font-style: italic;
}
.pifster-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    padding: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

@media (width <= 900px) {
    .pifster-grid { grid-template-columns: 1fr; }
}

.pifster-btn {
    display: flex;
    align-items: center;
    gap: 0.5em;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.65rem 1.5rem;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s;
    color: #fff;
    margin-bottom: 0;
    line-height: 1.1;
}

/* Ensure anchor tags styled as buttons override default link styles */
a.pifster-btn {
    color: #fff !important; /* Override default link color */
    text-decoration: none !important; /* Remove underline */
}

.pifster-btn:disabled {
    opacity: 0.5; cursor: not-allowed;
}

.pifster-btn-row {
    display: flex;
    gap: 0.5em;
    margin-bottom: 1em;
    justify-content: center;
}

/* Description toggle button */
.pifster-description-toggle {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: #f1f5f9;
    border: none;
    color: #22223b;
    cursor: pointer;
    font-weight: 600;
    margin: 0; /* No margins */
    padding: 0.5rem 1.5rem; /* Compact padding */
    font-size: 1em;
    border-radius: 6px; /* Default full rounding */
    text-align: left;
    justify-content: flex-start;
    padding-right: 2.2em;
    transition: background 0.18s, color 0.18s;
}

.pifster-description-toggle[aria-expanded="true"] {
    background: #e2e8f0;
    color: #3182ce;
    border-radius: 6px 6px 0 0; /* Round only top corners when expanded */
    border-bottom: none;
    margin-bottom: 0;
}

.pifster-turn-arrow {
    display: block;
    position: absolute;
    right: 1.1em;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    font-size: 1.15em;
    transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
    pointer-events: none;
}

.pifster-description-toggle[aria-expanded="true"] .pifster-turn-arrow {
    transform: translateY(-50%) rotate(90deg);
}

.pifster-description-content {
    max-height: 0;
    overflow: hidden;
    background: #f7fafc;
    border-radius: 0 0 6px 6px; /* Round only bottom corners */
    padding: 0;
    margin: -2px 0 0 0; /* More aggressive negative margin to eliminate gap */
    transition: max-height 0.3s ease, padding 0.2s ease;
    position: relative;
    z-index: 0; /* Place behind toggle button */
    border-top: none;
}

.pifster-description-content.open {
    padding: 0.5em 1em;
    max-height: 400px;
    border-top: none; /* Ensure no border creates extra space */
}

/*
 * PIFster Shared Accordion/Dropdown Styles for Card Descriptions
 *
 * These classes unify the dropdown/accordion animation for both Monthly Charity and Past Winner components.
 * Use the correct toggle, arrow, and content class for each card type.
 *
 * Usage:
 * <button class="monthly-charity-description-toggle">...<span class="monthly-charity-turn-arrow"></span></button>
 * <div class="monthly-charity-description-content"></div>
 *
 * <button class="past-winner-description-toggle">...<span class="past-winner-turn-arrow"></span></button>
 * <div class="past-winner-description-content"></div>
 */

/* --- Monthly Charity Dropdown Styles (source of truth) --- */
.monthly-charity-description-toggle,
.past-winner-description-toggle {
    display: block;
    width: 100%;
    padding: 0.75em 1em;
    background: #f1f5f9;
    color: #22223b;
    border: none;
    border-radius: 0 0 6px 6px;
    text-align: left;
    font-size: 1.02rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    margin-top: 0.5em;
    margin-bottom: 2.2em; /* Increased from -0.2em to 2.2em to match the spacing for opened accordion */
}

.monthly-charity-description-toggle:focus,
.past-winner-description-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px #cbd5e1;
}

.monthly-charity-description-toggle[aria-expanded="true"],
.past-winner-description-toggle[aria-expanded="true"] {
    background: #e2e8f0;
    color: #3182ce;
}

.monthly-charity-turn-arrow,
.past-winner-turn-arrow {
    display: inline-block;
    margin-left: 0.5em;
    transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}

.monthly-charity-description-toggle[aria-expanded="true"] .monthly-charity-turn-arrow,
.past-winner-description-toggle[aria-expanded="true"] .past-winner-turn-arrow {
    transform: rotate(90deg);
}

.monthly-charity-description-content,
.past-winner-description-content {
    max-height: 0;
    overflow: hidden;
    background: #f8fafc;
    border-radius: 0 0 6px 6px;
    margin-bottom: 0.5em;
    transition: max-height 0.36s cubic-bezier(0.4, 0, 0.2, 1), padding 0.18s;
    padding: 0 1em;
}

.monthly-charity-description-content.open,
.past-winner-description-content.open {
    padding: 0.75em 1em;
    max-height: 400px;
    margin-bottom: 2.2em; /* Doubled from 1.1em to create more space */
}

.monthly-charity-action-row,
.past-winner-action-row {
    margin-top: 0.7em;
}

/*
 * PIFster Action Row & Col Utilities
 *
 * Use .pifster-action-row for flex row of action buttons and .pifster-action-col for each button/label column.
 * Ensures buttons are equal width and labels are centered below each button.
 * 
 * Common button styles are also defined here, used by both MonthlyCharityComponent and PastWinnerComponent.
 */
/* Legacy styles preserved for backwards compatibility */

/* Shared charity component button styles for both <a> and <button> elements */
.pifster-charity-btn,
a.pifster-charity-btn {
    display: inline-block;
    background: #4299e1;
    color: white !important; /* Use !important to override default link color */
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.65rem 1.5rem;
    cursor: pointer;
    transition: background 0.18s;
    margin-bottom: 0;
    width: 100%;
    text-align: center;
    text-decoration: none !important; /* Remove underline from links */
    line-height: 1.2; /* Explicitly set line-height for consistent height */
    box-sizing: border-box; /* Ensure padding and border are included in the width/height */
}

.pifster-charity-btn:hover {
    background: #2563eb;
}

/* Disable interactivity for explicitly disabled buttons/links */
a.pifster-charity-btn.is-disabled,
.pifster-charity-btn.is-disabled,
.pifster-charity-btn[aria-disabled="true"] {
    pointer-events: none;
    cursor: not-allowed;
}

.pifster-action-row {
    display: flex;
    gap: 1.2em;
    justify-content: center;
    margin-bottom: 0.3em;
    margin-top: 0.7em;
}

.pifster-action-col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Shared button styles for charity components */
.pifster-charity-btn {
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.65rem 1.5rem;
    cursor: pointer;
    transition: background 0.18s;
    text-align: center;
    margin-bottom: 0;
}

.pifster-charity-btn:hover {
    background: #2563eb;
}

/* Legacy button sizing */
.pifster-action-col > button,
.pifster-action-col > .monthly-charity-donate-btn,
.pifster-action-col > .monthly-charity-vote-btn,
.pifster-action-col > .past-winner-donate-btn,
.pifster-action-col > .past-winner-btn,
.pifster-action-col > .pifster-charity-btn {
    width: 100%;
    min-width: 120px;
    max-width: 220px;
    margin-bottom: 0.3em;
}

.pifster-action-label {
    text-align: center;
    font-size: 0.98rem;
    color: #22223b;
    opacity: 0.82;
    margin-top: 0.1em;
    margin-bottom: 1.4em; /* Modern, balanced spacing for grabber handle */
}

@media (width <= 600px) {
  .pifster-action-row {
    flex-direction: column;
    gap: 0.75em;
    align-items: stretch;
  }

  .pifster-action-col {
    align-items: stretch;
  }

  .pifster-action-col > button,
  .pifster-action-col > .monthly-charity-donate-btn,
  .pifster-action-col > .monthly-charity-vote-btn,
  .pifster-action-col > .past-winner-donate-btn,
  .pifster-action-col > .past-winner-info-btn {
    min-width: 0;
    max-width: 100%;
  }
}

/*
 * PIFster Card Grid & Row Layout Utilities
 *
 * .pifster-card-grid: Use for responsive 2-column (or more) grid layouts of card components (e.g., Monthly Charity, Past Winner).
 * .pifster-card-row: Use for horizontal flex row layouts (e.g., single row of cards, mobile fallback).
 *
 * Usage Example:
 * <div class="pifster-card-grid">
 *   <div class="monthly-charity-card">...</div>
 *   <div class="monthly-charity-card">...</div>
 * </div>
 *
 * These classes provide consistent spacing and alignment for card-based layouts across the PIFster platform.
 */
.pifster-card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin: 2rem 0;
}

@media (width <= 900px) {
    .pifster-card-grid {
        grid-template-columns: 1fr;
    }
}

.pifster-card-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin: 2rem 0;
}

.pifster-card-row > * {
    flex: 1 1 45%;
    min-width: 300px;
    max-width: 100%;
}

@media (width <= 900px) {
    .pifster-card-row {
        flex-direction: column;
    }

    .pifster-card-row > * {
        min-width: 0;
    }
}

/*
 * Shared card container for all PIFster card-based components (monthly charity, past winner, etc.)
 */
.pifster-charity-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgb(34 34 59 / 8%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 2.5em; /* Ensure space for grabber handle */
    outline: 2px solid transparent; /* Added for green outline on hover */
    transition: box-shadow 0.18s, transform 0.18s, outline-color 0.3s ease;
}

.pifster-charity-card:hover {
    box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
    transform: scale(1.015);
    outline-color: #4CAF50; /* Green outline on hover, matches past-winner-card effect */
}

.pifster-charity-card::after {
    content: "";
    display: block;
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: 38px;
    height: 5px;
    border-radius: 3px;
    background: #e2e8f0;
    opacity: 0.7;
    pointer-events: none;
}

.test {
  color: #e53935 !important;
  font-weight: bold;
  background: #fff3e0 !important;
  border-radius: 3px;
  padding: 0 0.2em;
}

/*
 * PIFster Modal Styles
 * Clean, organized styles for modals and close buttons
 */

/* Base modal styles */
.pifster-generic-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pifster-generic-modal.open {
    display: flex;
    pointer-events: auto;
}

/* Modal overlay */
.pifster-generic-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1;
    cursor: pointer;
}

/* Modal content container */
.pifster-generic-modal-content {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    margin: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.32);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    padding: 1.5rem;
}

/* Close button */
#pifster-youtube-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 4;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
}

#pifster-youtube-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

#pifster-youtube-modal-close:focus {
    outline: none;
    box-shadow: 0 0 0 2px #a0aec0;
}

#pifster-youtube-modal-close:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/*
 * PIFster YouTube Modal Styles
 */
.pifster-youtube-modal.open {
    display: flex !important;
    pointer-events: auto;
}

/*
 * PIFster Generic Modal Styles
 */
.pifster-generic-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 999999; /* Very high z-index to ensure it's on top */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Allow clicks to pass through when not open */
}

.pifster-generic-modal.open {
    display: flex; /* Show when .open class is added */
    pointer-events: auto; /* Enable interaction when open */
}

.pifster-generic-modal-overlay {
    position: fixed; /* Changed from absolute to fixed */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.85); /* Darker overlay for better contrast */
    cursor: pointer;
    z-index: 1; /* Ensure overlay is below content but above everything else */
}

/* Generic modal content */
.pifster-generic-modal-content {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    margin: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.32);
    overflow: hidden;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem;
}

/* YouTube specific modal styles */
.pifster-youtube-modal .pifster-youtube-iframe-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
    background: #000;
}

.pifster-youtube-iframe-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.pifster-youtube-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.pifster-youtube-modal .pifster-youtube-modal-content {
    padding: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    max-width: 1000px;
    max-height: 90vh;
    margin: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.32);
    overflow: hidden;
    pointer-events: auto;
}

.pifster-youtube-modal .pifster-youtube-modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: flex-end;
    padding: 10px;
    z-index: 3; /* Above the iframe */
}

/* Close button styles are now consolidated at the top of the file */

.pifster-generic-modal-title {
    font-size: 1.25rem; /* Slightly larger for emphasis */
    font-weight: 600;
    color: #22223b;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.pifster-generic-modal-content h2 {
    margin-bottom: 1rem;
    color: #22223b;
    font-weight: 700;
    line-height: 1.3;
}

.pifster-generic-modal-content p {
    margin-bottom: 2rem;
    line-height: 1.6;
    max-width: 42rem;
}

.pifster-generic-modal-body {
    font-size: 1rem;
    color: #4a5568;
    line-height: 1.6;
    text-align: center; /* Center body text */
}

.pifster-generic-modal-body p {
    margin-bottom: 0.5rem;
}

.pifster-maintenance-modal-image {
    display: block;
    max-width: 180px;
    width: 100%;
    height: auto;
    margin: 0 auto 1.5rem;
    filter: drop-shadow(0 8px 20px rgba(15, 23, 42, 0.18));
}

.pifster-generic-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.75rem; /* Adjusted size */
    color: #64748b;
    cursor: pointer;
    z-index: 10;
}

/* Maintenance modal primary action */
.pifster-generic-modal .pifster-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.4rem;
    font-weight: 700;
    border-radius: 999px;
    border: none;
    color: #ffffff !important;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.25);
    min-width: 140px;
    text-align: center;
    margin: 0.5rem auto; /* center horizontally */
}

.pifster-generic-modal .pifster-btn:hover,
.pifster-generic-modal .pifster-btn:focus {
    background: linear-gradient(135deg, #1d4ed8, #0284c7);
    text-decoration: none;
}

/* Close button tweaks (restore declarations to the right block) */
.pifster-generic-modal-close {
    padding: 0.25em 0.5em;
    line-height: 1;
}

.pifster-generic-modal-close:hover,
.pifster-generic-modal-close:focus {
    color: #22223b;
    outline: none; /* Or add a custom focus ring if preferred */
}

/* Utility to hide scroll on body when modal is open */
body.pifster-modal-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .pifster-generic-modal-content {
        max-width: 95vw;
        padding: 1rem;
    }
    .pifster-generic-modal-title {
        font-size: 1.1rem;
    }
    .pifster-generic-modal-body {
        font-size: 0.95rem;
    }
}

/*
 * PIFster Shared Video Play Icon
 *
 * Unified play button overlay for charity videos that appears on hover.
 * Used by both Monthly Charity and Past Winner components.
 */
.pifster-play-icon {
    position: absolute;
    bottom: 14px;
    right: 18px;
    background: rgb(0 0 0 / 30%);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: auto;
    transition: background 0.18s;
    cursor: pointer;
}

.pifster-play-icon:hover {
    background: rgb(0 0 0 / 85%);
}

/* === Normalization: Shared content padding & image aspect across cards === */
.monthly-charity-content,
.past-winner-content {
    padding: 16px;
}

.monthly-charity-aspect-16-9,
.past-winner-aspect-16-9 {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.monthly-charity-aspect-16-9 img,
.past-winner-aspect-16-9 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Bias focus upward: center horizontally (50%), ~top-third vertically (30%) */
    object-position: 50% 30%;
}

/* Medal overlay: minimal, decorative badge for leader status */
.monthly-charity-card .pifster-medal-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 40px;  /* ~30% smaller */
    height: 40px;
    z-index: 2; /* below play icon (z-index:3) */
    pointer-events: none; /* never intercept clicks */
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.34));
}

/* Contrast halo backdrop */
.monthly-charity-card .pifster-medal-overlay::before {
    content: "";
    position: absolute;
    inset: -4px; /* scale halo to new size */
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.85) 55%, rgba(255,255,255,0.0) 72%);
    box-shadow: 0 3px 14px rgba(0,0,0,0.22);
    z-index: -1; /* sit behind medal image */
}

.monthly-charity-card .pifster-medal-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 768px) {
    .monthly-charity-card .pifster-medal-overlay {
        width: 26px; /* ~30% smaller */
        height: 26px;
        top: 8px;
        left: 8px;
    }
}

/* Progressive enhancement: slight blur/saturation if supported */
@supports (backdrop-filter: blur(2px)) {
    .monthly-charity-card .pifster-medal-overlay::before {
        backdrop-filter: blur(2px) saturate(1.08);
    }
}

/* === Past Winner: Meta bar layout (Month & Donation) === */
.past-winner-content .past-winner-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* allow soft wrapping by default */
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 12px 0; /* compact bottom spacing */
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

.past-winner-content .past-winner-meta-row .meta-col {
    flex: 1 1 auto;
    min-width: 180px; /* clean wrap threshold on medium widths */
}

/* Small screens: stack Month over Donation for clarity */
@media (max-width: 640px) {
  .past-winner-content .past-winner-meta-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .past-winner-content .past-winner-meta-row .meta-col {
    min-width: 0;
    width: 100%;
  }
}

/* === Past Winner: Gold gradient theme for meta bar === */
.past-winner-content .past-winner-meta-row {
  /* Subtle gold gradient */
  background: linear-gradient(90deg, #FFF9EE 0%, #FFF2DA 50%, #FFE8BD 100%);
  border: 1px solid #f2dfb9;
}

.past-winner-content .past-winner-meta-row .past-winner-winning-month-label,
.past-winner-content .past-winner-meta-row .past-winner-donation-total-label {
  color: #7A5A26; /* warm brown label */
  font-weight: 600;
  opacity: .95;
}

.past-winner-content .past-winner-meta-row .past-winner-winning-month-value,
.past-winner-content .past-winner-meta-row .past-winner-donation-total-value {
  color: #9A3A00; /* deeper accent for values */
  font-weight: 700;
}

/* Remove month pill background to keep Month and Donation consistent */
.past-winner-content .past-winner-meta-row .past-winner-winning-month-value {
  background: transparent;
  padding: 0;
  border-radius: 0;
}
