/* YARN FOREST Styles */

/* Grid Layout represented as "Zukan" (Picture Book) */
.yarn-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 40px;
    margin-bottom: 80px;
}

/* Intro Section (New Design) */
/* Intro Section (New Design) */
/* Intro Section (New Design) */
.yarn-intro-grid {
    display: grid;
    /* Logo/Text : Visual = 4:6 */
    grid-template-columns: 4fr 6fr;
    gap: 60px;
    align-items: center;
    margin-bottom: 80px;
}

.yarn-intro-visual {
    width: 100%;
    /* 1.85:1 aspect ratio (Wider than 16:9, deeper than 21:9) */
    aspect-ratio: 1.85 / 1;
    overflow: hidden;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes pan-vertical {
    0% {
        object-position: center top;
    }

    100% {
        object-position: center bottom;
    }
}

.yarn-mv-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Cover the scope */
    object-position: center top;
    transition: transform 0.8s ease;
    /* 15s round trip => 7.5s one way */
    animation: pan-vertical 7.5s ease-in-out infinite alternate;
}

.yarn-intro-visual:hover .yarn-mv-img {
    transform: scale(1.03);
}

.yarn-intro-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.yarn-logo-wrapper {
    max-width: 400px;
    margin: 0 auto 20px auto;
}

.yarn-intro-text p {
    font-family: var(--font-body, "Archivo", sans-serif);
    font-size: 1rem;
    line-height: 2.0;
    color: #1a1a1a;
    text-align: center;
    /* Center aligned */
    font-weight: 350;
    letter-spacing: 0.03em;
}

/* Section title default spacing (desktop) */
.yarn-section-title {
    margin-bottom: 30px;
}

/* Intro section default spacing (desktop) */
.yarn-intro-section {
    margin-top: 40px;
    margin-bottom: 60px;
}

@media (max-width: 768px) {
    .yarn-intro-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .yarn-intro-visual {
        aspect-ratio: 16 / 9;
    }

    .yarn-logo-wrapper {
        margin: 0 auto 20px auto;
        max-width: 250px;
    }

    .yarn-intro-text p {
        font-size: 0.75rem;
        /* Even smaller on mobile */
        text-align: center;
        /* Center aligned */
        line-height: 1.8;
    }

    /* Reduce spacing between intro and grid */
    .yarn-intro-section {
        margin-bottom: 30px !important;
    }

    .yarn-section-title {
        margin-top: 0 !important;
        margin-bottom: 20px !important;
    }

    .yarn-section-title img {
        max-width: 250px !important;
    }

    /* Instagram-style 3-column grid for YARN FOREST */
    .yarn-grid-container {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2px !important;
        margin-top: 5px !important;
    }

    .yarn-item-image {
        aspect-ratio: 1 / 1 !important;
        /* Perfect square */
        width: 100% !important;
        object-fit: cover !important;
        margin-bottom: 0 !important;
    }

    .yarn-item-title {
        font-size: 0.65rem !important;
        margin-top: 4px !important;
        line-height: 1.2 !important;
    }

    /* YARN FOREST Modal - Mobile Responsive */
    .yarn-modal-content {
        width: 100%;
        height: 100vh;
        max-width: 100%;
        flex-direction: column;
    }

    .yarn-modal-left {
        flex: 1;
        width: 100%;
        height: 60%;
    }

    .yarn-modal-right {
        width: 100%;
        height: 40%;
        overflow-y: auto;
        padding: 15px;
    }

    .yarn-modal-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }

    .yarn-modal-info h2 {
        font-size: 1.2rem;
    }

    .yarn-modal-meta {
        font-size: 0.85rem;
    }

    .yarn-modal-description {
        font-size: 0.9rem;
    }
}

.yarn-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    /* Slightly rounded */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 1 / 1;
    background: #f9f9f9;
}

.yarn-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.yarn-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.yarn-item:hover .yarn-item-image {
    transform: scale(1.05);
}

