/*
  Design plan
  -----------
  Subject: emergency speed restriction (ESR) boards, drawing on real
  lineside signage — permanent/temporary speed restriction diamond boards
  (black on yellow), and mechanical departure/indicator boards (amber-on-
  black split-flap displays).

  Palette:
    --bg:        #0b0e11  (near-black board casing)
    --panel:     #15191e  (card surface)
    --panel-edge:#252b32  (hairline borders)
    --amber:     #ffb100  (indicator-board amber — headers, normal speed)
    --red:       #e2231a  (BR "danger" red — severe restrictions)
    --yellow:    #f4c430  (lineside warning yellow — medium restrictions)
    --green:     #4caf7d  (all-clear — low restrictions / empty state)
    --text-dim:  #8b95a1  (secondary text)

  Type: system monospace with tabular numerals for the speed figures
  (mechanical board feel, no external font dependency — this runs on a
  Pi that may have no internet), a bold system sans, uppercase and
  letter-spaced, for headers and labels.

  Signature: each card carries a hazard-stripe edge (diagonal black/
  colour chevron, like a lineside warning board) whose colour encodes
  severity, and the speed change is set as two large mono figures
  either side of an arrow — read the way a driver reads a lineside sign.
*/

:root {
    --bg: #0b0e11;
    --panel: #15191e;
    --panel-edge: #252b32;
    --amber: #ffb100;
    --red: #e2231a;
    --yellow: #f4c430;
    --green: #4caf7d;
    --text-dim: #8b95a1;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    padding-bottom: 8vh;
    background: var(--bg);
    color: #f2f2f0;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    /* Portrait-first: comfortably fills a vertical kiosk screen, but
       scales down fine on a phone or tablet browser too. */
}

.board-header {
    padding: 4vh 5vw 2.5vh;
    text-align: center;
    border-bottom: 3px solid var(--amber);
    background:
        repeating-linear-gradient(
            135deg,
            var(--bg) 0 14px,
            #14110a 14px 28px
        );
    background-size: 100% 6px;
    background-position: bottom;
    background-repeat: no-repeat;
}

.board-title {
    font-size: clamp(1.6rem, 6vw, 2.6rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--amber);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
}

.warning-icon { font-size: 0.85em; }

.board-subtitle {
    margin-top: 0.6vh;
    font-size: clamp(0.95rem, 3vw, 1.2rem);
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

#board-body {
    padding: 3vh 4vw 3vh;
}

/* ---- Blanket restriction banner (pinned at the top) ---- */
.blanket-banner-wrap {
    display: flex;
    flex-direction: column;
    gap: 1.6vh;
    padding: 2.4vh 4vw 0;
    max-width: 720px;
    margin: 0 auto;
}

.blanket-banner {
    border-radius: 6px;
    padding: 2vh 4vw;
    text-align: center;
    border: 2px solid;
}

.blanket-banner.severity-high {
    background: rgba(226, 35, 26, 0.16);
    border-color: var(--red);
}
.blanket-banner.severity-medium {
    background: rgba(244, 196, 48, 0.14);
    border-color: var(--yellow);
}
.blanket-banner.severity-low {
    background: rgba(76, 175, 125, 0.14);
    border-color: var(--green);
}

.blanket-banner-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--amber);
}

.blanket-banner-route {
    margin-top: 0.3vh;
    font-size: clamp(1.1rem, 4.5vw, 1.5rem);
    font-weight: 700;
}

.blanket-banner-speeds {
    margin-top: 0.8vh;
    font-family: "Courier New", ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: clamp(1.6rem, 7vw, 2.2rem);
    font-weight: 800;
}
.blanket-normal { color: var(--text-dim); }
.blanket-arrow { color: var(--text-dim); margin: 0 0.3em; font-weight: 400; }
.blanket-restricted { color: var(--amber); }

.blanket-banner-reason {
    margin-top: 0.5vh;
    font-size: clamp(0.9rem, 3.2vw, 1.05rem);
}

/* ---- Autumn adhesion banner (pinned at the bottom) ---- */
.adhesion-banner {
    max-width: 720px;
    margin: 2vh auto 3vh;
    padding: 1.8vh 4vw;
    border-radius: 6px;
    text-align: center;
    border: 2px solid var(--panel-edge);
}

.adhesion-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.85;
}

