/* =========================================
   1) BASE / TOKENS
   -----------------------------------------
   Keep repeated values centralized so the
   rest of the file stays easy to maintain.
========================================= */

:root {
    --color-navy: #0a4c86;
    --color-white: #ffffff;
    --color-light: #f7f9fc;
    --color-border: #d9d9d9;
    --color-dark: #1e1e1e;
    --color-muted: #bbb;
    --color-stripe-1: #666;
    --color-stripe-2: #444;

    --gradient-accent: linear-gradient(
        90deg,
        #2ca6a4,
        #3f7cff,
        #7a4dff,
        #e94e9a,
        #f4a43a
    );

    --radius-md: 12px;
    --radius-lg: 16px;

    --space-xs: 0.35rem;
    --space-sm: 0.5rem;
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 3rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    color: var(--color-navy);
}


/* =========================================
   2) PAGE / GENERAL LAYOUT
========================================= */

.chart-container {
    width: 100%;
    max-width: 1020px;
    margin: 1rem auto 0;
    padding: 1.5rem;
    background-color: var(--color-white);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 3px solid;
    border-image: var(--gradient-accent) 1;
}

.controls-section {
    width: 100%;
    margin: 2rem 0 0;
}

.summary-container {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 2rem;
    width: 100%;
}

.driver-summary-section {
    width: 100%;
    margin: 0;
    padding: 2rem 3rem;
    background: var(--color-navy);
    font-size: 0.9rem;
}

.race-summary-container {
    width: 100%;
    margin: 2rem 0;
    padding: 0 2rem;
}


/* =========================================
   3) TYPOGRAPHY / HEADINGS
========================================= */

.title-heading {
    margin-left: 1.5rem;
    color: var(--color-navy);
    font-size: 4rem;
}

.section-heading {
    margin-bottom: 1.5rem;
    color: var(--color-white);
    font-size: 1.5rem;
}

.section-heading-light {
    margin-left: 1.5rem;
    color: var(--color-navy);
    font-size: 1.5rem;
}


/* =========================================
   4) CONTROL ROWS
========================================= */

.race-controls,
.driver-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 2rem;
    font-size: 1.75rem;
}

.driver-controls {
    background: var(--gradient-accent);
    color: var(--color-white);
}

select {
    min-width: 180px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
}

#start-button {
    padding: 0.5rem 1rem;
    border: none;
    background: var(--color-navy);
    color: var(--color-white);
    font-size: 2rem;
    cursor: pointer;
}


/* =========================================
   5) DRIVER SUMMARY CARDS
========================================= */

.driver-card {
    display: flex;
    flex: 1 1 500px;
    gap: 1.25rem;
    min-width: 0;
    max-width: 500px;
    padding: 1.5rem;
    background: var(--color-white);
    color: var(--color-navy);
    border: 3px solid;
    border-image: var(--gradient-accent) 1;
}

.driver-photo {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    border: 6px solid #ffffff;
}

.driver-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.driver-content h3 {
    margin: 0;
    font-size: 1.5rem;
}

.driver-stats {
    margin-top: 0.25rem;
}

.driver-stats p {
    margin: 0.4rem 0;
}

.team-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.team-logo-small {
    display: block;
    width: 30px;
    height: auto;
    object-fit: contain;
}

.team-name {
    font-size: 1rem;
    font-weight: 600;
}

#fastest-gap-summary {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    color: var(--color-white);
    text-align: center;
    font-size: 1.1rem;
}


/* =========================================
   6) GRADIENT BARS / SECTION DIVIDERS
========================================= */

.gradient-bar,
.gradient-bar-top,
.gradient-bar-bottom {
    border-image: var(--gradient-accent) 1;
}

.gradient-bar {
    margin-top: 0;
    border-top: 8px solid;
    border-bottom: 8px solid;
}

.gradient-bar-top {
    margin-bottom: 0;
    border-top: 8px solid;
}

.gradient-bar-bottom {
    border-bottom: 8px solid;
}


/* =========================================
   7) RACE SUMMARY
========================================= */

.race-summary-panel {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    align-items: start;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.race-summary-main,
.race-summary-track {
    background: var(--color-white);
}

.race-summary-main {
    padding: 2rem;
}

.race-summary-header {
    margin-bottom: 1.5rem;
}

.race-name {
    margin: 0;
    color: var(--color-navy);
    font-size: 2rem;
}

.race-date {
    margin: 0.5rem 0 0;
    color: var(--color-navy);
    font-size: 1rem;
}

.race-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.race-stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
    background: var(--color-light);
    border-radius: var(--radius-md);
}

.race-stat-label {
    color: var(--color-navy);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
}

.race-stat-value {
    color: var(--color-navy);
    font-size: 1rem;
}

.race-summary-track {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 1.5rem;
}

#track-image {
    display: block;
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
}


/* =========================================
   8) PODIUM
========================================= */

.podium-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.podium-heading {
    margin: 0 0 0.75rem;
    color: var(--color-navy);
    font-size: 1.1rem;
}

