@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --table-bg: #fdfaf6;
    --card-bg: #ffffff;
    --text-main: #2d2d2d;
    --text-muted: #666666;
    --accent-rare: #3498db;
    --accent-legendary: #d4af37;
    --border-color: rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #f8f9fa;
    background-image: radial-gradient(#e0e0e0 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
}

/* Minimalist Header */
.container {
    max-width: 700px;
    width: 100%;
    text-align: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
}

h1 {
    font-family: 'Lora', serif;
    font-size: clamp(2rem, 5vw, 2.8rem); /* Responsive size */
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
    color: #1a1a1a;
}

/* Accessibility: Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--text-main);
    color: white;
    padding: 8px;
    z-index: 2000;
    transition: top 0.3s;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Better focus states */
button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent-rare);
    outline-offset: 4px;
}

p {
    font-size: 1rem;
    font-weight: 300;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0.5px;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
}

.social-links a {
    color: var(--text-main);
    font-size: 1.2rem;
    opacity: 0.4;
    transition: all 0.3s;
    text-decoration: none;
}

.social-links a:hover {
    opacity: 1;
    transform: translateY(-2px);
}

/* Table Controls */
.controls {
    display: flex;
    gap: 12px;
    margin-top: -10px; /* Densify */
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 100;
}

.btn-table {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-table:hover {
    background: #fcfcfc;
    border-color: #ccc;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transform: translateY(-1px);
}

/* Card Design - Collector's Style */
.project-grid {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1600px;
    min-height: 100vh;
    margin: 0;
    pointer-events: none;
}

.project-card {
    pointer-events: auto;
    width: 230px;
    height: 380px; /* Increased height for better breathing room */
    perspective: 1000px;
    cursor: grab;
    user-select: none;
    position: absolute;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%; /* Match fixed parent height */
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.project-card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    padding: 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    overflow: hidden; 
    isolation: isolate; 
}

/* Shiny Effect moved to faces */
.card-front::after {
    content: "";
    position: absolute;
    top: -150%;
    left: -150%;
    width: 300%;
    height: 300%;
    background: linear-gradient(135deg, rgba(255,255,255,0) 45%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0) 55%);
    z-index: 2;
    pointer-events: none;
    transition: all 0s;
    opacity: 0.8;
}

.project-card:active .card-front::after {
    top: 150%;
    left: 150%;
    transition: all 0.8s ease-in-out;
}

