/* Font Face Declaration */
@font-face {
    font-family: 'EurostileExtended';
    src: url('/fonts/eurostile-extd-medium.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Global Styles */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    color: #333;
    font-family: 'EurostileExtended', Arial, sans-serif;
    background-color: #f5f5f5;
    text-align: center;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout Styles */
.page-container {
    flex: 1;
    display: flex;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

main {
    flex-grow: 1;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header Styles */
header {
    background-color: #005EB8;
    padding: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

header h1, header h1 a {
    font-size: clamp(28px, 5vw, 56px);
    color: white;
    -webkit-text-stroke: clamp(1px, 0.15vw, 4px) #DA291C;
    margin: 0;
    font-family: 'EurostileExtended', Arial, sans-serif;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

header h1 a:hover, header h1 a:focus {
    text-decoration: none;
    color: white;
}

header h2 {
    font-size: clamp(14px, 3vw, 20px);
    color: #DA291C;
    margin: 10px 0 0;
    padding-top: 10px;
    font-family: 'EurostileExtended', Arial, sans-serif;
    text-transform: lowercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quiz List and Button Styles */
#wrapper, .quiz-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.button, .quiz-item {
    flex: 1 1 calc(50% - 20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: calc(50% - 20px);
    min-width: 150px;
    min-height: 250px;
    padding: 20px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    user-select: none;
    overflow: hidden;
    position: relative;
}

.button:hover, .button:focus, .quiz-item:hover, .quiz-item:focus {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(218, 41, 28, 0.8);
}

.button .image, .quiz-item .image {
    width: 100%;
    height: calc(90% - 3em);
    display: flex;
    justify-content: center;
    align-items: center;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    margin-bottom: 10px;
}

.button .image img, .quiz-item .image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
    pointer-events: none;
}

.button .text, .quiz-item h3 {
    font-size: clamp(14px, 3vw, 20px);
    color: #333;
    text-align: center;
    margin-top: 10px;
    white-space: nowrap;
    overflow: break-word;
    text-overflow: ellipsis;
    width: 100%;
    height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Results Container Styles */
#results-container {
    display: none;
    padding: 20px;
    margin: 20px auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 1000px;
    text-align: center;
    font-size: 1.2em;
    width: 100%;
}

#results-top {
    margin-bottom: 30px;
}

#top-team {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
    flex-direction: column;
}

#top-team .ranking-logo {
    width: 120px; /* increased horizontally */
    height: 100px; /* fixed height for alignment */
    object-fit: contain;
    margin-bottom: 5px;
}

#top-team .team-info {
    font-size: 24px;
    font-weight: bold;
}

/* Quiz Results Team Rows */
.team-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.team-row:last-child {
    border-bottom: none;
    justify-content: center;
}

/* Updated team-item to align content consistently */
.team-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: calc(16.666% - 10px);
    min-height: 150px;  /* Ensure a consistent height */
}

/* Updated ranking-logo for all team items */
.ranking-logo {
    width: 120px; /* increased size */
    height: 100px; /* fixed height to standardize the image area */
    object-fit: contain;
    margin-bottom: 5px;
}

/* Updated team-info: allow text to wrap and align top */
.team-info {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    margin-top: 5px;
    padding-top: 5px;
    width: 100%;
    white-space: normal;      /* allow wrapping */
    word-wrap: break-word;      /* break long words */
    line-height: 1.2em;
}

/* Progress Bar Styles */
.progress {
    max-width: calc(90% - 3vh);
    min-width: 50%;
    height: 20px;
    margin: 20px auto;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

#completion {
    height: 100%;
    width: 0%;
    background: #DA291C;
    transition: width 0.5s ease;
}

/* Download Chart Button Styles */
#download-chart {
    display: none;
    margin: 20px auto 70px;
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s;
}

#download-chart:hover {
    background-color: #45a049;
}

/* Footer Styles */
footer {
    background-color: #005EB8;
    padding: 20px 0;
    width: 100%;
    color: white;
    text-align: center;
    font-family: 'EurostileExtended', Arial, sans-serif;
}