.podium-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.podium-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
    color: var(--color-navy);
    border-radius: var(--radius-md);
}

.podium-position {
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.95;
}

.podium-driver {
    font-size: 1rem;
    font-weight: 600;
}


/* =========================================
   9) STINT BAR
========================================= */

.stint-bar {
    display: flex;
    width: 100%;
    height: 16px;
    margin-top: 0.5rem;
    overflow: hidden;
    background: var(--color-dark);
    border: 2px solid;
    border-image: var(--gradient-accent) 1;
}

.stint-segment {
    height: 100%;
}

.stint-segment.unfinished {
    background: repeating-linear-gradient(
        45deg,
        var(--color-stripe-1),
        var(--color-stripe-1) 6px,
        var(--color-stripe-2) 6px,
        var(--color-stripe-2) 12px
    );
}

.stint-bar.empty {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    color: var(--color-muted);
    font-size: 0.8rem;
}


/* =========================================
   10) RACE RESULTS TABLE
========================================= */

.race-results-section {
    width: 100%;
    margin-top: 0.5rem;
}

.race-results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    color: var(--color-navy);
    font-size: 0.7rem;
    line-height: 1.15;
}

.race-results-table th,
.race-results-table td {
    padding: 0.22rem 0.3rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-navy);
    text-align: left;
    vertical-align: top;
}

.race-results-table th {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.race-results-table td:nth-child(1) {
    width: 18%;
    white-space: nowrap;
    font-weight: 700;
}

.race-results-table td:nth-child(2) {
    width: 42%;
}

.race-results-table td:nth-child(3) {
    width: 40%;
}


/* =========================================
   11) RESPONSIVE
   -----------------------------------------
   Keep breakpoints grouped at the end so
   overrides are easy to find.
========================================= */

@media (max-width: 900px) {
    .title-heading {
        margin-left: 1rem;
        margin-right: 1rem;
        font-size: 3rem;
    }

    .race-controls,
    .driver-controls {
        flex-wrap: wrap;
        justify-content: flex-start;
        padding: 1rem;
        font-size: 1.2rem;
    }

    .summary-container {
        gap: 1rem;
    }

    .driver-card {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .driver-summary-section {
        padding: 1.5rem;
    }

    .race-summary-container {
        padding: 0 1rem;
    }

    .race-summary-panel {
        grid-template-columns: 1fr;
    }

    .race-summary-stats,
    .podium-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .title-heading {
        margin: 1rem;
        font-size: 2.25rem;
        line-height: 1.1;
    }

    .section-heading,
    .section-heading-light {
        margin-left: 0;
        font-size: 1.25rem;
    }

    .controls-section {
        display: flex;
        flex-direction: column;
        margin: 1rem 0 0;
    }

    .driver-controls {
        order: 1;
    }

    .race-controls {
        order: 2;
    }

    .race-controls,
    .driver-controls {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
        font-size: 1rem;
    }

    .race-controls label,
    .driver-controls label {
        margin-bottom: 0.15rem;
    }

    .race-controls select,
    .driver-controls select,
    #start-button {
        width: 100%;
        max-width: 100%;
    }

    #start-button {
        order: 3;
        margin-top: 0.75rem;
        font-size: 1.25rem;
    }

    .summary-container {
        flex-direction: column;
        gap: 1rem;
    }

    .driver-summary-section {
        padding: 1rem;
    }

    .driver-card {
        width: 100%;
        max-width: 100%;
        padding: 1rem;
    }

    .driver-photo {
        height: 130px;
    }

    .driver-content h3 {
        font-size: 1.25rem;
    }

    .chart-container {
        padding: 1rem 0;
    }

    .race-summary-main {
        padding: 1rem;
    }

    .race-summary-panel {
        gap: 1rem;
    }

    .race-name {
        font-size: 1.5rem;
    }

    .race-summary-track {
        min-height: 220px;
        padding: 1rem;
    }

    #track-image {
        max-height: 260px;
    }

    .race-results-table {
        font-size: 0.62rem;
    }

    .race-results-table th,
    .race-results-table td {
        padding: 0.2rem 0.25rem;
    }
}

@media (max-width: 560px) {
    .driver-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .driver-photo {
        width: 96px;
        height: 96px;
    }

    .team-row {
        flex-wrap: wrap;
    }
}

@media (max-width: 400px) {
    .title-heading {
        font-size: 1.9rem;
    }

    .driver-summary-section,
    .race-summary-container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

.compound-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #0a4c86;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: #c7deff;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(10, 76, 134, 0.2);
}

.legend-color.soft {
  background: #ff3333;
}

.legend-color.medium {
  background: #ffd84d;
}

.legend-color.hard {
  background: #f2f2f2;
}

.legend-color.inter {
  background: #43a047;
}

.legend-color.wet {
  background: #3f7cff;
}

.about-section {
    margin: 3rem auto 0;
    padding: 2rem;
    background: var(--color-white);
    font-size: .9rem;
}