/* =====================================================
   KlubKlar cost calculator ("Hvad koster en infoskærm?")
   Namespaced with .kk-calc-* to avoid collisions.
   ===================================================== */

.kk-calc {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.75rem;
    margin: 1.5rem 0;
}

.kk-calc-intro {
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

/* ---------- Form ---------- */
.kk-calc-form {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.kk-calc-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.kk-calc-row.is-hidden {
    display: none;
}

.kk-calc-label {
    font-weight: 600;
    color: var(--color-text-primary);
    flex: 1 1 55%;
    min-width: 220px;
}

.kk-calc-hint {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.kk-calc-control {
    flex: 0 1 auto;
}

.kk-calc-number,
.kk-calc-select {
    font: inherit;
    color: var(--color-text-primary);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.75rem;
    min-height: 44px;
}

.kk-calc-number {
    width: 5.5rem;
    text-align: center;
}

.kk-calc-select {
    min-width: 240px;
    max-width: 100%;
}

.kk-calc-number:focus,
.kk-calc-select:focus,
.kk-calc-switch input:focus-visible + .kk-calc-switch-track {
    outline: 2px solid var(--color-blue-accessible);
    outline-offset: 2px;
}

/* ---------- Toggle switch ---------- */
.kk-calc-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.kk-calc-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.kk-calc-switch-track {
    display: inline-block;
    width: 52px;
    height: 30px;
    background: var(--color-border);
    border-radius: var(--radius-pill);
    transition: background var(--transition-fast);
    position: relative;
    flex: none;
}

.kk-calc-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: var(--color-white);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

.kk-calc-switch input:checked + .kk-calc-switch-track {
    background: var(--color-green-accessible);
}

.kk-calc-switch input:checked + .kk-calc-switch-track::after {
    transform: translateX(22px);
}

/* ---------- Result ---------- */
.kk-calc-result {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
}

.kk-calc-result h3 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.kk-calc-lines {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.kk-calc-lines li {
    display: flex;
    justify-content: space-between;
    /* Baseline so a wrapped label keeps its value aligned to the first text
       line instead of floating pinned to the top of the row. */
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--color-border);
}

.kk-calc-lines li:last-child {
    border-bottom: none;
}

.kk-calc-line-label {
    color: var(--color-text-secondary);
}

.kk-calc-line-value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
    color: var(--color-text-primary);
}

.kk-calc-totals {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 1fr;
    margin-top: 0.5rem;
}

@media (max-width: 480px) {
    .kk-calc-totals {
        grid-template-columns: 1fr;
    }
}

.kk-calc-total {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.kk-calc-total-once {
    border-color: var(--color-blue);
    background: var(--color-blue-light);
}

.kk-calc-total-monthly {
    border-color: var(--color-green);
    background: var(--color-green-light);
}

.kk-calc-total-label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.kk-calc-total-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.kk-calc-total-unit {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* ---------- Disclaimer + CTA ---------- */
.kk-calc-note {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: 1.25rem 0 0;
    line-height: 1.5;
    /* Hanging indent: the icon sits to the left, wrapped text lines align under
       the text (not under the icon). NOT flex – flex made every word a flex item
       and the gap spaced them apart. */
    padding-left: 1.5rem;
}

.kk-calc-note i {
    color: var(--color-blue-accessible);
    float: left;
    margin-left: -1.5rem;
    margin-top: 0.15rem;
    width: 1.5rem;
}

.kk-calc-cta {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* Links inside the calculator note must not rely on color alone to be
   distinguishable (WCAG 1.4.1 / Lighthouse link-in-text-block). */
.kk-calc-note a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .kk-calc {
        padding: 1.25rem;
    }

    /* Stack label above a full-width control instead of a cramped
       side-by-side that squeezes the numbers/selects. */
    .kk-calc-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .kk-calc-label {
        flex: 1 1 auto;
        min-width: 0;
    }

    .kk-calc-control {
        flex: 1 1 auto;
        width: 100%;
    }

    .kk-calc-number,
    .kk-calc-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        text-align: left;
    }

    /* The toggle-switch row: label left, switch right (its natural size),
       not a full-width stretched control. */
    .kk-calc-row:has(.kk-calc-switch) {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .kk-calc-row:has(.kk-calc-switch) .kk-calc-label {
        flex: 1 1 auto;
    }

    .kk-calc-row:has(.kk-calc-switch) .kk-calc-control {
        flex: 0 0 auto;
        width: auto;
    }

    .kk-calc-result {
        padding: 1.1rem 1.15rem;
    }

    /* Result lines: value drops below its label if the row gets tight,
       keeping currency from being clipped. */
    .kk-calc-lines li {
        gap: 0.5rem;
    }

    /* Full-width CTA button on mobile. */
    .kk-calc-cta {
        flex-direction: column;
        align-items: stretch;
    }

    .kk-calc-cta .btn {
        width: 100%;
    }
}