footer .footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
}

footer a {
    color: white;
    text-decoration: none;
    margin: 5px 10px;
    font-size: 16px;
    white-space: nowrap;
    display: inline-block;
}

footer a:hover {
    text-decoration: underline;
}

/* Media Queries */
@media screen and (max-width: 1200px) {
    .page-container {
        flex-direction: row;
    }
    main {
        width: 100%;
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    html, body {
        width: 100%;
        overflow-x: hidden;
    }
    .page-container, main {
        padding: 0;
        width: 100%;
    }
    #wrapper, .quiz-list {
        padding: 0 10px;
        gap: 10px;
    }
    header {
        padding: 10px 5px;
    }
    header h1, header h1 a {
        font-size: 28px;
        -webkit-text-stroke: 1px #DA291C;
    }
    header h2 {
        font-size: 16px;
    }
    #results-container {
        padding: 10px;
    }
    .team-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 10px;
        margin-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }
    .team-item {
        flex: 0 0 auto;
        width: 100px;
        margin-right: 10px;
    }
    .ranking-logo {
        width: 120px;
        height: 100px;
    }
    .team-info {
        font-size: 12px;
    }
    .button, .quiz-item, .quiz-content .quiz-item {
        width: 35%;
        min-width: 120px;
        height: 160px;
    }
    .quiz-content {
        justify-content: space-around;
    }
    #top-team .ranking-logo {
        width: 120px;
    }
    #top-team .team-info {
        font-size: 18px;
    }
    .button .text, .quiz-item h3 {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    header h1, header h1 a {
        font-size: 24px;
        -webkit-text-stroke: 1px #DA291C;
    }
    header h2 {
        font-size: 14px;
    }
    .button, .quiz-item, .quiz-content .quiz-item {
        width: 35%;
        height: 160px;
    }
    .button .text, .quiz-item h3 {
        font-size: 12px;
    }
}

@media (max-width: 375px) {
    header h1, header h1 a {
        font-size: 22px;
        -webkit-text-stroke: 1px #DA291C;
    }
    header h2 {
        font-size: 12px;
    }
    .button, .quiz-item, .quiz-content .quiz-item {
        width: 35%;
        height: 160px;
    }
    .button .text, .quiz-item h3 {
        font-size: 10px;
    }
    .ranking-logo {
        width: 120px;
        height: 100px;
    }
    .team-info {
        font-size: 10px;
    }
    footer a {
        font-size: 12px;
        margin: 3px 5px;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .button, .quiz-item {
        transition: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    body {
        background-color: #000;
        color: #fff;
    }
    .button, .quiz-item, #results-container {
        background-color: #000;
        border: 2px solid #fff;
        color: #fff;
    }
    header, footer {
        background-color: #000;
    }
    header h1, header h1 a, header h2, footer a {
        color: #fff;
        -webkit-text-stroke: 1px #fff;
    }
}

/* Print Styles */
@media print {
    body {
        font-size: 12pt;
        line-height: 1.5;
        background: #fff;
        color: #000;
    }
    header h1, header h1 a {
        font-size: 24pt;
        -webkit-text-stroke: none;
        color: #000;
    }
    header h2 {
        font-size: 18pt;
        color: #000;
    }
    .button, .quiz-item {
        page-break-inside: avoid;
        border: 1px solid #000;
        background: #fff;
        width: 35%;
        min-height: 160px;
    }
    a {
        text-decoration: underline;
        color: #000;
    }
    #results-container {
        border: 1px solid #000;
    }
}

/* Homepage Overrides for Vertical Stacking of Quiz Boxes */
.quiz-list {
    flex-direction: column;
    align-items: center;
}

/* Updated quiz-item for home page: shortened buttons and scaled text */
.quiz-list .quiz-item {
    width: 100%;
    height: 120px; /* reduced height from 150px */
    flex: 0 0 auto;
    margin-bottom: 20px;
    padding: 10px; /* reduced padding */
}

.quiz-list .quiz-item h3 {
    font-size: clamp(12px, 2.5vw, 16px); /* scaled text size */
    height: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}
