/* ABOUTME: Main stylesheet for the Name That Yankee trivia game. */
/* ABOUTME: Manages responsive layouts, interactive elements, and broadcast tribute themes. */
:root {
    --primary-color: #0C2340;
    /* Yankees Navy */
    --secondary-color: #C4CED3;
    /* Gray */
    --background-color: #f4f4f4;
    --text-color: #333;
    --card-bg: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 0.9rem 1rem;
    border-bottom: 4px solid var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: center;
}

header .header-content {
    text-align: left;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    color: white;
}

header p {
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.instructions-link {
    color: white;
    font-weight: 600;
    text-decoration: none;
    transition: text-decoration 0.2s ease;
}

.instructions-link:hover {
    text-decoration: underline;
}

.analytics-link {
    color: white;
    font-weight: 600;
    text-decoration: none;
    transition: text-decoration 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.analytics-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

main {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 1rem;
}

footer {
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.8rem;
    color: #555;
}

/* --- Gallery & Search Styles --- */
.sticky-search-wrapper {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: rgba(244, 244, 244, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid #ddd;
    padding: 1rem 1rem;
}

.search-container {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

#search-bar {
    flex-grow: 1;
    width: 100%;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    border-radius: 9999px;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.filter-container {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.filter-container label {
    margin-left: 0.5rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.filter-container input[type="checkbox"] {
    cursor: pointer;
    width: 1.15rem;
    height: 1.15rem;
}


#no-results {
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: #555;
    display: none;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    padding-top: 0.5rem;
}

.gallery-container {
    background-color: var(--card-bg);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    position: relative;
    height: fit-content;
    /* Skip rendering when off-screen */
    content-visibility: auto;
    /* Maintain scrollbar stability (standard card height) */
    contain-intrinsic-size: auto 450px;
}

.gallery-container.completed .gallery-item::after {
    content: '✔';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    color: white;
    text-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 6rem;
    font-weight: bold;
    opacity: 1;
    pointer-events: none;
}

.gallery-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    pointer-events: none;
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: contain;
    display: block;
    background-color: #f8f9fa;
    padding-top: 0.5rem;
}

.gallery-date {
    text-align: center;
    margin: 0;
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.p-4 {
    padding: 0.5rem 0.75rem !important;
}

.action-links {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem 0.5rem 1rem;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.action-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    min-width: 90px;
    justify-content: center;
    flex: 1;
}

.reveal-link {
    background-color: #1d4ed8;
    /* Blue */
}

.reveal-link:hover {
    background-color: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(29, 78, 216, 0.3);
}

.quiz-link {
    background-color: #0C2340;
    /* Dark blue matching header */
}

.quiz-link:hover {
    background-color: #1a3a63;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(12, 35, 64, 0.3);
}

.action-link.disabled {
    background-color: #9ca3af !important;
    color: white;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

.quiz-link.disabled:hover {
    background-color: #9ca3af !important;
    transform: none !important;
    box-shadow: none !important;
}


/* --- Detail Page & Quiz Page Layout Styles --- */
.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    text-decoration: none;
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.back-link:hover {
    background-color: #1a3a63;
}

.detail-layout,
.quiz-layout {
    display: flex;
    align-items: flex-start;
}

/* THE FIX: Specific gap and flex properties for each layout */
.detail-layout {
    gap: 2rem;
}

.quiz-layout {
    gap: 1.5rem;
}

.left-column,
.right-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.detail-layout .left-column {
    flex: 3;
}

.detail-layout .right-column {
    flex: 1;
}

.quiz-layout .left-column {
    flex: 1;
}

.quiz-layout .right-column {
    flex: 1;
}


.player-profile {
    display: flex;
    flex-wrap: nowrap;
    gap: 2rem;
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.player-photo {
    flex: 1 1 80px;
}

.player-photo img {
    width: 100%;
    border-radius: 8px;
}

.player-info {
    flex: 2 1 300px;
}

.player-info h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 2.2rem;
}

.facts-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.disclaimer {
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
    margin-top: 0;
    margin-bottom: 0;
}

.player-info ul {
    list-style-type: '⚾';
    padding-left: 1.5rem;
    margin-top: 0;
}

.player-info li {
    padding-left: 0.8rem;
    margin-bottom: 0.5rem;
}

.followup-section {
    margin-top: 1rem;
}

.followup-section h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.followup-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 100%;
}

.followup-btn {
    background-color: #0C2340;
    /* Match primary dark blue */
    color: white;
    border: none;
    padding: 0.55rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.followup-btn:hover {
    background-color: #1a3a63;
    box-shadow: 0 2px 6px rgba(12, 35, 64, 0.25);
    transform: translateY(-1px);
}

.followup-answer {
    margin-top: 0.6rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
}

.original-card {
    min-width: 250px;
    margin-top: 0;
    text-align: center;
    background-color: var(--card-bg);
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.original-card img {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.original-card h3,
.facts-header h3 {
    margin-top: 0;
    font-size: 1.5rem;
    margin-bottom: 0;
}

/* --- Stats Table & Chart Styles --- */
.stats-table-container,
.chart-container {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stats-table-container h3,
.chart-container h3 {
    margin-top: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0;
}

.chart-container h3 {
    text-align: center;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
}

tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

tbody tr:hover {
    background-color: #e9ecef;
}

.citation {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #666;
    text-align: right;
    font-style: italic;
}

/* General chart wrapper for detail pages */
.chart-container .chart-wrapper {
    position: relative;
    min-height: 24rem;
    width: 100%;
}

/* --- Quiz Page Styles --- */
.quiz-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

#clue-image {
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-bottom: 1.5rem;
}

#guess-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.quiz-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

#submit-guess,
#request-hint,
#give-up-btn {
    flex: 1;
    padding: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#submit-guess {
    background-color: var(--primary-color);
}

#give-up-btn {
    background-color: #555;
    /* Dark gray for better contrast with white text */
}

#request-hint {
    background-color: #ffc107;
    /* Yellow */
    color: #212529;
}

#submit-guess:hover {
    background-color: #1a3a63;
}

#request-hint:hover {
    background-color: #e0a800;
}

#give-up-btn:hover {
    background-color: #333;
}

#submit-guess:disabled,
#request-hint:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
}

#feedback-message {
    margin-top: 1rem;
    font-weight: 600;
    min-height: 24px;
}

