@charset "UTF-8";

body {
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

.works-section {
    margin: 0 auto;
    padding: 30px 20px;
    box-sizing: border-box;
    min-height: 100vh;
}

.masonry {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    margin: calc(-1 * var(--gap)) 0 0 calc(-1 * var(--gap));
    --gap: 20px;
}

.masonry-item {
    width: calc(100% / 4 - var(--gap));
    margin-top: var(--gap);
    margin-left: var(--gap);
}

.masonry-item img {
    width: 100%;
    display: block;
    border-radius: 12px;
    box-sizing: border-box;
}

.overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    color: #fff;
    padding: 10px;
    box-sizing: border-box;
    display: none;
}

.overlay-title {
    margin: 0 0 5px;
    font-size: 1.1rem;
    display: none;
}

.overlay-desc {
    margin: 0;
    font-size: 0.9rem;
}

.overlay-description {
    display: none !important;
}

@media (max-width: 1500px) {
    .works-section {
        padding: 30px 20px;
    }
    .masonry {
        --gap: 16px;
    }
    .masonry-item {
        width: calc(100% / 4 - var(--gap));
    }
}

@media (max-width: 430px) {
    .works-section {
        padding: 30px 10px;
    }
    .masonry {
        --gap: 10px;
    }
    .masonry-item {
        width: calc(100% / 2 - var(--gap));
    }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 20px;
    width: 640px;
    height: 480px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    padding: 0 60px;
    box-sizing: border-box;
}

.modal-body {
    display: flex;
    flex: 1;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.modal-image-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}
.modal-image {
    height: 100%;
    width: auto;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    border-radius: 10px;
}

.modal-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
    max-height: 100%;
}
.modal-title {
    font-size: 1.5rem;
    margin-bottom: 12px;
    font-family: "Noto Serif JP", serif;
    color: #333;
}
.modal-description {
    font-size: 1rem;
    line-height: 1.6;
    color: #444;
}

.modal-button {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #f7cdc2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background-color 0.2s ease-in-out;
}

.modal-button:hover {
    background-color: #e0b3a5;
}

.modal-button img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: auto;
}

.modal-close {
    top: 10px;
    right: 10px;
}

.modal-nav {
    top: 50%;
    transform: translateY(-50%);
}
.modal-nav.left {
    left: 10px;
}
.modal-nav.right {
    right: 10px;
}

.fade-in {
    opacity: 1 !important;
}

@media (min-width: 769px) {
    .modal-content {
        overflow: visible;
    }
    .modal-close {
        top: -20px;
        right: -20px;
        width: 48px;
        height: 48px;
    }
    .modal-nav.left {
        left: 20px;
    }
    .modal-nav.right {
        right: 20px;
    }
}

.modal-back {
    display: none;
}

@media (max-width: 768px) {
    .modal-content {
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
        max-width: none;
        max-height: none;
        overflow-y: auto;
        box-shadow: none;
        padding: 0;
    }
    .modal-body {
        display: block;
        padding: 0;
        margin: 0;
        overflow: visible;
    }
    .modal-image-container {
        width: 100%;
        height: auto;
    }
    .modal-image {
        width: 95%;
        height: auto;
        object-fit: cover;
        border-radius: 20px;
        margin-top: 2.5vw;
        border: 2px solid #f7cdc2;
    }
    .modal-text {
        width: 100%;
        padding: 16px;
        box-sizing: border-box;
        height: auto;
        max-height: none;
        overflow-y: auto;
    }
    .modal-nav,
    .modal-close {
        display: none;
    }
    .modal-back {
        display: flex;
        position: fixed;
        top: 16px;
        left: 16px;
        width: 40px;
        height: 40px;
        background: #f7cdc2;
        border-radius: 50%;
        border: none;
        font-size: 24px;
        font-family: inherit;
        line-height: 1;
        color: #000;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        cursor: pointer;
        z-index: 10000;
    }
}
