/* ============================================================
   PokéGallery — gallery.css
   Styles the output of make_gallery() in functions.php:
     <div class="responsive-gallery"><div class="gallery">...
   ============================================================ */

.box.main:has(.responsive-gallery) {
    padding-bottom: 12px;
}

/* Wrap the gallery cards into a responsive grid */
.responsive-gallery {
    display: inline-block;
    width: calc(33.333% - 14px);
    margin: 0 14px 18px 0;
    vertical-align: top;
    animation: card-in 0.5s ease both;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .responsive-gallery { animation: none; }
}

/* Stagger the first several cards so they don't all pop in at once */
.responsive-gallery:nth-child(1) { animation-delay: 0.02s; }
.responsive-gallery:nth-child(2) { animation-delay: 0.08s; }
.responsive-gallery:nth-child(3) { animation-delay: 0.14s; }
.responsive-gallery:nth-child(4) { animation-delay: 0.20s; }
.responsive-gallery:nth-child(5) { animation-delay: 0.26s; }
.responsive-gallery:nth-child(6) { animation-delay: 0.32s; }
.responsive-gallery:nth-child(n+7) { animation-delay: 0.36s; }

.responsive-gallery:nth-child(3n+1) {
    margin-right: 14px;
}

.gallery {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 3px solid var(--card);
    outline: 1px solid var(--line);
    background: #F1EEE3;
    aspect-ratio: 1 / 1;
}

.gallery a { display: block; height: 100%; }

.gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.gallery::after {
    /* small Pokéball corner badge on every card */
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(var(--accent) 0 47%, var(--ink) 47% 53%, #fff 53% 100%);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.85), 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
}

.gallery:hover img {
    transform: scale(1.06);
}

.gallery:hover {
    outline: 2px solid var(--accent);
}

.gallery {
    transition: outline-color 0.3s ease;
}

@media (max-width: 700px) {
    .responsive-gallery {
        width: calc(50% - 10px);
    }
}

@media (max-width: 440px) {
    .responsive-gallery {
        width: 100%;
        margin-right: 0 !important;
    }
}

/* Strip of featured type-representative thumbnails at the top of each type gallery page */
.type-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 18px;
    margin: 4px 0 22px;
}

.type-thumb {
    width: 96px;
    height: 96px;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(34, 38, 43, 0.22));
    transition: transform 0.18s ease, filter 0.18s ease;
    cursor: pointer;
}

.type-thumb:first-child {
    width: 150px;
    height: 150px;
}

.type-thumb:hover {
    transform: scale(1.15);
}

/* Replace the browser's default square focus outline with a rounded glow.
   :focus-visible keeps it for keyboard/arrow-key navigation (so it doesn't
   disappear for accessibility) while skipping it on a plain mouse click. */
.type-thumb:focus {
    outline: none;
}

.type-thumb:focus-visible {
    outline: none;
    border-radius: 8px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 6px var(--accent);
}

.type-thumb.active {
    filter:
        drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 85%, transparent))
        drop-shadow(0 0 26px color-mix(in srgb, var(--accent) 65%, transparent))
        drop-shadow(0 0 46px color-mix(in srgb, var(--accent) 40%, transparent));
    animation: active-glow-pulse 1.6s ease-in-out infinite;
}

@keyframes active-glow-pulse {
    0%, 100% {
        filter:
            drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 85%, transparent))
            drop-shadow(0 0 26px color-mix(in srgb, var(--accent) 65%, transparent))
            drop-shadow(0 0 46px color-mix(in srgb, var(--accent) 40%, transparent));
    }
    50% {
        filter:
            drop-shadow(0 0 14px color-mix(in srgb, var(--accent) 95%, transparent))
            drop-shadow(0 0 34px color-mix(in srgb, var(--accent) 75%, transparent))
            drop-shadow(0 0 60px color-mix(in srgb, var(--accent) 50%, transparent));
    }
}

@media (prefers-reduced-motion: reduce) {
    .type-thumb.active { animation: none; }
}

.type-summary {
    max-width: 420px;
    margin: 0 auto 22px;
    padding: 16px 20px;
    background: #FFF8E7;
    border: 2px dashed var(--accent);
    border-radius: 10px;
    text-align: center;
}

/* display is only set when the panel isn't [hidden], so the browser's
   default "[hidden] { display: none }" behaviour still works to hide it */
.type-summary:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.type-summary-content {
    flex: 1 1 auto;
    min-width: 0;
}

/* Prev/next controls for stepping between Pokémon, styled to match the
   photo gallery's lightbox arrows (.sl-next / .sl-prev in this file) */
.type-nav-prev,
.type-nav-next {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.type-nav-prev:hover,
.type-nav-next:hover {
    background: var(--accent-dark);
}

.type-nav-prev:active,
.type-nav-next:active {
    transform: scale(0.92);
}

.type-summary h4 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--accent-dark);
    margin: 0 0 8px;
}

.type-summary p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

@media (max-width: 600px) {
    .type-thumb { width: 68px; height: 68px; }
    .type-thumb:first-child { width: 110px; height: 110px; }
    .type-strip { gap: 12px; }
}
.sl-overlay { background: rgba(20, 20, 20, 0.92) !important; }
.sl-close { color: var(--poke-yellow) !important; }

.sl-next, .sl-prev {
    background: var(--accent) !important;
    border-radius: 50% !important;
    width: 44px !important;
    height: 44px !important;
    opacity: 0.9 !important;
}

.sl-next:hover, .sl-prev:hover {
    background: var(--accent-dark) !important;
    opacity: 1 !important;
}

.sl-caption {
    background: rgba(0, 0, 0, 0.65) !important;
    font-family: var(--font-body) !important;
}
