/* =========================================================
   EVHUB LCD — 1024×600 station touchscreen
   Colors come from shared/tokens.css.

   TYPE SCALE — every text on the LCD uses one of these roles,
   nothing else. Nothing is smaller than 16px.
     label    16px bold, caps    status, step labels, "PLUG INTO"
     body     16px regular       secondary text, user names, notes
     strong   20px bold display  names, values, buttons, step titles
     lead     20px regular       sentence under a screen title
     title    24px bold display  port names, bottom-bar heading
     heading  32px bold display  screen titles, charge %
     hero     64px bold display  the big port number

   SPACING SCALE — every gap, margin and padding is one of:
     4 (lines inside one group) · 8 (label to its text)
     16 (between items) · 24 (between groups, screen edges) · 32
   ========================================================= */

:root{
    --lcd-label:var(--ev-weight-bold) var(--ev-text-md)/1.4 var(--ev-font-body);
    --lcd-body:var(--ev-weight-regular) var(--ev-text-md)/1.4 var(--ev-font-body);
    --lcd-strong:var(--ev-weight-bold) var(--ev-text-lg)/1.2 var(--ev-font-display);
    --lcd-lead:var(--ev-weight-regular) var(--ev-text-lg)/1.4 var(--ev-font-body);
    --lcd-title:var(--ev-weight-bold) var(--ev-text-xl)/1.2 var(--ev-font-display);
    --lcd-heading:var(--ev-weight-bold) var(--ev-text-2xl)/1.2 var(--ev-font-display);
    --lcd-hero:800 64px/1 var(--ev-font-display);
    --lcd-tracking:.06em;

    --s1:4px;--s2:8px;--s3:16px;--s4:24px;--s5:32px;
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
    background:var(--ev-surface);
    color:var(--ev-ink);
    font:var(--lcd-body);
    overflow:hidden;
    -webkit-user-select:none;user-select:none;
    -webkit-tap-highlight-color:transparent;
}
button{font:inherit;color:inherit;cursor:pointer;border:0;background:none}
h1,h2,h3{color:var(--ev-ink-strong)}

/* Port identity colours — match the stickers on the station.
   Any element with data-port="1|2|3" gets --port (fill) and --port-ink (text). */
[data-port="1"]{--port:var(--ev-port-1);--port-ink:var(--ev-port-1-ink);--port-soft:var(--ev-port-1-soft)}
[data-port="2"]{--port:var(--ev-port-2);--port-ink:var(--ev-port-2-ink);--port-soft:var(--ev-port-2-soft)}
[data-port="3"]{--port:var(--ev-port-3);--port-ink:var(--ev-port-3-ink);--port-soft:var(--ev-port-3-soft)}

/* Sticker-style port label, same look as the label on the hardware */
.port-tag{
    display:inline-flex;align-items:center;
    padding:var(--s1) var(--s3);border-radius:8px;
    font:var(--lcd-title);letter-spacing:.02em;white-space:nowrap;
    color:#fff;background:var(--port,var(--ev-muted));
}

/* Shared text roles */
.eyebrow{font:var(--lcd-label);letter-spacing:var(--lcd-tracking);color:var(--ev-brand)}
.lead{font:var(--lcd-lead);color:var(--ev-muted)}
.muted{font:var(--lcd-body);color:var(--ev-muted)}

.lcd-app{height:100vh;display:flex;flex-direction:column}

/* ---------- Top bar ---------- */
.lcd-topbar{
    height:72px;flex:none;
    display:flex;align-items:center;gap:var(--s4);
    padding:0 var(--s4);
    background:var(--ev-accent-soft);   /* cream band, same as the portals */
    border-bottom:1px solid var(--ev-line);
}
.lcd-logo{height:48px;width:auto}
.lcd-availability{margin-left:auto;font:var(--lcd-label);color:var(--ev-muted)}
.lcd-availability.none{color:var(--ev-ink-strong)}
.lcd-clock{font:var(--lcd-strong);color:var(--ev-ink-strong)}

/* ---------- Screens ---------- */
.lcd-main{flex:1;min-height:0;padding:0 var(--s4)}
.lcd-screen{display:none;height:100%}
.lcd-screen.active{display:flex;flex-direction:column}

