/**
 * cube-selector.css
 * Donate-page cube selector component.
 * BEM prefix: .cube-selector / .cube-card
 * Follows the project's Bootstrap 5 + CSS custom-properties design system.
 * RTL layout is provided by the parent dir="rtl" context.
 */

/* ─── Container ──────────────────────────────────────────────── */
.cube-selector {
    width: 100%;
}

/* ─── Scrollable wrapper ─────────────────────────────────────── */
.cube-selector__scroll-wrapper {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.375rem 0.125rem 1.125rem; /* bottom for shadow clearance */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;

    /* Mobile scroll snap */
    scroll-snap-type: x mandatory;
    -webkit-scroll-snap-type: x mandatory;
}

.cube-selector__scroll-wrapper::-webkit-scrollbar {
    height: 5px;
}

.cube-selector__scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.cube-selector__scroll-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 99px;
}

/* Allow wrapping on desktop */
@media (min-width: 768px) {
    .cube-selector__scroll-wrapper {
        flex-wrap: wrap;
        overflow-x: visible;
        scroll-snap-type: none;
    }
}

/* ─── Individual cube card ───────────────────────────────────── */
.cube-card {
    /* Layout */
    flex: 0 0 145px;
    min-width: 130px;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow: hidden;

    /* Appearance */
    background: #fff;
    border: 2px solid var(--color-neutral-200, #e2e8f0);
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);

    /* Typography */
    text-align: right;
    direction: rtl;
    color: inherit;

    /* Interaction */
    cursor: pointer;
    user-select: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;

    /* Scroll snap */
    scroll-snap-align: start;
    -webkit-scroll-snap-align: start;
}

