/* ---------------- Reset ---------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---------------- Body ---------------- */
body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #2b2723; /* dark grey with slight brown */
    color: #fdfdfd;
    margin: 0;
}

header {
    background-color: #1e1b19;
    color: #fdfdfd;
    padding: 20px;
    font-size: 1.5rem;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-container h1 {
    flex: 1;
    text-align: center;
}

/* Burger menu */
.burger-menu {
    display: none;
    flex-direction: column;
    cursor: pointer;
    width: 30px;
    justify-content: space-around;
    height: 25px;
}

.burger-line {
    width: 25px;
    height: 3px;
    background-color: #fdfdfd;
    border-radius: 3px;
    transition: 0.3s;
}

/* Navigation menu */
.nav-menu {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
}

.nav-link {
    color: #fdfdfd;
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.3s;
}

.nav-link:hover {
    color: #ddd;
}

.nav-link.active {
    color: #d4af37;
    font-weight: bold;
}

/* Mobile burger menu */
@media (max-width: 600px) {
    .burger-menu {
        display: flex;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        flex-direction: column;
        background-color: #1e1b19;
        padding: 20px;
        gap: 15px;
        z-index: 9998;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-link {
        padding: 10px;
        text-align: center;
    }
}

/* Content pages */
.content-page {
    padding: 40px;
    color: #fdfdfd;
}

.content-page h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.content-page p {
    line-height: 1.6;
    margin-bottom: 15px;
}

/* ---------------- Gallery ---------------- */
.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    padding: 10px 10px; /* side padding so images don't touch edges */
    gap: 2px;
    box-sizing: border-box;
}

/* Filters UI */
.search-bar {
    width: 100%;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    box-sizing: border-box;
}

#search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.02);
    color: #fff;
}

.filter-toggle-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.filter-toggle-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* Filter sidebar */
.filter-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background-color: #1e1b19;
    border-right: 1px solid rgba(255,255,255,0.1);
    z-index: 9998;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.filter-sidebar.open {
    transform: translateX(0);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.filter-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-filters-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}

.filter-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mode-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mode-section label {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-section h4 {
    margin: 0;
    font-size: 0.95rem;
    text-transform: uppercase;
    color: #d4af37;
}

.tag-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tag-item {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
}

.tag-item input {
    margin-right: 6px;
}

.category-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category {
    border: 1px solid rgba(255,255,255,0.06);
    padding: 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.02);
}

.category h4 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
}

.subcategory {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.subcategory input {
    margin-right: 6px;
}

.clear-filters-btn {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(220, 20, 20, 0.3);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
    margin-top: auto;
}

.clear-filters-btn:hover {
    background: rgba(220, 20, 20, 0.5);
}


.gallery .tile {
    position: relative;
}

.gallery img {
    width: 100%;
    height: 33vw;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.gallery img:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Multi-image overlay icon */
.multi-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255,255,255,0.7);
    color: #000;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9rem;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }
    .gallery img {
        height: 45vw;
    }
}

@media (max-width: 600px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr); /* two images per row on mobile */
    }
    .gallery img {
        height: 45vw;
    }
}

/* ---------------- Modal ---------------- */
.modal {
    display: none;
    position: fixed;
    top:0;
    left:0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 20px;
}

/* Flex container: image + metadata */
.modal-inner {
    display: flex;
    flex-direction: row;
    max-width: 90%;
    width: 100%;
    align-items: flex-start;
    gap: 12px; /* keep gap small */
    justify-content: center;
}

/* Image container (~70%) */
.modal-image-container {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* keep arrows relative to this container */
    overflow: hidden; /* ensure transformed image cannot draw outside its border */
}

/* Pan/zoom cursor states when enabled */
.modal-image-container.panzoom-enabled { touch-action: none; cursor: grab; }
.modal-image-container.panzoom-enabled.grabbing { cursor: grabbing; }


/* Modal image */
.modal-content {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    object-fit: contain;
    display: block;
}


/* Metadata container (~30%) */
.modal-meta {
    flex: 0 0 350px;
    color: #fdfdfd;
    overflow-y: auto;
    max-height: 90vh;
    padding: 0 15px;
    font-size: 1.5rem; /* slightly larger body text for metadata */
    line-height: 1.5;
}

.modal-meta h2 {
    margin-bottom: 10px;
    font-size: 1.75rem; /* larger title */
}

