/* ====================== */
/* Boardgame Collection Page Styles */
/* ====================== */

.page-shell.loading {
    opacity: 0;
    transition: opacity 0.3s ease;
    min-height: 100vh;
}

.page-shell.loaded {
    opacity: 1;
    min-height: unset;
}

/* Section Setup */
.games-section {
    position: relative;
    background: linear-gradient(to bottom, #1e1e1e, #3a3a3a);
    overflow: hidden;
    padding: 30px 0 80px 0; /* Top 30px, Bottom 60px */
    transform: translateZ(0); /* if you still want GPU-acceleration */
    will-change: transform;
}

.games-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("../images/stars-parallax.png") repeat;
    background-size: 1000px auto;
    opacity: 0.1;
    animation: moveBackground 180s linear infinite;
    z-index: 0;
}
@keyframes moveBackground {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 1000px;
    }
}

.games-section h1 {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 40px;
    color: #cce7ff;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
    animation: fadeUp 1s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
    animation-delay: 0.2s;
}

/* Mobile Friendly Heading */
@media (max-width: 768px) {
    .games-section h1 {
        font-size: 2rem;
        padding: 0 20px; /* Add some side padding */
        line-height: 1.2;
    }
}

.section-divider {
    width: 80px;
    height: 4px;
    background: rgb(0, 183, 255);
    margin: 20px auto 40px auto;
    border-radius: 2px;
}

.hidden {
    display: none !important;
}

#emptyMessage {
    font-size: 20px;
    color: #cce7ff;
    text-align: center;
    margin-top: 60px;
    animation: fadeIn 0.4s ease;
}

.games-grid.empty #emptyMessage {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

/* Boardgame Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 300px);
    place-content: center;
    gap: 30px;
    margin: 40px 0 0 0;
    padding: 0 16px;
}

.games-grid {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.games-grid.loading {
    min-height: 1000px; /* Adjust to match approximate height of a few cards */
}

.games-grid.loaded {
    opacity: 1;
}

#gameCount {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#gameCount.visible {
    opacity: 1;
}

/* Individual Game Cards */
.game-card {
    background: none;
    border-radius: 15px;
    overflow: visible;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 2000px;
    min-height: 450px; /* Ensures all cards have similar height */
    max-width: 300px;
}

/* Image Wrapper */
.game-image-wrapper {
    flex-shrink: 0;
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 0px;
    padding: 25px;
    padding-top: 13px;
    padding-bottom: 0px;
}

.game-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

/* Title and Description */
.game-title {
    font-size: 22px;
    color: rgb(0, 122, 204);
    margin: 0;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    word-break: break-word;

    /* Clamp to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-title-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    width: 100%;
    text-align: center;
}

.game-attributes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    padding: 0px;
    margin-top: 0px;
    color: #555;
}

.game-attributes div {
    white-space: nowrap;
}

.game-rating-star {
    position: absolute;
    top: -5px;
    right: 0px;
    width: 75px; /* bigger star */
    height: 75px; /* bigger star */
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 53 48"><defs><linearGradient id="grad" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:%23ffe066;stop-opacity:1" /><stop offset="100%" style="stop-color:%23ff9900;stop-opacity:1" /></linearGradient></defs><polygon points="26.5,0 34.5,17 53,18 38,30 43,48 26.5,39 10,48 15,30 0,18 18,17" fill="url(%23grad)"/></svg>')
        no-repeat center/contain;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transform: rotate(20deg);
    background-size: 85%;
    background-position: center;
    background-repeat: no-repeat;
}

.rating-number {
    font-size: 18px; /* bigger rating text */
    font-weight: bold;
    color: #333;
    text-shadow: 0 0 3px white;
    transform: translateY(4px); /* move number slightly DOWN */
}

.ribbon {
    position: absolute;
    top: 12px;
    left: -40px;
    transform: rotate(-40deg);
    background: #ff8c00;
    color: white;
    font-weight: bold;
    font-size: 12px;
    width: 140px;
    text-align: center;
    padding: 4px 0;
    padding-right: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 5;
    pointer-events: none;
}

/* Responsive Tweaks */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(auto-fit, 300px);
        place-content: center;
        gap: 20px;
    }

    .game-card {
        max-width: 300px;
        width: 100%;
    }

    .game-card-inner {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .game-image-wrapper {
        height: 230px;
        padding: 10px;
        padding-top: 20px;
        margin-bottom: 0px;
    }

    .game-title {
        font-size: 20px;
        margin-bottom: 5px;
    }

    .game-attributes {
        padding: 0px;
        gap: 3px;
        font-size: 14px;
    }

    .rating-number {
        font-size: 16px;
    }

    .game-details {
        font-size: 13px;
        gap: 4px;
        margin-top: 5px;
    }

    .game-card-back .game-cover-small {
        display: none !important;
    }
}

