/**
 * RaceForge Premium Timing Deck - High Density Mobile Responsive
 */

.telemetry-wrapper {
    display: flex;
    gap: 2rem;
    padding: 2rem 40px;
    max-width: 1600px;
    margin: 0 auto;
}

/* --- SIDEBAR RAIL --- */
.circuit-rail { width: 220px; flex-shrink: 0; }
.rail-label { font-family: var(--font-mono); font-size: 0.6rem; color: var(--accent-blue); letter-spacing: 3px; margin-bottom: 1rem; opacity: 0.7; }

.rail-list {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    height: 410px; /* Locked to 10 rows height */
    overflow-y: auto;
    scrollbar-width: none;
}
.rail-list::-webkit-scrollbar { display: none; }

.rail-item {
    display: block;
    padding: 11px 15px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #555;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    transition: 0.2s;
}
.rail-item:hover { color: #fff; background: rgba(255, 255, 255, 0.02); }
.rail-item.active { 
    color: var(--accent-blue); 
    background: rgba(0, 170, 255, 0.08); 
    border-left: 2px solid var(--accent-blue); 
}

/* --- TIMING DECK --- */
.timing-deck { flex-grow: 1; min-width: 0; } /* min-width 0 prevents flex blowouts */
.deck-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 1rem; padding: 0 10px; }
.deck-title { font-size: clamp(1.2rem, 4vw, 1.8rem); font-family: var(--font-mono); font-weight: 700; color: #fff; letter-spacing: 1px; }
.sim-tag { font-family: var(--font-mono); font-size: 1.2rem; margin-right: 10px; font-weight: 800; }
.deck-metadata { font-family: var(--font-mono); font-size: 0.6rem; color: #444; letter-spacing: 2px; }

/* --- LAYOUT SELECTOR BAR --- */
.layout-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    background: rgba(255,255,255,0.02);
    padding: 10px 15px;
    border: 1px solid rgba(255,255,255,0.05);
}
.selector-label { font-family: var(--font-mono); font-size: 0.6rem; color: #444; letter-spacing: 2px; }
.layout-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.layout-btn {
    font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-secondary); text-decoration: none; padding: 4px 10px; border: 1px solid #222; transition: 0.2s;
}
.layout-btn:hover { border-color: #444; color: #fff; }
.layout-btn.active { border-color: var(--accent-blue); color: var(--accent-blue); background: rgba(0, 170, 255, 0.05); }

/* --- THE GRID --- */
.timing-grid { width: 100%; }
.grid-row { display: flex; align-items: center; height: 41px; padding: 0 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.grid-head { height: 32px; background: rgba(255, 255, 255, 0.02); font-family: var(--font-mono); font-size: 0.65rem; color: var(--accent-blue); font-weight: 700; letter-spacing: 1px; }
.grid-row:hover:not(.grid-head) { background: rgba(255, 255, 255, 0.03); }


/* === COLUMN DEFINITIONS (CORRECT SPACING) === */
.g-pos { flex: 0 0 45px; font-family: var(--font-mono); color: #444; font-size: 0.9rem; }
.g-driver { flex: 2 1 20%; font-weight: 700; color: #fff; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 120px; }
.g-car { flex: 1.5 1 18%; color: var(--text-secondary); font-size: 0.75rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 150px; text-align: left; padding-left: 1rem; }
.g-time { flex: 1 1 12%; text-align: right; font-family: var(--font-mono); font-size: 1rem; color: #fff; font-weight: 700; min-width: 100px;}
.g-int { flex: 1 1 10%; text-align: right; font-family: var(--font-mono); font-size: 0.75rem; color: #555; min-width: 80px;}
.g-conditions { flex: 2 1 25%; display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; min-width: 230px;}
/* === END COLUMN DEFINITIONS === */


/* Conditions Widgets */
.condition-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: help;
}
.condition-pill i { opacity: 0.6; }

/* --- THE ONLY CHANGE IS ADDING THIS SECTION --- */
/* 4-TIER TEMPERATURE COLOR SCALE */
.g-time.temp-cool,       .condition-pill.temp-cool       { color: #a0c4ff; } /* Light Blue (< 20°C) */
.g-time.temp-warm,       .condition-pill.temp-warm       { color: #8cb6ff; } /* Blue (20-29°C) */
.g-time.temp-hot,        .condition-pill.temp-hot        { color: #ffb18c; } /* Orange (30-39°C) */
.g-time.temp-very-hot,   .condition-pill.temp-very-hot   { color: #ff8c8c; } /* Red (>= 40°C) */
.g-time.temp-unknown,    .condition-pill.temp-unknown    { color: #555; }    /* Grey for missing data */
/* --- END OF CHANGE --- */

@keyframes spin { 100% { transform: rotate(360deg); } }
.condition-pill.wind-calm i { animation: none; }
.condition-pill.wind-breezy i { animation: spin 4s linear infinite; }
.condition-pill.wind-fast i { animation: spin 1.5s linear infinite; }

/* Podium Colors - Desktop */
.p1-row { border-left: 2px solid #FFD700; background: rgba(255, 215, 0, 0.03); }
.p1-row .g-pos { color: #FFD700; }
.grid-row:nth-of-type(3) { border-left: 2px solid #C0C0C0; }
.grid-row:nth-of-type(3) .g-pos { color: #C0C0C0; }
.grid-row:nth-of-type(4) { border-left: 2px solid #CD7F32; }
.grid-row:nth-of-type(4) .g-pos { color: #CD7F32; }


/* Pagination */
.deck-footer { margin-top: 1.5rem; display: flex; justify-content: center; }
.pg-nav { display: flex; align-items: center; gap: 1rem; }
.nav-btn { font-family: var(--font-mono); font-size: 0.7rem; color: #fff; padding: 8px 15px; border: 1px solid #333; text-decoration: none; }
.nav-btn.disabled { opacity: 0.1; pointer-events: none; }
.pg-indicator { font-family: var(--font-mono); font-size: 0.7rem; color: #444; }


/* ==========================================================
   MOBILE OPTIMIZATION (Dropdown Menu & Themed Card Layout)
   ========================================================== */

.mobile-only { display: none; }
.desktop-only { display: block; }
.mobile-track-select { width: 100%; padding: 12px 15px; font-family: var(--font-mono); font-size: 0.9rem; background-color: var(--bg-panel); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 0; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml;charset=UTF8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='%23555'%3E%3Cpath%20d='M7%2010l5%205%205-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 15px center; background-size: 1.2em; cursor: pointer; }

@media (max-width: 992px) {
    .desktop-only { display: none; }
    .mobile-only { display: block; }
    .telemetry-wrapper { flex-direction: column; padding: 1rem; gap: 1rem; }
    .circuit-select-mobile { margin-bottom: 1rem; }
    .deck-header { flex-direction: column; align-items: flex-start; gap: 5px; padding: 0; }
    .layout-selector { flex-direction: column; align-items: flex-start; padding: 10px; }
    .timing-grid { display: flex; flex-direction: column; gap: 0.75rem; }
    .grid-head { display: none; }

    .grid-row { background: var(--bg-panel); border: 1px solid var(--border-color); clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%); padding: 0.75rem 1rem; display: flex; flex-wrap: wrap; align-items: center; height: auto; border-bottom: 1px solid var(--border-color); }
    .grid-row:hover { background: rgba(0, 170, 255, 0.04); border-color: rgba(0, 170, 255, 0.4); }

    .p1-row { border: 1px solid #FFD700; box-shadow: 0 0 12px -2px #FFD700; border-left: 1px solid #FFD700; }
    .p1-row .g-pos { color: #FFD700; }
    .grid-row:nth-of-type(3) { border-color: #C0C0C0; }
    .grid-row:nth-of-type(3) .g-pos { color: #C0C0C0; }
    .grid-row:nth-of-type(4) { border-color: #CD7F32; }
    .grid-row:nth-of-type(4) .g-pos { color: #CD7F32; }

    .g-pos, .g-driver, .g-car, .g-time, .g-int { width: auto; flex: none; text-align: left; white-space: normal; margin: 0.1rem 0; }

    .g-pos { width: 45px; font-size: 1.6rem; font-weight: 700; color: var(--text-secondary); flex-shrink: 0; text-align: center; }
    .g-driver { width: calc(100% - 45px); padding-left: 0.75rem; font-size: 1rem; font-weight: 700; color: var(--text-primary); }
    .grid-row::before { content: ''; width: 45px; order: 2; }
    .g-time { order: 3; font-size: 1.1rem; font-family: var(--font-mono); color: var(--text-primary); font-weight: 700; padding-left: 0.75rem; }
    .g-int { order: 4; font-size: 0.8rem; font-family: var(--font-mono); color: var(--text-secondary); padding-left: 1rem; }
    .g-car, .g-conditions { display: none; }
}

@media (max-width: 480px) {
    .telemetry-wrapper { padding: 0.5rem; }
    .grid-row { padding: 0.75rem; }
    .g-pos { width: 40px; font-size: 1.3rem; }
    .g-driver { width: calc(100% - 40px); font-size: 0.9rem; }
    .grid-row::before { width: 40px; }
    .g-time { font-size: 1rem; }
    .g-int { font-size: 0.75rem; }
    .nav-btn { padding: 6px 10px; font-size: 0.6rem; }
}