.modal-meta p {
    margin-bottom: 8px;
    font-size: 1.5rem;
    color: #f6f6f6;
}

/* Tags are slightly dimmer than the main metadata to differentiate */
.modal-meta #modal-tags {
    color: #838383;
    font-weight: 600;
}

/* Close button */
.close {
    position: fixed;
    top: 20px;
    right: 35px;
    font-size: 40px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    z-index: 10000;
}

.close:hover {
    color: #bbb;
}

/* Arrows */
.arrow {
    position: absolute;
    top: 50%;
    font-size: 50px;
    color: #fff;
    cursor: pointer;
    user-select: none;
    padding: 5px 10px;
    background-color: rgba(0,0,0,0.3);
    border-radius: 3px;
    transform: translateY(-50%);
    z-index: 10001;
    opacity: 0; /* hidden by default */
    transition: opacity 150ms ease, transform 150ms ease;
    pointer-events: none; /* avoid clicks when hidden */
}

/* If modal has only a single image, hide arrows (CSS-driven) */
.modal[data-multi="false"] .arrow {
    display: none;
}

/* On mobile, always show arrows regardless of single/multiple images */
@media (max-width: 600px) {
    .modal[data-multi="false"] .arrow {
        display: block;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Left arrow positioned over image edge (not over metadata) */
#modal-prev {
    left: 12px; /* sit inside left edge of image */
    transform: translateY(-50%) translateX(0);
}

/* Right arrow positioned over image edge (not over metadata) */
#modal-next {
    right: 12px; /* sit inside right edge of image */
    transform: translateY(-50%) translateX(0);
}

/* Reveal arrows only when hovering the image area so they show on image hover */
.modal-image-container:hover .arrow {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0);
}

/* On small screens keep arrows closer but still outside image */
@media (max-width: 900px) {
    #modal-prev { left: 8px; }
    #modal-next { right: 8px; }
}

/* ---------------- Responsive Modal ---------------- */
/* Responsive adjustments */
@media (max-width: 900px) {
    #modal-prev {
        left: 5px;   /* arrows closer on smaller screens */
    }
    #modal-next {
        right: 5px;
    }
}

/* Mobile-specific modal behavior: stack image above metadata, scale image, hide arrows and enable swipe */
@media (max-width: 600px) {
    .modal-inner {
        flex-direction: column;
        align-items: flex-start; /* anchor content to top so image top is visible */
        gap: 12px;
        max-width: 100%;
    }

    .modal-image-container {
        width: 100%;
        flex: none;
        padding: 0 10px;
        margin-bottom: 8px; /* space between image and metadata */
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        height: auto;
        max-height: 50vh; /* limit height on phones so metadata remains reachable */
    }

    .modal-meta {
        flex: none;
        width: 100%;
        max-height: 40vh; /* allow metadata to scroll within the modal */
        overflow-y: auto;
        padding: 10px 15px 30px;
        text-align: left;
    }

    /* Hide arrows on mobile - use swipe instead */
    .arrow {
        display: none !important;
    }

    #modal-prev { left: 12px; }
    #modal-next { right: 12px; }
}

/* Loading Spinner */
#loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fdfdfd;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Small spinner used inside modal when loading full image */
.modal-loading {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10002;
    display: none;
    align-items: center;
    justify-content: center;
}
.spinner-small {
    border: 3px solid rgba(255,255,255,0.25);
    border-top: 3px solid #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.pagination-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.05);
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s, opacity 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.95rem;
    color: #aaa;
    min-width: 120px;
    text-align: center;
}

@media (max-width: 600px) {
    .pagination {
        gap: 8px;
    }
    
    .pagination-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .page-info {
        font-size: 0.85rem;
    }
}

/* Recipes layout */
.recipe-category {
    margin-bottom: 28px;
}
.recipe-category h3 {
    font-size: 1.25rem;
    color: #d4af37;
    margin-bottom: 12px;
}
.recipe {
    padding: 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: 6px;
    margin-bottom: 12px;
}
.recipe h4 { margin-bottom: 6px; }
.recipe-desc { color: #dcdcdc; margin-bottom: 8px; }
.recipe-steps { margin-left: 18px; }
.recipe-step { margin-bottom: 8px; line-height: 1.4; }
.paint-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.35);
    margin-right: 6px;
    vertical-align: middle;
}
.paint-name { margin-right: 6px; color: #fff; font-size: 0.95rem; }
.paint-ratio { color: #aaa; font-size: 0.9rem; }



