/* Case Studies Grid Layout */

.sm-case-studies-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 60px;
    width: 100%;
    align-items: start; /* Prevents stretching to match tallest item */
}

/* Stagger even items so they are not perfectly horizontal */
.sm-case-study-card:nth-child(even) {
    margin-top: 120px;
}

.sm-case-study-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    transition: none;
    color: var(--e-global-color-uicore_headline);
    position: relative;
    cursor: pointer;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

[data-theme="dark"] .sm-case-study-card {
    color: var(--e-global-color-uicore_white);
}

.sm-case-study-card:hover {
    color: var(--e-global-color-uicore_headline) !important; /* Force text color to stay */
}

[data-theme="dark"] .sm-case-study-card {
    color: var(--e-global-color-uicore_white);
}

[data-theme="dark"] .sm-case-study-card:hover {
    color: var(--e-global-color-uicore_white) !important;
}

.sm-case-study-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    margin-bottom: 24px;
    background-color: transparent; /* Outside the mask should stay transparent */
    border-radius: 15px;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
    isolation: isolate; /* helps prevent flicker when masking */
}

/* Base image (normal rectangle) */
.sm-case-study-image-base {
    display: none;
}

/* Masked image overlay */
.sm-case-study-image-masked {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    display: block;
    pointer-events: none;

    opacity: 1;
    transform: translateZ(0) scale(1);
    will-change: mask-size, -webkit-mask-size, transform;
    transition: -webkit-mask-size 0.75s cubic-bezier(0.16, 1, 0.3, 1), mask-size 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);

    border-radius: inherit;
    -webkit-backface-visibility: hidden;

    -webkit-mask-image: var(--sm-case-study-mask, none);
    mask-image: var(--sm-case-study-mask, none);
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
    -webkit-mask-size: 400% 400%;
    mask-size: 400% 400%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center center;
    mask-position: center center;
}

/* Hover: Scale down mask to reveal the shape */
.sm-case-study-card:hover .sm-case-study-image-masked {
    -webkit-mask-size: 98% 98%;
    mask-size: 98% 98%;
    transform: translateZ(0) scale(0.98); /* slight scale down for the whole image */
}

@media (prefers-reduced-motion: reduce) {
    .sm-case-study-card,
    .sm-case-study-image-base,
    .sm-case-study-image-masked,
    .sm-case-link-arrow {
        transition: none !important;
    }
}

.sm-case-study-image-placeholder {
    width: 100%;
    height: 100%;
    background-color: #2a2a2a;
}

/* Rounded Categories inside the image */
.sm-case-badges {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 12px;
    z-index: 5;
    pointer-events: none;
}

.sm-case-badge {
    background: #f4f4f5; /* Light soft gray */
    color: #111;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 50px;
    letter-spacing: 0;
    pointer-events: none;
}

[data-theme="dark"] .sm-case-badge {
    background: rgba(0, 0, 0, 0.6);
    color: var(--e-global-color-uicore_white);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Bottom Right Action Arrow - Re-purposed for Custom Mouse Follower */
.sm-case-link-arrow {
    position: absolute;
    width: 60px;
    height: 60px;
    background: #161616; /* Brand Grey */
    color: #E4E4E3;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.5);
    transition: opacity 0.3s ease, transform 0.3s ease, width 0.3s ease, height 0.3s ease;
    will-change: transform, opacity, left, top;
    -webkit-backface-visibility: hidden;
    left: 50%;
    top: 50%;
}

[data-theme="dark"] .sm-case-link-arrow {
    background: #E4E4E3;
    color: #161616;
}

.sm-case-link-arrow svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
}

/* Reveal Arrow natively inside image */
.sm-case-study-card:hover .sm-case-link-arrow {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Card Text Meta Content */
.sm-case-study-content {
    display: flex;
    flex-direction: column;
}

.sm-case-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 8px;
    color: #111 !important; /* Keep solid back text */
}

.sm-case-date {
    color: #111;
}

.sm-case-client {
    color: #111;
}

[data-theme="dark"] .sm-case-meta {
    color: #fff !important;
}

.sm-case-study-title {
    font-size: 2.4rem;
    font-weight: 500;
    line-height: 1.1;
    margin: 0;
    letter-spacing: -0.03em;
}

.sm-case-study-title {
    font-size: 1.8rem;
    line-height: 1.3;
    font-weight: 500;
    margin: 0;
    letter-spacing: -0.01em;
    color: inherit;
}

/* Pagination for Full Archive Pages */
.sm-case-studies-pagination {
    margin-top: 60px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.sm-case-studies-pagination a,
.sm-case-studies-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--e-global-color-uicore_light);
    color: var(--e-global-color-uicore_headline);
    text-decoration: none;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.sm-case-studies-pagination .page-numbers:not(.prev):not(.next):not(.dots),
.sm-case-studies-pagination span.current {
    width: 44px;
    padding: 0;
    border-radius: 50%;
}

[data-theme="dark"] .sm-case-studies-pagination a,
[data-theme="dark"] .sm-case-studies-pagination span {
    border-color: rgba(255,255,255,0.2);
    color: var(--e-global-color-uicore_white);
}

.sm-case-studies-pagination span.current {
    background-color: var(--e-global-color-uicore_headline);
    color: var(--e-global-color-uicore_white);
    border-color: var(--e-global-color-uicore_headline);
}

[data-theme="dark"] .sm-case-studies-pagination span.current {
    background-color: var(--e-global-color-uicore_white);
    color: var(--e-global-color-uicore_headline);
    border-color: var(--e-global-color-uicore_white);
}

.sm-case-studies-pagination a:hover {
    background-color: var(--e-global-color-uicore_headline);
    color: var(--e-global-color-uicore_white);
    border-color: var(--e-global-color-uicore_headline);
}

[data-theme="dark"] .sm-case-studies-pagination a:hover {
    background-color: var(--e-global-color-uicore_white);
    color: var(--e-global-color-uicore_headline);
    border-color: var(--e-global-color-uicore_white);
}


/* Responsive Layout */
@media (max-width: 768px) {
    .sm-case-studies-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    .sm-case-study-card:nth-child(even) {
        margin-top: 0;
    }
}
