/* ================================================
   VERSIONED SCRIPT CARDS
   Cards that rotate between multiple versions
   ================================================ */

/* ===== BASE VERSIONED CARD STYLES ===== */

/* Versioned card container - prevent view mode grid from breaking layout */
.script-card.versioned-card {
    position: relative;
    overflow: hidden;
    display: block !important;
    grid-template-columns: none !important;
}

/* Version content - hidden by default, shown when active */
.version-content {
    display: none;
}

.version-content.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    animation: versionFadeIn 0.4s ease;
}

/* Ensure card-image-container behaves properly */
.versioned-card .card-image-container {
    position: relative;
    flex-shrink: 0;
}

/* Ensure card-content is visible and styled */
.versioned-card .card-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.versioned-card .card-category {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cosmic-pink);
    margin-bottom: 0.6rem;
}

.versioned-card .card-title {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--pure-light);
    margin-bottom: 0.8rem;
    line-height: 1.3;
}

.versioned-card .card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.versioned-card .card-synopsis {
    color: rgba(233, 213, 255, 0.8);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.versioned-card .card-synopsis-container {
    margin-bottom: 1.2rem;
}

.versioned-card .card-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: auto;
}

/* ===== VIEW MODE: 1 COLUMN (HORIZONTAL LAYOUT) ===== */

.scripts-grid.view-1 .versioned-card .version-content.active {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 240px;
}

.scripts-grid.view-1 .versioned-card .card-image-container {
    height: 100%;
    aspect-ratio: auto;
}

.scripts-grid.view-1 .versioned-card .card-image,
.scripts-grid.view-1 .versioned-card .card-placeholder-image {
    height: 100%;
    min-height: 240px;
    object-fit: contain;
    background: linear-gradient(135deg, var(--nebula-purple) 0%, var(--deep-space) 100%);
}

.scripts-grid.view-1 .versioned-card .card-content {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.8rem;
}

.scripts-grid.view-1 .versioned-card .card-synopsis {
    -webkit-line-clamp: 5;
    flex-grow: 1;
}

.scripts-grid.view-1 .versioned-card .card-synopsis-container {
    flex-grow: 1;
    margin-bottom: 1rem;
}

.scripts-grid.view-1 .versioned-card .card-tags {
    margin-bottom: 1rem;
}

.scripts-grid.view-1 .versioned-card .card-buttons {
    margin-top: auto;
}

/* ===== VIEW MODE: 2 COLUMNS (VERTICAL LAYOUT) ===== */

.scripts-grid.view-2 .versioned-card .version-content.active {
    display: flex;
    flex-direction: column;
}

.scripts-grid.view-2 .versioned-card .card-image-container {
    aspect-ratio: 4 / 3;
    height: auto;
}

.scripts-grid.view-2 .versioned-card .card-image,
.scripts-grid.view-2 .versioned-card .card-placeholder-image {
    height: 100%;
    object-fit: contain;
    background: linear-gradient(135deg, var(--nebula-purple) 0%, var(--deep-space) 100%);
}

.scripts-grid.view-2 .versioned-card .card-synopsis {
    -webkit-line-clamp: 3;
}

/* ===== VIEW MODE: 3 COLUMNS (COMPACT VERTICAL) ===== */

.scripts-grid.view-3 .versioned-card .version-content.active {
    display: flex;
    flex-direction: column;
}

.scripts-grid.view-3 .versioned-card .card-image-container {
    aspect-ratio: 4 / 3;
    height: auto;
}

.scripts-grid.view-3 .versioned-card .card-image,
.scripts-grid.view-3 .versioned-card .card-placeholder-image {
    height: 100%;
    object-fit: contain;
    background: linear-gradient(135deg, var(--nebula-purple) 0%, var(--deep-space) 100%);
}

.scripts-grid.view-3 .versioned-card .card-title {
    font-size: 1.15rem;
}

.scripts-grid.view-3 .versioned-card .card-synopsis {
    -webkit-line-clamp: 2;
    font-size: 0.85rem;
}

.scripts-grid.view-3 .versioned-card .card-tags {
    margin-bottom: 0.8rem;
}

.scripts-grid.view-3 .versioned-card .tag {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
}

.scripts-grid.view-3 .versioned-card .card-link {
    font-size: 0.8rem;
    padding: 0.5rem 0.9rem;
}

/* ===== VERSION LABEL BADGE ===== */