.correct {
    color: #16a34a;
}

.incorrect {
    color: #dc2626;
}

#hints-container {
    margin-top: 1.5rem;
    text-align: left;
}

#hints-container h3 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

#hints-list {
    list-style-type: '⚾';
    padding-left: 1.5rem;
}

#hints-list li {
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
}

#score-display {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 20;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    user-select: none;
}

#score-display:hover {
    filter: brightness(95%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

#score-display:active {
    transform: translateY(0);
}

.chevron-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

#score-display.is-active .chevron-icon {
    transform: rotate(180deg);
}

#score-breakdown-container {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 100;
    min-width: 250px;
    margin-top: 0.5rem;
    cursor: default;
}

.breakdown-header {
    font-weight: bold;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    text-align: center;
}

#score-breakdown-container table {
    width: 100%;
    font-size: 0.85rem;
}

#score-breakdown-container th {
    text-align: left;
    padding: 0.25rem 0.5rem;
}

#score-breakdown-container td {
    padding: 0.25rem 0.5rem;
}

.answer-photo {
    max-width: 250px;
    max-height: 350px;
    margin: 0 auto 1.5rem auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.guesses-container {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#show-guesses-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#show-guesses-btn:hover {
    background-color: #1a3a63;
}

#show-guesses-btn:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

.suggestion-item.highlighted {
    background-color: var(--primary-color);
    color: white;
}

@media (max-width: 992px) {

    .detail-layout,
    .quiz-layout {
        flex-direction: column;
    }

    .player-profile {
        flex-wrap: wrap;
    }

    header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 0.75rem;
    }

    .action-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .action-link {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 0.5rem;
    }
}

