/* race.css
   Dark-theme layout for the interactive race view.
   Grid: metadata | map (flex:1) | transport | telemetry.
*/

html, body {
    height: 100%;
    margin: 0;
    background-color: #111;
    color: #ffffff;
    font-family: "Neue Helvetica", system-ui, -apple-system, Arial, sans-serif;
}

#race-root {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
}

/* ---------- metadata strip ---------- */
#metadata-strip {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    background-color: #1a1a1a;
    border: 1px solid #333;
    padding: 10px 16px;
    flex-wrap: wrap;
}
#metadata-strip .metric {
    text-align: center;
}
#metadata-strip .metric .label {
    font-size: 11px;
    text-transform: uppercase;
    color: #aaaaaa;
    letter-spacing: 0.06em;
}
#metadata-strip .metric .value {
    font-size: 20px;
    color: #ff9955;
    margin-top: 2px;
}
#metadata-strip .metric .value .unit {
    font-size: 12px;
    color: #888;
    margin-left: 3px;
}

/* ---------- map ---------- */
#map {
    width: 100%;
    min-height: 0;
    background-color: #0b0b0b;
    border: 1px solid #333;
    position: relative;
}
.load-error {
    color: #e06060;
    text-align: center;
    padding-top: 40px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- transport controls ---------- */
#transport {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background-color: #1a1a1a;
    border: 1px solid #333;
}

#play-pause {
    background-color: #ff9955;
    color: #111;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 2px;
    min-width: 72px;
}
#play-pause:hover {
    background-color: #ffaa77;
}

#scrubber-wrap {
    flex: 1;
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}
#scrubber-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: #333;
    border-radius: 2px;
    pointer-events: none;
}
.scrubber-gap {
    position: absolute;
    top: 0;
    height: 100%;
    background: #c23b3b;
    border-radius: 2px;
}
#scrubber {
    flex: 1;
    width: 100%;
    height: 24px;
    position: relative;
    z-index: 1;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
#scrubber::-webkit-slider-runnable-track {
    background: transparent;
    height: 4px;
    border-radius: 2px;
}
#scrubber::-moz-range-track {
    background: transparent;
    height: 4px;
    border-radius: 2px;
}
#scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff9955;
    border: 2px solid #111;
    margin-top: -6px;
    cursor: grab;
}
#scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff9955;
    border: 2px solid #111;
    cursor: grab;
}

.time-label {
    color: #ccc;
    font-variant-numeric: tabular-nums;
    min-width: 68px;
    text-align: right;
    font-size: 14px;
}

#rates {
    display: flex;
    gap: 4px;
}
#rates button {
    background-color: #222;
    color: #bbb;
    border: 1px solid #333;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 2px;
    min-width: 40px;
}
#rates button:hover {
    background-color: #2a2a2a;
    color: #fff;
}
#rates button.active {
    background-color: #ff9955;
    color: #111;
    border-color: #ff9955;
    font-weight: bold;
}

/* ---------- telemetry readout ---------- */
#telemetry {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    padding: 10px 16px;
    background-color: #1a1a1a;
    border: 1px solid #333;
    flex-wrap: wrap;
}
#telemetry .readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}
#telemetry .readout .label {
    font-size: 11px;
    text-transform: uppercase;
    color: #aaaaaa;
    letter-spacing: 0.06em;
}
#telemetry .readout .value {
    font-size: 20px;
    color: #ff9955;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
#telemetry .readout .value .unit {
    font-size: 12px;
    color: #888;
    margin-left: 3px;
}
#telemetry .readout .heading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.heading-arrow {
    display: inline-block;
    width: 1em;
    height: 1em;
    line-height: 1em;
    text-align: center;
    color: #ff9955;
    transition: transform 0.15s ease-out;
    transform-origin: center;
}

/* Wind readouts: one pill per station in payload.wind_sources,
   injected at runtime by race.js. The pill carries the station
   label + wind speed; the numeric "from" direction is rendered as
   a text label next to the arrow on the map instead, so the
   direction lives at the place the wind was measured. */
#wind-readouts {
    display: contents;
}

/* Tack pill uses side-coded color so you can eyeball the current tack
   from across the room. "PORT" red, "STARBOARD" green — racing
   convention (nav-light colors). */
#readout-tack.tack-port {
    color: #e06060;
}
#readout-tack.tack-starboard {
    color: #77dd77;
}

/* Point-of-sail value stays on the default orange; long labels
   ("broad reach") need a wider min-width to keep the pill stable. */
#readout-pos-box {
    min-width: 150px;
}

#readout-pair-angle-box {
    min-width: 150px;
}

/* ---------- sensors row ---------- */
#sensors-row {
    padding: 4px 16px 10px;
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-top: none;
    margin-top: -8px;
}
.sensors-toggle {
    background: transparent;
    color: #aaaaaa;
    border: 1px solid #333;
    padding: 3px 10px;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 2px;
    margin-bottom: 6px;
}
.sensors-toggle:hover {
    background-color: #222;
    color: #fff;
}
#sensors-panel {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    flex-wrap: wrap;
}
#sensors-panel .readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 110px;
}
#sensors-panel .readout .label {
    font-size: 11px;
    text-transform: uppercase;
    color: #aaaaaa;
    letter-spacing: 0.06em;
}
#sensors-panel .readout .value {
    font-size: 16px;
    color: #ff9955;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
#sensors-panel .readout .value .unit {
    font-size: 11px;
    color: #888;
    margin-left: 3px;
}

/* Heel horizon: a tiny tilted line next to the angle readout. A
   minimalist cousin of an attitude indicator — gives an at-a-glance
   visual on which side the boat is leaning without needing a full
   animated gauge. */
.heel-horizon {
    display: inline-block;
    position: relative;
    width: 28px;
    height: 14px;
    border: 1px solid #444;
    border-radius: 2px;
    background-color: #0e0e0e;
    margin-left: 6px;
    overflow: hidden;
    vertical-align: middle;
}
.heel-line {
    position: absolute;
    left: 2px;
    right: 2px;
    top: 50%;
    height: 2px;
    background-color: #77dd77;
    transform-origin: center center;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
    #transport {
        flex-wrap: wrap;
    }
    #scrubber-wrap {
        flex-basis: 100%;
        order: 3;
    }
    #rates {
        order: 2;
    }
    .time-label {
        order: 4;
        flex: 1;
    }
}
