/* FILE: style.css */

/* Basic Reset and Body Styling */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Montserrat', sans-serif;

    background-color: #121212; /* Dark background */
    color: #E0E0E0; /* Light text */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to the top */
    min-height: 100vh;
    padding: 1rem;
}

/* Main container for the entire app */
.app-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Header section with title and puzzle date */
.header {
    text-align: center;
    border-bottom: 1px solid #333;
    padding-bottom: 1rem;
    width: 100%;
    max-width: 500px; /* Constrain header width */
}

.title {
    font-size: 1.8rem;
    font-weight: 700;
}

.sub-header {
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #9E9E9E;
}

.puzzle-prefix {
    font-size: .9rem;
}

/* Game board where all guesses will appear */
.game-board {
    width: 100%;
    max-width: 500px;
    display: grid;
    /* grid-template-rows: repeat(6, 1fr); */ /* <-- DELETE THIS LINE */
    gap: 0.5rem;
}

/* A single row of 5 guesses */
.guess-row {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* This creates space between the boxes and the button */
    position: relative;        /* ADD THIS */
    justify-content: center;   /* ADD THIS */
    padding: 0 3rem;
}

.guess-boxes-container {
    flex-grow: 1; /* Allows the container to take up available space */
    display: flex;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.guess-row.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden;
}

.guess-row.locked {
}

/* An individual box for a team guess */
.guess-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid #3A3A3C;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    position: relative; /* Needed for the 3D effect */
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.guess-box .team-logo {
    width: 100%;
    height: 100%;
    background-color: transparent; /* No background needed */
    cursor: grab;
}

/* Highlight for a valid drop target */
.guess-box.drag-over {
    background-color: #2a2a2c;
    border-color: #818384;
}

