/* Filterable Project Gallery */

.squirrel-project-gallery {
    margin: 2rem 0;
}

.squirrel-project-gallery__controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.squirrel-project-gallery__search {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

.squirrel-project-gallery__search:focus {
    outline: none;
    border-color: #82672d;
    box-shadow: 0 0 0 3px rgba(130, 103, 45, 0.1);
}

.squirrel-project-gallery__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Pills are outlined in the site's standard button colour when resting, and
   fill with it when selected. #5d4a20 is the darker tone the site's other
   buttons already use on hover. */

/* The parent theme styles bare <button> elements, including
   `button:hover  { background: rgba(241,78,78,.8) }` and
   `button:active, button:focus { background: #f14e4e }`.
   Those beat a plain class selector, so every state below has to declare its
   own background or the theme's coral leaks through — that focus rule was why
   a clicked pill stayed highlighted until you clicked elsewhere. */

.squirrel-project-gallery__pill,
.squirrel-project-gallery__pill:focus,
.squirrel-project-gallery__pill:active {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 2px solid var(--squig-gold);
    border-radius: 20px;
    color: var(--squig-gold);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: inset 0 0 0 0 transparent;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease,
                box-shadow 0.3s ease;
}

.squirrel-project-gallery__pill--active,
.squirrel-project-gallery__pill--active:focus,
.squirrel-project-gallery__pill--active:active {
    background: var(--squig-gold);
    border-color: var(--squig-gold);
    color: #fff;
}

@media (hover: hover) {
    /* Unselected: darken the outline and text only, no fill.
       The outline thickens to 4px via a 2px inset shadow sitting against the
       2px border, rather than by growing border-width. A shadow takes up no
       space in the box model, so nothing reflows and nothing below shifts —
       and unlike border-width it animates without thrashing layout. */
    .squirrel-project-gallery__pill:not(.squirrel-project-gallery__pill--active):hover {
        background: transparent;
        border-color: #5d4a20;
        color: #5d4a20;
        box-shadow: inset 0 0 0 2px #5d4a20;
    }

    .squirrel-project-gallery__pill--active:hover {
        background: #5d4a20;
        border-color: #5d4a20;
        color: #fff;
    }
}

.squirrel-project-gallery__pill:focus-visible {
    outline: 2px solid var(--squig-brown);
    outline-offset: 2px;
}

/* 320px minimum gives three columns at the 1170px content width instead of
   four, so each square is meaningfully larger. */
.squirrel-project-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Block flow, not flex. As a column flex item the image link has no in-flow
   content (the img is absolutely positioned), so it collapsed to zero height
   and aspect-ratio was ignored — which dropped the caption on top of the
   picture. In normal flow the link sizes from its aspect-ratio correctly and
   the caption follows underneath. */
.squirrel-project-gallery__item {
    display: block;
}

/* The image keeps a hard square crop; the caption flows beneath it.
   The img is positioned rather than sized with height:100% — inside an
   aspect-ratio box a percentage height can resolve against an auto height and
   collapse, which left the pictures short of square. */
/* The link wraps image, title and excerpt so the whole tile is clickable. */
.squirrel-project-gallery__item-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.squirrel-project-gallery__item-link:focus-visible {
    outline: 2px solid var(--squig-brown);
    outline-offset: 4px;
}

.squirrel-project-gallery__item-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    overflow: hidden;
    border-radius: 3px;
}

.squirrel-project-gallery__item-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.squirrel-project-gallery__item:hover .squirrel-project-gallery__item-image img {
    transform: scale(1.05);
}

.squirrel-project-gallery__item-body {
    padding: 1rem 0.25rem 0;
}

.squirrel-project-gallery__item-title {
    margin: 0 0 0.5rem 0;
    font-family: artico_extracond_light, sans-serif;
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.2rem;
}

/* Underline-on-hover matches the homepage "Check out our work" treatment.
   Applied to the heading itself now that the link wraps the whole tile. */
.squirrel-project-gallery__item-title {
    color: var(--squig-brown);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 7px;
    transition: text-decoration-color 0.3s ease-in-out, color 0.3s ease-in-out;
}

.squirrel-project-gallery__item:hover .squirrel-project-gallery__item-title {
    color: var(--squig-gold);
    text-decoration-color: var(--squig-gold);
}

/* Clamped so a long excerpt cannot make one card tower over its neighbours. */
.squirrel-project-gallery__item-excerpt {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .squirrel-project-gallery__controls {
        flex-direction: column;
    }

    /* 240px keeps phones to a single large square and tablets to two, rather
       than three cramped ones. */
    .squirrel-project-gallery__grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
}
