/* ========== Unified Series Card (.oku-series-card) - Fanout Design ========== */

/* Card Container */
.oku-series-card {
    position: relative;
    transition: transform 0.25s ease, z-index 0s, filter 0.3s ease;
}

.oku-series-card:hover {
    transform: translateY(-6px);
    z-index: 100;
}

/* Selection checkbox */
.oku-series-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.oku-series-checkbox svg {
    width: 14px;
    height: 14px;
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.oku-series-checkbox.checked {
    background: var(--primary, #8b5cf6);
    border-color: var(--primary, #8b5cf6);
}

.oku-series-checkbox.checked svg {
    opacity: 1;
}

/* Score badge - top right, always visible */
.oku-series-score-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fcd34d;
    z-index: 25;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.oku-series-score-badge svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.oku-series-card:hover .oku-series-score-badge {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.05);
}

/* Selected state */
.oku-series-card.selected .oku-series-container {
    outline: 3px solid var(--primary, #8b5cf6);
    outline-offset: -3px;
    border-radius: 10px;
}

.oku-series-card.selected .oku-series-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(139, 92, 246, 0.15);
    pointer-events: none;
    border-radius: 10px;
    z-index: 20;
}

/* Link wrapper */
.oku-series-link {
    display: block;
    text-decoration: none;
}

/* Container - holds the fanout stack */
.oku-series-container {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 10px;
    overflow: visible;
    z-index: 2;
}

/* Stack container */
.oku-series-stack {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stacked Images */
.oku-series-fanout-img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    will-change: transform;
}

/* Default stacked positions */
.oku-series-fanout-img[data-index="0"] { transform: translateX(0) rotate(0deg); z-index: 5; }
.oku-series-fanout-img[data-index="1"] { transform: translateX(6px) translateY(3px) rotate(2deg); opacity: 0.5; z-index: 4; }
.oku-series-fanout-img[data-index="2"] { transform: translateX(12px) translateY(6px) rotate(4deg); opacity: 0.35; z-index: 3; }
.oku-series-fanout-img[data-index="3"] { transform: translateX(18px) translateY(9px) rotate(6deg); opacity: 0.2; z-index: 2; }
.oku-series-fanout-img[data-index="4"] { transform: translateX(24px) translateY(12px) rotate(8deg); opacity: 0.1; z-index: 1; }

/* Purple glow on hover - matching oku-card */
.oku-series-card:hover .oku-series-fanout-img[data-index="0"] {
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.4),
                0 0 20px rgba(139, 92, 246, 0.2);
}

/* Hover state - fan out (triggers on entire card hover including button) */
.oku-series-card:hover .oku-series-fanout-img {
    opacity: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.oku-series-card:hover .oku-series-fanout-img[data-index="0"] {
    transform: translateX(0) translateY(-8px) rotate(0deg) scale(1.02);
}
.oku-series-card:hover .oku-series-fanout-img[data-index="1"] {
    transform: translateX(-50%) translateY(0) rotate(-10deg) scale(0.88);
}
.oku-series-card:hover .oku-series-fanout-img[data-index="2"] {
    transform: translateX(50%) translateY(0) rotate(10deg) scale(0.88);
}
.oku-series-card:hover .oku-series-fanout-img[data-index="3"] {
    transform: translateX(-85%) translateY(12px) rotate(-18deg) scale(0.78);
}
.oku-series-card:hover .oku-series-fanout-img[data-index="4"] {
    transform: translateX(85%) translateY(12px) rotate(18deg) scale(0.78);
}

/* Hover Zone */
.oku-series-hover-zone {
    position: absolute;
    inset: 0;
    z-index: 15;
    border-radius: 10px;
    cursor: pointer;
}

/* Overlay with info */
.oku-series-overlay {
    position: absolute;
    bottom: 0;
    left: -2px;
    right: -2px;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.7) 35%, rgba(0,0,0,0.3) 65%, transparent 100%);
    border-radius: 0 0 10px 10px;
    padding: 3rem 0.75rem 0.75rem;
    z-index: 10;
    pointer-events: none;
    transition: background 0.3s ease;
}

/* Strengthen gradient on hover */
.oku-series-card:hover .oku-series-overlay {
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 40%, rgba(0,0,0,0.5) 70%, transparent 100%);
}

