/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #fafaf8;
    color: #2c2c2c;
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== HEADER ========== */
.site-header {
    background: #1a1a1a;
    color: #fff;
    text-align: center;
    padding: 3rem 1.5rem 2.5rem;
    overflow: hidden;
}

.site-title-link {
    text-decoration: none;
    color: inherit;
}

.header-inner {
    position: relative;
    max-width: 100%;
    overflow-wrap: break-word;
}

.back-arrow {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.6rem;
    color: #fff;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0.25rem;
}

.back-arrow:hover {
    opacity: 1;
}

@media (max-width: 768px) {
    .back-arrow {
        left: 0.5rem;
        font-size: 1.3rem;
        padding: 0.5rem;
    }
}

.site-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2.2rem, 6vw, 3.5rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.site-subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1.15rem);
    font-weight: 300;
    color: #b8b8b0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ========== CATEGORY NAV ========== */
.category-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e8e8e4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.nav-inner {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    max-width: 600px;
    margin: 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.category-btn {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 400;
    padding: 0.6rem 1.4rem;
    border: 1.5px solid #d4d4cf;
    border-radius: 100px;
    background: transparent;
    color: #555;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.category-btn:hover {
    border-color: #888;
    color: #1a1a1a;
}

.category-btn.active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
    font-weight: 500;
}

/* ========== GALLERY GRID (Masonry via CSS columns) ========== */
.gallery {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    columns: 4 280px;
    column-gap: 1.25rem;
}

/* ========== PROJECT CARD ========== */
.project-card {
    break-inside: avoid;
    margin-bottom: 1.25rem;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    -webkit-tap-highlight-color: transparent;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.project-card.loading {
    opacity: 0.7;
    pointer-events: none;
    animation: pulse 0.8s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.7; }
    to { opacity: 0.95; }
}

.project-card:focus-visible {
    outline: 3px solid #4a90d9;
    outline-offset: 2px;
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: linear-gradient(90deg, #f0f0ec 25%, #e8e8e3 50%, #f0f0ec 75%);
    background-size: 1200px 100%;
    animation: shimmer 1.8s infinite linear;
}

.card-image-wrapper.loaded {
    animation: none;
    background: #f0f0ec;
}

.card-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

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

.project-card:hover .card-image {
    transform: scale(1.02);
}

.project-card:hover .card-info {
    background: #fafaf8;
}

.card-info {
    padding: 1rem 1.15rem 1.15rem;
    transition: background 0.3s ease;
}

.card-category {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    margin-bottom: 0.25rem;
}

.card-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.3rem;
}

.card-size {
    font-size: 0.82rem;
    color: #999;
    font-style: italic;
}

/* ========== FULL-SCREEN BENTO PANEL ========== */
.panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px) brightness(0.65) saturate(0.5);
    -webkit-backdrop-filter: blur(20px) brightness(0.65) saturate(0.5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.panel-overlay.open {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.25s ease;
}

.panel-close {
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 1010;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    line-height: 1;
}

.panel-close:hover {
    background: rgba(255,255,255,0.2);
}

.panel-header {
    text-align: center;
    padding: 0.75rem 4rem 0.25rem;
    color: #fff;
    flex-shrink: 0;
}

.panel-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 600;
    display: inline;
}

.panel-details {
    font-size: 0.85rem;
    color: #aaa;
    font-style: italic;
    display: inline;
    margin-left: 0.75rem;
}

/* Bento grid container — fills viewport */
.panel-images {
    width: 98vw;
    max-width: 1600px;
    flex: 1 1 0;
    min-height: 0;
    padding: 0.25rem 0.5rem 0.5rem;
    display: grid;
    gap: 4px;
}

/* Grid cell */
.panel-cell {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    overflow: hidden;
    animation: imageIn 0.3s ease backwards;
}

