/* ══════════════════════════════════════════
   Pit Wall Broadcast Dashboard Styles
   ══════════════════════════════════════════ */

/* ── Mobile blocker ── */
.pw-mobile-block {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    background: #080808;
    font-family: 'Formula1', sans-serif;
    color: #e0e0e0;
    text-align: center;
    padding: 2rem;
}
.pw-mobile-icon { font-size: 3rem; margin-bottom: 1rem; }
.pw-mobile-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.pw-mobile-msg { font-size: 0.8rem; color: #8a8a94; max-width: 260px; line-height: 1.5; }

@media (max-width: 767px) {
    .pw-mobile-block { display: flex; }
    .pw-broadcast { display: none !important; }
}

/* ── Full-width breakout ── */
main:has(.pw-broadcast) {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 100dvh;
    overflow: hidden;
}
/* Hide base nav, racing stripe, mobile nav, footer — pitwall has its own header */
body:has(.pw-broadcast) nav,
body:has(.pw-broadcast) .racing-stripe,
body:has(.pw-broadcast) footer {
    display: none !important;
}
/* Also hide the mobile nav row (it uses bg-carbon-black) */
body:has(.pw-broadcast) > div > div.bg-carbon-black {
    display: none !important;
}

.pw-broadcast {
    width: 100%;
    height: 100%;
    background: #080808;
    font-family: 'Formula1', sans-serif;
    color: #e0e0e0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Header bar ── */
.pw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: linear-gradient(180deg, #111113 0%, #0a0a0c 100%);
    border-bottom: 1px solid #1a1a1e;
}
.pw-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.pw-header-left img { height: 32px; opacity: 0.9; }
.pw-header-left .pw-divider {
    width: 1px;
    height: 28px;
    background: #2e2e34;
}
.pw-driver-info {
    display: flex;
    align-items: center;
    gap: 16px;
}
.pw-driver-name {
    font-size: clamp(0.9rem, 2vw, 1.5rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #f0f0f0;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}
.pw-driver-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: #00e676;
    color: #0a0a0a;
    font-size: 1.4rem;
    font-weight: 700;
    border-radius: 6px;
}

/* ── Controls row ── */
.pw-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 24px;
    background: #0c0c0e;
    border-bottom: 1px solid #1a1a1e;
}

/* ── Main 3-column grid ── */
.pw-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1fr;
    gap: 10px;
    padding: 10px 14px;
    flex: 1;
    min-height: 0;
}

/* ── Column layouts ── */
.pw-col-left,
.pw-col-center,
.pw-col-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

/* ── Panel base ── */
.pw-panel {
    background: #111114;
    border: 1px solid #1e1e24;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}
.pw-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #8a8a94;
}
.pw-panel-title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: #ff7300;
    border-radius: 1px;
    flex-shrink: 0;
}
.pw-panel-body {
    padding: 6px 14px 14px;
}

/* ── Race Status Panel ── */
.pw-race-status {
    flex: 1.2;
    display: flex;
    flex-direction: column;
}
.pw-race-status > .pw-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.pw-status-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: #1a1a1e;
    border-radius: 4px;
    overflow: hidden;
}
.pw-status-cell {
    background: #0e0e10;
    padding: 5px 0;
    text-align: center;
}
.pw-status-label {
    font-size: 0.5rem;
    font-weight: 700;
    color: #55555e;
    letter-spacing: 0.1em;
    margin-bottom: 1px;
}
.pw-status-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e0e0e0;
}
.pw-track-map-mini {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 3px;
    min-height: 0;
}
.pw-track-map-mini canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.pw-track-flag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    font-weight: 700;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.pw-race-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
}
.pw-race-stat {
    text-align: center;
}
.pw-race-stat-label {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #55555e;
    margin-bottom: 2px;
}
.pw-race-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e0e0e0;
    line-height: 1.2;
}
.pw-race-stat-sub {
    font-size: 0.7rem;
    font-weight: 700;
    color: #00e676;
}

/* ── Speed Gauge ── */
.pw-speed-gauge {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}
.pw-gauge-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 22dvh;
}
.pw-gauge-container canvas {
    width: 100%;
    height: 100%;
}

/* ── Weather Panel ── */
.pw-weather { flex: 0 0 auto; }
.pw-weather-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    text-align: center;
}
.pw-weather-item-label {
    font-size: 0.45rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #55555e;
    margin-bottom: 2px;
    white-space: nowrap;
}
.pw-weather-item-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e0e0e0;
}
.pw-weather-item-unit {
    font-size: 0.55rem;
    color: #55555e;
    margin-left: 1px;
}

/* ── Center Column: Car Telemetry ── */
.pw-car-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.pw-car-section > .pw-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 3-column flex: left-data | car | right-data */
.pw-car-layout {
    display: flex;
    align-items: stretch;
    flex: 1;
    position: relative;
    min-height: 0;
}