/* Info container */
.oku-series-info {
    display: flex;
    flex-direction: column;
}

/* Title */
.oku-series-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    line-height: 1.15;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta info - hidden by default, slides in on hover */
.oku-series-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.oku-series-card:hover .oku-series-meta {
    max-height: 50px;
    margin-top: 4px;
    opacity: 1;
}

/* Entry count badge */
.oku-series-entries {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 3px;
    background: rgba(139, 92, 246, 0.25);
    color: #a78bfa;
}

.oku-series-seasons {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

/* Score */
.oku-series-score {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fcd34d;
}

.oku-series-score svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* Progress bar */
.oku-series-progress {
    margin-top: 6px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.oku-series-card:hover .oku-series-progress {
    max-height: 30px;
    opacity: 1;
}

.oku-series-progress-text {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
    display: block;
    margin-bottom: 3px;
}

.oku-series-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.oku-series-progress-fill {
    height: 100%;
    background: var(--primary, #8b5cf6);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Status badge row */
.oku-series-status-row {
    margin-top: 6px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.oku-series-card:hover .oku-series-status-row {
    max-height: 30px;
    opacity: 1;
}

/* Status badge */
.oku-series-status {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 3px;
    background: rgba(107, 114, 128, 0.3);
    color: #9ca3af;
}

.oku-series-status.watching {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

.oku-series-status.completed {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.oku-series-status.plan-to-watch {
    background: rgba(167, 139, 250, 0.2);
    color: #a78bfa;
}

.oku-series-status.on-hold {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.oku-series-status.dropped {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

.oku-series-status.rewatching {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {
    /* Disable hover transform on mobile */
    .oku-series-card:hover {
        transform: none !important;
        z-index: 1 !important;
    }

    /* Show meta info always on mobile */
    .oku-series-meta,
    .oku-series-progress,
    .oku-series-status-row {
        max-height: none !important;
        opacity: 1 !important;
    }

    /* Simpler stacking on mobile */
    .oku-series-fanout-img {
        will-change: transform;
    }

    .oku-series-fanout-img[data-index="0"] {
        z-index: 5;
    }

    .oku-series-fanout-img[data-index="1"] {
        z-index: 4;
        opacity: 1 !important;
        filter: brightness(0.25);
        transform: translateX(3px) translateY(2px) rotate(1.5deg);
    }

    .oku-series-fanout-img[data-index="2"] {
        z-index: 3;
        opacity: 1 !important;
        filter: brightness(0.15);
        transform: translateX(6px) translateY(3px) rotate(3deg);
    }

    /* Hide extra cards on mobile */
    .oku-series-fanout-img[data-index="3"],
    .oku-series-fanout-img[data-index="4"] {
        opacity: 0 !important;
        pointer-events: none;
    }

    .oku-series-container {
        border-radius: 8px;
    }

    .oku-series-fanout-img {
        border-radius: 8px;
    }

    .oku-series-title {
        font-size: 0.8rem;
    }

    .oku-series-entries,
    .oku-series-status {
        font-size: 0.6rem;
    }
}

/* ========== Add/Edit Button ========== */
.series-add-btn {
    position: absolute;
    bottom: 16px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(var(--primary-rgb), 0.5);
    background: rgba(var(--primary-rgb), 0.4);
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
}

/* Show button on card hover */
.oku-series-card:hover .series-add-btn {
    opacity: 1;
    pointer-events: auto;
}

.series-add-btn svg {
    width: 16px;
    height: 16px;
}

.series-add-btn:hover {
    background: rgba(var(--primary-rgb), 0.6);
    border-color: rgba(var(--primary-rgb), 0.8);
    color: #fff;
    transform: scale(1.1);
}

/* Status-specific button colors */
.series-add-btn.status-watching {
    border-color: rgba(34, 197, 94, 0.6);
    background: rgba(34, 197, 94, 0.45);
    color: #fff;
}
.series-add-btn.status-watching:hover {
    background: rgba(34, 197, 94, 0.65);
    border-color: rgba(34, 197, 94, 0.8);
    color: #fff;
}

.series-add-btn.status-completed {
    border-color: rgba(59, 130, 246, 0.6);
    background: rgba(59, 130, 246, 0.45);
    color: #fff;
}
.series-add-btn.status-completed:hover {
    background: rgba(59, 130, 246, 0.65);
    border-color: rgba(59, 130, 246, 0.8);
    color: #fff;
}

.series-add-btn.status-plan {
    border-color: rgba(var(--primary-rgb), 0.6);
    background: rgba(var(--primary-rgb), 0.45);
    color: #fff;
}
.series-add-btn.status-plan:hover {
    background: rgba(var(--primary-rgb), 0.65);
    border-color: rgba(var(--primary-rgb), 0.8);
    color: #fff;
}

.series-add-btn.status-paused {
    border-color: rgba(234, 179, 8, 0.6);
    background: rgba(234, 179, 8, 0.45);
    color: #fff;
}
.series-add-btn.status-paused:hover {
    background: rgba(234, 179, 8, 0.65);
    border-color: rgba(234, 179, 8, 0.8);
    color: #fff;
}

.series-add-btn.status-dropped {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.45);
    color: #fff;
}
.series-add-btn.status-dropped:hover {
    background: rgba(239, 68, 68, 0.65);
    border-color: rgba(239, 68, 68, 0.8);
    color: #fff;
}

.series-add-btn.status-rewatching {
    border-color: rgba(6, 182, 212, 0.6);
    background: rgba(6, 182, 212, 0.45);
    color: #fff;
}
.series-add-btn.status-rewatching:hover {
    background: rgba(6, 182, 212, 0.65);
    border-color: rgba(6, 182, 212, 0.8);
    color: #fff;
}

/* ========== Neighbor Dim Effect ========== */
/* Directional dim effect - dims neighboring cards when hovering fanout cards */
/* Only applies to physically adjacent cards (respects row boundaries) */

/* === Direct cards (anime page) === */
/* Dim right neighbor when hovering a card with 3+ entries */
.oku-series-card[data-count="3"]:not(.row-end):hover + .oku-series-card,
.oku-series-card[data-count="4"]:not(.row-end):hover + .oku-series-card,
.oku-series-card[data-count="5"]:not(.row-end):hover + .oku-series-card {
    filter: brightness(0.7);
}

/* Dim left neighbor when hovering a card with 2+ entries */
.oku-series-card:not(.row-end):has(+ .oku-series-card[data-count="2"]:not(.row-start):hover),
.oku-series-card:not(.row-end):has(+ .oku-series-card[data-count="3"]:not(.row-start):hover),
.oku-series-card:not(.row-end):has(+ .oku-series-card[data-count="4"]:not(.row-start):hover),
.oku-series-card:not(.row-end):has(+ .oku-series-card[data-count="5"]:not(.row-start):hover) {
    filter: brightness(0.7);
}

/* === Wrapped cards (user page with .series-grid-card-wrapper) === */
/* Wrapper has data-count attribute for simpler selectors */

/* Dim right neighbor when hovering a wrapper with 3+ entries */
.series-grid-card-wrapper[data-count="3"]:not(.row-end):hover + .series-grid-card-wrapper .oku-series-card,
.series-grid-card-wrapper[data-count="4"]:not(.row-end):hover + .series-grid-card-wrapper .oku-series-card,
.series-grid-card-wrapper[data-count="5"]:not(.row-end):hover + .series-grid-card-wrapper .oku-series-card {
    filter: brightness(0.7);
}

/* Dim left neighbor when hovering a wrapper with 2+ entries */
.series-grid-card-wrapper:not(.row-end):has(+ .series-grid-card-wrapper[data-count="2"]:not(.row-start):hover) .oku-series-card,
.series-grid-card-wrapper:not(.row-end):has(+ .series-grid-card-wrapper[data-count="3"]:not(.row-start):hover) .oku-series-card,
.series-grid-card-wrapper:not(.row-end):has(+ .series-grid-card-wrapper[data-count="4"]:not(.row-start):hover) .oku-series-card,
.series-grid-card-wrapper:not(.row-end):has(+ .series-grid-card-wrapper[data-count="5"]:not(.row-start):hover) .oku-series-card {
    filter: brightness(0.7);
}

/* Disable dim effect on mobile */
@media (max-width: 768px) {
    .oku-series-card {
        filter: none !important;
    }
}

/* Mobile: always show button */
@media (max-width: 768px) {
    .series-add-btn {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* ========== Grid Layout Helper ========== */
.oku-series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .oku-series-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .oku-series-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}
