/**
 * Custom Mobile Carts: Portfolio page and single project
 *
 * Lays out the type filter, the project cards, the build details strip,
 * the photo gallery, the previous and next links and the closing band.
 * Cards, chips, badges, buttons, breadcrumbs and the section header come
 * from style.css; the pagination and the empty state box come from
 * blog.css, which loads with this file on both views. Mobile first.
 *
 * @package CustomMobileCarts
 */

/* ==========================================================================
   Editor content under the hero
   ========================================================================== */

.portfolio-content {
    padding-bottom: 0;
}

.portfolio-prose {
    max-width: 46rem;
}

.portfolio-prose > :first-child {
    margin-top: 0;
}

/* ==========================================================================
   Type filter: plain links, 44px tall, the active one filled
   ========================================================================== */

.project-filter {
    margin-bottom: var(--spacing-xl);
}

.project-filter__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.project-filter__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1.125rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

.project-filter__link:hover {
    color: var(--color-link);
    border-color: var(--color-primary-40);
}

.project-filter__link[aria-current] {
    color: var(--color-text-white);
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.project-filter__status {
    margin: calc(-1 * var(--spacing-md)) 0 var(--spacing-xl);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.project-filter__status strong {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

/* ==========================================================================
   Project cards (built on .card, .card--link and .card__media)
   ========================================================================== */

.project-grid {
    align-items: stretch;
}

.project-card {
    height: 100%;
}

/* Photos of carts are framed 4:3, same as the cmc-card image size */
.project-card .card__media img,
.project-card__placeholder {
    aspect-ratio: 4 / 3;
}

.project-card .card__media img {
    transition: transform var(--transition-slow);
}

@media (hover: hover) {
    .project-card:hover .card__media img {
        transform: scale(1.03);
    }
}

.project-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--color-primary);
    background-color: var(--color-bg-tint);
}

.project-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.project-card__type {
    align-self: flex-start;
    margin-bottom: 0.75rem;
}

.project-card__title {
    line-height: 1.3;
}

/* Location and length on one line with a dot between them */
.project-card__facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.project-card__fact + .project-card__fact::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 3px;
    margin: 0 0.5rem;
    vertical-align: middle;
    background-color: currentColor;
    border-radius: var(--radius-full);
}

.project-card__more {
    align-self: flex-start;
    margin-top: auto;
    padding-top: var(--spacing-md);
}

/* ==========================================================================
   Empty states (box from blog.css)
   ========================================================================== */

.project-empty .empty-state__title {
    font-size: var(--font-size-2xl);
}

.project-empty__admin {
    margin: var(--spacing-lg) 0 0;
    padding-top: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    border-top: 1px dashed var(--color-border-strong);
}

.project-empty__admin a {
    font-weight: var(--font-weight-semibold);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

/* ==========================================================================
   Single project: hero and the build details strip
   ========================================================================== */

.project-hero .page-hero__title {
    max-width: 24ch;
}

.project-hero .eyebrow a {
    color: inherit;
    text-decoration: none;
}

.project-hero .eyebrow a:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* The strip overlaps the bottom of the dark hero */
.project-details-wrap {
    position: relative;
    z-index: 1;
    margin-top: calc(-1 * var(--spacing-xl));
}

.project-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-md) var(--spacing-lg);
    margin: 0;
    padding: var(--spacing-lg);
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

@media (min-width: 768px) {
    .project-details {
        grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

.project-details__item {
    min-width: 0;
}

.project-details__label {
    margin-bottom: 0.25rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.4;
    letter-spacing: var(--letter-spacing-eyebrow);
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.project-details__value {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    color: var(--color-heading);
    overflow-wrap: anywhere;
}

/* ==========================================================================
   Gallery: one column, two from 768px, three from 1024px
   ========================================================================== */

.project-gallery-section {
    padding-block: var(--spacing-3xl);
}

.project-details-wrap + .project-gallery-section {
    padding-top: var(--spacing-2xl);
}

.project-gallery {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-lg);
}

@media (min-width: 768px) {
    .project-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--spacing-xl);
    }
}

@media (min-width: 1024px) {
    .project-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.project-gallery__figure {
    margin: 0;
}

.project-gallery__link {
    position: relative;
    display: block;
    overflow: hidden;
    background-color: var(--color-bg-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.project-gallery__link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.project-gallery__image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

@media (hover: hover) {
    .project-gallery__link:hover {
        box-shadow: var(--shadow-lg);
    }

    .project-gallery__link:hover .project-gallery__image {
        transform: scale(1.03);
    }
}

.project-gallery__caption {
    margin-top: 0.625rem;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    color: var(--color-text-muted);
}

/* A lone photo keeps its own proportions and spans the row */
.project-gallery--single {
    grid-template-columns: minmax(0, 1fr);
}

.project-gallery--single .project-gallery__image {
    max-height: 42rem;
    aspect-ratio: auto;
    object-fit: contain;
    background-color: var(--color-bg-light);
}

/* ==========================================================================
   Write up, previous and next, related
   ========================================================================== */

.project-body {
    padding-bottom: var(--spacing-3xl);
}

.project-body--no-gallery {
    padding-top: var(--spacing-3xl);
}

.project-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-md);
    padding-block: var(--spacing-xl) var(--spacing-3xl);
}

@media (min-width: 640px) {
    .project-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.project-nav__link {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 44px;
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--color-text);
    text-decoration: none;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.project-nav__link:hover {
    border-color: var(--color-primary-30);
    box-shadow: var(--shadow-sm);
}

.project-nav__link:hover .project-nav__title {
    color: var(--color-link);
}

.project-nav__link--next {
    text-align: right;
    align-items: flex-end;
}

@media (min-width: 640px) {
    .project-nav__link--next {
        grid-column: 2;
    }
}

.project-nav__label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-eyebrow);
    text-transform: uppercase;
    color: var(--color-eyebrow);
}

.project-nav__icon--previous {
    transform: scaleX(-1);
}

.project-nav__title {
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    color: var(--color-heading);
    transition: color var(--transition-fast);
}

.project-related__all {
    margin: var(--spacing-xl) 0 0;
}

.project-related__back {
    padding-bottom: var(--spacing-3xl);
}

/* ==========================================================================
   Closing call to action (same pattern as the Start Here page)
   ========================================================================== */

.portfolio-cta__inner {
    display: grid;
    gap: var(--spacing-xl);
}

@media (min-width: 1024px) {
    .portfolio-cta__inner {
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: var(--spacing-3xl);
        align-items: center;
    }
}

.portfolio-cta__copy > :last-child {
    margin-bottom: 0;
}

.portfolio-cta__title {
    max-width: 24ch;
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-4xl);
}

.portfolio-cta__text {
    max-width: 40rem;
    font-size: var(--font-size-lg);
    line-height: 1.6;
}

.portfolio-cta__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 480px) {
    .portfolio-cta__actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   Reduced motion and print
   ========================================================================== */

/* style.css already zeroes the motion tokens; the photo zoom and card lift
   are switched off too, so nothing moves under the pointer. */
@media (prefers-reduced-motion: reduce) {
    .project-card:hover,
    .project-card:hover .card__media img,
    .project-gallery__link:hover .project-gallery__image {
        transform: none;
    }
}

@media print {
    .page-hero .breadcrumbs,
    .project-filter,
    .pagination,
    .project-nav,
    .portfolio-cta {
        display: none !important;
    }

    .project-details-wrap {
        margin-top: var(--spacing-lg);
    }

    .project-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .card,
    .project-gallery__item,
    .project-details {
        break-inside: avoid;
    }
}