/* Center car column — fixed width, image absolutely positioned inside */
.pw-car-center {
    flex: 0 0 300px;
    position: relative;
    overflow: visible;
    pointer-events: none;
}
.pw-car-center img {
    position: absolute;
    top: 50%;
    left: 50%;
    /*
     * car.png = 1436×796 (landscape, nose right).
     * rotate(-90deg) → nose up.  After rotation the CSS width
     * controls visual height.  min() caps at 680px on large
     * screens, scales down via 70dvh on shorter viewports (iPad).
     */
    width: min(800px, 58dvh);
    height: auto;
    max-width: none;
    transform: translate(-50%, -50%) rotate(-90deg);
    filter: drop-shadow(0 0 30px rgba(0,0,0,0.8));
    opacity: 0.92;
}

/* Data columns — flanking the car on left and right */
.pw-car-data-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    z-index: 1;
    padding: 16px 10px;
    min-width: 0;
}
.pw-car-data-col.left { text-align: right; }
.pw-car-data-col.right { text-align: left; }

/* Tire info blocks — semi-transparent background for readability over car */
.pw-tire-block {
    background: rgba(10, 10, 14, 0.88);
    border: 1px solid rgba(30, 30, 40, 0.6);
    border-radius: 4px;
    padding: 6px 10px;
}
.pw-tire-sub-label {
    font-size: 0.45rem;
    font-weight: 700;
    color: #55555e;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0;
    margin-top: 3px;
}
.pw-tire-sub-label:first-child { margin-top: 0; }
.pw-tire-temp-value {
    font-size: clamp(0.8rem, 1.8vw, 1.15rem);
    font-weight: 700;
    color: #e0e0e0;
    line-height: 1.3;
}
.pw-tire-temp-value .pw-unit {
    font-size: 0.55rem;
    color: #55555e;
    margin-left: 2px;
}

