/* ==========================================================
   TASSEL Animated Grid  v1.2
   Flex rows, asymmetric proportions, hover description
   ========================================================== */

/* ---- Container ---- */
.td-anim-grid {
    display: flex;
    flex-direction: column;
    gap: var(--td-g-gap, 16px);
    width: 100%;
}

/* ---- Row ---- */
.td-anim-grid__row {
    display: flex;
    gap: var(--td-g-gap, 16px);
    height: var(--td-g-h, 200px);
}

/* ---- Individual tile ---- */
.td-anim-grid__tile {
    position: relative;
    overflow: hidden;
    border-radius: var(--td-g-r, 0px);
    display: block;
    text-decoration: none !important;
    cursor: pointer;
    flex: var(--td-flex, 1);
    min-width: 0;

    /* Initial state: small + hidden */
    opacity: 0;
    transform: scale(0.55);
    transition:
        opacity var(--td-g-dur, 600ms) cubic-bezier(0.4, 0, 0.2, 1),
        transform var(--td-g-dur, 600ms) cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: calc(var(--ti, 0) * 150ms);
}

/* Phase 1: tiles grow in */
.td-anim-grid.is-animating .td-anim-grid__tile {
    opacity: 1;
    transform: scale(1);
}

/* ---- Image layer ---- */
.td-anim-grid__img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
    transition: transform 0.5s ease;
}

/* Hover zoom */
.td-anim-grid.is-revealed .td-anim-grid__tile:hover .td-anim-grid__img,
.td-anim-grid.is-revealed .td-anim-grid__tile:focus-visible .td-anim-grid__img {
    transform: scale(1.06);
}

/* ---- Color overlay ---- */
.td-anim-grid__overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.6s ease;
}

/* Phase 2: overlay fades, image appears */
.td-anim-grid.is-revealed .td-anim-grid__overlay {
    opacity: 0;
}

/* Hover: bring overlay back semi-transparent for text readability */
.td-anim-grid.is-revealed .td-anim-grid__tile:hover .td-anim-grid__overlay {
    opacity: 0.55;
}

/* ---- Title + description content ---- */
.td-anim-grid__content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Gradient scrim for text readability */
.td-anim-grid__content::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.55) 0%,
        rgba(0, 0, 0, 0.15) 40%,
        transparent 65%
    );
    z-index: -1;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* Stronger scrim on hover for description readability */
.td-anim-grid__tile:hover .td-anim-grid__content::before {
    opacity: 1;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.35) 60%,
        rgba(0, 0, 0, 0.15) 100%
    );
}

.td-anim-grid.is-revealed .td-anim-grid__content {
    opacity: 1;
}

.td-anim-grid__title {
    font-size: var(--td-g-fs, 28px);
    font-weight: 700;
    color: var(--td-g-tc, #fff);
    font-family: inherit;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    line-height: 1.2;
    margin: 0;
}

/* ---- Description (visible on hover) ---- */
.td-anim-grid__desc {
    font-size: calc(var(--td-g-fs, 28px) * 0.5);
    font-weight: 400;
    color: var(--td-g-tc, #fff);
    font-family: inherit;
    line-height: 1.45;
    margin-top: 8px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition:
        opacity 0.35s ease,
        max-height 0.4s ease;
}

.td-anim-grid.is-revealed .td-anim-grid__tile:hover .td-anim-grid__desc,
.td-anim-grid.is-revealed .td-anim-grid__tile:focus-visible .td-anim-grid__desc {
    opacity: 1;
    max-height: 200px;
}

/* ---- no-JS / reduced-motion fallback ---- */
.no-js .td-anim-grid__tile,
.td-anim-grid.td-no-anim .td-anim-grid__tile {
    opacity: 1;
    transform: none;
}
.no-js .td-anim-grid__overlay,
.td-anim-grid.td-no-anim .td-anim-grid__overlay {
    opacity: 0;
}
.no-js .td-anim-grid__content,
.td-anim-grid.td-no-anim .td-anim-grid__content {
    opacity: 1;
}

/* ---- Kadence overrides ---- */
.entry-content .td-anim-grid__tile,
.kb-row-layout-wrap .td-anim-grid__tile,
.kadence-column .td-anim-grid__tile {
    text-decoration: none !important;
    box-shadow: none !important;
    color: inherit !important;
}

/* ---- Responsive: stack on mobile ---- */
@media (max-width: 768px) {
    .td-anim-grid__row {
        flex-direction: column;
        height: auto;
    }
    .td-anim-grid__tile {
        flex: none !important;
        height: var(--td-g-h, 180px);
    }
    /* Always show description on mobile (no hover) */
    .td-anim-grid.is-revealed .td-anim-grid__desc {
        opacity: 1;
        max-height: 200px;
    }
}

/* ---- Editor preview ---- */
.td-anim-grid-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.td-anim-grid-preview__row {
    display: flex;
    gap: 8px;
    height: 120px;
}
.td-anim-grid-preview__tile {
    position: relative;
    overflow: hidden;
    min-width: 0;
}
.td-anim-grid-preview__tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.65;
}
.td-anim-grid-preview__label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    z-index: 2;
}
.td-anim-grid-preview__desctext {
    font-weight: 400;
    font-size: 11px;
    display: block;
    margin-top: 2px;
    opacity: 0.8;
}