/* ========== Flip Card Setup ========== */
.game-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s ease, box-shadow 0.8s ease;
    transform-style: preserve-3d;
    transform-origin: center center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); /* <<< normal resting shadow */
}

/* Desktop Hover Flip (only on hover devices!) */
@media (hover: hover) and (pointer: fine) {
    .game-card:not(.add-game-card):hover .game-card-inner {
        transform: rotateY(180deg);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    }

    .game-card:not(.add-game-card):hover .game-card-back {
        opacity: 1;
    }
}

/* Mobile Tap Flip (flip-mobile class active) */
.game-card-inner.flip-mobile:not(.add-game-card .game-card-inner) {
    transform: rotateY(180deg);
}

.game-card-inner.flip-mobile:not(.add-game-card .game-card-inner)
    .game-card-back {
    opacity: 1;
}

@media (max-width: 768px) {
    .game-card-inner {
        transition: transform 0.5s ease, box-shadow 0.5s ease;
    }
}

/* Front and Back Faces */
.game-card-front,
.game-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Front Style */
.game-card-front {
    background: linear-gradient(
        to right,
        #ffffff,
        #cce7ff
    ); /* subtle blue tone */
    color: #333;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100%; /* take full height of card */
    padding: 12px;
}

/* Back Style */
.game-card-back {
    background: rgb(0, 122, 204);
    color: white;
    transform: rotateY(180deg) translateZ(0);
    position: relative;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    opacity: 0; /* <<< start invisible */
    transition: opacity 0.3s ease 0.3s; /* <<< fade in with a delay */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    backface-visibility: hidden;
}

.game-card-back .game-title {
    margin-top: 15px;
    color: white;
}

/* Back Title + Divider */
.game-card-back h2 {
    margin-bottom: 10px;
    position: relative;
}

.game-card-back h2::after {
    content: "";
    display: block;
    width: 40%;
    margin: 8px auto 0 auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

.game-year {
    font-size: 13px;
    color: rgb(255, 255, 255);
    text-align: center;
    margin-top: -4px;
    margin-bottom: 8px;
}

/* Front Inner Content */
.game-attributes {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Back Inner Content */
.game-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    text-align: left;
    width: 90%;
    margin-top: 10px;
    margin-left: 5%; /* slight right shift */
}

/* Tiny Cover Image */
.game-cover-small {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.game-cover-small img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    box-shadow: none;
}

.remove-button {
    position: absolute;
    width: 130px;
    bottom: 10px;
    left: 10px;
    background: linear-gradient(to right, #00b7ff, #007acc);
    color: white;
    font-weight: bold;
    letter-spacing: 0.5px;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 2;
    text-align: left;
}

.remove-button:hover {
    background: #005fa3;
    transform: scale(1.05);
}

.edit-button {
    position: absolute;
    width: 130px;
    bottom: 60px;
    left: 10px;
    background: linear-gradient(to right, #00b7ff, #007acc);
    color: white;
    font-weight: bold;
    letter-spacing: 0.5px;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 2;
    text-align: left;
}

.edit-button:hover {
    background: #005fa3;
    transform: scale(1.05);
}

/* === Add Game Card === */
.add-game-card .add-icon-svg {
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.85;
}

.add-game-card:hover .add-icon-svg {
    transform: scale(1.05);
    opacity: 1;
}

.add-game-card .game-card-inner.flip-mobile {
    transform: none !important;
}

.add-game-card .game-card-back {
    opacity: 1; /* or your intended value */
}

.inline-input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
}

.input-label {
    display: block;
    font-weight: bold;
    font-size: 15px;
    color: #007acc;
    margin-top: 12px;
    margin-bottom: 0px;
}

.rating-scale label {
    display: block;
    font-weight: bold;
    font-size: 15px;
    color: #007acc;
    margin-top: 12px;
    margin-bottom: 8px;
}

.rating-options {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
    justify-content: center;
}

@media (max-width: 768px) {
    .rating-options {
        display: none;
    }
}

.rating-options button {
    width: 32px;
    text-align: center;
    padding: 6px 0;
    font-size: 13px;
    margin-top: 0 !important;
    border: 1px solid rgb(0, 183, 255);
    border-radius: 4px;
    background-color: #f0f8ff;
    color: rgb(0, 183, 255);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.rating-options button:hover {
    background-color: rgb(0, 150, 210);
}

.rating-options button.selected {
    background: rgb(0, 150, 210);
    color: white;
    font-weight: bold;
}

#ratingOverride {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    box-sizing: border-box;
}

select[multiple] {
    min-height: 120px;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    padding: 8px;
    background-color: white;
}

#mechanicsSelect {
    min-height: 160px;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    padding: 10px 12px;
    background-color: #f8fbff;
    font-size: 14px;
    color: #333;
    margin-top: 8px;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: auto;
    white-space: normal; /* allows wrapping if needed */
}

#mechanicsSelect:focus {
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
    outline: none;
}