/* ---------- Buttons ---------- */
.btn{
    display:inline-flex;align-items:center;justify-content:center;
    min-height:56px;padding:0 var(--s4);border-radius:14px;
    font:var(--lcd-strong);letter-spacing:.02em;white-space:nowrap;
    transition:transform .12s ease,background-color .15s ease;
}
.btn:active:not(:disabled){transform:scale(.97)}
.btn:disabled{opacity:.55;cursor:not-allowed}
.btn-primary{background:var(--ev-accent);color:#fff}
.btn-primary:active:not(:disabled){background:var(--ev-accent-hover)}
.btn-xl{min-height:72px;padding:0 var(--s5);font:var(--lcd-title);border-radius:16px}
.btn-ghost{background:var(--ev-surface);color:var(--ev-ink);border:2px solid var(--ev-line)}
.btn-ghost:active:not(:disabled){background:var(--ev-accent-soft)}

/* =========================================================
   HOME — live port dashboard
   ========================================================= */
/* Three separate panels, one per port, with equal gaps */
.port-grid{flex:1;min-height:0;display:grid;grid-template-columns:repeat(3,1fr);gap:var(--s3);padding-top:var(--s3)}

/* Ports: open columns split by hairlines. Only the port label uses the
   sticker colour; readings keep the standard colours (green = charging or
   available, red = problem, grey = everything else). */
.port{
    --tone:var(--ev-muted);
    display:flex;flex-direction:column;gap:var(--s2);
    padding:var(--s4);min-width:0;
    border:1px solid var(--ev-line);border-radius:16px;background:var(--ev-surface);
}
.port.available,.port.finished{--tone:var(--ev-status-complete)}
.port.charging{--tone:var(--ev-charging)}
.port.alert{--tone:var(--ev-status-error)}

.port-head{display:flex;align-items:center}
.port-state{
    align-self:flex-start;
    display:inline-flex;align-items:center;gap:var(--s2);
    font:var(--lcd-label);letter-spacing:var(--lcd-tracking);color:var(--tone);
}
.port-state::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor}
.port.charging .port-state::before{animation:pulse 1.6s ease-in-out infinite}

.port-body{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;text-align:center}
/* Picture + names, centred between the status line and the bottom row.
   Fixed heights keep the names at the same height in all three tiles. */
.port-main{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--s3)}
.port-visual{height:140px;flex:none;display:grid;place-items:center}
/* Every tile shows exactly two lines here, so the spacing is the same in all of them */
.port-lines{height:52px;display:flex;flex-direction:column;align-items:center;gap:var(--s1);min-width:0;max-width:100%}
.port-lines strong{font:var(--lcd-strong);color:var(--ev-ink-strong)}
.port-lines p{font:var(--lcd-body);color:var(--ev-muted)}
.port.alert .port-lines strong{color:var(--ev-status-error)}

.port-user{
    display:inline-flex;align-items:center;gap:var(--s2);max-width:100%;
    font:var(--lcd-body);color:var(--ev-ink);
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.port-user .ev-icon{color:var(--ev-muted);font-size:1.25em}

.port-glyph{color:var(--tone);font-size:64px;line-height:1}
.port.available .port-glyph,.port.reserved .port-glyph{color:var(--ev-muted)}
.port-car{width:190px;height:130px;object-fit:contain}
.port.finished .port-stats b{color:var(--ev-brand)}

/* Charge ring: --soc 0–100 */
.soc-ring{
    --soc:0;
    width:136px;height:136px;border-radius:50%;
    display:grid;place-items:center;
    background:conic-gradient(var(--tone) calc(var(--soc)*1%),var(--ev-line) 0);
}
.soc-ring>span{
    width:116px;height:116px;border-radius:50%;background:var(--ev-surface);
    display:grid;place-items:center;
    font:var(--lcd-heading);color:var(--ev-ink-strong);
}
.soc-ring.unknown{background:conic-gradient(var(--tone) 0 25%,var(--ev-line) 0);animation:spin 2.4s linear infinite}
.soc-ring.unknown>span{animation:spin 2.4s linear infinite reverse}

.port-stats{
    width:100%;padding-top:var(--s3);
    display:flex;align-items:baseline;justify-content:space-between;gap:var(--s2);
    border-top:1px solid var(--ev-line);
}
.port-stats small{font:var(--lcd-body);color:var(--ev-muted)}
.port-stats b{font:var(--lcd-strong);color:var(--ev-ink-strong)}

/* Bottom bar (home: GET STARTED) */
.start-bar{
    flex:none;
    display:flex;align-items:center;gap:var(--s4);
    padding:var(--s3) 0;
}
.start-copy{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--s1)}
.start-copy h1{font:var(--lcd-title)}
.start-copy p{font:var(--lcd-body);color:var(--ev-muted)}
.start-bar.full .start-copy p{color:var(--ev-ink-strong);font-weight:var(--ev-weight-semibold)}
.start-bar.maintenance .start-copy h1{color:var(--ev-status-error)}
.start-bar.maintenance .start-copy p{color:var(--ev-ink-strong);font-weight:var(--ev-weight-semibold)}

