/*
 * Coding Ireland proprietary interactive activity
 * Copyright (c) 2017-2026 Coding Ireland. All rights reserved.
 *
 * Part of the Coding Ireland online learning platform. Licensed for use only
 * as delivered on the platform. Copying, redistributing, or adapting this
 * file, in whole or in part, for use in any other product or service is not
 * permitted. Ref: CI-maths-percent-scaler
 */
/*
 * percent-scaler — a starting amount, a rate, and what the rate does to it,
 * with the arithmetic written out. Markup / margin / multiplier / discount.
 */

.maths-activity .ps-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* ---- Controls ---- */

.maths-activity .ps-controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: #f7f9fc;
    border: 1px solid #e2e8f2;
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
}

.maths-activity .ps-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.maths-activity .ps-field-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: #47506b;
}

.maths-activity .ps-money-input {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #d7deeb;
    border-radius: 10px;
    padding: 0.35rem 0.6rem;
}

.maths-activity .ps-currency {
    font-weight: 800;
    color: #6b7590;
    margin-right: 0.35rem;
}

.maths-activity .ps-input {
    border: 0;
    outline: none;
    font: inherit;
    font-weight: 700;
    font-size: 1.15rem;
    width: 100%;
    background: transparent;
    color: #23293a;
}

.maths-activity .ps-rate-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.maths-activity .ps-slider {
    flex: 1;
    accent-color: #2f7d6d;
}

.maths-activity .ps-rate-readout {
    min-width: 4.2rem;
    text-align: right;
    font-weight: 800;
    font-size: 1.1rem;
    color: #2f7d6d;
}

.maths-activity .ps-slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #8b94ad;
    padding: 0 0.1rem;
}

.maths-activity .ps-op-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.maths-activity .ps-op-btn {
    border: 2px solid #d7deeb;
    background: #fff;
    color: #47506b;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.maths-activity .ps-op-btn:hover {
    border-color: #2f7d6d;
}

.maths-activity .ps-op-btn.is-active {
    background: #2f7d6d;
    border-color: #2f7d6d;
    color: #fff;
}

/* ---- Result ---- */

.maths-activity .ps-result {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.maths-activity .ps-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.maths-activity .ps-bar {
    display: flex;
    height: 62px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #d7deeb;
    background: #eef2f8;
}

.maths-activity .ps-bar-base,
.maths-activity .ps-bar-delta {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.18s ease;
    overflow: hidden;
    white-space: nowrap;
}

.maths-activity .ps-bar-base {
    background: #2f7d6d;
    color: #fff;
}

.maths-activity .ps-bar-delta {
    background: #f0a202;
    color: #3a2c00;
}

/* A discount takes a bite out of the amount rather than extending it, so the
   removed slice reads as a gap, not as more money. */
.maths-activity .ps-bar.is-discount .ps-bar-delta {
    background: repeating-linear-gradient(45deg, #e6ebf3, #e6ebf3 8px, #dbe2ec 8px, #dbe2ec 16px);
    color: #6b7590;
}

.maths-activity .ps-bar-tag {
    font-weight: 800;
    font-size: 0.82rem;
    padding: 0 0.5rem;
    text-overflow: ellipsis;
    overflow: hidden;
}

.maths-activity .ps-bar-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #8b94ad;
}

.maths-activity .ps-readouts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.maths-activity .ps-readout {
    background: #fff;
    border: 1px solid #e2e8f2;
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
}

.maths-activity .ps-readout-final {
    border-color: #2f7d6d;
    background: #f2f9f7;
}

.maths-activity .ps-readout-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #8b94ad;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.maths-activity .ps-readout-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: #23293a;
    margin-top: 0.15rem;
}

.maths-activity .ps-working {
    background: #23293a;
    color: #e8edf6;
    border-radius: 10px;
    padding: 0.75rem 0.95rem;
    font-size: 0.98rem;
    font-weight: 600;
    line-height: 1.5;
}

/* ---- Markup vs margin comparison ---- */

.maths-activity .ps-compare {
    border: 1px solid #e2e8f2;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    background: #fff;
}

.maths-activity .ps-compare-head {
    font-weight: 800;
    color: #47506b;
    margin-bottom: 0.5rem;
}

.maths-activity .ps-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.maths-activity .ps-compare-table th,
.maths-activity .ps-compare-table td {
    text-align: left;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #eef2f8;
}

.maths-activity .ps-compare-table thead th {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #8b94ad;
}

.maths-activity .ps-compare-note {
    margin-top: 0.6rem;
    font-size: 0.88rem;
    color: #47506b;
}

/* ---- Target + your turn ---- */

.maths-activity .ps-target-panel {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.maths-activity .ps-target-label {
    font-weight: 800;
    color: #2f7d6d;
}

.maths-activity .ps-target-prompt {
    font-weight: 600;
    color: #23293a;
}

.maths-activity .ps-callout.is-correct {
    color: #1d6b4f;
    font-weight: 700;
}

.maths-activity .ps-callout.is-wrong {
    color: #a33a2a;
    font-weight: 700;
}

.maths-activity .ps-mode-chip {
    display: inline-block;
    margin-top: 0.4rem;
    background: #eef2f8;
    color: #47506b;
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.maths-activity .ps-your-turn {
    margin-top: 1.1rem;
    border: 1px dashed #c9d3e4;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: #fbfcfe;
}

.maths-activity .ps-your-turn-label {
    font-weight: 800;
    color: #47506b;
    margin-bottom: 0.35rem;
}

.maths-activity .ps-your-turn-list {
    margin: 0;
    padding-left: 1.15rem;
}

/* ---- Display mode ----
   Read-only snapshot: hide every control and zero the reserved heights so the
   iframe shrinks instead of leaving dead vertical space. */

body.display-mode .ps-controls,
body.display-mode .ps-target-panel,
body.display-mode .ps-callout,
body.display-mode .ps-your-turn,
body.display-mode #challengeRunner {
    display: none !important;
}

body.display-mode .ps-layout {
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

body.display-mode .ps-bar {
    height: 48px;
}

body.display-mode .ps-readout {
    padding: 0.6rem 0.75rem;
}

body.display-mode .ps-readout-value {
    font-size: 1.15rem;
}

body.display-mode .ps-working {
    font-size: 0.92rem;
    padding: 0.6rem 0.8rem;
}

@media (max-width: 820px) {
    .maths-activity .ps-layout {
        grid-template-columns: 1fr;
    }
    .maths-activity .ps-readouts {
        grid-template-columns: 1fr;
    }
}
