/*
 * Finansieringsmodulen och rutan från bilkorten (se finance-module.php).
 */
.rwf {
    --rwf-blue: #0060a8;
    --rwf-track: #d6e4f5;
    color: #1a1a1a;
    margin: 3em 0;
    scroll-margin-top: 120px;
}

.rwf__heading {
    margin: 0 0 0.75em;
}

.rwf__box {
    container-type: inline-size;
    background: #f5f6f8;
    border-radius: 0.75em;
    padding: 1.75em 2em 1.5em;
}

/* Alla uppgifter i samma storlek: effektiv ränta ska synas minst lika tydligt
   som månadskostnaden och kreditränta. */
.rwf__facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25em 1.5em;
    margin: 0 0 1.5em;
}

.rwf__fact dt {
    margin: 0;
    color: #555;
    font-size: 0.9em;
    font-weight: 400;
}

.rwf__fact dd {
    margin: 0.15em 0 0;
    font-family: "Host Grotesk", sans-serif;
    font-size: 1.15em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.rwf__controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5em 2.5em;
    background: #fff;
    border: 1px solid #e4e6ea;
    border-radius: 0.75em;
    padding: 1.5em 2em;
}

.rwf__control {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    margin: 0;
    cursor: default;
}

.rwf__control-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5em;
    flex-wrap: wrap;
    font-size: 0.95em;
}

.rwf__control-head strong {
    font-family: "Host Grotesk", sans-serif;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rwf__hint {
    color: #666;
    font-size: 0.8em;
}

.rwf input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    margin: 0;
    background: transparent;
    cursor: pointer;
    --rwf-fill: 0%;
}

.rwf input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--rwf-blue) var(--rwf-fill), var(--rwf-track) var(--rwf-fill));
}

.rwf input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--rwf-track);
}

.rwf input[type="range"]::-moz-range-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--rwf-blue);
}

.rwf input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -8px;
    border: 3px solid var(--rwf-blue);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.rwf input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 3px solid var(--rwf-blue);
    border-radius: 50%;
    background: #fff;
}

.rwf input[type="range"]:focus-visible {
    outline: 2px solid var(--rwf-blue);
    outline-offset: 4px;
    border-radius: 4px;
}

.rwf__example {
    margin: 1.25em 0 0;
    line-height: 1.6;
}

/* Varningen: svart text på vit bakgrund, röd symbol minst tre textrader hög
   (texten har line-height 1.5, så 3 rader = 4.5em). */
.rwf__warning {
    display: flex;
    align-items: center;
    gap: 1.25em;
    margin: 1em 0 0;
    padding: 1em 1.5em;
    background: #fff;
    color: #000;
    border: 1px solid #e4e6ea;
    border-radius: 0.75em;
}

.rwf__warning p {
    margin: 0;
    font-size: 1em;
    line-height: 1.5;
    color: #000;
}

.rwf__warning a {
    color: inherit;
    text-decoration: underline;
}

.rwf__warning-icon {
    flex: 0 0 auto;
    width: 5em;
    height: 5em;
    fill: none;
    stroke: #d0021b;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Efter modulens egen bredd, inte fönstrets: på bilsidan ligger den i en
   smalare spalt bredvid kontaktrutan. */
@container (max-width: 860px) {
    .rwf__controls { grid-template-columns: 1fr; gap: 1.25em; padding: 1.25em 1.5em; }
}

@container (max-width: 560px) {
    .rwf__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rwf__controls { padding: 1.25em; }
}

@media screen and (max-width: 600px) {
    .rwf__box { padding: 1.25em; }
    .rwf__warning { align-items: flex-start; padding: 1em; gap: 1em; }
    .rwf__warning-icon { width: 4.5em; height: 4.5em; }
}

/* ---------- Knappen på bilkorten ---------- */

.rwf-open {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.45em 0.8em;
    border: 1px solid #0060a8;
    border-radius: 999px;
    background: #fff;
    color: #0060a8;
    font: inherit;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

.rwf-open:hover,
.rwf-open:focus-visible {
    background: #0060a8;
    color: #fff;
}

.rwf-open svg {
    width: 1.25em;
    height: 1.25em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Prisraden på korten: priset till vänster, knappen till höger. */
.vehicle .price_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75em;
    margin: 1em 0 0;
    font-family: "Host Grotesk", sans-serif;
    line-height: 130%;
}

.vehicle .price_row p {
    margin: 0;
}

.vehicle .price_row a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Rutan ---------- */

html.rwf-lock {
    overflow: hidden;
}

.rwf-modal {
    width: min(960px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    border-radius: 1em;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.rwf-modal::backdrop {
    background: rgba(10, 20, 35, 0.55);
}

.rwf-modal__inner {
    max-height: inherit;
    overflow-y: auto;
    padding: 1.75em 2em 2em;
    box-sizing: border-box;
}

.rwf-modal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1em;
    margin: 0 0 1.25em;
}

.rwf-modal__kicker {
    margin: 0 0 0.25em;
    color: #666;
    font-size: 0.85em;
}

.rwf-modal__title {
    margin: 0;
    font-size: 1.25em;
    line-height: 1.3;
}

.rwf-modal__close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    padding: 8px;
    border: 0;
    border-radius: 50%;
    background: #f0f1f3;
    color: #1a1a1a;
    cursor: pointer;
}

.rwf-modal__close:hover { background: #e2e4e8; }

.rwf-modal__close svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.rwf-modal .rwf {
    margin: 0;
}

.rwf-modal__cta {
    display: inline-block;
    margin: 1.25em 0 0;
}

.rwf-modal__cta[hidden] { display: none; }

@media screen and (max-width: 600px) {
    .rwf-modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100dvh;
        margin: 0;
        border-radius: 0;
    }
    .rwf-modal__inner { padding: 1.25em 16px 1.5em; }
}