/* Hover Overlay */
.yarn-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 15px;
    text-align: center;
}

.yarn-item:hover .yarn-overlay {
    opacity: 1;
}

.yarn-title-overlay {
    color: #fff;
    font-family: var(--font-heading, sans-serif);
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
}


/* Modal Window */
.yarn-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
}

.yarn-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.yarn-modal-content {
    width: 95%;
    max-width: 1400px;
    height: 85vh;
    background: #fff;
    display: flex;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 1px solid #eee;
    overflow: hidden;
}

/* Modal Layout: Left (Slider 70-75%) / Right (Info 25-30%) */
.yarn-modal-left {
    flex: 1;
    /* Takes remaining space */
    min-width: 0;
    /* Critical for Swiper/Flex */
    overflow: hidden;
    /* Ensure content stays inside */
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.yarn-modal-right {
    width: 350px;
    /* Fixed width for Info Panel as requested "Narrower" */
    min-width: 300px;
    flex-shrink: 0;
    /* Prevent shrinking when image is large */
    padding: 30px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Scrollable if content long */
    position: relative;
    background: #fff;
    border-left: 1px solid #eee;
    z-index: 10;
    /* Ensure it stays on top if overlapping occurs */
}

/* Swiper in Modal */
.swiper-container {
    width: 100%;
    height: 100%;
}

.swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    user-select: none;
    /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.swiper-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
    /* Prevent drag selection on images */
}

.swiper-slide iframe {
    width: 1000px;
    height: 1000px;
    max-width: 100%;
    max-height: 100%;
    border: none;
    pointer-events: auto;
    /* Allow interaction with iframe */
}

/* Prevent selection on no-swiping slides */
.swiper-no-swiping {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}


/* Close Button */
.yarn-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.yarn-modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.yarn-modal-close::before,
.yarn-modal-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: #333;
}

.yarn-modal-close::before {
    transform: rotate(45deg);
}

.yarn-modal-close::after {
    transform: rotate(-45deg);
}


/* Modal Info Typography */
.yarn-info-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    line-height: 1.1;
    margin-bottom: 20px;
    font-weight: 800;
}

.yarn-info-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #444;
    margin-bottom: 30px;
}

/* Meta Data */
.yarn-info-meta-container {
    margin-top: auto;
    /* Push to bottom if sparse, or just follow flow */
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.yarn-info-meta-row {
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.yarn-label {
    font-weight: bold;
    color: #888;
}

.yarn-status.in_stock {
    color: #2ecc71;
    font-weight: bold;
}

.yarn-status.sold {
    color: #e74c3c;
    font-weight: bold;
}

/* Navigation Buttons */
.yarn-modal-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.yarn-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: bold;
    color: #333;
    font-size: 0.9rem;
    transition: color 0.2s;
    padding: 5px 10px;
}

.yarn-nav-btn:hover {
    color: #000;
    background: #f0f0f0;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .yarn-modal-content {
        flex-direction: column;
        height: 100%;
        width: 100%;
        max-width: none;
        border: none;
    }

    .yarn-modal-left {
        width: 100%;
        height: 50%;
        flex: none;
    }

    .yarn-modal-right {
        width: 100%;
        height: 50%;
        padding: 20px;
        border-left: none;
        border-top: 1px solid #eee;
    }

    /* Single Yarn Page (Single Template) & Modal Content */
    .yarn-content,
    .yarn-info-desc {
        color: #1a1a1a;
        line-height: 1.8;
    }
}

/* Single Yarn Page (Single Template) & Modal Content */
.yarn-content,
.yarn-info-desc {
    color: #1a1a1a;
    line-height: 1.8;
}

.yarn-content p,
.yarn-info-desc p {
    margin-bottom: 15px !important;
    /* Spacing for Paragraphs (Enter) */
    margin-top: 0 !important;
}

/* Z-Index Adjustment for WebPet when Modal is Open */
body.yarn-modal-open .web-pet {
    z-index: 9000 !important;
    /* Lower than modal's 9999 */
}