/**
 * WeTown shortcode styles for [wetown_images] and [wetown_files].
 */

.wetown-image-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 15px;
}

.wetown-image-item {
    width: 100%;
    padding-top: 66.66%;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.wetown-image-item img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: translate(-50%, -50%);
}

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

@media (min-width: 900px) {
    .wetown-image-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Adjunts en targetes a l'estil de Material Design (Gmail), amb el llenguatge
   de les targetes del web: vora de 2px, radi de 12px i hover amb elevació. */
.wetown-attachments__grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    list-style: none;
    margin: 0;
    padding: 0;
}

.wetown-attachments__item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    min-width: 0;
    padding: 0;
}

.wetown-attachments__card {
    --wetown-attachments-color: #5f6368;
    --wetown-attachments-fold: 1.35rem;
    --wetown-attachments-fold-open: 1.85rem;
    --wetown-attachments-radius: 12px;
    --wetown-attachments-line: var(--wp--preset--color--contrast-3, #eee);
    --wetown-attachments-accent: var(--wp--preset--color--accent, #1a73e8);
    border-radius: var(--wetown-attachments-radius);
    color: var(--wp--preset--color--contrast, #111);
    display: flex;
    flex: 1 1 auto;
    filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
    position: relative;
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), filter 0.3s ease;
}

/* La superfície es retalla en diagonal al cantó de baix a la dreta i el
   plec (::after) omple la meitat superior d'aquest retall, com a Gmail. */
.wetown-attachments__surface {
    background: #fff;
    border: 2px solid var(--wetown-attachments-line);
    border-radius: var(--wetown-attachments-radius);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--wetown-attachments-fold)), calc(100% - var(--wetown-attachments-fold)) 100%, 0 100%);
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    transition: border-color 0.2s ease, clip-path 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.wetown-attachments__card::after {
    background: linear-gradient(to top left, transparent 50%, color-mix(in srgb, var(--wetown-attachments-color), #000 22%) 50%, var(--wetown-attachments-color) 100%);
    border-top-left-radius: 3px;
    bottom: 0;
    content: "";
    filter: drop-shadow(-1px -1px 1px rgba(0, 0, 0, 0.18));
    height: var(--wetown-attachments-fold);
    pointer-events: none;
    position: absolute;
    right: 0;
    transition: width 0.3s cubic-bezier(0.2, 0, 0, 1), height 0.3s cubic-bezier(0.2, 0, 0, 1);
    width: var(--wetown-attachments-fold);
}

.wetown-attachments__card:hover,
.wetown-attachments__card:focus-visible {
    --wetown-attachments-fold: var(--wetown-attachments-fold-open);
    color: var(--wp--preset--color--contrast, #111);
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.12));
    text-decoration: none;
    transform: translateY(-3px);
}

.wetown-attachments__card:hover .wetown-attachments__surface,
.wetown-attachments__card:focus-visible .wetown-attachments__surface {
    border-color: var(--wetown-attachments-accent);
}

.wetown-attachments__card:focus-visible {
    outline: 2px solid var(--wetown-attachments-accent);
    outline-offset: 3px;
}

.wetown-attachments__card:active {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.12));
    transform: translateY(-1px);
}

.wetown-attachments__card--pdf,
.wetown-attachments__card--image { --wetown-attachments-color: #ea4335; }
.wetown-attachments__card--doc { --wetown-attachments-color: #4285f4; }
.wetown-attachments__card--xls { --wetown-attachments-color: #0f9d58; }
.wetown-attachments__card--ppt { --wetown-attachments-color: #f4b400; }

.wetown-attachments__thumb {
    align-items: center;
    aspect-ratio: 16 / 9;
    background: var(--wp--preset--color--base, #f9f9f9);
    border-radius: calc(var(--wetown-attachments-radius) - 2px) calc(var(--wetown-attachments-radius) - 2px) 0 0;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.wetown-attachments__thumb.has-image {
    align-items: flex-start;
    background: #fff;
}

.wetown-attachments__thumb img {
    display: block;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transform-origin: top center;
    transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1);
    width: 100%;
}

.wetown-attachments__card:hover .wetown-attachments__thumb img,
.wetown-attachments__card:focus-visible .wetown-attachments__thumb img {
    transform: scale(1.06);
}

.wetown-attachments__icon {
    color: var(--wetown-attachments-color);
    display: inline-flex;
}

.wetown-attachments__icon svg {
    display: block;
    height: 100%;
    width: 100%;
}

.wetown-attachments__thumb .wetown-attachments__icon {
    height: 3rem;
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
    width: 3rem;
}

.wetown-attachments__card:hover .wetown-attachments__thumb .wetown-attachments__icon,
.wetown-attachments__card:focus-visible .wetown-attachments__thumb .wetown-attachments__icon {
    transform: scale(1.1);
}

.wetown-attachments__bar {
    align-items: flex-start;
    background: #fff;
    border-top: 2px solid var(--wetown-attachments-line);
    display: flex;
    flex: 1 1 auto;
    gap: 0.5rem;
    padding: 0.6rem 1rem 0.95rem 0.7rem;
    transition: border-color 0.2s ease;
}

.wetown-attachments__card:hover .wetown-attachments__bar,
.wetown-attachments__card:focus-visible .wetown-attachments__bar {
    border-top-color: var(--wetown-attachments-accent);
}

.wetown-attachments__bar .wetown-attachments__icon {
    flex: 0 0 1.125rem;
    margin-top: 0.05rem;
    height: 1.125rem;
    width: 1.125rem;
}

.wetown-attachments__name {
    flex: 1 1 auto;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    min-width: 0;
    overflow-wrap: break-word;
}

@media (prefers-reduced-motion: reduce) {
    .wetown-attachments__card,
    .wetown-attachments__card::after,
    .wetown-attachments__surface,
    .wetown-attachments__thumb img {
        transition: none;
    }

    .wetown-attachments__card:hover,
    .wetown-attachments__card:focus-visible,
    .wetown-attachments__card:active,
    .wetown-attachments__card:hover .wetown-attachments__thumb img,
    .wetown-attachments__card:focus-visible .wetown-attachments__thumb img {
        transform: none;
    }
}

.wetown-attachments__heading {
    margin-top: 50px;
}

.wetown-attachments__meta {
    color: var(--wp--preset--color--contrast-2, #636363);
    font-size: 0.8125rem;
    line-height: 1.35;
}

.wetown-attachments .screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}
