/* TF2 Font Face Declarations - Safari Compatible */
@font-face {
    font-family: 'TF2build';
    src: url('Fonts/TF2build.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    /* Safari font loading optimization */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Optimize font loading */
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'TF2secondary';
    src: url('Fonts/TF2secondary.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    /* Safari font loading optimization */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Optimize font loading */
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'tf2professor';
    src: url('Fonts/tf2professor.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    /* Safari font loading optimization */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Optimize font loading */
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* CSS Variables - TF2 Theme Colors */
:root {
    --dark-grey: #34312c;
    --beige: #cdc0af;
    --yellow: #e2c867;
    --white: #fbeccb;
    --green: #4d6b1c;
    --red: #934739;
    --darkest-grey: #292526;
    --blue: #4d5e7f;
    --grey: #807868;
    --button-gradient-start: #ded3be;
    --button-gradient-mid: #b9ac93;
    --button-gradient-end: #a09073;
    --red-button-start: #a35142;
    --red-button-mid: #73382e;
    --red-button-end: #552a24;
}

/* Font loading optimization */
.fonts-loaded {
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
}

.fonts-loading {
    font-family: 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    /* Slight adjustment to match TF2build better during loading */
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Safari compatibility */
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    /* Safari text rendering fixes */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--darkest-grey);
    color: var(--beige);
    line-height: 1.4;
    overflow-x: auto;
    scroll-padding-top: 120px; /* Account for sticky header height */
    /* Prevent font flash during loading */
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    min-height: 100vh;
    position: relative;
}

/* Header Styles */
.header {
    background-color: var(--dark-grey);
    padding: 2rem 1.5rem; /* Match detail page padding */
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Header Row - using exact same structure as record rows */
.header-row {
    display: -webkit-grid;
    display: -ms-grid;
    display: grid;
    -webkit-grid-template-columns: 1fr auto auto;
    -ms-grid-template-columns: 1fr auto auto;
    grid-template-columns: 1fr auto auto;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-items: start;
    -ms-grid-column-align: start;
    justify-items: start;
    background-color: transparent; /* Remove grey bar background */
    padding: 1rem 1.5rem;
    margin: 0 auto 0.5rem auto; /* Center like records container */
    max-width: 1400px; /* Match records container max-width */
    border-radius: 0; /* Remove border radius */
    /* Safari gap fallback */
    margin-bottom: 0.5rem;
    cursor: default;
}

.header-row > * {
    margin-right: 1rem;
}

.header-row > *:last-child {
    margin-right: 0;
}

/* No hover state for header row */

.header-row .hidden {
    visibility: hidden; /* Hide map name and date but maintain layout */
}

.header-content {
    margin-bottom: 1rem; /* Slightly increased spacing for better balance */
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
}

.achievement-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
    object-fit: contain;
}

.title {
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: 24px; /* Further reduced for compact header */
    font-weight: normal;
    color: var(--beige);
    margin-bottom: 0;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px; /* Further reduced for compact header */
    font-weight: normal;
    margin-bottom: 0.5rem; /* Reduced spacing between subtitle and navigation */
    letter-spacing: 0.5px;
    color: var(--beige);
}

.subtitle .blue {
    color: #64A136;
}

.subtitle .red {
    color: #64A136;
}

/* Navigation Tabs */
.nav-tabs {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    /* Safari gap fallback */
    margin: 1.5rem -0.25rem 0.5rem -0.25rem; /* Reduced margins to fit better */
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 0.5rem; /* Add vertical spacing between wrapped rows */
}

.nav-tabs .tab-button,
.nav-tabs .search-input-tab {
    margin: 0 0.25rem;
}

.tab-button {
    background: #766B5E;
    color: #EEE4CF;
    border: none;
    border-radius: 4px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    padding: 0.5rem 1rem; /* Match search input padding */
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem; /* Increased font size */
    font-weight: normal;
    cursor: pointer;
    line-height: 1; /* Remove extra line spacing */
    padding-top: calc(0.5rem + 2px); /* Slight downward adjustment to compensate for font metrics */
    padding-bottom: calc(0.5rem - 2px);
    box-shadow: 0 0 1px var(--darkest-grey);
    text-transform: uppercase;
    width: 180px; /* Match search input width */
    height: 2.5rem; /* Match search input height exactly */
    flex-shrink: 0;
    /* Prevent text wrapping */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Match search input styling */
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    /* Safari button styling fixes */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tab-button:hover {
    background: #934739;
    color: #F4DCC6;
}

.tab-button.active {
    background: #934739;
    color: #F4DCC6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* New button styling - original beige gradient with brown text */
.tab-button.new-button {
    background: linear-gradient(to bottom, 
        var(--button-gradient-start) 0%, 
        var(--button-gradient-mid) 49.519%, 
        var(--button-gradient-end) 97.596%);
    color: var(--darkest-grey);
    box-shadow: 
        0 1px 0 inset #fef7eb,
        0 0 1px var(--darkest-grey);
}

.tab-button.new-button:hover {
    background: #934739;
    color: #F4DCC6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tab-button.new-button.active {
    background: linear-gradient(to bottom, 
        var(--button-gradient-start) 0%, 
        var(--button-gradient-mid) 49.519%, 
        var(--button-gradient-end) 97.596%);
    color: var(--darkest-grey);
    box-shadow: 
        0 1px 0 inset #fef7eb,
        0 0 1px var(--darkest-grey);
}

/* Search Input Tab - matches tab button styling */
.search-input-tab {
    background: var(--darkest-grey);
    color: var(--white);
    border: 1px solid var(--beige);
    border-radius: 4px;
    padding: 0.5rem 1rem; /* Match tab button padding */
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem; /* Increased font size to match tab buttons */
    font-weight: normal;
    text-align: center;
    width: 180px; /* Match tab button width */
    height: 2.5rem; /* Match tab button height */
    outline: none;
    /* Prevent text wrapping */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Cross-browser compatibility - Safari specific */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    /* Center the search field */
    margin: 0 0.25rem;
    /* Match button styling */
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    /* Consistent outline in all states */
    box-shadow: 0 0 1px var(--darkest-grey);
    line-height: 1; /* Remove extra line spacing */
    padding-top: calc(0.5rem + 2px); /* Slight downward adjustment to compensate for font metrics */
    padding-bottom: calc(0.5rem - 2px);
    /* Safari input styling fixes */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.search-input-tab::placeholder {
    color: var(--white);
    opacity: 0.7;
}

.search-input-tab:hover {
    border: 1px solid var(--yellow);
    box-shadow: 0 0 1px var(--darkest-grey);
    /* No background change on hover */
}

.search-input-tab:focus {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border: 1px solid var(--white);
    box-shadow: 0 0 1px var(--darkest-grey);
}

.search-input-tab:focus::placeholder {
    color: var(--white);
    opacity: 0.5;
}


/* Search Container for KOTH section */
.search-container {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    margin: 2rem 0;
    padding: 0 1rem;
}

/* Header Search Container */
.header-search-container {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    margin: 1rem 0 2rem 0;
    padding: 0 1rem;
}

/* KOTH Search Container - Centered like KOTH button */
.koth-search-container {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    margin: 2rem 0;
    padding: 0 1rem;
}



/* Removed header-row styles - now integrated into main header */



/* Records Container */
.records-container {
    padding: 0.5rem 2rem 2rem; /* Reduced top padding since sticky row is now part of header */
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Record Rows */
.record-row {
    display: -webkit-grid;
    display: -ms-grid;
    display: grid;
    -webkit-grid-template-columns: 1fr auto auto;
    -ms-grid-template-columns: 1fr auto auto;
    grid-template-columns: 1fr auto auto;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-items: start;
    -ms-grid-column-align: start;
    justify-items: start;
    background-color: transparent;
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    /* Safari gap fallback */
    cursor: pointer;
}

.record-row > * {
    margin-right: 1rem;
}

.record-row > *:last-child {
    margin-right: 0;
}

.record-row:hover {
    background-color: var(--grey);
    transform: translateY(-2px);
}

.record-row:hover .map-name {
    color: var(--white);
}

.header-row:hover {
    background-color: transparent !important;
    transform: none !important;
}

/* Removed header-row styles - now integrated into main header */


.record-row.highlight {
    background-color: var(--grey);
    position: relative;
}

/* Removed hover animations for record rows */

.map-info {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    /* Safari gap fallback */
}

.map-info > * {
    margin-right: 1rem;
}

.map-info > *:last-child {
    margin-right: 0;
}

.map-thumbnail {
    width: 80px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid var(--beige);
    transition: all 0.3s ease;
    background-color: var(--darkest-grey); /* Placeholder background while loading */
    opacity: 0.7; /* Slightly transparent while loading */
}

/* Smooth fade-in when image loads */
.map-thumbnail[loading="lazy"] {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.map-thumbnail[loading="lazy"]:not([src=""]) {
    opacity: 1;
}

.record-row:hover .map-thumbnail {
    border-color: var(--yellow);
    transform: scale(1.05);
}

.map-name {
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: clamp(1rem, 2vw, 1.5rem);
    font-weight: normal;
    color: var(--beige);
    text-transform: uppercase;
    position: relative;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-content: flex-start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    /* Safari gap fallback */
}

.map-name > * {
    margin-right: 1rem;
}

.map-name > *:last-child {
    margin-right: 0;
}

.new-badge {
    background-color: var(--beige);
    color: var(--blue);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'TF2build', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8rem;
    animation: pulse 2s infinite;
    white-space: nowrap;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.date {
    font-family: 'TF2secondary', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--yellow);
    text-align: right;
    min-width: 100px;
    display: none; /* Hide all yellow dates */
}

.time-container {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between; /* Distribute labels across the container */
    /* Safari gap fallback */
}

.time-container > * {
    margin-right: 0.5rem;
}

.time-container > *:last-child {
    margin-right: 0;
}

.new-record, .old-record {
    padding: 0.5rem 1rem; /* Reduced padding */
    border-radius: 4px;
    font-family: 'TF2secondary', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: clamp(1.1rem, 2vw, 1.4rem); /* Increased font size to match sticky row */
    font-weight: normal;
    color: var(--white);
    text-align: center;
    width: 100px; /* Slightly smaller width */
    height: 2.5rem; /* Reduced height */
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    line-height: 1; /* Remove extra line spacing */
    padding-top: calc(0.5rem + 2px); /* Slight downward adjustment to compensate for font metrics */
    padding-bottom: calc(0.5rem - 2px);
}

/* Header row button styling - no borders but same dimensions */
.header-row .new-record, .header-row .old-record {
    background: linear-gradient(180deg, var(--button-gradient-start) 0%, var(--button-gradient-mid) 50%, var(--button-gradient-end) 100%);
    border: none; /* Remove borders */
    color: var(--darkest-grey);
    font-family: 'TF2secondary', 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    box-shadow: none; /* Remove box shadow */
    /* Ensure same dimensions as data row buttons */
    padding: 0.5rem 1rem;
    width: 100px;
    height: 2.5rem;
    font-size: clamp(0.8rem, 1.2vw, 1.1rem);
}

.new-record {
    background-color: var(--green);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.old-record {
    background-color: var(--darkest-grey);
    border: none;
    color: var(--green);
    box-shadow: none;
}

.record-row:hover .old-record {
    color: var(--green);
}

/* Style for "x" (no record) values */
.new-record:has-text("x"), .old-record:has-text("x") {
    background-color: var(--darkest-grey);
    color: var(--beige);
    opacity: 0.6;
}

/* Alternative CSS selector for x values */
.new-record[data-value="x"], .old-record[data-value="x"] {
    background-color: var(--darkest-grey);
    color: var(--beige);
    opacity: 0.6;
}

/* Responsive Design - DISABLED - Desktop only */
/*
@media (max-width: 1200px) {
    .nav-tabs {
        gap: 0.25rem;
    }
    
    .tab-button {
        min-width: 100px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1.5rem 0.5rem;
    }
    
    .achievement-icon {
        width: 30px;
        height: 30px;
        margin-bottom: 0.25rem;
    }
    
    .nav-tabs {
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
        -webkit-align-items: center;
        -ms-flex-align: center;
        align-items: center;
        margin-bottom: 1rem;
    }
    
    .nav-tabs .tab-button {
        margin: 0.25rem 0;
    }
    
    .tab-button {
        width: 200px;
        min-width: auto;
    }
    
    .search-input-tab {
        width: 150px;
        font-size: 0.9rem;
    }
    
    .header-search-container {
        margin: 0.5rem 0 1rem 0;
    }
    
    .koth-search-container {
        margin: 1rem 0;
    }
    
    
    .records-container {
        padding: 0.5rem 1rem 2rem;
    }
    
    .record-row {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .date {
        text-align: center;
    }
    
    .time-container {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .new-record, .old-record {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem 0.5rem;
    }
    
    .title {
        font-size: 1.2rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .tab-button {
        width: 150px;
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .search-input-sticky {
        width: 100%;
        max-width: 180px;
        padding: 0.6rem 1rem;
        font-size: 1rem;
        margin: 0.5rem 0;
    }
    
    .header-search-container {
        margin: 0.25rem 0 0.5rem 0;
    }
    
    .koth-search-container {
        margin: 0.5rem 0;
    }
    
    .map-name {
        font-size: 1rem;
        justify-content: center;
        text-align: center;
    }
    
    .new-badge {
        margin: 0.5rem 0 0 0;
        text-align: center;
        width: fit-content;
    }
    
    .time-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .new-record, .old-record {
        width: 100%;
        max-width: 200px;
    }

}
*/

/* Removed hover effects for time containers */

/* Loading Animation for Tab Content */
.tab-content {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.tab-content.active {
    opacity: 1;
}

/* Accessibility Improvements - Removed yellow focus borders */

/* Solly Tag Background - Fixed behind control point list */
.solly-tag-background {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: -1; /* Behind the content */
    opacity: 0.3;
    pointer-events: none; /* Don't interfere with clicks */
}

.solly-tag-bg-image {
    max-width: 200px;
    height: auto;
    filter: blur(1px); /* Slight blur to make it more background-like */
}


/* Print Styles */
@media print {
    .header {
        position: static;
        background: white;
        color: black;
    }
    
    .record-row {
        break-inside: avoid;
        background: white;
        border: 1px solid black;
    }
    
    .new-record {
        background: #90EE90;
        color: black;
    }
    
    .old-record {
        background: transparent;
        border: none;
        color: var(--green);
    }
    
}