/* Hover: slight shadow increase */
.cube-card:hover {
    border-color: var(--color-primary-600, #2563eb);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.18);
    transform: translateY(-2px);
}

/* Accessibility: keyboard focus ring */
.cube-card:focus-visible {
    outline: 3px solid var(--color-primary-600, #2563eb);
    outline-offset: 3px;
    border-color: var(--color-primary-600, #2563eb);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.18);
}

/* Selected state: prominent border, scale, shadow */
.cube-card--selected {
    border-color: var(--color-primary-600, #2563eb);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.28);
    transform: scale(1.02);
    position: relative;
}

.cube-card--selected:hover {
    transform: scale(1.02) translateY(-1px);
}

/* Link variant: reset anchor default styles */
.cube-card--link {
    text-decoration: none;
    color: inherit;
}

.cube-card--link:hover,
.cube-card--link:visited {
    color: inherit;
    text-decoration: none;
}

/* Disable snap on desktop */
@media (min-width: 768px) {
    .cube-card {
        flex: 0 0 auto;
        width: calc((100% - 2.25rem) / 4); /* ~4 per row */
        min-width: 140px;
        max-width: 200px;
        scroll-snap-align: none;
    }
}

/* ─── Image area ─────────────────────────────────────────────── */
.cube-card__image-wrap {
    width: 100%;
/*    height: 110px;
*/    overflow: hidden;
    flex-shrink: 0;
    background: var(--color-neutral-50, #f8fafc);
}

.cube-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.cube-card:hover .cube-card__image {
    transform: scale(1.05);
}

/* Gradient placeholder when no image */
.cube-card__placeholder {
    width: 100%;
/*    aspect-ratio: 3 / 2;
*/    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cube-card__placeholder-icon {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.75);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* ─── Text body ──────────────────────────────────────────────── */
.cube-card__body {
    padding: 0.625rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
    flex: 1;
    text-align: right;
    direction: rtl;
}

/* Monthly amount: largest, bold, primary */
.cube-card__monthly {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--color-primary-600, #2563eb);
}

/* × N months — secondary style */
.cube-card__months {
    font-size: 0.75rem;
    color: var(--color-neutral-500, #64748b);
    font-weight: 500;
}

/* = Total — prominent */
.cube-card__total {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-neutral-900, #0f172a);
    margin-top: 0.15rem;
}

/* Title — medium weight */
.cube-card__title {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-neutral-500, #64748b);
    margin-top: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Legacy formula line (monthly × months = total inline) */
.cube-card__formula {
    font-size: 0.75rem;
    color: var(--color-neutral-500, #64748b);
    font-weight: 500;
}

/* ─── Selected checkmark ─────────────────────────────────────── */
.cube-card__checkmark {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;  /* LTR positioning; in RTL context this is visually right */
    width: 1.25rem;
    height: 1.25rem;
    background: var(--color-primary-600, #2563eb);
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

/* ─── "Other" / custom amount card ──────────────────────────── */
.cube-card--other {
    border: 2px dashed var(--color-neutral-200, #e2e8f0);
    background: var(--color-neutral-50, #f8fafc);
    color: var(--color-neutral-500, #64748b);
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.cube-card--other:hover {
    border-color: var(--color-primary-600, #2563eb);
    background: #eff6ff;
    color: var(--color-primary-600, #2563eb);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
}

.cube-card--other:focus-visible {
    border-style: dashed;
    border-color: var(--color-primary-600, #2563eb);
    background: #eff6ff;
    color: var(--color-primary-600, #2563eb);
}

/* Active "Other" state (when no cube is selected) */
.cube-card--other-active {
    border-color: var(--color-primary-600, #2563eb);
    border-style: dashed;
    background: #eff6ff;
    color: var(--color-primary-600, #2563eb);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.18);
}

.cube-card__other-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.1);
    margin-bottom: 0.4rem;
    transition: background 0.18s ease;
}

.cube-card--other:hover .cube-card__other-icon,
.cube-card--other-active .cube-card__other-icon {
    background: rgba(37, 99, 235, 0.15);
}

/* "Other" body centered */
.cube-card--other .cube-card__body {
    text-align: center;
    align-items: center;
    direction: rtl;
    padding-top: 0;
}

.cube-card--other .cube-card__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: inherit;
    white-space: normal;
}

.cube-card--other .cube-card__formula {
    font-size: 0.72rem;
    color: inherit;
    opacity: 0.8;
}

/* ─── Dark mode ──────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .cube-card {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }

    .cube-card:hover {
        border-color: #60a5fa;
        box-shadow: 0 6px 20px rgba(96, 165, 250, 0.22);
    }

    .cube-card--selected {
        border-color: #60a5fa;
        box-shadow: 0 8px 28px rgba(96, 165, 250, 0.3);
    }

    .cube-card__monthly {
        color: #60a5fa;
    }

    .cube-card__total {
        color: #f1f5f9;
    }

    .cube-card--other {
        background: #0f172a;
        border-color: #334155;
        color: #94a3b8;
    }

    .cube-card--other:hover,
    .cube-card--other-active {
        border-color: #60a5fa;
        background: #1e3a5f;
        color: #93c5fd;
    }
}

[data-bs-theme="dark"] .cube-card {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .cube-card:hover {
    border-color: #60a5fa;
    box-shadow: 0 6px 20px rgba(96, 165, 250, 0.22);
}

[data-bs-theme="dark"] .cube-card--selected {
    border-color: #60a5fa;
    box-shadow: 0 8px 28px rgba(96, 165, 250, 0.3);
}

[data-bs-theme="dark"] .cube-card__monthly {
    color: #60a5fa;
}

[data-bs-theme="dark"] .cube-card__total {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .cube-card--other {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

[data-bs-theme="dark"] .cube-card--other:hover,
[data-bs-theme="dark"] .cube-card--other-active {
    border-color: #60a5fa;
    background: #1e3a5f;
    color: #93c5fd;
}

/* ─── Mobile refinements ─────────────────────────────────────── */
@media (max-width: 479.98px) {
    .cube-card {
        flex: 0 0 130px;
        min-width: 115px;
    }

    .cube-card__body {
        padding: 0.5rem 0.6rem 0.6rem;
    }

    .cube-card__monthly {
        font-size: 1.25rem;
    }

    .cube-card__total {
        font-size: 0.8rem;
    }

    .cube-card--other {
        min-height: 100px;
    }
}

/* ─── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cube-card,
    .cube-card__image {
        transition: none;
        transform: none !important;
    }

    .cube-card--selected {
        transform: none !important;
    }
}