.version-label {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, rgba(107, 63, 160, 0.95) 0%, rgba(217, 70, 168, 0.95) 100%);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-family: 'Raleway', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 5;
    pointer-events: none;
}

/* ===== NAVIGATION ARROWS ===== */

.version-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(18, 16, 31, 0.85);
    border: 1px solid rgba(217, 70, 168, 0.4);
    color: #e9d5ff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    opacity: 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.version-arrow svg {
    width: 18px;
    height: 18px;
}

.version-arrow-prev {
    left: 8px;
}

.version-arrow-next {
    right: 8px;
}

/* Show arrows on hover */
.versioned-card:hover .version-arrow {
    opacity: 1;
}

.version-arrow:hover {
    background: rgba(107, 63, 160, 0.9);
    border-color: rgba(217, 70, 168, 0.8);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.version-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

/* For horizontal layout, position arrows on image area only */
.scripts-grid.view-1 .versioned-card .version-arrow {
    top: 120px;
}

/* ===== VERSION DOTS INDICATOR ===== */

.version-dots {
    position: absolute;
    top: 12px;
    right: 50px; /* Leave room for favorite button */
    display: flex;
    gap: 6px;
    z-index: 10;
    padding: 4px 10px;
    background: rgba(18, 16, 31, 0.8);
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.version-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(233, 213, 255, 0.3);
    border: 1px solid rgba(233, 213, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.version-dot:hover {
    background: rgba(233, 213, 255, 0.5);
    transform: scale(1.2);
}

.version-dot.active {
    background: linear-gradient(135deg, #d946a8 0%, #f472b6 100%);
    border-color: #f472b6;
    box-shadow: 0 0 8px rgba(217, 70, 168, 0.5);
}

/* ===== ANIMATIONS ===== */

@keyframes versionFadeIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== READER PAGE VERSION SWITCHER ===== */

.version-switcher {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 12px 16px;
    background: rgba(45, 27, 78, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(217, 70, 168, 0.2);
}

.version-switcher-label {
    font-family: 'Raleway', sans-serif;
    font-size: 0.85rem;
    color: #c4b5fd;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
}

.version-switcher-label svg {
    width: 16px;
    height: 16px;
}

.version-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(217, 70, 168, 0.3);
    background: rgba(18, 16, 31, 0.6);
    color: #e9d5ff;
    font-family: 'Raleway', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.version-btn:hover {
    background: rgba(107, 63, 160, 0.5);
    border-color: rgba(217, 70, 168, 0.6);
}

.version-btn.active {
    background: linear-gradient(135deg, rgba(107, 63, 160, 0.8) 0%, rgba(217, 70, 168, 0.8) 100%);
    border-color: #d946a8;
    color: #fff;
    box-shadow: 0 0 12px rgba(217, 70, 168, 0.3);
}

.version-btn.active:hover {
    background: linear-gradient(135deg, rgba(107, 63, 160, 0.9) 0%, rgba(217, 70, 168, 0.9) 100%);
}

/* ===== MOBILE RESPONSIVE ===== */

@media (max-width: 768px) {
    /* Force vertical layout on mobile for all view modes */
    .scripts-grid.view-1 .versioned-card .version-content.active {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        min-height: auto;
    }
    
    .scripts-grid.view-1 .versioned-card .card-image-container {
        aspect-ratio: 4 / 3;
        height: auto;
    }
    
    .scripts-grid.view-1 .versioned-card .card-image,
    .scripts-grid.view-1 .versioned-card .card-placeholder-image {
        min-height: auto;
    }
    
    /* Reset arrow position for mobile */
    .scripts-grid.view-1 .versioned-card .version-arrow {
        top: 50%;
    }
    
    .version-arrow {
        width: 32px;
        height: 32px;
        opacity: 0.8;
    }
    
    .version-arrow svg {
        width: 16px;
        height: 16px;
    }
    
    .version-arrow-prev {
        left: 4px;
    }
    
    .version-arrow-next {
        right: 4px;
    }
    
    .version-dots {
        padding: 4px 8px;
        gap: 5px;
    }
    
    .version-dot {
        width: 8px;
        height: 8px;
    }
    
    .version-label {
        font-size: 0.7rem;
        padding: 3px 10px;
    }
    
    .version-switcher {
        padding: 10px 12px;
    }
    
    .version-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* Touch-friendly: always show arrows on touch devices */
@media (hover: none) {
    .version-arrow {
        opacity: 0.9;
    }
}