/* ── Engine Temp / RPM / Gauge bars ── */
.pw-gauges-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex: 0 0 auto;
}
.pw-bar-gauge-title {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #8a8a94;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pw-bar-gauge-title::before {
    content: '';
    width: 3px;
    height: 10px;
    border-radius: 1px;
}
.pw-bar-gauge-title.engine::before { background: #ff1744; }
.pw-bar-gauge-title.fuel::before { background: #00b0ff; }
.pw-bar-gauge-title.rpm::before { background: #ff7300; }
.pw-bar-gauge-title.shift::before { background: #00cc66; }

/* ── Shift Lights ── */
.pw-shift-lights {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 6px 0 2px;
}
.pw-shift-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1a1a2e;
    transition: background 0.1s, box-shadow 0.1s;
}
.pw-shift-led.pw-shift-lit.pw-shift-green {
    background: #00cc66;
    box-shadow: 0 0 6px rgba(0, 204, 102, 0.6);
}
.pw-shift-led.pw-shift-lit.pw-shift-red {
    background: #ff3333;
    box-shadow: 0 0 6px rgba(255, 51, 51, 0.6);
}
.pw-shift-led.pw-shift-lit.pw-shift-blue {
    background: #9933ff;
    box-shadow: 0 0 6px rgba(153, 51, 255, 0.6);
}
.pw-shift-led.pw-shift-flash.pw-shift-lit {
    animation: pw-shift-blink 0.25s step-end infinite;
}
.pw-shift-led.pw-shift-flash.pw-shift-lit.pw-shift-green {
    animation: pw-shift-blink-green 0.25s step-end infinite;
}
.pw-shift-led.pw-shift-flash.pw-shift-lit.pw-shift-red {
    animation: pw-shift-blink-red 0.25s step-end infinite;
}
.pw-shift-led.pw-shift-flash.pw-shift-lit.pw-shift-blue {
    animation: pw-shift-blink-blue 0.25s step-end infinite;
}
@keyframes pw-shift-blink-green {
    0%, 49% { background: #00cc66; box-shadow: 0 0 6px rgba(0,204,102,0.6); }
    50%, 100% { background: #1a1a2e; box-shadow: none; }
}
@keyframes pw-shift-blink-red {
    0%, 49% { background: #ff3333; box-shadow: 0 0 6px rgba(255,51,51,0.6); }
    50%, 100% { background: #1a1a2e; box-shadow: none; }
}
@keyframes pw-shift-blink-blue {
    0%, 49% { background: #9933ff; box-shadow: 0 0 6px rgba(153,51,255,0.6); }
    50%, 100% { background: #1a1a2e; box-shadow: none; }
}

/* ── Gear Strip ── */
.pw-gear-strip {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 4px 0;
}
.pw-gear-indicator {
    width: 1.8rem;
    height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #333;
    border-radius: 3px;
    background: #0a0a0c;
    transition: color 0.15s, background 0.15s;
}
.pw-gear-active {
    color: #ff7300;
    background: rgba(255, 115, 0, 0.15);
    box-shadow: 0 0 6px rgba(255, 115, 0, 0.3);
}

/* ── Lap Times Panel ── */
.pw-lap-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #1a1a1e;
    border-radius: 4px;
    overflow: hidden;
}
.pw-lap-time-item {
    background: #0e0e10;
    padding: 5px 10px;
    text-align: center;
}
.pw-lap-time-label {
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #55555e;
    margin-bottom: 2px;
}
.pw-lap-time-value {
    font-size: 1rem;
    font-weight: 700;
    color: #e0e0e0;
    font-variant-numeric: tabular-nums;
}
.pw-lap-time-value.best { color: #b388ff; }

/* ── Sector Times Panel ── */
.pw-sector-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #1a1a1e;
    border-radius: 4px;
    overflow: hidden;
}
.pw-sector-cell {
    background: #0e0e10;
    padding: 5px 0;
    text-align: center;
}
.pw-sector-label {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 1px;
}
.pw-sector-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e0e0e0;
    font-variant-numeric: tabular-nums;
}
.pw-bar-gauge-track {
    height: 14px;
    background: #0a0a0c;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.pw-bar-gauge-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease-out;
}
.pw-bar-gauge-fill.engine {
    background: linear-gradient(90deg, #ff1744, #ff4444);
}
.pw-bar-gauge-fill.rpm {
    background: linear-gradient(90deg, #00e676 0%, #32CD32 30%, #ffeb3b 55%, #ff9100 75%, #ff1744 90%);
}
.pw-bar-gauge-fill.fuel {
    background: linear-gradient(90deg, #0077b6, #00b0ff);
}
.pw-bar-scale {
    display: flex;
    justify-content: space-between;
    padding: 2px 0 0;
    font-size: 0.45rem;
    font-weight: 700;
    color: #3a3a42;
}

/* ── Right Column: Chart Panels ── */
.pw-chart-card {
    flex: 1;
    background: #111114;
    border: 1px solid #1e1e24;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.pw-chart-header {
    padding: 8px 12px 4px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.pw-chart-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #8a8a94;
}
.pw-chart-range {
    font-size: 0.55rem;
    font-weight: 700;
    color: #3a3a42;
}
.pw-chart-body {
    display: flex;
    flex: 1;
    align-items: stretch;
    gap: 10px;
    padding: 0 8px;
    min-height: 0;
}
.pw-chart-canvas-wrap {
    flex: 1;
    position: relative;
    min-height: 80px;
}
.pw-chart-canvas-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.pw-chart-stats-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    align-self: center;
    min-width: 60px;
}
.pw-chart-body > .pw-value-ring {
    align-self: center;
    flex-shrink: 0;
}

/* Current value ring */
.pw-value-ring {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
}
.pw-value-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--ring-color, #ff7300);
    opacity: 0.5;
}
.pw-value-ring-number {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ring-color, #ff7300);
}
.pw-value-ring-unit {
    font-size: 0.45rem;
    font-weight: 700;
    color: #55555e;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 1px;
}

/* High/Low stats */
.pw-chart-stat {
    text-align: center;
    line-height: 1.2;
}
.pw-chart-stat-label {
    font-size: 0.45rem;
    font-weight: 700;
    color: #3a3a42;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.pw-chart-stat-value {
    font-size: 0.7rem;
    font-weight: 700;
}
.pw-chart-stat-value.high { color: #ff7300; }
.pw-chart-stat-value.low { color: #00b0ff; }

/* ── Streaming pulse ── */
@keyframes pw-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0,230,118,0.5); }
    70% { box-shadow: 0 0 0 8px rgba(0,230,118,0); }
    100% { box-shadow: 0 0 0 0 rgba(0,230,118,0); }
}
.pw-led-pulse { animation: pw-pulse 2s ease-in-out infinite; }

/* ── Fade-in animation ── */
@keyframes pw-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.pw-fade-in {
    animation: pw-fade-in 0.4s ease-out forwards;
    opacity: 0;
}

/* ── Responsive: Desktop large ── */
@media (min-width: 1440px) {
    .pw-value-ring { width: 90px; height: 90px; }
    .pw-chart-body { gap: 16px; padding: 0 12px; }
    .pw-value-ring::before { border-width: 3px; }
    .pw-value-ring-number { font-size: 2rem; }
    .pw-value-ring-unit { font-size: 0.55rem; }
    .pw-chart-stat-label { font-size: 0.65rem; }
    .pw-chart-stat-value { font-size: 1.1rem; }
    .pw-car-center { flex: 0 0 350px; }
    .pw-car-center img { width: min(800px, 65dvh); }
    .pw-tire-block { padding: 10px 14px; }
    .pw-tire-temp-value { font-size: 1.3rem; }
    .pw-tire-sub-label { font-size: 0.55rem; }
}

/* ── Responsive: iPad / tablets ── */
@media (max-width: 1280px) {
    .pw-car-center { flex: 0 0 220px; }
    .pw-car-data-col { padding: 8px 4px; }
    .pw-tire-block { padding: 4px 6px; }
    .pw-tire-sub-label { font-size: 0.4rem; margin-top: 2px; }
    .pw-tire-temp-value { font-size: 0.8rem; line-height: 1.2; }
}

/* ── Responsive: Small screens ── */
@media (max-width: 1024px) {
    .pw-grid {
        grid-template-columns: 1fr;
    }
    .pw-driver-name { font-size: 1rem; }
    .pw-header { padding: 8px 16px; }
    .pw-car-center { flex: 0 0 180px; }
}
