/* Film Panel Styles */

/* Film link - flexible height based on image */
.film-link {
    display: block;
    position: relative;
    overflow: hidden;
    background: #333;
    border-radius: 20px;
    min-height: 200px;
}

/* Control aspect ratio by orientation, not exact image size */
.film-link.is-portrait { aspect-ratio: 2 / 3; }
.film-link.is-landscape { aspect-ratio: 16 / 9; }

/* Images maintain their aspect ratio */
.film-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* 40% dark overlay for readability */
.film-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1;
    opacity: 0.4;
    transition: opacity 200ms ease-in-out;
}

/* Placeholder when image is missing */
.placeholder-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: #333;
}

.film-link:hover .film-poster {
    animation: filmZoomIn 20s ease-out;
}

@keyframes filmZoomIn {
    from { transform: scale(1); }
    to   { transform: scale(1.06); }
}

/* Fade out tint on hover */
.film-link:hover .film-overlay {
    opacity: 0;
}

.placeholder-content { display: none; }

/* Caption overlay when an image exists */
.film-caption {
    position: absolute;
    left: 0;
    top: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    color: #fff;
    z-index: 2;
}
.film-caption h4 {
    margin: 0;
    font-size: 1.1rem;
}
.film-caption .film-year {
    margin: 0;
    font-size: 0.95rem;
    color: #fff;
}

/* Composable masonry layout (Piccalilli method) */
.masonry {
  --gutter: 0.5rem;
  --flow-space: var(--gutter);
  --switcher-target-container-width: 25rem;
}
.switcher {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gutter, 1em);
  align-items: var(--switcher-vertical-alignment, flex-start);
}
.switcher > * {
  flex-grow: 1;
  flex-basis: calc((var(--switcher-target-container-width, 40rem) - 100%) * 999);
}
.flow > * + * {
  margin-block-start: var(--flow-space, 1em);
}
.wrapper { max-width: 80rem; margin-inline: auto; padding-inline: var(--gutter); }

/* Optional size variants using aspect ratios */
.flow-item.size-small .film-poster { aspect-ratio: 2 / 3; }
.flow-item.size-medium .film-poster { aspect-ratio: 3 / 4; }
.flow-item.size-large .film-poster { aspect-ratio: 4 / 5; }

/* Staggered fade-in for items on load/insert */
.flow .flow-item {
  opacity: 0;
  transform: translateY(6px);
  animation: filmFadeIn 400ms ease-out forwards;
}

@keyframes filmFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Stagger delays up to a reasonable number per column */
.flow .flow-item:nth-child(1)  { animation-delay: 0.00s; }
.flow .flow-item:nth-child(2)  { animation-delay: 0.12s; }
.flow .flow-item:nth-child(3)  { animation-delay: 0.24s; }
.flow .flow-item:nth-child(4)  { animation-delay: 0.36s; }
.flow .flow-item:nth-child(5)  { animation-delay: 0.48s; }
.flow .flow-item:nth-child(6)  { animation-delay: 0.60s; }
.flow .flow-item:nth-child(7)  { animation-delay: 0.72s; }
.flow .flow-item:nth-child(8)  { animation-delay: 0.84s; }
.flow .flow-item:nth-child(9)  { animation-delay: 0.96s; }
.flow .flow-item:nth-child(10) { animation-delay: 1.08s; }
.flow .flow-item:nth-child(11) { animation-delay: 1.20s; }
.flow .flow-item:nth-child(12) { animation-delay: 1.32s; }
.flow .flow-item:nth-child(13) { animation-delay: 1.44s; }
.flow .flow-item:nth-child(14) { animation-delay: 1.56s; }
.flow .flow-item:nth-child(15) { animation-delay: 1.68s; }
.flow .flow-item:nth-child(16) { animation-delay: 1.80s; }
.flow .flow-item:nth-child(17) { animation-delay: 1.92s; }
.flow .flow-item:nth-child(18) { animation-delay: 2.04s; }
.flow .flow-item:nth-child(19) { animation-delay: 2.16s; }
.flow .flow-item:nth-child(20) { animation-delay: 2.28s; }

.placeholder-content h4 {
    color: #fff;
    font-size: 1.2rem;
    margin: 0;
    word-wrap: break-word;
}

.placeholder-content .film-year {
    color: #aaa;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}