/* ==========================================================================
   Stagger Testimonials (Reviews Section)
   - Light / Dark theme aware (relies on .dark ancestor toggled by the app)
   - Fully responsive (card size driven by CSS variables, tuned by JS)
   - Progressive enhancement: usable horizontal scroll-snap fallback until the
     JS module adds `.is-ready` and switches to the 3D staggered layout.
   ========================================================================== */

.stagger {
    position: relative;
    --st-w: 320px;          /* card width  */
    --st-card-h: 360px;     /* card height (stagger mode) */
    --st-h: 460px;          /* viewport height (stagger mode) */
    --st-cut: 40px;         /* size of the cut top-right corner */
}

/* --------------------------------------------------------------------------
   Viewport
   -------------------------------------------------------------------------- */
.stagger__viewport {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0.25rem 1.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.stagger__viewport::-webkit-scrollbar {
    display: none;
}

/* Stagger (JS enhanced) mode */
.stagger.is-ready .stagger__viewport {
    display: block;
    position: relative;
    overflow: hidden;
    padding: 0;
    height: var(--st-h);
    touch-action: pan-y;
}

.stagger.is-ready .stagger__viewport.is-dragging {
    cursor: grabbing;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.stagger-card {
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: min(86vw, var(--st-w));
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    background: #ffffff;
    color: #1f2937;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.06);
    transition: border-color .3s ease, box-shadow .3s ease, transform .3s ease;
}

.dark .stagger-card {
    background: #111827;
    color: #e5e7eb;
    border-color: #374151;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

/* Stagger mode: absolute positioning + cut corner. JS sets the transform,
   opacity and z-index inline. */
.stagger.is-ready .stagger-card {
    position: absolute;
    left: 50%;
    top: 50%;
    margin: 0;
    width: var(--st-w);
    height: var(--st-card-h);
    border-radius: 0;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - var(--st-cut)) 0, 100% var(--st-cut), 100% 100%, 0 100%);
    transform: translate(-50%, -50%);
    transition: transform .6s cubic-bezier(.22, 1, .36, 1), opacity .45s ease,
        box-shadow .35s ease, background-color .35s ease, border-color .35s ease;
    will-change: transform, opacity;
}

.stagger.is-ready .stagger-card.is-center {
    cursor: default;
}

/* Highlighted / centered card uses the brand colour */
.stagger-card.is-center {
    background: #ffdd57;
    color: #1f2937;
    border-color: #f7b700;
    box-shadow: 0 12px 0 4px rgba(247, 183, 0, .35);
}

.dark .stagger-card.is-center {
    background: #ffcc00;
    color: #111827;
    border-color: #a66d00;
    box-shadow: 0 12px 0 4px rgba(0, 0, 0, .45);
}

/* --------------------------------------------------------------------------
   Cut-corner accent line (only meaningful in stagger mode)
   -------------------------------------------------------------------------- */
.stagger-card__corner {
    display: none;
}

.stagger.is-ready .stagger-card__corner {
    display: block;
    position: absolute;
    top: calc(var(--st-cut) / 2);
    right: calc(var(--st-cut) * -0.2071 + 2px);
    width: calc(var(--st-cut) * 1.4142 - 6px);
    height: 2px;
    background: #e5e7eb;
    transform: rotate(45deg);
    transform-origin: center;
    pointer-events: none;
}

.dark .stagger.is-ready .stagger-card__corner {
    background: #374151;
}

.stagger.is-ready .stagger-card.is-center .stagger-card__corner {
    background: #f7b700;
}

.dark .stagger.is-ready .stagger-card.is-center .stagger-card__corner {
    background: #a66d00;
}

/* --------------------------------------------------------------------------
   Card content
   -------------------------------------------------------------------------- */
.stagger-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}

.st-stars {
    display: inline-flex;
    gap: 2px;
    color: #f59e0b;
    font-size: .95rem;
    line-height: 1;
}

.stagger-card.is-center .st-stars {
    color: #b45309;
}

.dark .stagger-card.is-center .st-stars {
    color: #7c2d12;
}

.stagger-card__source {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    object-fit: contain;
}

.st-quote {
    flex: 1 1 auto;
    margin: 0 0 1.25rem;
    font-size: 1rem;
    line-height: 1.6;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

.stagger.is-ready .st-quote {
    -webkit-line-clamp: 6;
    line-clamp: 6;
}

.stagger-card__foot {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: auto;
}

.stagger-card__avatar {
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    object-fit: cover;
    flex: 0 0 auto;
    border: 2px solid rgba(0, 0, 0, .06);
    background: #f3f4f6;
}

.stagger-card.is-center .stagger-card__avatar {
    border-color: rgba(0, 0, 0, .12);
}

.stagger-card__meta {
    min-width: 0;
}

.st-name {
    margin: 0;
    font-weight: 600;
    font-size: .98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-role {
    margin: 2px 0 0;
    font-size: .8rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark .st-role {
    color: #9ca3af;
}

.stagger-card.is-center .st-role {
    color: rgba(31, 41, 55, .72);
}

.st-link {
    margin-left: auto;
    flex: 0 0 auto;
    display: inline-flex;
    color: #9ca3af;
    font-size: 1.05rem;
    transition: color .2s ease, transform .2s ease;
}

.st-link:hover {
    color: #2563eb;
    transform: translateY(-1px);
}

.stagger-card.is-center .st-link {
    color: rgba(31, 41, 55, .55);
}

.stagger-card.is-center .st-link:hover {
    color: #1f2937;
}

/* --------------------------------------------------------------------------
   Navigation buttons
   -------------------------------------------------------------------------- */
.stagger__nav {
    display: flex;
    justify-content: center;
    gap: .75rem;
    margin-top: 1.5rem;
}

.stagger__btn {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    border: 2px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease,
        transform .2s ease, box-shadow .2s ease;
}

.stagger__btn:hover {
    background: #ffdd57;
    border-color: #ffdd57;
    color: #1f2937;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(247, 183, 0, .35);
}

.stagger__btn:focus-visible {
    outline: 3px solid rgba(72, 149, 239, .5);
    outline-offset: 2px;
}

.dark .stagger__btn {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

.dark .stagger__btn:hover {
    background: #ffcc00;
    border-color: #ffcc00;
    color: #111827;
}

.stagger:focus-visible {
    outline: none;
}

/* --------------------------------------------------------------------------
   Responsive sizing (fallback values; JS fine-tunes on resize)
   -------------------------------------------------------------------------- */
@media (min-width: 640px) {
    .stagger {
        --st-w: 360px;
        --st-card-h: 380px;
        --st-h: 480px;
    }
}

@media (min-width: 1024px) {
    .stagger {
        --st-w: 380px;
        --st-card-h: 380px;
        --st-h: 500px;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

    .stagger.is-ready .stagger-card,
    .stagger-card,
    .stagger__btn,
    .st-link {
        transition: none !important;
    }
}
