/* AIWallcraft Custom Styles */

/* CSS Variables */
:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-elevated: #1f1f23;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* Image Card Styles */
.image-card {
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.image-card img {
    display: block;
    width: 100%;
    height: auto;
}

/* Lazy Loading Image Styles */
.lazy-image-container {
    position: relative;
    overflow: hidden;
    background: var(--bg-tertiary);
}

/* Skeleton placeholder animation */
.lazy-image-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-elevated) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

.lazy-image-container.loaded::before {
    display: none;
}

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

/* Lazy image fade-in */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Aspect ratio containers for consistent layout before load */
.aspect-16-9 {
    aspect-ratio: 16 / 9;
}

.aspect-9-16 {
    aspect-ratio: 9 / 16;
}

.aspect-4-3 {
    aspect-ratio: 4 / 3;
}

.aspect-21-9 {
    aspect-ratio: 21 / 9;
}

/* Default aspect ratio for unknown */
.aspect-auto {
    aspect-ratio: 16 / 9;
}

/* ===========================================
   Masonry Grid Layout
   =========================================== */

/* Masonry grid - row height calculated so 3 landscape (16:9) images 
   stack to approximately match 1 portrait (9:16) image height.
   Each landscape card needs ~56% of its width in height.
   Portrait needs ~178% of its width in height.
   3 landscapes ≈ 1 portrait when row heights are tuned correctly. */
.masonry-grid {
    grid-auto-rows: 100px;
}

@media (min-width: 640px) {
    .masonry-grid {
        grid-auto-rows: 90px;
    }
}

@media (min-width: 1024px) {
    .masonry-grid {
        grid-auto-rows: 100px;
    }
}

@media (min-width: 1280px) {
    .masonry-grid {
        grid-auto-rows: 95px;
    }
}

/* Portrait images (9x16) span 3 rows to match height of 3 landscape images stacked
   Math: 16:9 height = 0.5625 × width, 9:16 height = 1.778 × width
   3 × 0.5625 = 1.6875 ≈ 1.778 */
.masonry-portrait {
    grid-row: span 3;
}

/* Landscape images span 1 row */
.masonry-landscape {
    grid-row: span 1;
}

/* Override aspect ratios in masonry mode - let grid handle sizing */
.masonry-grid .lazy-image-container {
    aspect-ratio: unset;
    height: 100%;
}

/* Ensure images fill their containers properly */
.masonry-grid .image-card {
    height: 100%;
}

.masonry-grid .image-card img {
    height: 100%;
    object-fit: cover;
}

/* HTMX Loading Indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}

.htmx-request.htmx-indicator {
    display: inline-flex;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Focus styles */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Selection styles */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Spin animation for loading */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Button hover glow effect */
.btn-glow:hover {
    box-shadow: var(--shadow-glow);
}

/* Navigation link styles */
.nav-link {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.nav-link.active {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Tag styles */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 9999px;
    transition: all 0.15s ease;
}

.tag:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Glass effect */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
}

/* Privacy policy sections */
.privacy-section {
    border-left: 2px solid var(--border-glass);
    padding-left: 1.5rem;
    transition: border-color 0.2s ease;
}

.privacy-section:hover {
    border-left-color: var(--accent-primary);
}

.privacy-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.privacy-section-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.privacy-section-body {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.privacy-section-body p {
    line-height: 1.7;
}

/* Cookie consent banner */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