.panel-cell:nth-child(1) { animation-delay: 0s; }
.panel-cell:nth-child(2) { animation-delay: 0.06s; }
.panel-cell:nth-child(3) { animation-delay: 0.12s; }
.panel-cell:nth-child(4) { animation-delay: 0.18s; }
.panel-cell:nth-child(5) { animation-delay: 0.24s; }
.panel-cell:nth-child(6) { animation-delay: 0.30s; }
.panel-cell:nth-child(7) { animation-delay: 0.36s; }

/* Grid cell image */
.panel-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    user-select: none;
    -webkit-user-drag: none;
}

.panel-img:hover {
    opacity: 0.85;
    transform: scale(1.01);
}

/* ---- Bento layout variants ---- */

.bento-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    place-items: center;
}

.bento-1 .panel-cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bento-1 .panel-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.bento-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.bento-3 {
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.bento-3 .panel-cell:first-child {
    grid-row: 1 / 3;
}

.bento-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.bento-5 {
    grid-template-columns: 1.5fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.bento-5 .panel-cell:first-child {
    grid-row: 1 / -1;
}

.bento-6 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
}

.bento-7 {
    grid-template-columns: 2fr repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
}
.bento-7 .panel-cell:first-child {
    grid-row: 1 / -1;
}

/* ========== ZOOM OVERLAY ========== */
.zoom-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(24px) brightness(0.5);
    -webkit-backdrop-filter: blur(24px) brightness(0.5);
    cursor: zoom-out;
    justify-content: center;
    align-items: center;
}

.zoom-overlay.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.zoom-image {
    max-width: 96%;
    max-height: 96%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* ========== ZOOM NAV ARROWS ========== */
.zoom-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2010;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1;
    user-select: none;
}

.zoom-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.zoom-prev { left: 1rem; }
.zoom-next { right: 1rem; }

/* ========== SKIP LINK ========== */
.skip-link {
    position: fixed;
    top: -100%;
    left: 0;
    z-index: 9999;
    background: #1a1a1a;
    color: #fff;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    text-decoration: none;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #4a90d9;
    outline-offset: 2px;
}

/* ========== BACKDROP-FILTER FALLBACK ========== */
@supports not (backdrop-filter: blur(1px)) {
    .panel-overlay { background: rgba(0, 0, 0, 0.9); }
    .zoom-overlay { background: rgba(0, 0, 0, 0.95); }
}

/* ========== LANDING PAGE ========== */

/* Hero */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 500px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-collage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 4px;
}

.collage-cell {
    overflow: hidden;
}

.collage-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.collage-cell img.loaded {
    opacity: 1;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: #fff;
    padding: 2rem 2rem 1rem;
    margin-bottom: 1rem;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Hero category cards */
.hero-categories {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    max-width: 780px;
    width: 100%;
    padding: 0 2rem;
}

.hero-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2.5rem, 10vw, 6rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

.hero-tagline {
    font-size: clamp(1rem, 3vw, 1.4rem);
    font-weight: 300;
    color: #d4d4cc;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* About */
.about-section {
    background: #fff;
    padding: 5rem 2rem;
    border-top: 1px solid #e8e8e4;
}

.about-inner {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.about-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1a1a1a;
}

.about-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #555;
}

/* Category Cards */
.category-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: #fff;
    aspect-ratio: 3 / 4;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px) saturate(1.5);
    -webkit-backdrop-filter: blur(12px) saturate(1.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: cardGlow 3s ease-in-out infinite;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.category-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3), 0 0 20px 4px rgba(255,255,255,0.2);
    animation: none;
}

.category-card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.category-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.4s ease;
}

.category-card-img img.loaded {
    opacity: 1;
}

.category-card:hover .category-card-img img {
    transform: scale(1.06);
}

.category-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    z-index: 1;
}

.category-card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 2;
    padding: 1.25rem;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.03em;
}

