/**
 * Collection V2 -- Masonry Gallery + Artist Overlay
 * Full-width CSS columns masonry with hover/tap artist attribution.
 * @version 2.0.0
 */
@import url('./tokens.css');

/* ==========================================================================
   Page Layout
   ========================================================================== */

.collection-page {
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* Article container (hero only) */
.collection-article {
    max-width: var(--coll-container-max);
    margin: 0 auto;
    padding: var(--space-8) var(--coll-container-padding) 0;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.collection-hero {
    display: flex;
    flex-direction: column;
    gap: var(--coll-hero-gap);
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.collection-title {
    font-family: var(--font-display);
    font-size: var(--coll-title-size);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--color-text);
}

.collection-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--coll-meta-size);
    color: var(--color-text-secondary);
}

.collection-meta time {
    color: var(--color-text-muted);
}

.collection-meta__author {
    color: var(--color-text-secondary);
}

.collection-description {
    font-size: var(--coll-desc-size);
    line-height: var(--line-height-normal);
    color: var(--color-text-secondary);
    max-width: 65ch;
}

/* ==========================================================================
   MASONRY GALLERY -- CSS Columns
   ========================================================================== */

.collection-gallery {
    column-count: var(--coll-columns-mobile);
    column-gap: var(--coll-gap);
    padding: 0 var(--coll-gap);
}

/* ==========================================================================
   Gallery Item
   ========================================================================== */

.coll-item {
    position: relative;
    break-inside: avoid;
    margin-bottom: var(--coll-gap);
    border-radius: var(--coll-item-radius);
    overflow: hidden;
    cursor: pointer;
}

.coll-item__img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--coll-item-radius);
    transition: filter 0.3s ease;
}

/* ==========================================================================
   OVERLAY -- appears on hover (desktop) / tap (mobile)
   ========================================================================== */

.coll-item__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--coll-overlay-padding);
    opacity: 0;
    transition: opacity 0.25s ease;
    border-radius: var(--coll-item-radius);
    pointer-events: none;
}

.coll-item:hover .coll-item__overlay,
.coll-item.is-active .coll-item__overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Fav button -- always visible independent of overlay.
   PKG-5: 44px hit-zone (in-box pattern) — 44px box, 32px visual disc via
   transparent border + background-clip so the glyph stays small on a >70%
   mobile surface while the tap target meets WCAG 2.5.5. */
.coll-item__fav-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 6px solid transparent;
    background: rgba(0, 0, 0, 0.5);
    background-clip: padding-box;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    pointer-events: auto;
    opacity: 0;
    z-index: 2;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.coll-item:hover .coll-item__fav-btn,
.coll-item.is-active .coll-item__fav-btn {
    opacity: 1;
}

.coll-item__fav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    transform: scale(1.1);
}

.coll-item__fav-btn.saved {
    background: rgba(224, 92, 122, 0.9);
    color: #fff;
    opacity: 1;
}

.coll-item__fav-btn.saved svg {
    fill: currentColor;
}

.coll-item__author {
    font-size: var(--coll-author-size);
    color: var(--coll-author-color);
    text-decoration: none;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

a.coll-item__author:hover {
    text-decoration: underline;
}

/* Dimmed Gallery Rule (PKG-5): base is brightness(0.9); the work GLOWS to full
   brightness when attended — not dim further. */
.coll-item:hover .coll-item__img {
    filter: brightness(1.0);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (min-width: 481px) {
    .collection-gallery {
        column-count: var(--coll-columns-tablet);
    }
}

@media (min-width: 1025px) {
    .collection-gallery {
        column-count: var(--coll-columns-desktop);
    }
}

@media (min-width: 1441px) {
    .collection-gallery {
        column-count: var(--coll-columns-wide);
    }
}

/* ==========================================================================
   LIGHTBOX
   ========================================================================== */

.coll-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.coll-lightbox.open {
    display: flex;
}

.coll-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.coll-lightbox__content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coll-lightbox__img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--coll-item-radius);
}

.coll-lightbox__close,
.coll-lightbox__prev,
.coll-lightbox__next {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.2s;
}

.coll-lightbox__close:hover,
.coll-lightbox__prev:hover,
.coll-lightbox__next:hover {
    background: rgba(255, 255, 255, 0.15);
}

.coll-lightbox__close {
    top: -48px;
    right: 0;
    width: 36px;
    height: 36px;
    font-size: 24px;
}

.coll-lightbox__prev {
    left: -56px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
}

.coll-lightbox__next {
    right: -56px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
}

@media (max-width: 768px) {
    .coll-lightbox__prev { left: var(--space-2); }
    .coll-lightbox__next { right: var(--space-2); }
    .coll-lightbox__close { top: var(--space-2); right: var(--space-2); }
}

.coll-lightbox__counter {
    position: absolute;
    bottom: -36px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--text-sm);
    white-space: nowrap;
}

body.coll-lightbox-open {
    overflow: hidden;
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */

.coll-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: var(--text-sm);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    border: 1px solid var(--color-border);
}

.coll-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Curatorial Content (PKG-5)
   ========================================================================== */

.collection-content {
    max-width: 65ch;
    margin: var(--space-6) 0 0;
    font-size: var(--coll-desc-size);
    line-height: var(--line-height-normal);
    color: var(--color-text-secondary);
}

.collection-content p {
    margin: 0 0 var(--space-4);
}

/* ==========================================================================
   Empty State (PKG-5) — honest block, not a void
   ========================================================================== */

.collection-empty {
    grid-column: 1 / -1;
    column-span: all;
    text-align: center;
    padding: var(--space-10) var(--coll-container-padding);
    max-width: 48ch;
    margin: 0 auto;
}

.collection-empty__title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    color: var(--color-text);
    margin: 0 0 var(--space-3);
}

.collection-empty__text {
    font-size: var(--coll-desc-size);
    color: var(--color-text-secondary);
    line-height: var(--line-height-normal);
    margin: 0 0 var(--space-5);
}

.collection-empty__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 var(--space-5);
    background: var(--color-gold, #E8C547);
    color: #171717;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: filter 0.2s;
}

.collection-empty__cta:hover {
    filter: brightness(1.08);
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .coll-item__overlay {
        transition: none;
    }
    .coll-item__img {
        transition: none;
    }
    .coll-item__fav-btn {
        transition: none;
    }
    .coll-lightbox__close,
    .coll-lightbox__prev,
    .coll-lightbox__next {
        transition: none;
    }
    .coll-toast {
        transition: none;
    }
}
