/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', serif;
    background: linear-gradient(135deg, #cfe2f3 0%, #9fc5e8 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: darkslategray;
    font-size: 3rem;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Index page card list */
.card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
}

.card-link {
    text-decoration: none;
    color: inherit;
}

.card-preview {
    position: relative;
    background: white;
    border-radius: 15px;
    padding: 0;
    overflow: hidden;
    /* 2:3 aspect ratio for rectangular cards */
    aspect-ratio: 2 / 3;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.card-preview:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0,0,0,0.2);
}

/* Image in card preview - fills entire card */
.card-preview .card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Icon in card preview - centers in card */
.card-preview .card-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    z-index: 1;
}

/* Title overlaid at bottom with gradient background */
.card-preview h2 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 20px 15px;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
    z-index: 10;
}

/* Card detail page */
.card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.card-wrapper {
    perspective: 1000px;
    width: 400px;
    height: 600px;
    margin-bottom: 30px;
}

.card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    overflow-y: auto;
}

.card-front {
    /* Front face with full-bleed image */
    padding: 0;
    overflow: hidden;
}

.card-back {
    transform: rotateY(180deg);
}

.card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-position: top;
    object-fit: cover;
    margin: 0;
}

.card-title {
    font-size: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: white;
    text-align: center;
    margin: 0;
    position: relative;
    z-index: 10;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
}

/* Title positioning on front of card */
.card-front .card-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
}

/* Title styling on back of card */
.card-back .card-title {
    color: #333;
    text-shadow: none;
    margin-top: 0;
}

.card-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #555;
    text-align: left;
}

/* Info button and popup */
.info-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    font-size: 1rem;
    font-weight: 600;
    font-style: italic;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.hidden {
    display: none;
}

.info-btn:hover {
    border-color: rgba(255, 255, 255, 0.9);
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.info-btn:active {
    transform: scale(0.95);
}

.info-popup {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 30;
    border-radius: 20px;
}

.info-popup.visible {
    display: flex;
}

.info-content {
    background: white;
    padding: 25px;
    border-radius: 15px;
    max-width: 85%;
    max-height: 80%;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.info-content h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.3rem;
}

.info-content p {
    margin: 8px 0;
    color: #555;
    line-height: 1.5;
}

.info-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.info-content a:hover {
    text-decoration: underline;
}

.info-license {
    font-size: 0.9rem;
    font-style: italic;
    color: #888;
    margin-top: 15px !important;
}

.info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.info-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
}

.btn {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    padding: 15px 30px;
    font-size: 1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

/* Responsive design */
@media (max-width: 768px) {
    p {
        font-size: 1rem;
    }

    .card-title {
        font-size: 1.25rem;
    }

    .card-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        padding: 10px;
    }

    .card-wrapper {
        width: 100%;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
    }
}
