@import url('variables.css');

.card-grid {
    display: grid;
    gap: 0.5em;
    padding: 0;
    width: 100%;
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.5rem);
}

.magic-bento-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    aspect-ratio: 4/3;
    min-height: 200px;
    width: 100%;
    max-width: 100%;
    padding: 1.25em;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Lighter border for white bg */
    background: var(--background-dark);
    font-weight: 300;
    overflow: hidden;
    transition: all 0.3s ease;

    --glow-x: 50%;
    --glow-y: 50%;
    --glow-intensity: 0;
    --glow-radius: 200px;
}

.magic-bento-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
    /* Softer shadow */
}

.magic-bento-card__header,
.magic-bento-card__content {
    display: flex;
    position: relative;
    color: inherit;
    /* Inherit form inline style */
}

.magic-bento-card__header {
    gap: 0.75em;
    justify-content: space-between;
}

.magic-bento-card__content {
    flex-direction: column;
}

.magic-bento-card__label {
    font-size: 16px;
}

.magic-bento-card__title,
.magic-bento-card__description {
    --clamp-title: 1;
    --clamp-desc: 2;
}

.magic-bento-card__title {
    font-weight: 400;
    font-size: 16px;
    margin: 0 0 0.25em;
}

.magic-bento-card__description {
    font-size: 12px;
    line-height: 1.2;
    opacity: 0.9;
}

.magic-bento-card--text-autohide .magic-bento-card__title,
.magic-bento-card--text-autohide .magic-bento-card__description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.magic-bento-card--text-autohide .magic-bento-card__title {
    -webkit-line-clamp: var(--clamp-title);
    line-clamp: var(--clamp-title);
}

.magic-bento-card--text-autohide .magic-bento-card__description {
    -webkit-line-clamp: var(--clamp-desc);
    line-clamp: var(--clamp-desc);
}

@media (max-width: 599px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        /* Slightly wider for 2 cols */
        margin: 0 auto;
        padding: 0;
        gap: 0.5em;
    }

    .magic-bento-card {
        width: 100%;
        min-height: 160px;
        /* Reduced slightly */

        /* Always on glow for mobile */
        --glow-intensity: 1 !important;
        --glow-x: 50%;
        --glow-y: 50%;
        --glow-radius: 500px !important;
    }

    /* Make large blocks span full width */
    .magic-bento-card:nth-child(3),
    .magic-bento-card:nth-child(4) {
        grid-column: span 2;
    }

    .magic-bento-card__title {
        font-size: 18px;
        /* Slightly smaller title for 2-col */
    }

    .magic-bento-card__description {
        font-size: 13px;
        line-height: 1.3;
    }

    .magic-bento-card--border-glow::after {
        opacity: 1 !important;
    }

    /* Subtler glow for FAQs on mobile */
    #faq-list-root .magic-bento-card--border-glow::after {
        opacity: 0.5 !important;
    }
}

@media (min-width: 600px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Stack large cards on tablet ONLY on Mi Espacio page */
    .mi-espacio-page .magic-bento-card:nth-child(3),
    .mi-espacio-page .magic-bento-card:nth-child(4) {
        grid-column: span 2;
        aspect-ratio: auto;
        min-height: 350px;
    }
}

@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .magic-bento-card:nth-child(3) {
        grid-column: span 2;
        grid-row: span 2;
    }

    .magic-bento-card:nth-child(4) {
        grid-column: 1 / span 2;
        grid-row: 2 / span 2;
    }

    .magic-bento-card:nth-child(6) {
        grid-column: 4;
        grid-row: 3;
    }

    /* Increase font size for larger blocks */
    .magic-bento-card:nth-child(3) .magic-bento-card__title,
    .magic-bento-card:nth-child(4) .magic-bento-card__title {
        font-size: 28px;
        margin-bottom: 0.2em;
    }

    .magic-bento-card:nth-child(3) .magic-bento-card__description,
    .magic-bento-card:nth-child(4) .magic-bento-card__description {
        font-size: 16px;
        line-height: 1.4;
    }
}

/* Border glow effect with footer gradient colors */
.magic-bento-card--border-glow::after {
    content: '';
    position: absolute;
    inset: 0;
    padding: 6px;
    background: radial-gradient(var(--glow-radius) circle at var(--glow-x) var(--glow-y),
            rgba(225, 148, 127, calc(var(--glow-intensity) * 0.4)) 0%,
            /* Soft Orange */
            rgba(157, 96, 207, calc(var(--glow-intensity) * 0.3)) 25%,
            /* Purple */
            rgba(128, 202, 205, calc(var(--glow-intensity) * 0.2)) 50%,
            /* Cyan */
            transparent 80%);
    border-radius: inherit;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.magic-bento-card--border-glow:hover::after {
    opacity: 1;
}

.particle-container {
    position: relative;
    overflow: hidden;
}

.particle::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: rgba(132, 0, 255, 0.2);
    border-radius: 50%;
    z-index: -1;
}

/* Global spotlight styles */
.global-spotlight {
    mix-blend-mode: screen;
    will-change: transform, opacity;
    z-index: 200 !important;
    pointer-events: none;
}

.bento-section {
    position: relative;
    /* user-select: none; ALLOW TEXT SELECTION */
}

/* =========================================
   RESPONSIVE TEXT UTILITIES (Refactored)
   ========================================= */

.bento-reflection-text {
    font-size: 21px;
    font-weight: 400;
    color: #333;
    margin: 0 0 0.25em;
    line-height: 1.3;
    overflow: visible;
    display: block;
}

.bento-card-title {
    font-weight: 600;
    margin: 0;
    color: #333;
    font-size: 1.1rem;
    line-height: 1.2;
}

.bento-card-subtitle {
    font-weight: 500;
    color: #777;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
}

.bento-big-title {
    font-weight: 700;
    font-size: 1.6rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.bento-text-muted {
    color: #666;
    margin: 0;
    font-size: 0.9rem;
}

.bento-badge {
    font-size: 0.8rem;
    padding: 0.5em 0.8em;
    border-radius: 50px;
    font-weight: 500;
    margin-top: 0.5rem;
    display: inline-block;
}

.bento-heading {
    font-weight: 700;
    margin: 0;
    color: #333;
    font-size: 1.4rem;
    line-height: 1.2;
}

/* Mobile Adjustments */
@media (max-width: 599px) {
    .card-grid {
        grid-template-columns: 1fr;
        /* Stack cards vertically */
        width: 100%;
        margin: 0 auto;
        padding: 0;
        gap: 1rem;
        /* More gap for vertical stack */
    }

    .magic-bento-card {
        width: 100%;
        min-height: auto;
        /* Let content define height */
        aspect-ratio: auto;
        /* Disable fixed aspect ratio */
        padding: 1.25rem;
        /* Always on glow for mobile */
        --glow-intensity: 1 !important;
        --glow-x: 50%;
        --glow-y: 50%;
        --glow-radius: 500px !important;
    }

    /* Reset Spans for mobile stack */
    .magic-bento-card:nth-child(3),
    .magic-bento-card:nth-child(4) {
        grid-column: auto;
    }

    .bento-reflection-text {
        font-size: 18px;
        /* Can be slightly larger now that we have full width */
        line-height: 1.4;
    }

    .bento-card-title {
        font-size: 1.1rem;
    }

    .bento-heading {
        font-size: 1.3rem;
    }

    .bento-big-title {
        font-size: 1.5rem;
    }

    .bento-text-muted {
        font-size: 0.9rem;
    }
}