/* 實測校正。用法在解說員。色票只走 Titanium Dark token。 */
@import url('design-tokens.css');

.stake-cal {
    position: relative;
    margin: 10px 0 14px;
    padding: 12px;
    border-radius: var(--cm-radius-panel);
    border: 1px solid var(--cm-line-strong);
    background: var(--cm-panel);
    color: var(--cm-ivory);
}

.stake-cal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.stake-cal__title {
    margin: 0;
    font-size: 1.05rem;
    color: var(--cm-ivory);
}

.stake-cal__chip {
    color: var(--cm-lamp);
    border: 1px solid var(--cm-lamp);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 800;
}

.stake-cal > label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    color: var(--cm-lamp);
    font-size: 0.78rem;
    font-weight: 700;
}

.stake-cal > label select {
    min-height: var(--cm-tap-min);
    color: var(--cm-ivory);
    background: var(--cm-night);
    border: 1px solid var(--cm-line-strong);
    border-radius: var(--cm-radius-panel);
    padding: 8px 10px;
}

.stake-cal__fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.stake-cal__fields label,
.stake-cal__ack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--cm-lamp);
    font-size: 0.78rem;
    font-weight: 700;
}

.stake-cal__fields input,
.stake-cal__fields select,
.stake-cal__actions button,
.stake-cal__ack {
    min-height: var(--cm-tap-min);
}

.stake-cal__fields input,
.stake-cal__fields select {
    color: var(--cm-ivory);
    background: var(--cm-night);
    border: 1px solid var(--cm-line-strong);
    border-radius: var(--cm-radius-panel);
    padding: 8px 10px;
}

.stake-cal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.stake-cal__actions button {
    flex: 1 1 140px;
    border-radius: var(--cm-radius-panel);
    border: 1px solid var(--cm-line-strong);
    background: var(--cm-cta);
    color: var(--cm-cta-text);
    font-weight: 800;
}

.stake-cal__primary {
    flex: 1 1 100%;
    min-height: var(--cm-tap-primary);
    border-color: var(--cm-lamp);
    color: var(--cm-ivory);
}

.stake-cal__ack {
    flex-direction: row;
    align-items: center;
    margin: 0 0 8px;
    color: var(--cm-lamp);
}

.stake-cal__status {
    margin: 0 0 8px;
    color: var(--cm-teal);
    font-weight: 700;
}

.stake-cal__warn {
    margin: 0 0 8px;
    color: var(--cm-lamp);
    font-weight: 800;
}

.stake-cal__over {
    color: var(--cm-danger);
    font-weight: 800;
}

.stake-cal__residuals {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}

.stake-cal__residuals li {
    margin: 0 0 4px;
    padding: 6px 8px;
    border-radius: var(--cm-radius-panel);
    color: var(--cm-ivory);
    background: var(--cm-night);
}

.stake-cal__residuals li.is-largest {
    font-weight: 800;
    box-shadow: inset 4px 0 0 var(--cm-lamp);
}

.stake-cal__residuals li.is-over {
    color: var(--cm-danger);
    font-weight: 800;
    box-shadow: inset 4px 0 0 var(--cm-danger);
}

.stake-cal__stage {
    position: relative;
    width: 100%;
    min-height: 220px;
    height: 42dvh;
    margin-bottom: 8px;
    border-radius: var(--cm-radius-panel);
    overflow: hidden;
    border: 1px solid var(--cm-line);
    background: var(--cm-night);
}

.stake-cal__stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
}

.stake-cal__card {
    margin: 0 0 8px;
    padding: 10px 12px;
    border-radius: var(--cm-radius-panel);
    border: 1px solid var(--cm-line-strong);
    background: var(--cm-night);
    color: var(--cm-ivory);
}

.stake-cal__card[hidden] {
    display: none;
}

.stake-cal__card-title {
    margin: 0 0 6px;
    color: var(--cm-lamp);
    font-size: 1rem;
}