/* Announcement band under the top bar */
.lcd-announce{
    flex:none;display:flex;align-items:baseline;gap:var(--s3);
    margin:var(--s3) var(--s4) 0;padding:var(--s2) var(--s3);
    border-radius:12px;border:1px solid var(--ev-line);background:var(--ev-accent-soft);
}
.lcd-announce[hidden]{display:none}
.lcd-announce p{font:var(--lcd-strong);color:var(--ev-ink-strong);min-width:0}

/* =========================================================
   PANELS (pairing, reserved, messages)
   Rhythm: label → 8 → title → 8 → lead → 24 → content → 24 → actions
   ========================================================= */
.panel{flex:1;min-height:0;padding:var(--s4) 0}
.panel h1{font:var(--lcd-heading)}

.split{display:grid;grid-template-columns:1fr 340px;gap:var(--s5);align-items:center}
.split-main{display:flex;flex-direction:column;align-items:flex-start;gap:var(--s2);min-width:0}
.split-main>.steps,.split-main>.lcd-cancel-button{margin-top:var(--s3)}

.steps{list-style:none;display:flex;flex-direction:column;gap:var(--s3);width:100%}
.steps li{display:flex;align-items:center;gap:var(--s3)}
.steps li span{
    width:40px;height:40px;flex:none;border-radius:50%;
    display:grid;place-items:center;
    font:var(--lcd-strong);
    color:var(--ev-muted);border:2px solid var(--ev-line);
}
.steps li.current span{color:#fff;background:var(--ev-brand);border-color:var(--ev-brand)}
.steps li div{display:flex;flex-direction:column;gap:var(--s1)}
.steps strong{font:var(--lcd-strong);color:var(--ev-ink-strong)}
.steps small{font:var(--lcd-body);color:var(--ev-muted)}

.qr-panel{display:flex;flex-direction:column;align-items:center;gap:var(--s2);text-align:center}
/* QR and code in one card */
.connect-card{align-self:center;width:360px;max-width:100%;box-sizing:border-box;padding:20px 24px;gap:10px;
    background:var(--ev-surface);border:1px solid var(--ev-line);border-radius:24px;box-shadow:0 10px 30px rgba(27,94,32,.10)}
.connect-label{font:var(--lcd-label);letter-spacing:var(--lcd-tracking);color:var(--ev-brand)}
.connect-card .qr-frame{width:212px;height:212px;padding:0;margin:0}
.connect-or{display:flex;align-items:center;gap:12px;width:100%;font:var(--lcd-body);color:var(--ev-muted)}
.connect-or::before,.connect-or::after{content:"";flex:1;height:1px;background:var(--ev-line)}
.connect-code{display:flex;gap:10px}
.connect-code b{width:58px;height:66px;border-radius:14px;display:grid;place-items:center;
    background:var(--ev-accent-soft);border:2px solid var(--ev-line);font:800 40px/1 var(--ev-font-display);color:var(--ev-brand)}
.connect-timer{width:100%;display:flex;flex-direction:column;gap:6px}
.connect-bar{height:8px;border-radius:4px;background:#EEF1EC;overflow:hidden}
.connect-bar i{display:block;height:100%;width:100%;border-radius:4px;background:var(--ev-brand);transition:width 1s linear}
.connect-card .qr-countdown{font:var(--lcd-body);color:var(--ev-muted)}
.qr-frame{width:300px;height:300px;padding:var(--s2);background:#fff;margin-bottom:var(--s2)}
.qr-frame img{width:100%;height:100%;object-fit:contain;display:block}
.qr-countdown{font:var(--lcd-strong);color:var(--ev-brand)}
.connect-url{font:var(--lcd-body);color:var(--ev-muted)}

/* Message screens */
.message{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:var(--s2)}
.message .lead{max-width:640px}
.message .btn,.message .waiting{margin-top:var(--s3)}
.state-icon{font-size:64px;line-height:1;margin-bottom:var(--s3)}
.state-icon.ok{color:var(--ev-brand)}
.state-icon.error{color:var(--ev-status-error)}

.waiting{
    display:inline-flex;align-items:center;gap:var(--s2);
    font:var(--lcd-body);font-weight:var(--ev-weight-semibold);color:var(--ev-muted);
}
.pulse{width:8px;height:8px;border-radius:50%;background:currentColor;animation:pulse 1.4s ease-in-out infinite}

/* Reserved */
.reserved-vehicle{display:flex;align-items:center;gap:var(--s3);margin:var(--s2) 0}
.reserved-vehicle img{width:150px;height:110px;object-fit:contain;flex:none}
.reserved-vehicle h1{margin-bottom:var(--s1)}
.reserved-vehicle .lead{font:var(--lcd-body);color:var(--ev-muted)}
.instruction{font:var(--lcd-strong);color:var(--ev-ink-strong)}
.reserved .waiting{margin-top:0}
.reserved-actions{display:flex;align-items:center;gap:var(--s3);margin-top:var(--s3)}
/* Step 3: centre the left column's content in its half of the screen */
.reserved .split-main{align-items:center;text-align:center}
.reserved .reserved-vehicle{flex-direction:column;gap:var(--s2)}
.reserved .reserved-actions{justify-content:center}
.reserved-actions .btn{flex:none}

.port-target{
    height:100%;
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--s2);
    padding:var(--s4);border-left:1px solid var(--ev-line);
}
.port-target small{font:var(--lcd-label);letter-spacing:var(--lcd-tracking);color:var(--ev-muted)}
.port-target strong{font:var(--lcd-hero);color:var(--port-ink,var(--ev-brand))}
.port-target>span{font:var(--lcd-title);color:#fff;background:var(--port,var(--ev-muted));padding:var(--s1) var(--s3);border-radius:8px}
.port-diagram{display:flex;gap:var(--s3);margin-top:var(--s3)}
.port-diagram span{
    width:56px;height:56px;border-radius:14px;
    display:grid;place-items:center;
    font:var(--lcd-title);
    color:var(--port-ink);border:2px solid var(--port);opacity:.45;
}
.port-diagram span.active{color:#fff;background:var(--port);opacity:1}
.port-diagram span.wrong{color:#fff;background:var(--ev-status-error);border-color:var(--ev-status-error);opacity:1}

/* Wrong port / wrong battery on the reserved screen */
/* The target port keeps its sticker colour; only the warning text is red */
#vehicleScreen.port-warning .port-target small,
#vehicleScreen.port-warning .instruction{color:var(--ev-status-error)}

/* ---------- Motion ---------- */
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

/* ---------- Smaller screens (dev browsers, portrait) ---------- */
@media (max-width:860px){
    body{overflow:auto}
    .lcd-app{height:auto;min-height:100vh}
    .port-grid{grid-template-columns:1fr}
    .port{min-height:260px}
    .start-bar{flex-direction:column;align-items:stretch;text-align:center}
    .split{grid-template-columns:1fr}
    .qr-frame{width:240px;height:240px}
    .port-target{height:auto;border-left:0;border-top:1px solid var(--ev-line)}
}

/* Announcement on: shorter port panels so the bottom bar keeps its spacing */
body.has-announce .port{padding:var(--s3) var(--s4);gap:var(--s1)}
body.has-announce .port-main{gap:var(--s2)}
body.has-announce .port-visual{height:104px}
body.has-announce .soc-ring{width:104px;height:104px}
body.has-announce .soc-ring>span{width:88px;height:88px}
body.has-announce .port-car{width:150px;height:100px}
body.has-announce .port-glyph{font-size:52px}
body.has-announce .start-bar{padding-top:var(--s4)}
