/* Apostolate 3D card — vanilla port of React Bits ProfileCard.
 * Liturgical green theme with gold/amber/sage/burgundy/purple shine
 * (the six liturgical colours, replacing the original rainbow sunpillars).
 */

.apostolate-cards-grid--3d {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-lg, 24px);
}

.apostolate-3d-card {
    --card-radius: 14px;
    --card-opacity: 0;
    --pointer-x: 50%;
    --pointer-y: 50%;
    --pointer-from-center: 0;
    --pointer-from-top: 0.5;
    --pointer-from-left: 0.5;
    --rotate-x: 0deg;
    --rotate-y: 0deg;
    --background-x: 50%;
    --background-y: 50%;

    /* Liturgical sunpillars (replacing the original rainbow) */
    --sp-1: hsl(45, 80%, 60%);    /* gold */
    --sp-2: hsl(35, 70%, 55%);    /* amber */
    --sp-3: hsl(140, 32%, 48%);   /* liturgical green */
    --sp-4: hsl(85, 22%, 60%);    /* sage */
    --sp-5: hsl(355, 50%, 50%);   /* burgundy */
    --sp-6: hsl(280, 32%, 55%);   /* royal purple */

    position: relative;
    display: block;
    aspect-ratio: 5 / 7;
    border-radius: var(--card-radius);
    text-decoration: none;
    color: inherit;
    perspective: 600px;
    transform: translate3d(0, 0, 0.1px);
    touch-action: pan-y;
}

.apostolate-3d-card:hover,
.apostolate-3d-card:focus-visible {
    --card-opacity: 1;
}

/* Behind-glow follows pointer */
.a3d-glow {
    position: absolute;
    inset: -8px;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(
        circle at var(--pointer-x) var(--pointer-y),
        rgba(201, 162, 39, 0.55) 0%,
        transparent 55%
    );
    filter: blur(36px) saturate(1.1);
    opacity: calc(0.85 * var(--card-opacity));
    transition: opacity 220ms ease;
    border-radius: var(--card-radius);
}

/* Shell — the tilting layer */
.a3d-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border-radius: var(--card-radius);
    background: var(--green-dark, #1B3D26);
    overflow: hidden;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(201, 162, 39, 0.18);
    transform: translateZ(0) rotateX(0deg) rotateY(0deg);
    transition: transform 1s ease, box-shadow .35s ease;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.a3d-shell.active {
    transition: none;
    transform: translateZ(0) rotateX(var(--rotate-y)) rotateY(var(--rotate-x));
    box-shadow:
        0 18px 48px rgba(0, 0, 0, 0.32),
        0 0 0 1px rgba(201, 162, 39, 0.45);
}
.a3d-shell.entering {
    transition: transform 180ms ease-out;
}

/* All inner layers stacked at full size */
.a3d-shell > *:not(.a3d-content) {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

/* Photo background — default sepia, returns to colour on hover/spotlight */
.a3d-photo {
    background-size: cover;
    background-position: center;
    transform: scale(1.04) translateZ(0);
    transition: transform 0.8s ease, filter 0.6s ease;
    filter: sepia(0.85) saturate(0.6) contrast(1.05) brightness(0.9);
}
.apostolate-3d-card:hover .a3d-photo,
.apostolate-3d-card.a3d-spotlight .a3d-photo,
.a3d-shell.active .a3d-photo {
    filter: saturate(0.95) contrast(1.04);
}
.a3d-shell.active .a3d-photo {
    transform: scale(1.08) translateZ(0);
    filter: saturate(1.05) contrast(1.08);
}

/* Dark gradient (so the gold text reads on any photo) — visible on hover/spotlight */
.a3d-overlay {
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 25%,
        rgba(15, 35, 22, 0.45) 55%,
        rgba(10, 25, 16, 0.92) 100%
    );
    z-index: 2;
}
/* Cream caption strip — visible by default, fades on hover/spotlight so the
   dark green gradient shows through and the gold/cream text reads. */
.a3d-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 35%,
        rgba(245, 232, 208, 0.78) 65%,
        rgba(245, 232, 208, 0.96) 100%
    );
    opacity: 1;
    transition: opacity 0.6s ease;
    pointer-events: none;
}
.apostolate-3d-card:hover .a3d-overlay::before,
.apostolate-3d-card.a3d-spotlight .a3d-overlay::before {
    opacity: 0;
}

/* Holographic shine — six liturgical colours plus a metallic crossfade.
 * Idle: slow 18s rotation. On hover: paused, brightened, tracks pointer. */