/* Instruction page styles */

.instructions-container {
    max-width: 800px;
    margin: 2rem auto;
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.whats-new-section {
    background-color: #f8f9fa;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.whats-new-section h2 {
    color: var(--primary-color);
    margin-top: 0 !important;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.whats-new-section ul {
    list-style-type: none !important;
    padding-left: 0 !important;
}

.whats-new-section li {
    margin-bottom: 1rem;
    position: relative;
    padding-left: 1.5rem;
}

.whats-new-section li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.instructions-container h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

.instructions-container h3 {
    color: var(--primary-color);
    margin-top: 2rem;
}

.instructions-container p,
.instructions-container li {
    line-height: 1.8;
}

.instructions-container ul {
    list-style-type: '⚾';
    padding-left: 1.5rem;
}

.instructions-container code {
    background-color: #e9ecef;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.disclaimer-footer {
    font-size: 0.75rem;
    font-style: italic;
    color: #555;
    max-width: 700px;
    margin: 0 auto 1rem auto;
    /* Center the text and add space below */
}

/* Autocomplete Styles */
/* --- Autocomplete Styles --- */
.autocomplete-container {
    position: relative;
    margin-bottom: 1rem;
}

#suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-top: none;
    /* This makes it feel connected to the input box */
    border-radius: 0 0 8px 8px;
    /* Rounds the bottom corners */
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* Adds a subtle shadow */
}

.suggestion-item {
    padding: 0.75rem;
    text-align: left;
    cursor: pointer;
}

.suggestion-item:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
    /* Makes text darker on hover */
}

/* --- Analytics Page Styles --- */
#analytics-content .chart-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.5rem !important;
    margin-top: 2rem;
    width: 100%;
    max-width: 1200px;
    /* matches main container width */
    margin: 2rem auto !important;
    /* centers the grid */
}

.chart-card {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-width: 0;
    margin: 0 !important;
    box-sizing: border-box;
    /* Ensure padding doesn't affect width */
}

@media (max-width: 800px) {
    #analytics-content .chart-grid {
        grid-template-columns: 1fr !important;
    }
}

.chart-card h2 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Analytics page specific chart wrapper */
.chart-card .chart-wrapper {
    position: relative;
    height: 400px;
}

/* Make clickable charts show pointer cursor */
#teamChart,
#decadeChart,
#toughestPuzzlesChart {
    cursor: pointer;
}

/* Instruction text below clickable charts */
.chart-instruction {
    margin-top: 0.75rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: #666;
    font-style: italic;
    text-align: center;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* --- Share Button Styles --- */
.success-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.share-button {
    background-color: #e9ecef;
    color: var(--primary-color);
    border: 1px solid #ccc;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 3rem;
}

.share-button:hover {
    background-color: #dee2e6;
    border-color: #bbb;
}

.share-button:active {
    transform: scale(0.98);
}

.share-button.copied {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

.view-details-link {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 3rem;
    box-sizing: border-box;
}

.view-details-link:hover {
    background-color: #1a3a63;
    color: white;
}

#share-fail-container .share-button {
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Tribute Page Styles --- */
.tribute-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .tribute-layout {
        display: grid;
        grid-template-columns: 1fr 2fr;
        align-items: start;
    }
}

.tribute-layout .player-photo img {
    max-width: 300px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.broadcast-stats {
    display: flex;
    justify-content: space-around;
    background: var(--primary-color);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
}

.stat-box .count {
    display: block;
    font-size: 3rem;
    font-weight: bold;
}

.timeline-container {
    margin-top: 2rem;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-left: 4px solid var(--primary-color);
}

.mic-icon {
    font-size: 1.5rem;
}
