/* =========================================================
   RotoEdge — homepage "Our Work" showcase
   Plate → final frame "scan" reveal (no scroll-jacking)
   Desktop ≥1025px · Tablet 768–1024px · Mobile ≤767px
========================================================= */

.re-work {
    --work-red: #ff1f1f;
    --work-line: rgba(255, 255, 255, .12);
    --work-muted: rgba(255, 255, 255, .62);
    padding: clamp(32px, 3.5vw, 56px) 0;
    background: var(--e-global-color-primary, #121212);
    color: #fff;
}

.re-work__inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- header ---------- */

.re-work__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px 48px;
    margin-bottom: clamp(24px, 2.6vw, 40px);
}

.re-work__head > div:first-child {
    flex: 1 1 520px;
    min-width: 0;
}

.re-work .tp-subtitle-text { color: #fff; }

.re-work__title {
    margin: 18px 0 0;
    font-family: "Marcellus", serif;
    font-weight: 400;
    font-size: clamp(34px, 4.1vw, 64px);
    line-height: 1.05;
    color: var(--work-red);
    text-wrap: balance;
}

.re-work__aside {
    flex: 0 1 440px;
}

.re-work__aside p {
    margin: 0 0 18px;
    font-size: clamp(15px, 1.1vw, 17px);
    line-height: 1.6;
    color: var(--work-muted);
    text-wrap: pretty;
}

.re-work__all {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border-radius: 40px;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: #111;
    text-decoration: none;
    transition: background .3s ease, color .3s ease;
}

.re-work__all:hover,
.re-work__all:focus-visible {
    background: var(--work-red);
    color: #fff;
}

.re-work__all svg { width: 12px; height: 12px; }

/* ---------- cards ---------- */

.re-work__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(16px, 1.8vw, 26px);
    margin: 0;
    padding: 0;
    list-style: none;
}

.re-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--work-line);
    border-radius: 20px;
    background: #171717;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
    transition: transform .4s cubic-bezier(.2, .8, .2, 1), border-color .4s ease, box-shadow .4s ease;
}

.re-card:hover,
.re-card:focus-visible {
    color: #fff;
    transform: translateY(-6px);
    border-color: rgba(255, 31, 31, .55);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 31, 31, .25);
}

.re-card:focus-visible { outline: 2px solid var(--work-red); outline-offset: 4px; }

.re-card__media {
    --d: 0s;
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: #0d0d0d;
}

.re-card__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* the final frame is revealed left → right by the scan */
.re-card__after {
    clip-path: inset(0 100% 0 0);
    animation: re-scan-reveal 8s cubic-bezier(.65, 0, .35, 1) infinite;
    animation-delay: var(--d);
}

.re-card__scan {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background: var(--work-red);
    box-shadow: 0 0 16px 3px rgba(255, 31, 31, .8), 0 0 42px 10px rgba(255, 31, 31, .25);
    animation: re-scan-line 8s cubic-bezier(.65, 0, .35, 1) infinite;
    animation-delay: var(--d);
    pointer-events: none;
}

.re-card:hover .re-card__after,
.re-card:hover .re-card__scan,
.re-card:hover .re-card__label span,
.re-card:focus-visible .re-card__after,
.re-card:focus-visible .re-card__scan,
.re-card:focus-visible .re-card__label span {
    animation-play-state: paused;
}

@keyframes re-scan-reveal {
    0%, 12%   { clip-path: inset(0 100% 0 0); }
    38%, 62%  { clip-path: inset(0 0 0 0); }
    88%, 100% { clip-path: inset(0 100% 0 0); }
}

@keyframes re-scan-line {
    0%, 12%   { left: 0;    opacity: 0; }
    14%       { opacity: 1; }
    38%       { left: 100%; opacity: 1; }
    40%, 60%  { left: 100%; opacity: 0; }
    62%       { left: 100%; opacity: 1; }
    88%       { left: 0;    opacity: 1; }
    90%, 100% { left: 0;    opacity: 0; }
}

/* before / after label that swaps with the scan */
.re-card__label {
    position: absolute;
    top: 14px;
    left: 14px;
    display: grid;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 30px;
    background: rgba(10, 10, 10, .6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.re-card__label span {
    grid-area: 1 / 1;
    animation: re-label-before 8s linear infinite;
    animation-delay: var(--d);
}

.re-card__label span + span {
    color: #ff6b6b;
    animation-name: re-label-after;
}

@keyframes re-label-before {
    0%, 30%   { opacity: 1; }
    34%, 80%  { opacity: 0; }
    84%, 100% { opacity: 1; }
}

@keyframes re-label-after {
    0%, 30%   { opacity: 0; }
    34%, 80%  { opacity: 1; }
    84%, 100% { opacity: 0; }
}

.re-card__num {
    position: absolute;
    right: 14px;
    bottom: 14px;
    font-family: "Marcellus", serif;
    font-size: 54px;
    line-height: 1;
    color: rgba(255, 255, 255, .9);
    text-shadow: 0 4px 24px rgba(0, 0, 0, .6);
}

.re-card__body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px 20px;
}

.re-card__title {
    margin: 0 0 4px;
    font-family: "Marcellus", serif;
    font-weight: 400;
    font-size: clamp(20px, 1.6vw, 26px);
    line-height: 1.2;
    color: #fff;
}

.re-card__tags {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--work-muted);
}

.re-card__go {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 50%;
    transition: background .3s ease, border-color .3s ease, transform .3s ease;
}

.re-card__go svg { width: 14px; height: 14px; }

.re-card:hover .re-card__go,
.re-card:focus-visible .re-card__go {
    background: var(--work-red);
    border-color: var(--work-red);
    transform: rotate(-45deg);
}

.re-card:hover .re-card__title { color: #fff; }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
    .re-work__grid { gap: 14px; }
    .re-card__media { aspect-ratio: 3 / 4; }
    .re-card__num { font-size: 40px; }
    .re-card__body { padding: 14px 16px 16px; }
    .re-card__go { width: 36px; height: 36px; }
}

/* ---------- Mobile: swipeable row ---------- */
@media (max-width: 767px) {
    .re-work__inner { padding: 0 18px; }

    .re-work__grid {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 80%;
        gap: 14px;
        margin: 0 -18px;
        padding: 0 18px 6px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 18px;
        scrollbar-width: none;
    }

    .re-work__grid::-webkit-scrollbar { display: none; }

    .re-work__grid > li { scroll-snap-align: start; }

    .re-card:hover,
    .re-card:focus-visible { transform: none; }
}

/* Reduced motion: no scanning — show the final frame with the plate as an inset */
@media (prefers-reduced-motion: reduce) {
    .re-card__after { animation: none; clip-path: none; }
    .re-card__scan { display: none; }
    .re-card__label span { animation: none; }
    .re-card__label span:first-child { opacity: 0; }
    .re-card__label span + span { opacity: 1; }
    .re-card, .re-card__go { transition: none; }
}
