/* =========================================
   List Page CSS - Hybrid Gallery
   ========================================= */

/* Header Tweaks */
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: var(--backdrop-blur);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo a {
    font-family: var(--font-heading);
    font-weight: 900;
    letter-spacing: -1px;
}

.current-category {
    font-family: var(--font-heading);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
}

/* Main Navigation */
.main-nav {
    display: flex;
    gap: var(--spacing-lg);
    align-items: center;
}

.nav-link {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all var(--transition-fast);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 4px;
}

.nav-link:hover {
    color: var(--color-text-main);
}

.nav-link.active {
    color: var(--color-primary);
    background: rgba(0, 242, 255, 0.1);
}

/* Mobile Navigation */
@media (max-width: 768px) {
    /* .portal-header handled by base.css */

    .current-category {
        order: 3;
        width: 100%;
        text-align: center;
        font-size: 0.8rem;
        margin-top: var(--spacing-xs);
        color: var(--color-primary);
        /* Ensure visibility */
    }

    /* .main-nav and .nav-link handled by base.css */
}

/* =========================================
   Layout: Gallery Main
   ========================================= */

.gallery-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 60px);
    /* Keep base constraint */
    min-height: 0;
    /* Important for Firefox */
}

/* Fix Gallery Content to be a Column */
.gallery-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Default for single view */
    height: 100%;
    position: relative;
    transition: transform 0.5s var(--transition-smooth), filter 0.5s var(--transition-smooth);
}

/* ALL Categories View Override: Main Vertical Scroll */
.gallery-content.scrollable-y {
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Smooth mobile scroll */
}

/* Ensure Footer sits nicely in flex container */
.gallery-content .site-footer {
    margin-top: auto;
    padding-bottom: 2rem;
    flex-shrink: 0;
}

/* Background push-back effect when modal is open */
body.modal-open .gallery-content {
    transform: scale(0.98);
    filter: blur(4px);
    pointer-events: none;
}

.all-categories-container.visible {
    display: flex !important;
    width: 100%;
}

/* ALL Categories View Override: Main Vertical Scroll */
.gallery-content.scrollable-y {
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Smooth mobile scroll */
}

/* Ensure Footer sits nicely in flex container */
.gallery-content .site-footer {
    margin-top: auto;
    padding-bottom: 2rem;
    flex-shrink: 0;
}

/* ALL Categories View Override: Main Vertical Scroll */
.gallery-content.scrollable-y {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Ensure Footer sits nicely in flex container */
.gallery-content .site-footer {
    margin-top: auto;
    padding-bottom: 2rem;
    flex-shrink: 0;
}

.gallery-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =========================================
   Sidebar Navigation (All Categories View)
   ========================================= */

.sidebar-nav {
    display: none;
    /* Hidden by default (single category view) */
    width: 180px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--color-border);
    padding: var(--spacing-lg) 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.sidebar-nav.visible {
    display: block;
}

.sidebar-link {
    display: block;
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: var(--color-primary);
    background: rgba(0, 242, 255, 0.05);
}

.sidebar-link.active {
    color: var(--color-primary);
    background: rgba(0, 242, 255, 0.1);
    border-left-color: var(--color-primary);
}

/* =========================================
   Mobile Category Navigation
   ========================================= */

.mobile-category-nav {
    display: none;
    /* Desktop hidden */
}

@media (max-width: 768px) {
    .mobile-category-nav {
        display: flex;
        flex-direction: row;
        /* 横並びを強制 */
        height: 50px;
        /* 高さを固定 */
        width: 100%;
        /* 横幅いっぱい */
        align-items: center;
        /* 中央揃え */
        flex-shrink: 0;
        /* 潰れないように */

        /* Sticky position under header */
        position: sticky;
        top: 0;
        z-index: 99;
        background: rgba(10, 10, 20, 0.9);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 var(--spacing-md);
    }

    /* Hide scrollbar */
    .mobile-category-nav::-webkit-scrollbar {
        display: none;
    }
}

.mobile-cat-link {
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
    cursor: pointer;
}

.mobile-cat-link.active {
    background: var(--color-primary);
    color: #000;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

/* =========================================
   All Categories Container
   ========================================= */

.all-categories-container {
    display: none;
    /* Hidden by default (single category view) */
    flex-direction: column;
    gap: var(--spacing-xl);
    padding: var(--spacing-lg);
    /* Scroll handled by parent .gallery-content now */
    overflow-y: visible !important;
    height: auto !important;
    min-height: 100%;
}

.all-categories-container.visible {
    display: flex !important;
    width: 100%;
}

/* Category Section */
.category-section {
    scroll-margin-top: 130px;
    /* Increased for Sticky Header + Mobile Nav */
}

.category-section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

.category-section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-main);
}

