/* ============================================
   RAVEN OS - Race Control page styles
   Extends raven-theme.css. Pit-wall, glanceable-at-3m aesthetic.
   Sharp corners, thin hairline borders, monospace for numbers.
   ============================================ */

.rc-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 36px);
    background: #000;
    color: #fff;
    font-family: Rajdhani, sans-serif;
    overflow: hidden;
}

/* ---- SOS taskbar strip (fixed above everything) ---- */
.rc-sos-strip {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: #ef4444;
    box-shadow: 0 0 18px rgba(239,68,68,0.9);
    z-index: 10003;
    animation: rc-sos-strip 1s infinite;
}
.rc-sos-strip.show { display: block; }
@keyframes rc-sos-strip {
    0%,100% { opacity: 1; }
    50%     { opacity: 0.35; }
}

/* ---- Top bar: ELAPSED / REMAINING / LIVE ---- */
.rc-topbar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: #050505;
    flex-shrink: 0;
    height: 64px;
}

.rc-topbar-cell {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.rc-topbar-cell.center { justify-content: center; }
.rc-topbar-cell.right  { justify-content: flex-end; }

.rc-label {
    font-size: 11px;
    font-weight: 700;
    color: #666;
    letter-spacing: 3px;
    text-transform: uppercase;
}
.rc-big-clock {
    font-family: 'Liberation Mono', Consolas, monospace;
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}
.rc-big-clock.dim { color: #888; }

.rc-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 3px;
    color: #888;
    text-transform: uppercase;
}
.rc-live .dot {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    animation: rc-live-pulse 1.4s infinite;
}
.rc-live.stale .dot { background: #ef4444; animation: none; }
.rc-live.stale { color: #ef4444; }
@keyframes rc-live-pulse {
    0%,100% { opacity: 1; }
    50%     { opacity: 0.35; }
}

.rc-set-race-btn {
    background: transparent;
    border: 1px solid #333;
    color: #666;
    font-family: Rajdhani, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 4px 10px;
    cursor: pointer;
    margin-left: 8px;
}
.rc-set-race-btn:hover { border-color: #8b241d; color: #fff; }

/* ---- Main grid: one column per kart ---- */
.rc-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rc-col {
    position: relative;
    padding: 18px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
}
.rc-col + .rc-col {
    border-left: 1px solid rgba(255,255,255,0.08);
}
.rc-col.sos {
    background: #8b0000;
    animation: rc-col-sos 0.9s infinite;
}
@keyframes rc-col-sos {
    0%,100% { background: #7a0000; }
    50%     { background: #b30000; }
}

/* Kart header */
.rc-kart-header {
    display: flex;
    align-items: baseline;
    gap: 14px;
}
.rc-kart-name {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: #8b241d;
}
.rc-col.sos .rc-kart-name { color: #fff; }
.rc-kart-underline {
    height: 2px;
    background: #8b241d;
    width: 64px;
    margin-top: 4px;
}
.rc-col.sos .rc-kart-underline { background: #fff; }

.rc-sos-banner {
    display: none;
    margin-top: 4px;
    padding: 10px 14px;
    background: #000;
    border: 2px solid #fff;
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: #fff;
    animation: rc-sos-text 0.8s infinite;
    font-family: 'Liberation Mono', Consolas, monospace;
    text-align: center;
}
.rc-col.sos .rc-sos-banner { display: block; }
@keyframes rc-sos-text {
    0%,100% { opacity: 1; }
    50%     { opacity: 0.45; }
}

/* Driver name */
.rc-driver {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #fff;
    font-family: 'Liberation Sans', 'Segoe UI', sans-serif;
    line-height: 1;
}
.rc-driver.empty {
    color: #333;
    letter-spacing: 4px;
}

/* Position (P3 etc) */
.rc-position {
    font-size: 96px;
    font-weight: 700;
    color: #fff;
    line-height: 0.9;
    font-family: Rajdhani, sans-serif;
    letter-spacing: -2px;
}
.rc-position .p-prefix {
    font-size: 36px;
    color: #666;
    margin-right: 8px;
    vertical-align: top;
    letter-spacing: 0;
}
.rc-position.empty { color: #333; }

/* Lap time */
.rc-lap-time {
    font-size: 72px;
    font-weight: 700;
    color: #fff;
    font-family: 'Liberation Mono', Consolas, monospace;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: 1px;
}
.rc-lap-time.empty { color: #333; }
.rc-lap-best {
    font-size: 18px;
    color: #8b241d;
    font-family: 'Liberation Mono', Consolas, monospace;
    margin-top: 6px;
    letter-spacing: 2px;
}
.rc-col.sos .rc-lap-best { color: #fff; }

/* Battery bar */
.rc-battery-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 2px;
}
.rc-battery-bar {
    flex: 1;
    height: 14px;
    background: #111;
    border: 1px solid #333;
    position: relative;
    overflow: hidden;
}
.rc-battery-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: #fff;
    transition: width 0.8s ease;
    width: 0;
}
.rc-battery-fill.warn  { background: #eab308; }
.rc-battery-fill.alert { background: #ef4444; }
.rc-battery-pct {
    font-family: 'Liberation Mono', Consolas, monospace;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    min-width: 62px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.rc-battery-pct.alert { color: #ef4444; }
.rc-battery-pct.warn  { color: #eab308; }

/* Lap pill */
.rc-lap-pill {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-family: 'Liberation Mono', Consolas, monospace;
    font-size: 18px;
    font-weight: 700;
    color: #888;
    letter-spacing: 4px;
    text-transform: uppercase;
    justify-content: center;
}

/* Gap */
.rc-gap-row {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 14px;
    align-items: baseline;
}
.rc-gap-label {
    font-size: 13px;
    color: #666;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}
.rc-gap-value {
    font-family: 'Liberation Mono', Consolas, monospace;
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.rc-gap-value.ahead  { color: #22c55e; }
.rc-gap-value.behind { color: #ef4444; }
.rc-gap-value.empty  { color: #333; }

/* Stint */
.rc-stint-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.rc-stint-label {
    font-size: 13px;
    color: #666;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}
.rc-stint-value {
    font-family: 'Liberation Mono', Consolas, monospace;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.rc-stint-value.empty { color: #333; }

/* ---- Footer strip (fastest lap etc) ---- */
.rc-footer {
    height: 48px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    background: #050505;
    flex-shrink: 0;
    font-family: 'Liberation Mono', Consolas, monospace;
    font-size: 14px;
    color: #888;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.rc-footer-label {
    color: #555;
    font-weight: 700;
}
.rc-footer-value {
    color: #fff;
    font-weight: 700;
}
.rc-footer-sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.08);
}

/* ---- Tight-viewport tweaks (1366x768) ---- */
@media (max-height: 800px) {
    .rc-topbar { height: 52px; padding: 6px 16px; }
    .rc-big-clock { font-size: 26px; }
    .rc-col { padding: 12px 20px; gap: 8px; }
    .rc-kart-name { font-size: 22px; }
    .rc-driver { font-size: 38px; }
    .rc-position { font-size: 72px; }
    .rc-position .p-prefix { font-size: 28px; }
    .rc-lap-time { font-size: 56px; }
    .rc-stint-value { font-size: 22px; }
    .rc-footer { height: 36px; font-size: 12px; }
}

@media (max-width: 1100px) {
    .rc-kart-name { letter-spacing: 4px; }
    .rc-driver { letter-spacing: 2px; }
}

/* ---- Dashboard live tiles ---- */
.rc-tiles {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    padding: 12px;
    overflow: auto;
    align-content: start;
}
.rc-tile {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 160px;
    position: relative;
    overflow: hidden;
}
.rc-tile:hover {
    border-color: #8b241d;
    box-shadow: 0 0 0 1px #8b241d, 0 0 18px rgba(139,36,29,0.25);
}
.rc-tile.primary {
    border-color: rgba(139,36,29,0.5);
    grid-column: span 2;
    min-height: 180px;
}
.rc-tile-title {
    font-size: 11px;
    font-weight: 700;
    color: #8b241d;
    letter-spacing: 4px;
    text-transform: uppercase;
}
.rc-tile-sub {
    font-size: 10px;
    color: #555;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.rc-tile-hero {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    font-family: 'Liberation Mono', Consolas, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}
.rc-tile-status-ok  { color: #22c55e; font-weight: 700; letter-spacing: 2px; font-size: 12px; }
.rc-tile-status-sos { color: #ef4444; font-weight: 700; letter-spacing: 2px; font-size: 14px; animation: rc-live-pulse 1s infinite; }
.rc-tile-mini-map {
    flex: 1;
    background: #050505;
    border: 1px solid #111;
    position: relative;
    min-height: 80px;
}
.rc-tile-footer {
    display: flex;
    gap: 8px;
    align-items: baseline;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* small dot for mini-map markers */
.rc-mini-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px currentColor;
}
.rc-mini-dot.alpha { background: #8b241d; color: #8b241d; }
.rc-mini-dot.bravo { background: #1e40af; color: #1e40af; }
.rc-mini-dot.sos   { animation: rc-mini-sos 1s infinite; }
@keyframes rc-mini-sos {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.9); }
    50%     { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Server-dot in taskbar */
.raven-server-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #333;
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}
.raven-server-dot.ok   { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); }
.raven-server-dot.stale { background: #ef4444; }

/* ============================================================
   Arm-alarm chip (race-control.html).
   Rendered bottom-right near the footer — small, non-blocking, but
   clearly yellow when the audio context hasn't been unlocked yet.
   ============================================================ */
.rc-arm-alarm {
    position: fixed;
    right: 14px;
    bottom: 60px;
    z-index: 10005;
    min-height: 44px;    /* 44px = Apple touch-target baseline */
    padding: 8px 16px;
    background: #1a1204;
    border: 1px solid #eab308;
    color: #eab308;
    font-family: Rajdhani, sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.rc-arm-alarm:hover,
.rc-arm-alarm:focus {
    background: #2a1f08;
    outline: none;
}
.rc-arm-alarm .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #eab308;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.8);
    animation: rc-live-pulse 1.4s infinite;
}
.rc-arm-alarm.armed {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}
.rc-arm-alarm.armed .dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
    animation: none;
}

/* ============================================================
   Responsive / touch-friendly — phone and tablet viewports.
   Target iPhone 13 mini (390x844) and similar.
   ============================================================ */

/* All interactive controls hit the 44px touch-target minimum. */
@media (max-width: 768px) {
    .rc-set-race-btn,
    .rc-arm-alarm {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 13px;
    }

    /* Stack the race-control grid vertically — one kart per row. */
    .rc-grid {
        grid-template-columns: 1fr;
    }
    .rc-col + .rc-col {
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    /* Topbar reflows tighter on narrow screens. */
    .rc-topbar {
        grid-template-columns: 1fr 1fr;
        height: auto;
        padding: 8px 12px;
        row-gap: 4px;
    }
    .rc-topbar-cell.right {
        grid-column: 1 / -1;
        justify-content: space-between;
    }

    /* Fluid type that still reads at 3 m on bigger screens. */
    .rc-big-clock   { font-size: clamp(20px, 6vw, 32px); }
    .rc-kart-name   { font-size: clamp(18px, 5vw, 28px); letter-spacing: 4px; }
    .rc-driver      { font-size: clamp(28px, 8vw, 48px); letter-spacing: 2px; }
    .rc-position    { font-size: clamp(56px, 18vw, 96px); }
    .rc-position .p-prefix { font-size: clamp(22px, 6vw, 36px); }
    .rc-lap-time    { font-size: clamp(40px, 11vw, 72px); }
    .rc-stint-value { font-size: clamp(18px, 5vw, 28px); }
    .rc-sos-banner  { font-size: clamp(24px, 7vw, 40px); letter-spacing: 3px; }

    .rc-col { padding: 12px 14px; gap: 8px; }

    /* Footer wraps instead of clipping. */
    .rc-footer {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        row-gap: 4px;
    }
    .rc-footer-sep { display: none; }

    /* Dashboard tiles: full width cards, single column. */
    .rc-tiles {
        grid-template-columns: 1fr;
        padding: 8px;
    }
    .rc-tile.primary { grid-column: span 1; }
}

/* Even tighter — iPhone 13 mini portrait (≤430 px). */
@media (max-width: 430px) {
    .rc-topbar-cell { gap: 6px; }
    .rc-label       { letter-spacing: 2px; font-size: 10px; }
    .rc-set-race-btn { margin-left: 0; }
    .rc-arm-alarm    { right: 8px; bottom: 50px; font-size: 12px; }
}