label[for="mechanicsSelect"] {
    font-weight: bold;
    font-size: 15px;
    color: #007acc;
    margin: 12px 2px 0px;
    display: block;
}

.types-toggle-switches {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin-top: 12px;
    padding: 0;
    border: none;
}

.types-toggle-switches legend {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 8px;
    color: #007acc;
    grid-column: span 2;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #333;
}

.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #b3d9ff; /* light border color when off */
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background: rgb(0, 183, 255);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* === Add Game Modal === */
body.modal-open {
    overflow: hidden;
}

.card-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    padding-bottom: 5vh;
    overflow-y: auto;
    z-index: 2000;
}

.card-modal.hidden {
    display: none;
}

.card-modal-content {
    background: linear-gradient(to bottom, #ffffff, #f0f8ff);
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: 0 12px 40px rgba(0, 123, 204, 0.3);
    font-family: "Roboto", sans-serif;
    animation: fadeInScale 0.3s ease-out forwards;
    max-height: 70vh; /* ensures the modal fits in the viewport */
    overflow-y: auto; /* enables inner scroll */
    overscroll-behavior: contain; /* prevents scroll chaining on mobile */
}

@media (max-width: 768px) {
    .card-modal-content {
        padding: 20px 16px;
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOutScale {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.modal-closing .card-modal-content {
    animation: fadeOutScale 0.2s ease-out forwards;
}

.card-modal-content h2 {
    margin-top: 0;
    font-size: 24px;
    text-align: center;
    color: #007acc;
    margin-bottom: 20px;
}

.card-modal-content input,
.card-modal-content select,
.card-modal-content button {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #b3d9ff;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
}

.card-modal-content input:focus,
.card-modal-content select:focus {
    outline: none;
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.card-modal-content button {
    background: rgb(0, 183, 255);
    color: white;
    font-weight: bold;
    letter-spacing: 0.5px;
    border: none;
    transition: background 0.2s ease;
}

.card-modal-content button:hover {
    background: rgb(0, 150, 210);
}

.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: none;
    color: #666;
    font-size: 22px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    user-select: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
}

.bgg-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.bgg-preview img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #ccc;
}

.bgg-preview p {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.inline-inputs {
    display: flex;
    gap: 12px;
}

.inline-inputs input {
    flex: 1;
}

/* === Confirm Remove Modal === */
#confirmRemoveModal .card-modal-content h2 {
    color: #d9534f; /* red tone to signal danger */
}

#confirmRemoveModal .card-modal-content p {
    font-size: 16px;
    color: #333;
    text-align: center;
}

#confirmRemoveModal .card-modal-content button {
    flex: 1;
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 8px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

/* Abbrechen */
#confirmRemoveModal .card-modal-content button:first-child {
    background: #e0e0e0;
    color: #333;
}

#confirmRemoveModal .card-modal-content button:first-child:hover {
    background: #d0d0d0;
}

/* Entfernen / Danger */
#confirmRemoveModal .card-modal-content button:last-child {
    background: linear-gradient(to right, #ff5f5f, #cc0000);
    color: white;
}

#confirmRemoveModal .card-modal-content button:last-child:hover {
    background: #a30000;
}

#confirmRemoveModal .card-modal-content {
    animation: fadeInScale 0.3s ease-out forwards;
}

#confirmRemoveModal.modal-closing .card-modal-content {
    animation: fadeOutScale 0.2s ease-out forwards;
}

.import-bgg-button {
    width: 100%;
    max-width: 400px;
    font-size: 16px;
    padding: 12px;
    margin-top: 20px;
    border-radius: 25px;
    font-weight: bold;
    background: rgb(0, 183, 255);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px rgba(0, 183, 255, 0.3);
}

.import-bgg-button:hover {
    background: rgb(0, 150, 210);
}

.cancel-import-button {
    width: 100%;
    max-width: 400px;
    font-size: 16px;
    padding: 12px;
    margin-top: 20px;
    border-radius: 25px;
    font-weight: bold;
    background: #cc0000;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 10px #cc000049;
}

.cancel-import-button:hover {
    background: #a30000;
}

#importProgressContainer {
    width: 100%;
    max-width: 600px;
    margin: 30px auto;
    background: #444;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#importProgressBar {
    width: 0%;
    height: 24px;
    background: rgb(0, 183, 255);
    transition: width 0.3s ease;
}

#importProgressText {
    text-align: center;
    color: #cce7ff;
    font-size: 16px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.games-section > .container {
    position: relative;
    z-index: 1;
}

/* === Loading Spinner === */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 183, 255, 0.3);
    border-top: 4px solid #00b7ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner.hidden {
    display: none;
}