.category-section-header .template-count {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    padding: 4px 12px;
    border-radius: 20px;
}

/* Mini Gallery (horizontal scroll within section) */
.mini-gallery {
    display: flex;
    gap: var(--spacing-md);
    overflow-x: auto;
    padding: 20px 40px;
    /* Padding increased to prevent border clipping */
    scroll-snap-type: x mandatory;
    scrollbar-width: none;

    /* Prevent text selection during drag */
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.mini-gallery::-webkit-scrollbar {
    display: none;
}

/* Mini Card (Unified Glow Style) */
.mini-card {
    flex: 0 0 200px;
    height: 280px;
    background: rgba(255, 255, 255, 0.03);
    /* Subtle glass */
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Thin border */
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: pointer;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);

    /* Thumbnail Optimization */
    /* Zoom in (135%) to aggressively crop header/artifacts */
    /* Position (20%) to shift view further down, clearing all top borders */
    background-size: 135%;
    background-position: center 20%;
    background-repeat: no-repeat;
}

.mini-card .placeholder-content {
    text-align: center;
    width: 100%;
}

.mini-card:hover {
    background-color: rgba(0, 0, 0, 0.4);
    /* Darken for contrast */
    border-color: var(--card-color, #fff);
    /* Glow Color */
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 30px var(--card-color, rgba(255, 255, 255, 0.2));
    /* Color Glow */
    transform: translateY(-4px) scale(1.02);
    z-index: 10;
}

.mini-card .big-char {
    font-family: var(--font-heading);
    font-size: 5rem;
    font-weight: 900;
    line-height: 1;
    color: #fff;
    opacity: 0.8;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    transition: color 0.3s;
}

.mini-card:hover .big-char {
    color: var(--card-color, #fff);
}

.mini-card .theme-label {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: var(--spacing-xs);
    transition: color 0.3s;
}

.mini-card:hover .theme-label {
    color: #fff;
}

/* Remove grid texture from mini-card */
.mini-card::before {
    display: none;
}

/* Mobile: Hide sidebar, adjust layout */
@media (max-width: 768px) {
    .sidebar-nav {
        display: none !important;
    }

    .all-categories-container.visible {
        padding: var(--spacing-md);
    }

    .mini-card {
        flex: 0 0 160px;
        height: 220px;
    }

    .mini-card .big-char {
        font-size: 4rem;
    }
}

/* Tag Filter Container */
.tag-filter-container {
    flex-shrink: 0;
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    margin-bottom: var(--spacing-md);
    /* Align with index bar */
    position: sticky;
    top: 60px;
    z-index: 95;
    background: transparent;
    /* Clean look */
    /* Optional: Mask to fade edges if needed, but transparent is safer for blending */
    backdrop-filter: blur(10px);
}

.tag-filter-container::-webkit-scrollbar {
    display: none;
}

.tag-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.tag-btn:hover,
.tag-btn.active {
    background: var(--color-primary);
    color: #000;
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

/* Index Bar (A-Z) - Adjusted top to sit below if needed, or just keep as is */
.index-bar {
    flex-shrink: 0;
    top: 110px;
    /* Adjusted to accomodate tag filter if both present, roughly */
    /* ... existing styles ... */
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: var(--backdrop-blur);
    position: sticky;
    z-index: 50;
    /* Adjusted for stacking context */
    scrollbar-width: none;
}

.index-bar::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.index-link {
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 4px;
    transition: all var(--transition-fast);
    cursor: pointer;
    font-size: 1rem;
}

.index-link:hover,
.index-link.active {
    color: var(--category-accent, var(--color-primary));
    background: color-mix(in srgb, var(--category-accent, var(--color-primary)) 15%, transparent);
}

.index-link.disabled {
    color: rgba(255, 255, 255, 0.25);
    cursor: not-allowed;
    opacity: 0.5;
}

.index-link.disabled:hover {
    color: rgba(255, 255, 255, 0.35);
    background: transparent;
}

/* Gallery Container (The Swipe Area) */
.gallery-container {
    /* Flexbox layout fix: Fill remaining space */
    height: auto;
    flex: 1;
    min-height: 0;
    /* Allow shrinking */

    display: flex;
    align-items: center;
    gap: var(--spacing-lg);

    /* Padding adjustments */
    padding: 0 7.5vw;
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    padding-right: 10vw;

    overflow-x: auto;
    overflow-y: hidden;
    /* Prevent vertical drift */
    touch-action: pan-x;
    /* Explicitly allow only horizontal pan */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    /* Prevent text selection during drag */
    user-select: none;
    -webkit-user-select: none;
}

/* Custom Scrollbar for Gallery & Lists */
.gallery-container::-webkit-scrollbar,
.all-categories-container::-webkit-scrollbar,
.mini-gallery::-webkit-scrollbar {
    height: 6px;
    /* Horizontal */
    width: 6px;
    /* Vertical */
    display: block;
    /* Force display if hidden by default settings elsewhere */
}

.gallery-container::-webkit-scrollbar-track,
.all-categories-container::-webkit-scrollbar-track,
.mini-gallery::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.gallery-container::-webkit-scrollbar-thumb,
.all-categories-container::-webkit-scrollbar-thumb,
.mini-gallery::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.gallery-container::-webkit-scrollbar-thumb:hover,
.all-categories-container::-webkit-scrollbar-thumb:hover,
.mini-gallery::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Gallery Item (The Card) - Unified Glow */
.gallery-item {
    flex: 0 0 85vw;
    width: 85vw;
    scroll-snap-align: center;
    height: 80%;
    background: rgba(255, 255, 255, 0.03);
    /* Subtle glass */
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Thin border */
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-smooth), border-color var(--transition-smooth), background-color var(--transition-smooth), box-shadow var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    /* Lighter blur */
    box-shadow: none;
}

/* Remove liquid border pseudo */
.gallery-item::before {
    display: none;
}

/* Desktop override */
@media (min-width: 768px) {
    .gallery-container {
        padding: var(--spacing-xl) calc(50vw - 200px);
    }

    .gallery-item {
        flex: 0 0 400px;
        width: 400px;
    }
}

/* Hover & Active State - Unified Glow */
.gallery-item:hover,
.gallery-item.active-card {
    background: rgba(0, 0, 0, 0.4);
    /* Darken for contrast */
    border-color: var(--card-color, #fff);
    /* Glow Color */
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 30px var(--card-color, rgba(255, 255, 255, 0.2));
    /* Color Glow */
    transform: scale(1.02);
    z-index: 10;
}

/* Typographic Placeholder Style */
.gallery-item .placeholder-content {
    text-align: center;
    z-index: 2;
    /* Ensure text is visible over images */
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.gallery-item.has-image {
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center 50%;
}

.gallery-item.has-image::before {
    /* Darker overlay for readability when image is present */
    background: rgba(0, 0, 0, 0.6);
    /* Removed grid pattern if image is there, or keep it subtle? Let's hide grid for clear image view */
    background-image: none;
}

@keyframes aura-pulse {

    0%,
    100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Typographic Placeholder Style */
.gallery-item .placeholder-content {
    text-align: center;
    /* Removed grid pattern if image is there, or keep it subtle? Let's hide grid for clear image view */
    background-image: none;
}

/* Theme Label (e.g. "Gaming", "Corporate") */
.theme-label {
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    color: var(--color-primary);
    margin-top: -10px;
    /* Pull closer to Big Char */
    margin-bottom: var(--spacing-xs);
    opacity: 0.9;
}

.gallery-item .big-char {
    font-family: var(--font-heading);
    font-size: 10rem;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(to bottom right, #fff, rgba(255, 255, 255, 0.2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    opacity: 0.8;

    /* If image is present, maybe make char more solid or outlined? */
    /* text-shadow: 0 0 20px rgba(0,0,0,0.5); Not works with background-clip text */

    /* Fix for white backgrounds: Use drop-shadow filter on the clipped text */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

/* Fallback checked: Overlay handles contrast, no specific text shadow needed yet. */

.gallery-item h3 {
    font-size: 1.5rem;
    margin-top: var(--spacing-md);
    color: var(--color-text-main);
}

.gallery-item .btn-view {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md) var(--spacing-xl);
    background: rgba(0, 0, 0, 0.8);
    /* Dark background for legibility */
    backdrop-filter: blur(4px);
    /* Ghost button */
    color: var(--color-primary);
    font-weight: 700;
    border: 1px solid var(--color-primary);
    /* Outline */
    border-radius: 30px;
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    /* Neon glow effect for outline */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
}

.gallery-item:hover .btn-view,
.gallery-item.active-card .btn-view {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item .btn-view:hover {
    background: var(--color-primary);
    color: #000;
    box-shadow: 0 0 20px var(--color-primary);
}

/* Background Grid Effect for cards */
.gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
}

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-card {
    min-height: 400px;
    border-radius: 20px;
    background: var(--color-surface);
}

.skeleton-card .skeleton-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: var(--spacing-md);
}

.skeleton-char {
    width: 120px;
    height: 120px;
    border-radius: 12px;
}

.skeleton-label {
    width: 100px;
    height: 16px;
    border-radius: 8px;
}

.skeleton-btn {
    width: 120px;
    height: 40px;
    border-radius: 50px;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Controls */
.gallery-controls {
    display: none;
    /* No logic here, buttons are positioned individually */
}

@media (min-width: 768px) {
    .gallery-controls {
        display: block;
    }
}

.control-btn {
    background: rgba(255, 255, 255, 0.05);
    /* White-based glassmorphism */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-fast);

    /* Absolute positioning for screen edges */
    position: fixed;
    top: 55%;
    /* Visual center accounting for header */
    transform: translateY(-50%);
    z-index: 50;
}

#scrollLeft {
    left: var(--spacing-lg);
}

#scrollRight {
    right: var(--spacing-lg);
}

.control-btn:hover {
    background: var(--color-primary);
    color: black;
    border-color: var(--color-primary);
    transform: translateY(-50%) scale(1.1);
}

/* Aurora Container */
.aurora-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -15;
    background: #000;
}

/* Custom Scrollbar for Gallery & Lists */
.gallery-container::-webkit-scrollbar,
.all-categories-container::-webkit-scrollbar,
.mini-gallery::-webkit-scrollbar {
    height: 6px;
    /* Horizontal */
    width: 6px;
    /* Vertical */
    display: block;
    /* Force display if hidden by default settings elsewhere */
}

.gallery-container::-webkit-scrollbar-track,
.all-categories-container::-webkit-scrollbar-track,
.mini-gallery::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.gallery-container::-webkit-scrollbar-thumb,
.all-categories-container::-webkit-scrollbar-thumb,
.mini-gallery::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.gallery-container::-webkit-scrollbar-thumb:hover,
.all-categories-container::-webkit-scrollbar-thumb:hover,
.mini-gallery::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}