.a3d-shine {
    z-index: 3;
    background-image:
        repeating-linear-gradient(
            0deg,
            var(--sp-1) calc(5% * 1),
            var(--sp-2) calc(5% * 2),
            var(--sp-3) calc(5% * 3),
            var(--sp-4) calc(5% * 4),
            var(--sp-5) calc(5% * 5),
            var(--sp-6) calc(5% * 6),
            var(--sp-1) calc(5% * 7)
        ),
        repeating-linear-gradient(
            -45deg,
            #1a1410 0%,
            hsl(45, 28%, 55%) 4%,
            hsl(45, 50%, 62%) 4.5%,
            hsl(45, 28%, 55%) 5%,
            #1a1410 10%,
            #1a1410 12%
        );
    background-position: 0 var(--background-y), var(--background-x) var(--background-y);
    background-size: 400% 400%, 200% 200%;
    background-blend-mode: color, hard-light;
    mix-blend-mode: color-dodge;
    filter: brightness(0.5) contrast(1.1) saturate(0.3) opacity(0.16);
    animation: a3d-holo 22s linear infinite;
    transition: filter 0.6s ease;
}
.a3d-shell.active .a3d-shine {
    animation-play-state: paused;
    filter: brightness(0.85) contrast(1.3) saturate(0.5) opacity(0.50);
}
@keyframes a3d-holo {
    0%   { background-position: 0   0%, 0   0%; }
    100% { background-position: 0 100%, 90% 90%; }
}

/* Pointer-tracking glare highlight (the bright spot under the cursor). */
.a3d-glare {
    z-index: 4;
    background-image: radial-gradient(
        circle at var(--pointer-x) var(--pointer-y),
        rgba(255, 247, 215, 0.50) 0%,
        rgba(255, 247, 215, 0.22) 22%,
        rgba(255, 247, 215, 0.06) 45%,
        transparent 65%
    );
    mix-blend-mode: screen;
    opacity: var(--card-opacity);
    transition: opacity 220ms ease;
}

/* Content overlay (region name, church/tagline, visit button) */
.a3d-content {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 18px 18px 16px;
    pointer-events: none;
    border-radius: inherit;
    transform: translate3d(
        calc((var(--pointer-from-left) - 0.5) * -8px),
        calc((var(--pointer-from-top)  - 0.5) * -6px),
        0.1px
    );
}

.a3d-content h3 {
    font-family: var(--ff-heading, 'EB Garamond', serif);
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: 0.005em;
    line-height: 1.05;
    color: var(--burgundy-dark, #6b0a19);
    -webkit-text-fill-color: var(--burgundy-dark, #6b0a19);
    filter: none;
    transition: color 0.6s ease, -webkit-text-fill-color 0.6s ease, filter 0.6s ease;
}
.apostolate-3d-card:hover .a3d-content h3,
.apostolate-3d-card.a3d-spotlight .a3d-content h3 {
    background-image: linear-gradient(180deg, #fff7d4 0%, #c9a227 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

.a3d-content p {
    font-family: var(--ff-body, 'Source Sans 3', sans-serif);
    font-size: 0.85rem;
    color: var(--burgundy-dark, #6b0a19);
    margin: 0 0 14px;
    line-height: 1.4;
    text-shadow: none;
    transition: color 0.6s ease, text-shadow 0.6s ease;
}
.apostolate-3d-card:hover .a3d-content p,
.apostolate-3d-card.a3d-spotlight .a3d-content p {
    color: rgba(255, 247, 215, 0.88);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.a3d-visit {
    pointer-events: auto;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(107, 10, 25, 0.10);
    border: 1px solid rgba(107, 10, 25, 0.55);
    border-radius: 999px;
    color: var(--burgundy-dark, #6b0a19);
    font-family: var(--ff-ui, 'Source Sans 3', sans-serif);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: background 0.6s ease, border-color 0.6s ease, color 0.6s ease, transform 220ms ease;
}
.apostolate-3d-card:hover .a3d-visit,
.apostolate-3d-card:focus-visible .a3d-visit,
.apostolate-3d-card.a3d-spotlight .a3d-visit {
    background: rgba(201, 162, 39, 0.4);
    border-color: var(--gold, #c9a227);
    color: var(--cream, #fcf3e3);
    transform: translateY(-1px);
}

/* Responsive — collapse to 2 columns then 1 */
@media (max-width: 1024px) {
    .apostolate-cards-grid--3d { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .apostolate-cards-grid--3d { grid-template-columns: 1fr; }
    .apostolate-3d-card { aspect-ratio: 16 / 11; }
}


/* Honour reduced-motion preference: disable the sepia/colour transitions
   so the card simply renders in its colour state without animating. */
@media (prefers-reduced-motion: reduce) {
    .a3d-photo,
    .a3d-overlay::before,
    .a3d-content h3,
    .a3d-content p,
    .a3d-visit {
        transition: none !important;
    }
    .a3d-photo {
        filter: saturate(0.95) contrast(1.04) !important;
    }
    .a3d-overlay::before {
        opacity: 0 !important;
    }
}