/* Pinned state - pressed against the table */
.project-card[data-pinned="true"] .card-front,
.project-card[data-pinned="true"] .card-back {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Rarity Full Borders & Shiny */
.project-card.rare .card-front, 
.project-card.rare .card-back {
    border-color: var(--accent-rare);
    border-width: 3px; /* Thicker for impact */
    box-shadow: 0 8px 30px rgba(52, 152, 219, 0.15); /* Thematic glow */
}

.project-card.legendary .card-front, 
.project-card.legendary .card-back {
    border-color: var(--accent-legendary);
    border-width: 3px;
    background: linear-gradient(to bottom, #fff, #fff9e6); /* Warmer gold tint */
    box-shadow: 0 10px 40px rgba(212, 175, 55, 0.2); /* Golden glow */
}

.project-card.legendary .card-front::after {
    background: linear-gradient(135deg, rgba(255,255,255,0) 45%, rgba(212, 175, 55, 0.4) 50%, rgba(255,255,255,0) 55%);
}

/* Elevation and Interaction */
.project-card.is-dragging {
    cursor: grabbing;
    z-index: 1000;
    transform: scale(1.08) rotate(0deg) !important;
}

.project-card.is-dragging .card-front,
.project-card.is-dragging .card-back {
    box-shadow: 0 30px 60px rgba(0,0,0,0.18);
}

.project-card img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.project-card:hover img {
    filter: grayscale(0%);
}

.card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card .title {
    font-family: 'Lora', serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
}

.project-card .desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 12px;
    flex-grow: 1;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.rarity-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    color: #bbb;
}

/* Rarity Accents */
.project-card.rare {
    border-top: 4px solid var(--accent-rare);
}
.project-card.rare .rarity-badge { color: var(--accent-rare); }

.project-card.legendary {
    border-top: 4px solid var(--accent-legendary);
    background: linear-gradient(to bottom, #fff, #fff9e6);
}
.project-card.legendary .rarity-badge { color: var(--accent-legendary); }

/* Actions */
.card-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    background: none;
    border: none;
    padding: 0;
    color: #ccc;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    outline: none; /* Reset default focus */
}

.action-btn:focus-visible {
    outline: 2px solid var(--accent-rare);
    outline-offset: 4px;
}

.action-btn:hover { color: var(--text-main); transform: scale(1.2); }
.action-btn.pinned { color: var(--accent-legendary); opacity: 1; }

/* Mobile & Tablet: The Ordered Stack */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .container {
        margin-bottom: 2rem;
        padding: 1rem;
        border-bottom: none;
    }

    h1 {
        font-size: 2.2rem;
    }

    .controls {
        position: sticky;
        top: 10px;
        z-index: 1000;
        justify-content: center;
        width: auto;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(10px);
        padding: 8px 15px;
        border-radius: 50px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.05);
        border: 1px solid rgba(0,0,0,0.05);
    }

    #shuffleBtn {
        display: none !important; /* Scatter makes no sense on mobile */
    }

    .project-grid {
        position: relative !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        padding: 1rem;
        min-height: auto;
        margin-top: 2rem;
        left: 0;
        transform: none;
    }

    .project-card {
        position: relative !important;
        width: 100%;
        max-width: 340px;
        height: 420px !important; /* More space on mobile */
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
        margin: 0;
        animation: cardEntry 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    }

    .project-card img {
        aspect-ratio: 16/9; /* Less height consumed on mobile */
        height: auto;
    }

    /* Staggered entry animation */
    .project-card:nth-child(1) { animation-delay: 0.1s; }
    .project-card:nth-child(2) { animation-delay: 0.2s; }
    .project-card:nth-child(3) { animation-delay: 0.3s; }
    .project-card:nth-child(4) { animation-delay: 0.4s; }
    .project-card:nth-child(5) { animation-delay: 0.5s; }

    .project-card:active {
        transform: scale(0.98) !important; /* Press effect instead of lift */
    }
}

@keyframes cardEntry {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Collection Counter */
.collection-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    pointer-events: none;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .collection-counter {
        bottom: 15px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        padding: 4px 10px;
        font-size: 0.7rem;
    }
}

.card-back {
    transform: rotateY(180deg);
    background: #1a1a1a; /* Solid dark background */
    color: #ffffff;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.card-back::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle internal border */
    border-radius: 8px;
    opacity: 0.5;
    pointer-events: none;
}

.quote-container {
    padding: 30px;
    font-style: italic;
}

.quote-container p {
    color: #f0f0f0;
    font-size: 1rem;
    line-height: 1.6;
    font-family: 'Lora', serif;
}

.quote-container i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.2);
}

/* Dark Back Style */
.card-back {
    background: #1a1a1a !important; /* Solid dark background */
    color: #ffffff;
}

.card-back .quote-container p {
    color: #f0f0f0;
    font-size: 1rem;
    line-height: 1.5;
    font-family: 'Lora', serif;
}

.card-back .quote-container i {
    color: rgba(255, 255, 255, 0.2);
}

.card-back .fallback-pattern {
    display: none; /* Hide placeholder for now */
}

/* Rarity-based Card Backs */
.project-card.rare .card-back {
    background: #0d253f !important; /* Deep Midnight Blue */
}

.project-card.legendary .card-back {
    background: #4a3c10 !important; /* Deep Antique Gold */
}

/* Ensure consistent internal border for all backs */
.card-back::before {
    border-color: rgba(255, 255, 255, 0.15);
}
