/* ═══════════════════════════════════════════════════════════════════════════
   Pump-Aspirated Confined Space Gas Monitor Simulator
   Extends shared/base_fluid/_theme/simulator-theme.css — colours come from the
   shared :root variables only, never hardcoded.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout ───────────────────────────────────────────────────────────────*/
#main {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 320px;
    grid-template-rows: minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
    height: calc(100vh - 42px);
    position: relative;
    z-index: 1;
}

#side, #rp {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    min-height: 0;
}

#ctr {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

#op-bar {
    flex-shrink: 0;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg3);
}

.op-title {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--cyan);
}

#device-wrap {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px 14px;
}

#ctrl-bar {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}

.big-btn {
    flex: 1;
    padding: 10px 12px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--white);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.big-btn:hover      { background: var(--bg); border-color: var(--cyan); }
.big-btn.ok         { border-color: var(--green); color: var(--green); }
.big-btn.ok:hover   { background: rgba(37, 198, 133, 0.12); }
.big-btn.reset      { border-color: var(--red); color: var(--red); }
.big-btn.reset:hover{ background: rgba(239, 68, 88, 0.12); }

/* ── Sample line indicator ────────────────────────────────────────────────
   The visible embodiment of the transit delay.                              */
.sample-line {
    width: 100%;
    max-width: 640px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px 11px;
}

.sl-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 7px;
}

.sl-title {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--cyan);
}

.sl-sub {
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--muted);
}

.transit-track {
    height: 9px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 5px;
    overflow: hidden;
}

.transit-fill {
    height: 100%;
    width: 0;
    background: var(--amber);
    transition: width 0.4s linear, background 0.3s;
}
.transit-fill.full { background: var(--green); }

/* ── The instrument ───────────────────────────────────────────────────────*/
.device { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.device-boot {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: #8f2733;
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

/* The alarm LED arrays down each side of the boot. */
.device-led {
    width: 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.10);
    align-self: stretch;
    margin: 6px 4px;
}
.device-led.led-slow  { animation: led-blink 1s steps(2, end) infinite; }
.device-led.led-fast  { animation: led-blink 0.5s steps(2, end) infinite; }
.device-led.led-fault { animation: led-blink 1s steps(2, end) infinite; background: var(--amber); }
.device-led.led-slow, .device-led.led-fast { background: var(--red); }

@keyframes led-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.12; } }

.device-face {
    width: min(74vw, 560px);
    background: #14181d;
    border: 1px solid #2a3038;
    border-radius: 12px;
    padding: 10px 12px 12px;
}

.face-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.face-brand {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--cyan);
}