/* State styles for guess boxes */
.guess-box.correct { background-color: #538D4E; border-color: #538D4E; }
.guess-box.present { background-color: #B59F3B; border-color: #B59F3B; }
.guess-box.absent { background-color: #3A3A3C; border-color: #3A3A3C; }

.submit-row-btn {
    background-color: #2a2a2c; /* A neutral dark grey */
    color: #E0E0E0;           /* Light text color */
    border: 1px solid #3A3A3C; /* A subtle border */
    border-radius: 8px;
    padding: 0 .6rem;          /* Make it wide but not tall */
    font-weight: 600;
    font-size: .7rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    height: 50%;              /* Make it shorter than the guess boxes */
    position: absolute;
    right: 10px
}

/* MODIFIED: A more subtle hover effect */
.submit-row-btn:hover {
    background-color: #3A3A3C;
    border-color: #555;
}

/* Input area for searching teams */
.input-area {
    width: 100%;
    max-width: 500px;   
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background-color: #212121;
    border-radius: 12px;
    margin-top: 1rem;
}

.input-label {
    font-size: 1rem;
    font-weight: 600;
    color: #9E9E9E;
}

.team-input {
    width: 100%;
    max-width: 300px;
    padding: 0.75rem;
    font-size: 1rem;
    background-color: #3A3A3C;
    border: 1px solid #555;
    border-radius: 8px;
    color: #E0E0E0;
    text-align: center;
}

.team-input:focus {
    outline: none;
    border-color: #818384;
}

/* Container for the draggable team logos */
.team-logo-container {
    width: 100%;
    display: flex;
    justify-content: center; /* Align logos to the left */
    align-items: center;
    gap: 1rem; /* Space between logos */
    /*overflow-x: auto; !* Enable horizontal scrolling *!*/
    flex-wrap: wrap;
    padding: 1rem 0.5rem;
    min-height: 100px; /* Reserve space */
}

/* Custom scrollbar for dark theme */
.team-logo-container::-webkit-scrollbar {
    height: 8px;
}
.team-logo-container::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}
.team-logo-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}
.team-logo-container::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.team-logo {
    position: relative; 
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    background-color: #444;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    transition: transform 0.2s ease;
    touch-action: none;
}

.remove-logo-btn {
    position: absolute;
    top: -5px; /* Position it slightly outside the top corner */
    right: -5px; /* Position it slightly outside the right corner */
    width: 20px;
    height: 20px;
    background-color: #E53935; /* A nice red color */
    color: white;
    border: none;
    border-radius: 50%; /* Makes it a circle */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s ease;
}

.team-logo:hover .remove-logo-btn {
    opacity: 1;
}

.guess-box .team-logo .remove-logo-btn {
    display: none;
}

.team-logo:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.team-logo img {
    position: relative;
    width: 85%;
    height: 85%;
    object-fit: cover;
    pointer-events: none;
    border-radius: 8px; /* Optional: ensures image corners match the container */
}

.team-logo.dragging .remove-logo-btn {
    display: none;
}

.team-logo.dragging {
    cursor: grabbing;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 300px;
}

/* NEW: Custom search results dropdown */
.search-results {
    position: absolute;
    width: 100%;
    background-color: #3A3A3C;
    border-radius: 8px;
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    border: 1px solid #555;
}

/* Hides the dropdown when it's empty */
.search-results:empty {
    display: none;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    gap: 0.75rem;
}

.result-item:hover {
    background-color: #4a4a4c;
}

.result-item img {
    width: 30px;
    height: 30px;
}

.is-dragging {
    opacity: 0.5; /* Makes it clear which item is being dragged */
}

html.is-dragging-anywhere {
    user-select: none;
    -webkit-user-select: none; /* For Safari */
    overflow: hidden; 
    touch-action: none;
}

/* ADD THIS: Styles for the 'ghost' image that follows the cursor/finger */
.ghost {
    position: absolute;
    pointer-events: none; /* The ghost should not interfere with drop targets */
    z-index: 999; /* Ensure it's on top of everything */
    opacity: 0.8;
    transform: scale(1.1); /* Make it slightly larger to indicate it's being dragged */
}

.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent overlay */
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-container.show {
    display: flex; /* Shown when this class is added */
}

.modal-content {
    position: relative; /* This is required for positioning the 'X' button */
    background-color: #212121;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    color: #E0E0E0;
    border: 1px solid #3A3A3C;
    width: 90%;        
    max-width: 500px;

}

.modal-content ul {
    list-style-type: none; /* Changed: Removes the bullet points */
    text-align: center;    /* Changed: Centers the text inside each list item */
    text-justify: inter-word;
    margin: 0 auto;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.modal-content ul li {
    margin-bottom: .5rem;
}

/* NEW: Styles for the 'X' close button */
.modal-close-x {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #9E9E9E;
    font-size: 2rem;
    cursor: pointer;
}

/* NEW: Styles for the emoji grid container */
.share-grid {
    font-size: 1.5rem;
    line-height: 1.2;
    margin: .5rem 0 1rem;
    white-space: pre-wrap; /* Ensures newlines are respected */
}

.modal-content #share-grid-title {
    font-size: 1rem;
    line-height: 1.2;
    margin: 1rem 0 0;
    white-space: pre-wrap; 
}

/* NEW: Styles for the primary 'Share' button */
.share-btn {
    background-color: #538D4E;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2.5rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s ease;
}

.share-btn:hover {
    background-color: #4a7c44;
}

.give-up-btn {
    background-color: #3A3A3C; /* Neutral dark gray */
    color: #E0E0E0;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem; /* Space above the input area */
    transition: background-color 0.2s ease;
}

.give-up-btn:hover {
    background-color: #4a4a4c;
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: .5rem;
}

.solution-container {
    display: none; /* Hidden by default */
    margin-top: 1rem
}

.solution-logos {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.solution-logos .team-logo {
    width: 40px;
    height: 40px;
}

.modal-close-btn {
    background-color: #538D4E;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: bold;
    cursor: pointer;
}

@keyframes flip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.guess-box.flipping {
    animation: flip 0.6s ease-in-out;
}


.ranking-link-container {
    margin-top: 1.5rem; /* Adds space above the link */
    font-size: 0.9rem;
}

#hltv-ranking-link {
    color: #8cb4ff; /* A softer, more pleasant blue */
    text-decoration: none;
    transition: color 0.2s ease;
}

#hltv-ranking-link:hover {
    color: #a7c5ff; /* A slightly brighter blue on hover */
    text-decoration: underline;
}

.info-btn {
    margin-bottom: 0rem;
    width: 20px;
    height: 20px;
    border-radius: 50%; /* Makes it a circle */
    background-color: #3A3A3C;
    border: 1px solid #555;
    color: #E0E0E0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    font-weight: bold;
    font-family: serif; /* Gives the 'i' a classic info icon look */
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.info-btn:hover {
    background-color: #4a4a4c;
}