/* Post Grid Component - Generalized grid layout for any post type */
.post-grid {
    --color-primary: #2774AE;
    /* UCLA Blue */
    --color-primary-dark: #1a5a8a;
    /* Darker blue for hover */
    --color-secondary: #FFD100;
    /* UCLA Gold */
    --color-text-primary: #000000;
    --color-text-secondary: #000000;
    --color-text-tertiary: #000000;
    --color-text-muted: #000000;
    --color-background: #ffffff;
    --color-card: #ffffff;
    --color-border: rgba(0, 0, 0, 0.15);

    /* Typography */
    --font-family: var(--font-family-primary);
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-bold: 700;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --border-radius-sm: 8px;
    --border-radius-md: 10px;
    --border-radius-lg: 14px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-default: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-slow: 0.5s cubic-bezier(0.16, 1, 0.3, 1);

    font-family: var(--font-family);
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.post-grid *,
.post-grid *::before,
.post-grid *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Break out of WordPress entry-content constrained layout */
.entry-content > .post-grid {
    max-width: none;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Grid Container */
.post-grid__container {
    width: var(--container-width);
    max-width: var(--container-max-width);
    margin-inline: auto;
    padding: 3rem 0 4rem;
}

/* Collapse spacing between consecutive post grids */
.post-grid + .post-grid .post-grid__container {
    padding-top: 0;
}

/* Section Header */
.post-grid__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: nowrap;
    border-left: 4px solid #f76600;
    padding-left: var(--spacing-xl);
    padding-right: 0;
    margin-bottom: var(--spacing-xl);
}

.post-grid__title {
    font-size: 1.75rem;
    line-height: 1.3;
    font-weight: 100;
    color: var(--color-text-primary);
    margin: 0;
}

.post-grid__title strong {
    font-weight: 700;
}

/* Grid Layout */
.post-grid__layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
}

/* Individual Card */
.post-card {
    background-color: white;
    border-radius: 0;
    /* No overflow:hidden here — the image is already clipped by
       .post-card__image-container, and clipping the card cut off the keyboard
       focus ring on the full-card link (WCAG 2.4.7). */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    opacity: 0;
    transform: translateY(20px);
    animation: postCardFadeIn var(--transition-slow) forwards;
    animation-delay: calc(var(--animation-order) * 0.08s);
    position: relative;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 2px 8px rgba(0, 0, 0, 0.08);
    border: none;
}

@keyframes postCardFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Link Wrapper */
.post-card__link {
    color: var(--color-text-primary);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    background: white;
}

.post-card__link:hover {
    text-decoration: none;
    color: var(--color-text-primary);
}

/* Keyboard focus ring comes from the global :focus-visible baseline (focus.css).
   Do not re-add outline:none here — it removed the indicator (WCAG 2.4.7). */

/* Thumbnail and image handling */
.post-card__thumbnail {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 0;
    background-color: #eff0f2;
}

.post-card__image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #eff0f2;
}

.post-card__image-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #eff0f2;
}

.post-card__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
    opacity: 0;
}

.post-card__image.loaded {
    opacity: 1;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Placeholder handling */
.post-card__image-container--placeholder {
    background-color: #eff0f2;
}

.post-card__image-container--placeholder img {
    object-fit: contain;
    padding: 1.5rem;
    opacity: 0.9;
}

/* Image loading spinner */
.post-image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.image-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    color: #64748b;
}

/* Card Content */
.post-card__content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: var(--spacing-lg);
    flex-grow: 1;
}

/* Card Title */
.post-card__title {
    font-size: 18px !important;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-text-primary);
    margin: 0;
    padding-right: 1rem;
    transition: color 0.2s ease;
}

.post-card__link:hover .post-card__title {
    color: var(--color-primary);
}

.post-card__title-link {
    color: inherit;
    text-decoration: none;
}

/* The title is the single card link, but a stretched overlay keeps the whole
   card clickable. The Read More button sits above it via z-index. */
.post-card__title-link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Card Date */
.post-card__date {
    font-size: 0.875rem;
    line-height: 1.5;
    font-weight: var(--font-weight-regular);
    color: #000000;
    margin-top: 0.5rem;
    margin-bottom: var(--spacing-xs);
}

/* Event Metadata Styles - Matching events archive */
.post-card__meta.events-module__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.post-card .events-module__datetime,
.post-card .events-module__time-container,
.post-card .events-module__location-container {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: #000000;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.post-card .events-module__datetime svg,
.post-card .events-module__time-container svg,
.post-card .events-module__location-container svg {
    margin-right: var(--spacing-xs);
    opacity: 1;
    flex-shrink: 0;
    color: #000000;
}

.post-card .events-module__date,
.post-card .events-module__time,
.post-card .events-module__location {
    color: #000000;
}

.post-card__excerpt {
    font-size: 0.9375rem;
    color: var(--color-text-primary);
    line-height: 1.6;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    flex-grow: 1;
}

/* Card Button */
.post-card__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.2rem;
    background-color: var(--color-primary);
    color: white;
    text-decoration: none;
    border-radius: 0;
    font-weight: 500;
    font-size: 0.9375rem;
    align-self: flex-start;
    position: relative;
    z-index: 2;
    overflow: hidden;
    margin: 0 var(--spacing-lg) var(--spacing-lg);
    letter-spacing: 0.01em;
    transition: all var(--transition-fast);
}

/* Keyboard focus ring comes from the global :focus-visible baseline (focus.css). */

/* Button Icon */
.post-card__button-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    margin-left: 6px;
}

/* No Results Message */
.post-grid__no-results {
    text-align: center;
    padding: var(--spacing-xl) 0;
    color: var(--color-text-tertiary);
    font-size: 1.125rem;
    grid-column: 1 / -1;
}

/* Error Message */
.post-grid-error {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c66;
    padding: 1rem;
    border-radius: 0;
    margin: 1rem 0;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .post-grid__layout {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xl);
    }
}

@media (max-width: 768px) {
    .post-grid__layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .post-card__title {
        font-size: 1.125rem;
    }

    .post-card__excerpt {
        font-size: 0.875rem;
    }

    .post-card__button {
        width: calc(100% - 2 * var(--spacing-lg));
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {

    .post-card,
    .post-card__image,
    .post-card__button,
    .post-image-loading {
        transition: none;
        animation: none !important;
    }

    .post-card {
        opacity: 1;
        transform: none;
    }
}