/* Landing page responsive */
@media (max-width: 768px) {
    .hero-collage {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: repeat(3, 1fr);
    }

    .hero-content {
        padding: 1.5rem 1rem 0.5rem;
        margin-bottom: 0.5rem;
        width: 100%;
    }

    .hero-title {
        font-size: clamp(1.8rem, 9vw, 3rem);
    }

    .hero-tagline {
        font-size: clamp(0.55rem, 2.2vw, 0.85rem);
        letter-spacing: 0.06em;
    }

    .hero-categories {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
        padding: 0 0.75rem;
    }

    .category-card {
        aspect-ratio: 2 / 3;
    }

    .category-card-label {
        font-size: 0.95rem;
        padding: 0.75rem;
    }

    .about-section {
        padding: 3rem 1.25rem;
    }

    .about-text {
        font-size: 0.95rem;
    }
}

/* ========== FOOTER ========== */
.site-footer {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #bbb;
    font-size: 0.82rem;
    border-top: 1px solid #e8e8e4;
    letter-spacing: 0.02em;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes imageIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes cardGlow {
    0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.2), 0 0 0 0 rgba(255,255,255,0); }
    50% { box-shadow: 0 8px 32px rgba(0,0,0,0.2), 0 0 15px 2px rgba(255,255,255,0.25); }
}

/* Scroll-based fade-in (replaces render-time animation) */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .site-header {
        padding: 2rem 1rem 1.75rem;
    }

    .site-title {
        font-size: clamp(1.6rem, 5.5vw, 2.2rem);
    }

    .site-subtitle {
        letter-spacing: 0.04em;
        font-size: 0.75rem;
    }

    .gallery {
        columns: 2 160px;
        column-gap: 0.75rem;
        padding: 1rem 0.75rem 3rem;
    }

    .project-card {
        margin-bottom: 0.75rem;
    }

    .card-info {
        padding: 0.7rem 0.85rem 0.85rem;
    }

    .card-title {
        font-size: 0.95rem;
    }

    .card-size {
        font-size: 0.75rem;
    }

    .card-category {
        font-size: 0.65rem;
    }

    .panel-images {
        width: 100%;
        padding: 0.25rem;
        gap: 3px;
    }

    .panel-header {
        padding: 0.5rem 3.5rem 0.25rem;
    }

    .panel-title {
        font-size: 1rem;
    }

    .panel-details {
        display: block;
        margin-left: 0;
        font-size: 0.75rem;
    }

    /* On mobile, simplify grids to 2 columns */
    .bento-3 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
    }
    .bento-3 .panel-cell:first-child {
        grid-column: 1 / -1;
    }
    .bento-5 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr 1fr;
    }
    .bento-5 .panel-cell:first-child {
        grid-column: 1 / -1;
    }
    .bento-6 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr 1fr;
    }
    .bento-7 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr 1fr 1fr;
    }
    .bento-7 .panel-cell:first-child {
        grid-column: 1 / -1;
    }

    .category-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .project-card {
        border-radius: 8px;
    }
}

@media (max-width: 400px) {
    .gallery {
        columns: 2;
        column-gap: 0.5rem;
        padding: 0.75rem 0.5rem 3rem;
    }

    .project-card {
        margin-bottom: 0.5rem;
    }

    .nav-inner {
        gap: 0.2rem;
        padding: 0.5rem 0.5rem;
    }

    .category-btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.8rem;
    }

    .hero-categories {
        gap: 0.4rem;
        padding: 0 0.5rem;
    }

    .category-card-label {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .hero-tagline {
        letter-spacing: 0.04em;
    }

    .site-subtitle {
        letter-spacing: 0.02em;
        font-size: 0.68rem;
    }

    .back-arrow {
        left: 0.25rem;
        font-size: 1.1rem;
    }
}

/* columns: 4 280px already handles large screens */

/* ========== EMPTY STATE ========== */
.empty-state {
    column-span: all;
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
}

.empty-state h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #666;
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 3px solid #4a90d9;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
