/**
 * Services Grid – Block Styles
 *
 * Covers both the parent (rs-services-grid) and child (rs-service-card) elements.
 * Loaded once via the parent block; the child block shares these styles.
 *
 * Grid:
 *   Mobile  — Single column stack.
 *   Desktop — N equal-width columns, controlled by the CSS custom property
 *             --rs-grid-cols (set inline from the block `columns` attribute, 1–6).
 *
 * Image handling:
 *   - 1:1 aspect-ratio image wrapper ensures consistent card dimensions.
 *   - object-fit: cover crops any upload size to the slot.
 *   - Loading skeleton animates until the img fires its load event (JS in render.php).
 *
 * ADA:
 *   - Image link and READ MORE link both have visible focus rings.
 */

/* ====================================================================
   SECTION WRAPPER
   ==================================================================== */

.rs-services-grid {
    /* background-color is set via inline style from the block attribute */
    padding-top: 2rem;    /* 32px mobile */
    padding-bottom: 2rem;
    width: 100%;
}

@media (min-width: 1024px) {
    .rs-services-grid {
        padding-top: 4rem;    /* 64px desktop */
        padding-bottom: 4rem;
    }
}

/* ====================================================================
   SECTION HEADING (h2)
   ==================================================================== */

.rs-services-grid__title {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.875rem; /* 30px – mobile */
    line-height: 1.3;
    color: #0d1a3a;
    text-align: center;
    margin: 0 0 2rem;
}

@media (min-width: 1024px) {
    .rs-services-grid__title {
        font-size: 2.5rem;   /* 40px – desktop */
        margin-bottom: 3rem;
    }
}

/* ====================================================================
   GRID CONTAINER
   ==================================================================== */

.rs-services-grid__grid {
    display: grid;
    grid-template-columns: 1fr; /* single column on mobile */
    gap: 2rem;
}

@media (min-width: 768px) {
    .rs-services-grid__grid {
        grid-template-columns: repeat(var(--rs-grid-cols, 3), 1fr);
        gap: 1.5rem; /* 24px – matches Figma */
    }
}

/* ====================================================================
   SERVICE CARD
   ==================================================================== */

.rs-service-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem; /* 8px */
    padding-bottom: 0.5rem;
}

/* ====================================================================
   IMAGE LINK (clickable image wrapper)
   ==================================================================== */

.rs-service-card__image-link {
    display: block;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    /* Transition for hover state */
    transition: opacity 0.2s ease;
}

.rs-service-card__image-link:hover {
    opacity: 0.9;
}

.rs-service-card__image-link:focus-visible {
    outline: 3px solid #5279e0;
    outline-offset: 3px;
    border-radius: 8px;
}

/* ====================================================================
   IMAGE WRAPPER + SKELETON
   ==================================================================== */

.rs-service-card__image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* square — matches Figma 340×340 */
    background-color: #e4e4e4;
    border-radius: 8px;
    overflow: hidden;
}

/* Shimmer skeleton */
.rs-service-card__skeleton {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(
        90deg,
        #e4e4e4 25%,
        #f2f2f2 50%,
        #e4e4e4 75%
    );
    background-size: 200% 100%;
    animation: rs-service-skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes rs-service-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Actual image — hidden until JS adds .is-loaded */
.rs-service-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rs-service-card__img.is-loaded {
    opacity: 1;
}

/* Placeholder shown when no image is configured */
.rs-service-card__image-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    background-color: #ebeff9;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    width: 100%;
}

/* ====================================================================
   TEXT CONTENT
   ==================================================================== */

.rs-service-card__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
    gap: 0.25rem; /* 4px */
}

/* Service title (h3) */
.rs-service-card__title {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.25rem; /* 20px */
    line-height: 1.4;
    color: #0d1a3a;
    text-align: center;
    margin: 0;
    width: 100%;
}

/* Description */
.rs-service-card__description {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 0.9375rem; /* 15px mobile */
    line-height: 1.4;
    color: #0d1a3a;
    text-align: center;
    margin: 0;
}

@media (min-width: 1024px) {
    .rs-service-card__description {
        font-size: 1rem; /* 16px desktop */
    }
}

/* READ MORE link */
.rs-service-card__read-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    line-height: 2rem;
    letter-spacing: -0.015625rem; /* -0.25px */
    text-transform: uppercase;
    color: #0d1a3a;
    text-decoration: none;
    border-bottom: 1px solid #0d1a3a;
    margin-top: 0.25rem;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.rs-service-card__read-more:hover {
    opacity: 0.7;
}

.rs-service-card__read-more:focus-visible {
    outline: 3px solid #5279e0;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ====================================================================
   EDITOR STYLES
   Scoped to the block editor context.
   ==================================================================== */

.rs-service-card--editing .rs-service-card__image-wrapper {
    cursor: default;
}

.rs-service-card--editing .rs-service-card__read-more {
    /* Non-interactive in editor — display as visual hint only */
    pointer-events: none;
}