.adhesion-level {
    margin-top: 0.2vh;
    font-size: clamp(1.3rem, 5.5vw, 1.8rem);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.adhesion-desc {
    margin-top: 0.2vh;
    font-size: clamp(0.85rem, 3vw, 1rem);
}

.adhesion-note {
    margin-top: 0.6vh;
    font-size: 0.85rem;
    opacity: 0.85;
}

.adhesion-green {
    background: rgba(76, 175, 125, 0.14);
    border-color: var(--green);
    color: var(--green);
}
.adhesion-amber {
    background: rgba(244, 196, 48, 0.14);
    border-color: var(--yellow);
    color: var(--yellow);
}
.adhesion-red {
    background: rgba(226, 35, 26, 0.16);
    border-color: var(--red);
    color: var(--red);
}
.adhesion-black {
    background: repeating-linear-gradient(
        45deg, #000 0 10px, #1a1300 10px 20px
    );
    border-color: var(--amber);
    color: #fff;
}
.adhesion-black .adhesion-label,
.adhesion-black .adhesion-desc,
.adhesion-black .adhesion-note { color: #fff; }
.adhesion-black .adhesion-level { color: var(--amber); }

.empty-state {
    margin-top: 12vh;
    text-align: center;
    color: var(--green);
    font-size: clamp(1.2rem, 4.5vw, 1.8rem);
    font-weight: 600;
}

.empty-tick {
    font-size: clamp(3rem, 14vw, 5rem);
    line-height: 1;
    margin-bottom: 1vh;
}

.speed-list {
    display: flex;
    flex-direction: column;
    gap: 2.4vh;
    max-width: 720px;
    margin: 0 auto;
}

.speed-card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    padding: 2.4vh 4vw 2.4vh 6vw;
    overflow: hidden;
}

/* Hazard-stripe edge, coloured per severity — evokes a lineside
   warning board's diagonal chevrons. */
.speed-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3vw;
    min-width: 16px;
    max-width: 26px;
}

.severity-high::before {
    background: repeating-linear-gradient(
        45deg, var(--red) 0 8px, #1a1a1a 8px 16px
    );
}
.severity-medium::before {
    background: repeating-linear-gradient(
        45deg, var(--yellow) 0 8px, #1a1a1a 8px 16px
    );
}
.severity-low::before {
    background: repeating-linear-gradient(
        45deg, var(--green) 0 8px, #1a1a1a 8px 16px
    );
}

.speed-card-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1em;
    flex-wrap: wrap;
}

.route {
    font-weight: 700;
    font-size: clamp(1.05rem, 4vw, 1.35rem);
    letter-spacing: 0.01em;
}

.direction {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    border: 1px solid var(--panel-edge);
    border-radius: 4px;
    padding: 0.15em 0.6em;
    white-space: nowrap;
}

.location {
    margin-top: 0.6vh;
    color: var(--text-dim);
    font-size: clamp(0.9rem, 3.2vw, 1.05rem);
    font-family: "Courier New", ui-monospace, monospace;
}

.speed-figures {
    margin-top: 1.6vh;
    display: flex;
    align-items: center;
    gap: 3vw;
}

.speed-figure {
    text-align: center;
    font-family: "Courier New", ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
}

.speed-figure .figure-value {
    display: block;
    font-size: clamp(2.2rem, 11vw, 3.4rem);
    font-weight: 800;
    line-height: 1;
}

.speed-figure.normal .figure-value { color: var(--text-dim); }
.speed-figure.restricted .figure-value { color: var(--amber); }

.speed-figure .figure-label {
    display: block;
    margin-top: 0.3vh;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.speed-arrow {
    font-size: clamp(1.4rem, 6vw, 2rem);
    color: var(--text-dim);
}

.reason {
    margin-top: 1.6vh;
    font-size: clamp(0.95rem, 3.4vw, 1.15rem);
    font-weight: 600;
}

.end-date {
    margin-top: 0.6vh;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.reference {
    margin-top: 0.3vh;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: "Courier New", ui-monospace, monospace;
}

.board-footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 1.4vh 4vw;
    background: #0d1013;
    border-top: 1px solid var(--panel-edge);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

.dot-separator { margin: 0 0.6em; }

#connection-status.ok { color: var(--green); }
#connection-status.stale { color: var(--yellow); }
#connection-status.error { color: var(--red); }

@media (min-width: 900px) {
    /* If someone opens this wide/landscape, keep the board readable
       rather than stretching cards edge to edge. */
    .speed-list { max-width: 640px; }
}
