/* Google Font */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap'); /* Poppins eklendi */

/* === Arka Plan (Yıldızlı gökyüzü) === */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: black url('https://raw.githubusercontent.com/kubowania/starry-night-animation/main/stars.png') repeat;
    z-index: -2;
    animation: moveStars 200s linear infinite;
    opacity: 0.4;
}

@keyframes moveStars {
    from { background-position: 0 0; }
    to { background-position: -10000px 5000px; }
}

/* === Temel Gövde Ayarları === */
body {
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif; /* Poppins olarak güncellendi */
    background: linear-gradient(to bottom right, #3e1f47, #6a4c93);
    color: #f0e6f6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: start;
    overflow-y: auto; /* Dikey kaydırmayı etkinleştir */
}

/* === Sayfa Konteyneri === */
.container {
    text-align: center;
    padding: 20px;
    max-width: 1000px;
    width: 100%;
    position: relative; /* Mesaj alanı için */
    z-index: 1; /* Arka planın üzerinde kalması için */
}

/* === Başlık ve Alt Başlık === */
h1 {
    font-family: 'Crimson Pro', serif; /* Başlık fontu korundu */
    font-size: 40px;
    margin-bottom: 10px;
    color: #fefefe;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.subtitle {
    font-size: 18px;
    color: #d9b8ff;
    margin-bottom: 30px;
}

/* === Mesaj Alanı === */
.message-area {
    font-size: 1.1em;
    color: #ffda79; /* Sarımsı bir renk */
    margin-top: 15px;
    height: 20px; /* Yer tutucu yükseklik */
    opacity: 0; /* Başlangıçta gizli */
    transition: opacity 0.5s ease-in-out;
}

.message-area.show {
    opacity: 1;
}

/* === Buton Stili === */
button {
    padding: 12px 28px;
    font-size: 18px;
    background-color: #9d4edd;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease, transform 0.2s ease;
}

button:hover {
    background-color: #7b2cbf;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

/* === Kart Konteyneri === */
.card-container {
    display: flex;
    flex-direction: row;
    justify-content: center; /* Ortaya hizalama */
    align-items: center;
    position: relative;
    height: 200px; /* Yükseklik arttırıldı */
    padding: 40px 0; /* Yatayda padding kaldırıldı, dikeyde korundu */
    overflow-x: auto; /* Yatay kaydırma */
    white-space: nowrap;
    margin-top: 30px;
    scroll-behavior: smooth; /* Kaydırma animasyonu */
}

.card-container .card {
    position: relative;
    margin-left: -112px;
    z-index: 1;
    transition: transform 0.3s ease, z-index 0.3s ease, margin-left 0.3s ease; /* margin-left transition eklendi */
    flex: 0 0 auto;
}

.card-container .card:first-child {
    margin-left: 0;
}

.card-container .card:not(.flipped):hover { /* Çevrilmemiş kartlar için hover efekti */
    transform: translateY(-10px) scale(1.05);
    z-index: 10;
}

/* === Kart Temel Stil === */
.card {
    width: 120px;
    height: 175px;
    perspective: 1000px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid #ffffff22;
    border-radius: 10px;
    box-shadow: 0 0 10px #00000044;
    color: #fff;
    text-align: center;
    flex-shrink: 0; /* Kartların küçülmesini engelle */
}

/* === Kart İç Yapısı (Flip için) === */
.card-inner {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Yaylı animasyon */
    position: relative;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* === Kart Yüzeyleri === */
.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    overflow: hidden;
    background-color: #fff;
}

.card-front {
    transform: rotateY(180deg);
}

.card-front img,
.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block !important;
}

/* === Kart Bilgi Alanları (Ön Yüz) === */
.card-front h2 {
    font-size: 1em; /* Daha küçük font */
    margin: 5px 0 2px;
    color: #3e1f47; /* Koyu renk */
    text-align: center;
    padding: 0 5px;
    line-height: 1.2;
}

/* '-webkit-line-clamp' sorununu gidermek için potansiyel düzeltme */
.card-front p {
    font-size: 0.75em; /* Daha küçük font */
    color: #6a4c93; /* Daha açık mor */
    margin: 0 5px;
    text-align: center;
    overflow: hidden; /* Taşmayı gizle */
    text-overflow: ellipsis; /* Taşmayı üç nokta ile göster */
    /* Aşağıdaki iki satırın varlığından ve doğru çalıştığından emin olun */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; /* İki satırla sınırla */
    white-space: normal; /* Metnin normal şekilde sarılmasını sağlar */
}


/* === Seçilen Kartlar (Üst üste bindirme efekti) === */
.selected-cards-row {
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Kartları alta hizala */
    margin-top: 40px;
    min-height: 180px; /* Yeterli alan bırak */
    position: relative;
    padding: 10px;
    gap: 20px; /* Kartlar arasında boşluk */
    flex-wrap: wrap; /* Küçük ekranlarda sarmasını sağlar */
}

.selected-cards-row .card {
    margin-left: 0; /* Üst üste binme kaldırıldı */
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
    transform: translateY(0); /* Yeni pozisyonlandırma */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.selected-cards-row .card:hover {
    transform: translateY(-5px) scale(1.05); /* Hover efekti küçültüldü */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* === Modal (Detay açıklama kutusu) === */
.modal {
    display: none; /* Başlangıçta gizli tut */
    position: fixed;
    z-index: 100; /* Diğer her şeyin üzerinde olması için */
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    opacity: 0; /* Başlangıçta opaklık 0 */
    transition: opacity 0.3s ease-out;
}

.modal.show {
    display: flex; /* 'show' sınıfı eklendiğinde modalı görünür yap */
    opacity: 1;
}

.modal-content {
    background-color: #321f3e;
    color: #f0dfff;
    margin: 0 20px; /* Küçük ekranlarda kenar boşluğu */
    padding: 30px;
    border: 1px solid #aa73e8;
    width: 90%; /* Daha esnek genişlik */
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 0 25px rgba(203, 164, 255, 0.6); /* Daha belirgin gölge */
    font-family: 'Crimson Pro', serif;
    position: relative;
    transform: translateY(-20px); /* Açılış animasyonu */
    transition: transform 0.3s ease-out;
}

.modal.show .modal-content {
    transform: translateY(0);
}

/* === Modal Kapatma Butonu === */
.close {
    color: #ffffff;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    position: absolute; /* İçerik kaydırılmasın diye */
    top: 10px;
    right: 20px;
}

.close:hover {
    color: #d06fff;
}

/* === Karıştırma (Shuffle) Animasyonu === */
@keyframes advancedShuffle {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    25% { transform: translate(20px, -10px) rotate(5deg); opacity: 0.8; }
    50% { transform: translate(-20px, 10px) rotate(-5deg); opacity: 0.9; }
    75% { transform: translate(15px, -5px) rotate(3deg); opacity: 0.85; }
    100% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
}

.card.shuffle {
    animation: advancedShuffle 0.8s ease-in-out forwards;
}

/* Mobil Duyarlılık */
@media (max-width: 768px) {
    h1 {
        font-size: 32px;
    }

    .subtitle {
        font-size: 16px;
    }

    .card-container {
        height: 160px; /* Daha küçük kartlar için */
        padding: 20px 0;
    }

    .card {
        width: 100px; /* Kart genişliği daraltıldı */
        height: 145px; /* Kart yüksekliği daraltıldı */
        margin-left: -90px; /* Üst üste binme oranı ayarlandı */
    }

    .card-container .card:first-child {
        margin-left: 0;
    }

    .selected-cards-row {
        flex-direction: column; /* Seçilen kartlar dikeyde sıralansın */
        gap: 15px; /* Dikey boşluk */
        margin-top: 30px;
    }

    .selected-cards-row .card {
        width: 100px;
        height: 145px;
        margin-left: 0; /* Dikeyde olduğu için */
    }

    .modal-content {
        padding: 20px;
        margin: 5% 10px;
    }

    .close {
        font-size: 24px;
        top: 5px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 28px;
    }
    .card-container {
        height: 140px;
    }
    .card {
        width: 80px;
        height: 115px;
        margin-left: -70px;
    }
    .selected-cards-row .card {
        width: 80px;
        height: 115px;
    }
    .modal-content {
        font-size: 0.9em;
    }
}