/* Altair 4X — Simulator-specific styles (extends shared/simulator-theme.css) */

/* top-reading strong styling is handled by the shared .reading-card strong rule */

.device-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    gap: 20px;
    align-items: start;
}

.device-wrap {
    position: relative;
    width: min(100%, 720px);
    margin: 0 auto;
}

.device-image {
    width: 100%;
    display: block;
    border-radius: 28px;
}

.alarm-beacon {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    background: rgba(220, 30, 30, 0.82);
    box-shadow: 0 0 12px rgba(220, 30, 30, 0.6);
}

.screen-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    border-radius: 18px;
    padding: 14px 16px;
    background: linear-gradient(180deg, #c8edf8 0%, #a6ddf0 100%);
    color: #0f4268;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 0 0 0 2px rgba(10, 40, 70, 0.22);
    overflow: hidden;
}

.screen-overlay.is-off {
    background: #0a0a0a;
    overflow: hidden;
}

/* Blank screen when instrument is off — hide ALL content regardless of nesting */
.screen-overlay.is-off * {
    visibility: hidden !important;
    pointer-events: none;
}

/* ══ Message screen (startup, prompts) — 3 vertical sections ══ */
.screen-msg {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Section 1 of message: large primary text */
.screen-msg-top {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(6px, calc(var(--screen-scale, 1) * 18px), 18px);
    color: #0b3562;
    text-align: center;
    white-space: pre-wrap;
    letter-spacing: 0.05em;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1 1 0;
    padding: clamp(6px, calc(var(--screen-scale, 1) * 10px), 10px);
    box-sizing: border-box;
    overflow: auto;
    word-break: break-word;
}

/* Section 2 of message: horizontal divider rule */
.screen-msg-mid {
    width: 88%;
    height: clamp(2px, calc(var(--screen-scale, 1) * 2px), 2px);
    background: rgba(11, 53, 98, 0.35);
    margin: 0 auto;
    flex: 0 0 auto;
}

/* Section 3 of message: smaller detail / instruction text */
.screen-msg-bot {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(4px, calc(var(--screen-scale, 1) * 10px), 10px);
    color: #0b3562;
    text-align: center;
    white-space: pre-wrap;
    letter-spacing: 0.03em;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1 1 0;
    padding: clamp(6px, calc(var(--screen-scale, 1) * 8px), 8px);
    box-sizing: border-box;
    overflow: auto;
    word-break: break-word;
}

/* Allow flex children to shrink properly inside .screen-msg */
.screen-msg > 

/* ══ Message / menu mode — text only in rows 2 and 4 ══ */

/* Hide label rows (1 & 3) and status bar entirely */
.screen-normal.is-msg .screen-lbl-row,
.screen-normal.is-msg .screen-bot {
    display: none;
}

/* Switch val-rows from grid to flex so height:100% on children resolves correctly */
.screen-normal.is-msg .screen-val-row {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.screen-normal.is-msg .screen-val-row > div:last-child {
    display: none;
}

.screen-normal.is-msg .screen-val-row > div:first-child {
    width: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Row 2 — heading: large, single line (~1.5× row-unit, max 56px) */
.screen-normal.is-msg .screen-val-row:nth-child(2) strong {
    font-size: clamp(5px, calc(var(--screen-row-unit, 24px) * 1.5), 56px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    width: 100%;
    line-height: 1;
}

/* Row 4 — content: font scales with line count set via --msg-lines in JS */
.screen-normal.is-msg .screen-val-row:nth-child(4) strong {
    font-size: clamp(5px, calc(var(--screen-row-unit, 24px) * 1.72 / var(--msg-lines, 1)), 40px);
    white-space: pre-wrap;
    word-break: break-word;
    text-align: center;
    width: 100%;
    line-height: 1.4;
}

/* ══ Normal operation screen — 5 flex rows ══ */
.screen-normal {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* label(1) / value(3) / label(1) / value(3) / status(3) */
.screen-normal > * {
    min-height: 0;
}
.screen-normal > .screen-lbl-row {
    flex: 1 1 0;
}
.screen-normal > .screen-val-row,
.screen-normal > .screen-bot {
    flex: 3 1 0;
}

/* ── Row 1 & 3: thin label rows ── */
.screen-lbl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.screen-lbl-row span {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(4px, calc(var(--screen-row-unit, 24px) * 0.38), 15px);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #0f4268;
    line-height: 1;
}

/* ── Row 2 & 4: big value rows ── */
.screen-val-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.screen-val-row > div {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0;
}

.screen-val-row strong {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(10px, calc(var(--screen-row-unit, 24px) * 1.18), 90px);
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1;
    color: #0b3562;
}

/* Bottom time / status sizing — same height as value rows */
.screen-bot .screen-time {
    display: inline-block;
    font-size: clamp(8px, calc(var(--screen-row-unit, 24px) * 1.05), 75px);
    line-height: 1;
}

/* ── Row 5: Status bar — battery | alarm text | time ── */
.screen-bot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    padding: 0 clamp(2px, calc(var(--screen-scale, 1) * 4px), 4px);
}

.batt-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.08em;
    vertical-align: middle;
}

.batt-

.batt-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: currentColor;
    transition: width 0.3s ease;
}

.batt-tip {
    display: inline-block;
    width: 0.2em;
    height: 0.5em;
    background: currentColor;
    border-radius: 0 0.08em 0.08em 0;
}

.screen-batt,
.screen-alarm-lbl,
.screen-mode-lbl {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(4px, calc(var(--screen-row-unit, 24px) * 0.55), 32px);
    color: #0b3562;
    line-height: 1;
}

.screen-time {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    color: #0b3562;
    line-height: 1;
}

/* ── Alarm text flash animations ── */
.flash-warning {
    animation: blink-text 0.95s steps(2, end) infinite;
}

.flash-danger {
    animation: blink-text 0.55s steps(2, end) infinite;
}

.flash-batt {
    animation: blink-text 1.2s steps(2, end) infinite;
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Individual reading card alarm flashing ── */
.reading-alarm-warning strong {
    animation: blink-text 0.95s steps(2, end) infinite;
}

.reading-alarm-danger strong {
    animation: blink-text 0.55s steps(2, end) infinite;
}

.reading-card {
    border-radius: clamp(2px, calc(var(--screen-scale, 1) * 5px), 5px);
    padding: clamp(1px, calc(var(--screen-scale, 1) * 4px), 4px) clamp(2px, calc(var(--screen-scale, 1) * 6px), 6px);
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.reading-card span {
    display: block;
    font-size: clamp(3px, calc(var(--screen-scale, 1) * 10px), 10px);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #0f4268;
    line-height: 1.1;
}

.reading-card strong {
    display: block;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(5px, calc(var(--screen-scale, 1) * 52px), 52px);
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1;
    color: #0b3562;
}

.hotspot {
    position: absolute;
    border: 0;
    border-radius: 999px;
    background: rgba(212, 39, 28, 0.18);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
    /* Prevent long-press context menu on mobile browsers */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.is-held {
    transform: scale(1.05);
    background: rgba(232, 61, 48, 0.36);
    box-shadow: 0 0 0 3px rgba(255, 216, 75, 0.6);
    outline: none;
}

.hotspot span {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, 10px);
    background: rgba(22, 49, 71, 0.92);
    color: #fff;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.hotspot-mode {
    left: 0;
    top: 0;
    width: 0;
    height: 0;
}

.device-help {
    display: grid;
    gap: 12px;
}

.alarm-normal #alarmState,
.alarm-normal .status-chip {
    color: var(--ok);
}

.alarm-warning #alarmState,
.alarm-warning .status-chip {
    color: var(--warning);
}

.alarm-danger #alarmState,
.alarm-danger .status-chip {
    color: var(--danger);
}

.alarm-warning .alarm-beacon {
    animation: flash-beacon 0.95s steps(2, end) infinite;
}

.alarm-danger .alarm-beacon {
    animation: flash-beacon-urgent 0.55s steps(2, end) infinite;
}

@keyframes flash-beacon {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes flash-beacon-urgent {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 0.5;
    }
}

@media (max-width: 1080px) {
    .device-stage,
    .layout {
        grid-template-columns: 1fr;
    }

    .device-help {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .sim-shell {
        padding: 8px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .top-actions {
        width: 100%;
    }

    .top-actions .button {
        flex: 1 1 calc(50% - 5px);
    }

    .sim-header,
    .device-help {
        grid-template-columns: 1fr;
    }

    .sim-header {
        flex-direction: column;
    }

    .sim-main {
        padding: 14px 8px;
    }

    .device-wrap {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .top-actions .button {
        flex-basis: 100%;
    }

    .hotspot span {
        font-size: 0.68rem;
        padding: 4px 8px;
    }
}