.stake-cal__card p {
    margin: 0 0 6px;
    overflow-wrap: anywhere;
}

.stake-cal__swatch {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    color: var(--cm-ivory);
    background-color: var(--cm-teal);
    border-top: 1px solid var(--cm-lamp);
    outline: 1px solid var(--cm-night);
    caret-color: var(--cm-muted);
    border-right: 1px solid var(--cm-danger);
}

#siteModelOverlay .stake-cal__card {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-height: 42%;
    overflow: auto;
    z-index: 2;
}

/* 戶外 (sunlight-readable): colours come from the outdoor token remap in
   engineering-dark.css. Here only size and weight change, for gloves and glare. */
html.sunlight-readable body .stake-cal__fields label,
html.sunlight-readable body .stake-cal > label,
html.sunlight-readable body .stake-cal__ack,
body.sunlight-readable .stake-cal__fields label,
body.sunlight-readable .stake-cal > label,
body.sunlight-readable .stake-cal__ack {
    font-size: 0.92rem;
    font-weight: 800;
}

html.sunlight-readable body .stake-cal__fields input,
html.sunlight-readable body .stake-cal__fields select,
html.sunlight-readable body .stake-cal > label select,
html.sunlight-readable body .stake-cal__actions button,
html.sunlight-readable body .stake-cal__ack,
body.sunlight-readable .stake-cal__fields input,
body.sunlight-readable .stake-cal__fields select,
body.sunlight-readable .stake-cal > label select,
body.sunlight-readable .stake-cal__actions button,
body.sunlight-readable .stake-cal__ack {
    min-height: 56px;
    font-size: 1.1rem;
    font-weight: 800;
}

html.sunlight-readable body .stake-cal__ack input,
body.sunlight-readable .stake-cal__ack input {
    width: 28px;
    height: 28px;
}

html.sunlight-readable body .stake-cal__actions,
body.sunlight-readable .stake-cal__actions {
    gap: 10px;
}

html.sunlight-readable body .stake-cal__status,
body.sunlight-readable .stake-cal__status {
    color: var(--cm-ivory);
    font-size: 1.12rem;
    font-weight: 800;
}

html.sunlight-readable body .stake-cal__warn,
body.sunlight-readable .stake-cal__warn {
    padding: 8px 10px;
    border: 2px solid var(--cm-ivory);
    border-radius: var(--cm-radius-panel);
    color: var(--cm-ivory);
    font-size: 1.05rem;
}

html.sunlight-readable body .stake-cal__residuals li,
body.sunlight-readable .stake-cal__residuals li {
    margin-bottom: 6px;
    padding: 12px 12px 12px 16px;
    border: 1px solid var(--cm-line-strong);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
}

html.sunlight-readable body .stake-cal__residuals li.is-largest,
body.sunlight-readable .stake-cal__residuals li.is-largest {
    box-shadow: inset 6px 0 0 var(--cm-ivory);
}

html.sunlight-readable body .stake-cal__residuals li.is-over,
body.sunlight-readable .stake-cal__residuals li.is-over {
    background: var(--cm-panel);
    border: 2px solid var(--cm-danger);
    box-shadow: inset 8px 0 0 var(--cm-danger);
    font-weight: 900;
}

html.sunlight-readable body .stake-cal__card,
body.sunlight-readable .stake-cal__card {
    font-size: 1rem;
}

html.sunlight-readable body .stake-cal__over,
body.sunlight-readable .stake-cal__over {
    font-weight: 900;
}

@media (max-width: 720px) {
    .stake-cal {
        padding: 10px;
    }

    .stake-cal__fields {
        grid-template-columns: 1fr 1fr;
    }

    .stake-cal__stage {
        height: 46dvh;
        min-height: 240px;
    }

    .stake-cal__actions button,
    .stake-cal__primary {
        flex: 1 1 calc(50% - 8px);
        min-height: var(--cm-tap-primary);
    }
}
