/*
 * [savings_calculator] layout. Loaded only on pages that render the shortcode.
 * Text inputs and the submit button take the Elementor kit's global Form Field
 * and Button styles; this file only lays them out. Override the custom
 * properties below to restyle without touching this file.
 */
.savings-calculator {
    --savings-calculator-gap: 1.25rem;
    --savings-calculator-cell-width: 5.5rem;
    --savings-calculator-total-width: 7rem;
    --savings-calculator-border: 1px solid var(--e-global-color-secondary, rgba(0, 0, 0, 0.2));
    --savings-calculator-muted: #666;
    --savings-calculator-success: #2e7d32;
    --savings-calculator-error: #c62828;

    container-type: inline-size;
    color: var(--e-global-color-text, inherit);
    font-family: var(--e-global-typography-text-font-family, inherit);
}

.savings-calculator *,
.savings-calculator *::before,
.savings-calculator *::after {
    box-sizing: border-box;
}

/* :where() keeps this at class specificity so the element rules below win. */
.savings-calculator :where(p) {
    margin: 0;
}

.savings-calculator__title {
    margin: 0 0 1rem;
}

/* ===== Currency ===== */

.savings-calculator__currency {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 1rem;
}

.savings-calculator__currency label {
    margin: 0;
    white-space: nowrap;
}

/* The native caret hugs the right edge, so draw our own with breathing room. */
.savings-calculator__currency select {
    width: auto;
    min-width: 8rem;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23333' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 0.75rem auto;
}

/* ===== Rows ===== */

.savings-calculator__columns {
    display: flex;
    justify-content: space-between;
    gap: var(--savings-calculator-gap);
    margin-bottom: 0.625rem;
}

.savings-calculator__columns-left {
    font-weight: 600;
}

.savings-calculator__columns-right {
    font-size: 0.75rem;
    color: var(--savings-calculator-muted);
    white-space: nowrap;
}

.savings-calculator__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem var(--savings-calculator-gap);
    margin-bottom: var(--savings-calculator-gap);
}

/* Beats the theme's paragraph spacing so heading and question sit together. */
.savings-calculator .savings-calculator__question p {
    margin: 0;
}

.savings-calculator__heading {
    font-weight: 700;
}

/* Beats the kit's input:not([type="button"]):not([type="submit"]) field
   styles, which would otherwise box the slider like a text field. */
.savings-calculator .savings-calculator__question input[type="range"].savings-calculator__range {
    display: block;
    width: 100%;
    margin: 0.625rem 0 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    accent-color: var(--e-global-color-accent, currentColor);
}

/* ===== value × cost = total ===== */

.savings-calculator__sum {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}

.savings-calculator__field {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: var(--savings-calculator-cell-width);
}

.savings-calculator__field input {
    width: 100%;
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.savings-calculator__field input::-webkit-outer-spin-button,
.savings-calculator__field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Room for the £/€/$ prefix or % suffix inside the kit-styled field. */
.savings-calculator .savings-calculator__field--prefix input[type="number"].savings-calculator__input {
    padding-left: 1.75rem;
}

.savings-calculator .savings-calculator__field--suffix input[type="number"].savings-calculator__input {
    padding-right: 1.75rem;
}

.savings-calculator__affix {
    position: absolute;
    pointer-events: none;
}

.savings-calculator__field--prefix .savings-calculator__affix {
    left: 0.75rem;
}

.savings-calculator__field--suffix .savings-calculator__affix {
    right: 0.75rem;
}

.savings-calculator__operator {
    flex: 0 0 auto;
    width: 1rem;
    text-align: center;
    font-weight: 700;
}

.savings-calculator__row-total {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--savings-calculator-total-width);
    min-height: 2.5rem;
    padding: 0 0.5rem;
    border: var(--savings-calculator-border);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Narrow columns/phones: the sum moves under the question. */
@container (max-width: 40rem) {
    .savings-calculator__row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ===== Total and enquiry ===== */

.savings-calculator__total {
    margin: var(--savings-calculator-gap) 0;
    padding-top: var(--savings-calculator-gap);
    border-top: var(--savings-calculator-border);
    font-size: 1.125rem;
}

.savings-calculator__total output {
    font-weight: 700;
}

/* Sending needs the script; without it the calculator still shows the
   default figures but the enquiry form is hidden. */
.savings-calculator:not(.is-enhanced) .savings-calculator__contact {
    display: none;
}

.savings-calculator__email {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
    margin: 0.75rem 0 0.5rem;
}

.savings-calculator__email label {
    margin: 0;
    white-space: nowrap;
}

.savings-calculator__email input {
    flex: 1 1 12rem;
    min-width: 0;
}

.savings-calculator__submit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.savings-calculator__submit[disabled] {
    cursor: progress;
    opacity: 0.8;
}

.savings-calculator__spinner {
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: savings-calculator-spin 0.6s linear infinite;
}

.savings-calculator__spinner[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .savings-calculator__spinner {
        animation-duration: 2s;
    }
}

@keyframes savings-calculator-spin {
    to {
        transform: rotate(360deg);
    }
}

.savings-calculator__privacy {
    font-size: 0.875rem;
    color: var(--savings-calculator-muted);
}

.savings-calculator__status:not(:empty) {
    margin-top: 0.75rem;
}

.savings-calculator__status[data-state="success"] {
    color: var(--savings-calculator-success);
}

.savings-calculator__status[data-state="error"] {
    color: var(--savings-calculator-error);
}

/* ===== Hidden helpers ===== */

.savings-calculator .screen-reader-text,
.savings-calculator__hp {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
