/* Additional styles beyond Bootstrap */

body {
    padding-bottom: 40px;
    overflow-x: hidden;
    max-width: 100%;
}

.card {
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-header {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.badge {
    font-size: 0.85em;
}

/* Table styles */
.table {
    margin-bottom: 0;
}

.table thead th {
    position: sticky;
    top: 0;
    background-color: var(--bs-body-bg);
    z-index: 1;
}

/* Search functionality */
#mp-search {
    transition: width 0.3s ease;
}

#mp-search:focus {
    box-shadow: none;
    border-color: var(--bs-primary);
}

/* MP portrait styling */
.mp-portrait {
    border-radius: 4px;
    border: 1px solid var(--bs-border-color);
    object-fit: cover;
    transition: transform 0.2s ease-in-out;
}

.mp-portrait:hover {
    transform: scale(2.5);
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.placeholder-image {
    background-color: rgba(var(--bs-secondary-rgb), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid var(--bs-border-color);
}

/* Flashcard component */
.flashcard {
    width: 300px;
    height: 520px; /* Increased from 450px to 520px for more space */
    perspective: 1000px;
    margin: 0 auto;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    background-color: #ffffff; /* White background */
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 15px;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.95);
}

.flashcard-back {
    transform: rotateY(180deg);
    padding-top: 10px;
    padding-bottom: 25px; /* Added bottom padding to ensure everything is visible */
}

.mp-portrait-large {
    max-width: 95%;
    max-height: 180px; /* Reduced from 200px to save space */
    border-radius: 8px;
    object-fit: contain;
    margin-bottom: 10px;
    margin-top: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mp-placeholder {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(240, 240, 240, 0.5);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.mp-portrait-small {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.mp-placeholder-small {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

/* Party badge styles */
.party-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 5px;
    margin: 6px 0 10px 0; /* Added bottom margin to 10px */
    font-weight: 500;
    font-size: 0.9rem;
    color: white;
}

.score-display {
    display: none !important; /* Hide the old score display */
    font-size: 1.1rem;
    font-weight: 500;
}

.score-display .badge {
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background-color: #f8f9fa;
}

.constituency-text {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
    padding: 6px 10px;
    margin-top: 12px !important; /* Increased from 8px to 12px */
    background-color: rgba(240, 240, 240, 0.7);
    border-radius: 6px;
    display: inline-block;
    width: auto;
    max-width: 95%;
}

.labour { background-color: #d50000; }
.conservative { background-color: #0087dc; }
.liberal-democrats { background-color: #faa61a; color: #222; }
.green { background-color: #6ab023; }
.snp { background-color: #fdf38e; color: #333; }
.plaid { background-color: #3f8428; }
.reform { background-color: #12b6cf; }
.independent { background-color: #777777; }
.dup { background-color: #d46a4c; }
.sdlp { background-color: #2aa82c; }
.alliance { background-color: #f6cb2f; color: #333; }
.sinn-fein { background-color: #326760; }

/* Admin link */
.admin-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card-header h3 {
        font-size: 1.5rem;
    }
    
    .table-responsive {
        max-height: 500px;
        overflow-y: auto;
    }
    
    .mp-portrait:hover {
        transform: scale(1.8);
    }
    
    .flashcard {
        width: 280px;
        height: 500px; /* Increased to match the main flashcard height */
    }
    
    .mp-portrait-large {
        max-height: 200px;
    }
    
    .constituency-text {
        margin-top: 10px !important;
        max-width: 90%;
    }
    
    .mp-placeholder {
        height: 220px;
    }
}

/* Simplified sparkle effects */
.sparkle {
    position: absolute;
    background-color: gold;
    border-radius: 50%;
    opacity: 1;
    pointer-events: none;
    will-change: transform, opacity; /* Performance optimization hint */
}

/* Simple 4-point star - more efficient */
.sparkle.star-type-0, .sparkle.star-type-1, .sparkle.star-type-2 {
    clip-path: polygon(
        50% 0%,
        65% 35%,
        100% 50%,
        65% 65%,
        50% 100%,
        35% 65%,
        0% 50%,
        35% 35%
    );
}

/* Vertical feed styles */
.feed-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
}

.mp-card {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.mp-portrait-fullscreen {
    height: 100%;
    width: 100%;
    object-fit: scale-down;
    object-position: center center;
    position: relative;
}

.vertical-scroll-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.mp-cards {
    position: relative;
    width: 100%;
    height: 100%; /* Set to 100% for single card view with absolute positioning */
    will-change: transform; /* Performance hint for browsers */
    transform: translateZ(0); /* Force GPU acceleration */
}

.mp-card-container {
    position: relative;
    width: 100%;
    height: 100vh; /* Full viewport height */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000; /* Dark background for edges */
}

/* Support for the next card that slides in (TikTok style) */
.mp-card-container.next-card {
    position: absolute;
    top: 100%; /* Position below current card initially */
    left: 0;
    z-index: 5; /* Lower than current card */
}

.mp-loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #333;
}

.timer-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    background-color: #ffffff;
    width: 0;
    max-width: 100%;
    z-index: 110;
    transition: width 5s linear;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    transform-origin: left center;
}

.top-menu {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 110;
}

.menu-button {
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    padding: 10px;
    width: 200px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 120;
}

.menu-dropdown.show {
    display: block;
}

.score-display-top {
    position: absolute;
    top: 15px;
    left: 15px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 8px 12px;
    border-radius: 20px;
    color: white;
    font-weight: 500;
    z-index: 110;
    display: flex;
    align-items: center;
}

.score-display-top button {
    margin-left: 8px;
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    z-index: 100;
}

.mp-info-overlay.revealed {
    transform: translateY(0);
}

/* Hide overlay completely during transitions */
.mp-info-overlay.transitioning,
.mp-info-overlay.transitioning *,
.mp-info-overlay.transitioning .mp-info-header,
.mp-info-overlay.transitioning .mp-name,
.mp-info-overlay.transitioning .constituency-label {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(100%) !important;
    transition: none !important;
    pointer-events: none !important;
    display: none !important;
}

.mp-info-content {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7) 50%, transparent 100%);
    padding: 0; /* No padding needed with absolute positioning */
    position: relative; /* For absolute positioning of children */
    width: 100%;
    height: 100%; /* Full height */
}

.bottom-controls {
    position: absolute;
    bottom: 40px; /* Position from the bottom */
    left: 0;
    right: 0;
}

.answer-buttons {
    display: flex;
    justify-content: center;
    gap: 30px; /* Increased spacing between buttons */
}

.answer-button {
    width: 60px !important;
    height: 60px !important;
    padding: 0;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 60px !important;
    min-height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
}

.answer-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.answer-button i {
    margin: 0;
}

.answer-button.correct {
    background-color: #4caf50;
}

.answer-button.wrong {
    background-color: #f44336;
}

.answer-button:active {
    transform: scale(0.95);
}

.mp-info-header {
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    padding: 8px 15px; /* Further reduced vertical padding */
    position: absolute; 
    bottom: 120px; /* Position from bottom */
    left: 20px;
    right: 20px;
}

.mp-name {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 2px; /* Minimized margin */
}

.constituency-label {
    font-size: 16px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    margin: 0; /* No margin */
}

/* Party colors */
.mp-info-header.labour { background-color: #d50000; }
.mp-info-header.conservative { background-color: #0087dc; }
.mp-info-header.liberal-democrats { background-color: #faa61a; }
.mp-info-header.green { background-color: #02a201; }
.mp-info-header.snp { background-color: #fdf38e; color: #000; }
.mp-info-header.plaid { background-color: #3f8428; }
.mp-info-header.reform { background-color: #29b0ef; }
.mp-info-header.independent { background-color: #999; }
.mp-info-header.dup { background-color: #b01322; }
.mp-info-header.sdlp { background-color: #2aa82c; }
.mp-info-header.alliance { background-color: #f6cb2f; color: #000; }
.mp-info-header.sinn-fein { background-color: #326760; }

.mp-placeholder-fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #333;
}

/* Smoother scrolling */
.tiktok-smooth-scroll {
    transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
}

/* Preloaded container styles */
#preloaded-container {
    position: absolute;
    left: -9999px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

/* Style for the container being swiped away */
.mp-card-container.swiping-out {
    transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
    transform: translateY(-100%);
}

/* iPhone XR and other mobile-specific adjustments */
@media (max-width: 414px) {
    body, html {
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
    
    /* Make the menu bigger and more touch-friendly on mobile */
    .menu-button {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    
    /* Make the timer bar more visible on mobile */
    .timer-bar {
        height: 6px;
        background-color: #ffffff;
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
    }
    
    /* Mobile-specific positioning adjustments */
    .mp-info-header {
        bottom: 100px;
    }
    
    .bottom-controls {
        bottom: 30px;
    }
    
    .mp-name {
        font-size: 22px;
        margin-bottom: 1px; /* Even smaller margin on mobile */
    }
    
    .constituency-label {
        font-size: 15px;
        margin: 0; /* No margin */
    }
    
    .answer-button {
        width: 55px !important;
        height: 55px !important;
        min-width: 55px !important;
        min-height: 55px !important;
        max-width: 55px !important;
        max-height: 55px !important;
        font-size: 22px;
    }
    
    /* Menu dropdown adjustments */
    .menu-dropdown {
        width: 180px;
    }
    
    .menu-dropdown a, .menu-dropdown button {
        padding: 12px 10px;
        font-size: 15px;
    }
}
