/*
 * TASSEL Section Tiles - frontend styles
 * v1.0.0
 *
 * Uses --tst-color (CSS variable) set inline per section via the shortcode.
 * Layout: large = vertical (icon top, label below), small = horizontal (icon left, label right).
 */

.tst-grid {
    display: grid;
    gap: 18px;
    list-style: none;
    margin: 0 0 1.5em 0;
    padding: 0;
}

.tst-grid li,
.tst-tile {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ---------- Adaptive grid sizing ---------- */

.tst-size-large {
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 20px;
}

.tst-size-small {
    grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
    gap: 12px;
}

/* Explicit column count overrides */
.tst-grid.tst-cols-1 { grid-template-columns: 1fr; }
.tst-grid.tst-cols-2 { grid-template-columns: repeat(2, 1fr); }
.tst-grid.tst-cols-3 { grid-template-columns: repeat(3, 1fr); }
.tst-grid.tst-cols-4 { grid-template-columns: repeat(4, 1fr); }
.tst-grid.tst-cols-5 { grid-template-columns: repeat(5, 1fr); }
.tst-grid.tst-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Force-columns collapse on small screens for readability */
@media (max-width: 880px) {
    .tst-grid.tst-cols-5,
    .tst-grid.tst-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .tst-grid.tst-cols-3,
    .tst-grid.tst-cols-4,
    .tst-grid.tst-cols-5,
    .tst-grid.tst-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    .tst-size-large {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .tst-grid.tst-cols-3,
    .tst-grid.tst-cols-4,
    .tst-grid.tst-cols-5,
    .tst-grid.tst-cols-6,
    .tst-size-small {
        grid-template-columns: 1fr;
    }
}

/* ---------- Tile base (large is the default) ---------- */

.tst-tile-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 14px;

    height: 100%;
    min-height: 150px;
    padding: 28px 22px;

    border-radius: 14px;
    background-color: var(--tst-color, #2a9d8f);
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(0, 0, 0, 0.18) 100%);
    color: #fff;

    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;

    -webkit-tap-highlight-color: transparent;
}

.tst-tile-link:hover,
.tst-tile-link:focus,
.tst-tile-link:focus-visible {
    color: #fff;
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
    filter: brightness(1.06);
}

.tst-tile-link:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.85);
    outline-offset: 2px;
}

.tst-tile-link:active {
    transform: translateY(-1px);
}

.tst-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    opacity: 0.95;
}

.tst-tile-icon svg {
    display: block;
    width: 44px;
    height: 44px;
}

.tst-tile-label {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.005em;
    color: #fff;

    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    hyphens: auto;
}

/* ---------- Small (horizontal) variant ---------- */

.tst-size-small .tst-tile-link {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 12px;
    padding: 14px 16px;
    min-height: 64px;
    border-radius: 10px;
}

.tst-size-small .tst-tile-icon svg {
    width: 26px;
    height: 26px;
}

.tst-size-small .tst-tile-label {
    font-size: 14.5px;
    font-weight: 600;
    -webkit-line-clamp: 2;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .tst-tile-link {
        transition: none;
    }
    .tst-tile-link:hover,
    .tst-tile-link:focus-visible {
        transform: none;
    }
}