.face-model {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.face-body { display: flex; align-items: center; gap: 10px; }

.btn-col { display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }

.dev-btn {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #3a424c, #1c2128 70%);
    border: 1px solid #454e59;
    color: var(--white);
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.dev-btn:hover { border-color: var(--cyan); }
.dev-btn.is-held {
    transform: scale(0.95);
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(230, 165, 50, 0.35);
}
.db-1 { font-size: 13px; }
.db-2 { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; }
.db-2.wide { font-size: 9.5px; }
.db-3 { font-size: 9px; color: var(--muted); }

/* ── LCD ──────────────────────────────────────────────────────────────────*/
.lcd {
    flex: 1 1 0;
    min-width: 0;
    aspect-ratio: 16 / 10;
    background: linear-gradient(180deg, #cfe3c8 0%, #b9d3b0 100%);
    border: 2px solid #0d1b12;
    border-radius: 6px;
    padding: 6px 8px 7px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.lcd.is-off { background: #10130f; }
.lcd.is-off > * { visibility: hidden; }

.lcd-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: #14301c;
    flex-shrink: 0;
}
.lcd-pilot { color: #14301c; transition: opacity 0.2s; }
.lcd-pump  { transition: transform 0.4s linear, opacity 0.3s; }
.lcd-mode  { flex: 1; text-align: center; letter-spacing: 0.1em; font-weight: 700; }
.lcd-clock { font-variant-numeric: tabular-nums; }

/* Battery icon drawn in CSS so it needs no image. */
.lcd-batt {
    width: 20px; height: 10px;
    border: 1.5px solid #14301c;
    border-radius: 2px;
    position: relative;
}
.lcd-batt::after {
    content: ''; position: absolute; right: -3.5px; top: 2px;
    width: 2px; height: 4px; background: #14301c; border-radius: 0 1px 1px 0;
}
.lcd-batt::before {
    content: ''; position: absolute; left: 1px; top: 1px; bottom: 1px;
    background: #14301c; transition: width 0.4s;
}
.lcd-batt.b3::before { width: 14px; }
.lcd-batt.b2::before { width: 9px; }
.lcd-batt.b1::before { width: 4px; }
.lcd-batt.b0::before { width: 4px; animation: led-blink 1.2s steps(2, end) infinite; }

.lcd-grid {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px 10px;
    margin-top: 3px;
}

.lcd-cell { display: flex; flex-direction: column; justify-content: center; min-width: 0; }

.lcd-lbl {
    font-family: var(--font-mono);
    font-size: clamp(8px, 1.05vw, 11px);
    letter-spacing: 0.06em;
    color: #24462c;
    line-height: 1;
}
.lcd-lbl em { font-style: normal; opacity: 0.75; }

.lcd-val {
    font-family: var(--font-mono);
    font-size: clamp(20px, 3.7vw, 44px);
    font-weight: 400;
    line-height: 1;
    color: #0f2a17;
    font-variant-numeric: tabular-nums;
}

.lcd-bar {
    display: block;
    height: 5px;
    background: rgba(20, 48, 28, 0.16);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 3px;
}

.lcd-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: #2f5c3a;
    transition: width 0.4s linear, background 0.3s;
}
.lcd-bar-fill.at-first  { background: #9a6a12; }
.lcd-bar-fill.at-second { background: #a32235; }

.lcd-cell.alarm-first  .lcd-val { animation: lcd-flash 1s steps(2, end) infinite; }
.lcd-cell.alarm-second .lcd-val { animation: lcd-flash 0.5s steps(2, end) infinite; color: #8e1526; }
.lcd-cell.is-failed    .lcd-val { opacity: 0.55; }

@keyframes lcd-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }

/* Message screen overlays the readout for warm-up, air cal and the menus. */
.lcd-msg {
    display: none;
    position: absolute;
    inset: 22px 8px 7px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.lcd.is-msg .lcd-msg  { display: flex; }
.lcd.is-msg .lcd-grid { visibility: hidden; }

.lcd-msg-top {
    font-family: var(--font-mono);
    font-size: clamp(16px, 2.6vw, 30px);
    letter-spacing: 0.09em;
    color: #0f2a17;
    text-align: center;
}
.lcd-msg-rule { width: 78%; height: 1.5px; background: rgba(20, 48, 28, 0.35); }
.lcd-msg-bot {
    font-family: var(--font-mono);
    font-size: clamp(9px, 1.25vw, 14px);
    letter-spacing: 0.05em;
    color: #24462c;
    text-align: center;
}

.face-ports {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 9px;
}
.port {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.12em;
    color: var(--muted);
    border: 1px solid var(--border2);
    border-radius: 3px;
    padding: 2px 8px;
}

.device-hint {
    max-width: 640px;
    font-family: var(--font-ui);
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--muted);
    text-align: center;
}
.device-hint strong { color: var(--cyan); font-weight: 600; }

/* ── Left panel controls ──────────────────────────────────────────────────*/
.s-hd, .rp-hd {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--cyan);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg3);
    position: sticky;
    top: 0;
    z-index: 2;
}

.ctrl-section { padding: 10px 12px; border-bottom: 1px solid var(--border); }

.ctrl-section-hdr {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.11em;
    color: var(--muted);
    margin-bottom: 8px;
}

.ctrl-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 11.5px;
    color: var(--white);
    margin-bottom: 6px;
}
.ctrl-row .val { font-family: var(--font-mono); color: var(--cyan); }

.ctrl-section input[type="range"] {
    width: 100%;
    accent-color: var(--cyan);
    margin-bottom: 6px;
}

.ctrl-section select {
    width: 100%;
    padding: 6px 8px;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--white);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 4px;
    cursor: pointer;
}

.ctrl-note {
    font-family: var(--font-ui);
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--muted);
    margin-top: 6px;
}
.ctrl-note strong { color: var(--white); }
.ctrl-note.ok   { color: var(--green); }
.ctrl-note.wait { color: var(--amber); }
.ctrl-note.bad  { color: var(--red); }

.ctrl-btn {
    padding: 6px 9px;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--white);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.ctrl-btn:hover   { border-color: var(--cyan); background: var(--bg); }
.ctrl-btn.active  { border-color: var(--green); color: var(--green); }
.ctrl-btn.wide    { display: block; width: 100%; margin-bottom: 5px; text-align: left; }

.lvl-row { display: flex; gap: 5px; margin-bottom: 6px; }
.lvl-row .ctrl-btn { flex: 1; text-align: center; }
.lvl-d { display: block; font-family: var(--font-mono); font-size: 9px; color: var(--muted); }

/* ── Right panel ──────────────────────────────────────────────────────────*/
#rp { display: flex; flex-direction: column; overflow: hidden; }
.rp-block { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.rp-grow  { flex: 1 1 0; }
.rp-body  { padding: 8px 10px; }
.rp-scroll { overflow-y: auto; max-height: 210px; }
#alm-cnt { color: var(--red); font-family: var(--font-mono); }
.alm-list { flex: 1 1 0; overflow-y: auto; padding: 6px; min-height: 0; }

.alarm-item {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 6px;
    align-items: start;
    padding: 5px 6px;
    margin-bottom: 4px;
    border-radius: 4px;
    border-left: 3px solid var(--border2);
    background: var(--bg2);
    font-family: var(--font-ui);
    font-size: 11px;
    line-height: 1.45;
    cursor: pointer;
}
.alarm-item.active-alarm { border-left-color: var(--red);   background: rgba(239, 68, 88, 0.10); }
.alarm-item.active-warn  { border-left-color: var(--amber); background: rgba(230, 165, 50, 0.10); }
.alarm-item.active-fault { border-left-color: var(--orange);background: rgba(232, 116, 59, 0.10); }
.alarm-item.active-info  { border-left-color: var(--cyan);  background: rgba(43, 184, 224, 0.08); }
.alarm-item.ack          { opacity: 0.55; }

.alarm-tag {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.06em;
    padding: 1px 4px;
    border-radius: 2px;
    text-align: center;
}
.alarm-tag.A { color: var(--red); }
.alarm-tag.W { color: var(--amber); }
.alarm-tag.F { color: var(--orange); }
.alarm-tag.I { color: var(--cyan); }
.alarm-text  { color: var(--white); }
.alarm-time  { font-family: var(--font-mono); font-size: 9px; color: var(--muted); }

.checklist-item {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    padding: 4px 2px;
    font-family: var(--font-ui);
    font-size: 11px;
    line-height: 1.45;
    cursor: pointer;
    color: var(--white);
}
.checklist-item.done { color: var(--green); }
.checklist-item.done .chk-text { text-decoration: line-through; opacity: 0.75; }
.chk-icon { flex-shrink: 0; font-family: var(--font-mono); }

/* ── Scenario modal ───────────────────────────────────────────────────────*/
#modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 11, 16, 0.88);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#modal {
    max-width: 620px;
    width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
}
#modal h2 { font-family: var(--font-ui); font-size: 18px; color: var(--cyan); margin-bottom: 8px; }
#modal p  { font-family: var(--font-ui); font-size: 12.5px; line-height: 1.65; color: var(--muted); margin-bottom: 16px; }

.mg { display: grid; gap: 9px; }

.mb {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.mb:hover { border-color: var(--cyan); background: var(--bg3); }
.mt { font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--white); margin-bottom: 4px; }
.md { font-family: var(--font-ui); font-size: 11.5px; line-height: 1.5; color: var(--muted); }

.badge {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}
.badge.beginner     { color: var(--green); border: 1px solid var(--green); }
.badge.intermediate { color: var(--amber); border: 1px solid var(--amber); }
.badge.advanced     { color: var(--red);   border: 1px solid var(--red); }

/* ── Responsive ───────────────────────────────────────────────────────────*/
@media (max-width: 1400px) {
    #main { grid-template-columns: 260px minmax(0, 1fr) 280px; }
}
@media (max-width: 1150px) {
    #main { grid-template-columns: 230px minmax(0, 1fr) 250px; }
    .dev-btn { width: 54px; height: 54px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Diffusion-monitor specifics — layered on the shared instrument styling above
   ═══════════════════════════════════════════════════════════════════════════ */

/* The instrument is a personal monitor, so its body is smaller and the buttons
   sit in a single column beside the display rather than flanking it. */
.device-boot { background: #1f4f63; }
.device-face { width: min(66vw, 480px); }
.btn-col { gap: 9px; }
.dev-btn { width: 60px; height: 60px; }

/* Carry state on the LCD — replaces the aspirated instrument's pump indicator. */
.lcd-carry {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.09em;
    padding: 1px 5px;
    border: 1px solid rgba(20, 48, 28, 0.5);
    border-radius: 3px;
    color: #14301c;
}
.lcd-carry.is-bad {
    background: #8e1526;
    border-color: #8e1526;
    color: #e9f2ea;
    animation: lcd-flash 1.1s steps(2, end) infinite;
}

/* The contrast banner — what this instrument is not for. */
.contrast-note {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    width: 100%;
    max-width: 660px;
    padding: 10px 14px;
    background: rgba(43, 184, 224, 0.08);
    border: 1px solid rgba(43, 184, 224, 0.32);
    border-left-width: 3px;
    border-radius: var(--radius);
}
.cn-tag {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    color: var(--cyan);
    border: 1px solid var(--cyan);
    border-radius: 3px;
    padding: 2px 6px;
    margin-top: 1px;
}
.cn-txt {
    font-family: var(--font-ui);
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--muted);
}
.cn-txt strong { color: var(--white); }

/* Exposure bar reuses the transit track; it needs a "bad" state the aspirated
   sim has no use for. */
.transit-fill.bad { background: var(--red); }

/* Area buttons behave as a radio group. */
.area-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(43, 184, 224, 0.10);
}

/* Bump test result table. */
.bump-box {
    margin-top: 9px;
    padding: 9px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: var(--bg2);
}
.bump-box.ok  { border-color: var(--green); }
.bump-box.bad { border-color: var(--red); }
.bump-box strong {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.09em;
    margin-bottom: 6px;
}
.bump-box.ok  strong { color: var(--green); }
.bump-box.bad strong { color: var(--red); }
.bump-tbl {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--white);
}
.bump-tbl th {
    text-align: left;
    font-weight: 400;
    color: var(--muted);
    padding-bottom: 3px;
}
.bump-tbl td { padding: 2px 0; }
.bump-tbl tr.pass td { color: var(--green); }
.bump-tbl tr.fail td { color: var(--red); }
.bump-tbl tr.skip td { color: var(--muted); }
.bump-note {
    display: block;
    margin-top: 7px;
    font-family: var(--font-ui);
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--red);
}
