/* ============================================================
   BLOCK: Preisrechner — as-schoendienst/rechner
   Datei: page-builder/components/organisms/rechner/block.css

   Aufbau wie das abgenommene Mockup (kalkulator-psychische-
   gefaehrdung/mockup/preisrechner-mockup.html), aber in der
   Markenfarbwelt: Akzent #056ab4 (--as-color-accent-brand) auf
   Navy #0a192f, Ergebnispanel mit dem Markenverlauf.

   Typografie wird HIER gesetzt, nicht geerbt: Site-Parts und
   Alt-Pattern setzen body-Klassen-Typografie (z. B. .single-schulung),
   die sonst in Formularfelder und Labels durchschlägt (AGENTS.md).

   Kontraste (WCAG 2.2 AA) geprüft:
   - #5c6b7e auf #f2f8fd  = 4,9:1  (kleine Beschreibungstexte)
   - #cfe1f0 auf #074071  = 8,6:1  (Sekundärtext im Panel)
   - #7ddba1 auf #043349  = 7,3:1  (Ersparnis)
   - Weiß auf #056ab4     = 5,1:1  (Button)
   Fokus: 3 px Navy (#06284b) auf hellem Grund, 3 px Weiß im Panel —
   sichtbar in beiden Welten, nicht der blasse Standard-Ring.
   ============================================================ */
@import "../../../assets/tokens.css" layer(sdc-tokens);

.as-rechner {
    box-sizing: border-box;
    background: var(--as-color-white);
    padding-top: clamp(3.125rem, 2.5rem + 3.125vw, 6.25rem);
    padding-bottom: clamp(3.125rem, 2.5rem + 3.125vw, 6.25rem);
    font-family: var(--as-font-body);
    font-size: 17px;
    line-height: 1.65;
    color: var(--as-color-text);
}

/* Box-Modell selbst setzen: der Block darf sich nicht darauf verlassen, dass
   ein globales Reset im Theme/Alt-CSS greift — sonst laufen Button und Felder
   aus dem Raster (gemessen: CTA 40 px breiter als das Panel). */
.as-rechner *,
.as-rechner *::before,
.as-rechner *::after {
    box-sizing: border-box;
}

.as-rechner--bg-neutral {
    background: var(--as-color-neutral);
}

.as-rechner--bg-dark {
    background: var(--as-color-navy);
}

.as-rechner--bg-dark .as-eyebrow {
    color: var(--as-color-accent-light);
}

.as-rechner--bg-dark .as-headline {
    color: var(--as-color-white);
}

.as-rechner--bg-dark .as-section-head__intro {
    color: var(--as-color-light);
}

/* ============================================================
   Rechner-Rahmen: links Eingaben, rechts Ergebnis
   ============================================================ */
.as-rechner__calc {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 2rem;
    border: 1px solid var(--as-color-border);
    border-radius: var(--as-radius);
    background: var(--as-color-white);
    box-shadow: var(--as-shadow);
    overflow: hidden;
}

/* ---------- Eingaben ---------- */
.as-rechner__inputs {
    padding: 2.125rem 2rem 1.875rem;
    background: var(--as-color-white);
    min-width: 0;
}

.as-rechner__field + .as-rechner__field {
    margin-top: 1.75rem;
}

.as-rechner__fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.as-rechner__label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 0;
    font-family: var(--as-font-sans);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--as-color-navy);
}

/* legend ist kein Flex-Kind von sich aus — Breite erzwingen */
.as-rechner__fieldset > .as-rechner__label {
    display: flex;
    width: 100%;
    float: none;
}

.as-rechner__hint {
    font-family: var(--as-font-body);
    font-size: 13px;
    font-weight: 400;
    color: #5c6b7e;
}

/* Zahlenfeld + Slider */
.as-rechner__numrow {
    display: flex;
    align-items: center;
    gap: 10px;
}

.as-rechner__num {
    width: 110px;
    padding: 10px 12px;
    font-family: var(--as-font-sans);
    font-size: 17px;
    font-weight: 600;
    line-height: 1;
    color: var(--as-color-navy);
    background: var(--as-color-white);
    border: 1px solid var(--as-color-border);
    border-radius: var(--as-radius-sm);
}

.as-rechner__unit {
    font-size: 15px;
    color: #5c6b7e;
}

.as-rechner__range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 32px;
    margin: 14px 0 0;
    background: transparent;
    cursor: pointer;
}

.as-rechner__range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 99px;
    background: var(--as-color-border);
}

.as-rechner__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    margin-top: -9px;
    border: 3px solid var(--as-color-white);
    border-radius: 50%;
    background: var(--as-color-accent-brand);
    box-shadow: 0 2px 8px rgba(5, 106, 180, 0.4);
}

.as-rechner__range::-moz-range-track {
    height: 6px;
    border-radius: 99px;
    background: var(--as-color-border);
}

.as-rechner__range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 3px solid var(--as-color-white);
    border-radius: 50%;
    background: var(--as-color-accent-brand);
}

/* Pläne */
.as-rechner__plans {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.as-rechner__plan {
    position: relative;
    display: block;
    padding: 16px 16px 14px;
    border: 1px solid #d5dde7;
    border-radius: var(--as-radius-sm);
    background: var(--as-color-white);
    cursor: pointer;
    transition: border-color 0.18s var(--as-ease), background 0.18s var(--as-ease);
}

.as-rechner__plan:hover {
    border-color: #b6c6da;
}

.as-rechner__plan input,
.as-rechner__seg-item input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: 0;
}

.as-rechner__plan-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--as-font-sans);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--as-color-navy);
}

.as-rechner__plan-desc {
    display: block;
    margin-top: 4px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #5c6b7e;
}

.as-rechner__dot {
    position: relative;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    /* Ring = das eigentliche Bedienelement im Ruhezustand → 3:1 auf Weiß */
    border: 2px solid #64748b;
    border-radius: 50%;
}

.as-rechner__plan input:checked ~ .as-rechner__plan-name .as-rechner__dot {
    border-color: var(--as-color-accent-brand);
}

.as-rechner__plan input:checked ~ .as-rechner__plan-name .as-rechner__dot::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--as-color-accent-brand);
}

.as-rechner__plan:has(input:checked) {
    border-color: var(--as-color-accent-brand);
    background: #f2f8fd;
    box-shadow: inset 0 0 0 1px var(--as-color-accent-brand);
}

/* Laufzeit */
.as-rechner__seg {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.as-rechner__seg-item {
    position: relative;
    display: block;
    padding: 10px 4px 8px;
    text-align: center;
    border: 1px solid var(--as-color-border);
    border-radius: var(--as-radius-sm);
    background: var(--as-color-white);
    cursor: pointer;
    transition: border-color 0.18s var(--as-ease), background 0.18s var(--as-ease);
}

.as-rechner__seg-item:hover {
    border-color: #b6c6da;
}

.as-rechner__yrs {
    display: block;
    font-family: var(--as-font-sans);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--as-color-navy);
}

.as-rechner__off {
    display: block;
    min-height: 16px;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.3;
    color: #5c6b7e;
}

.as-rechner__seg-item:has(input:checked) {
    border-color: var(--as-color-accent-brand);
    background: #f2f8fd;
    box-shadow: inset 0 0 0 1px var(--as-color-accent-brand);
}

.as-rechner__seg-item:has(input:checked) .as-rechner__off {
    color: var(--as-color-accent-brand);
    font-weight: 600;
}

/* ---------- Fokus: deutlich, in beiden Welten sichtbar ---------- */
.as-rechner__num:focus-visible,
.as-rechner__range:focus-visible,
.as-rechner__cta:focus-visible {
    outline: 3px solid var(--as-color-navy-deep);
    outline-offset: 2px;
}

.as-rechner__plan:has(input:focus-visible),
.as-rechner__seg-item:has(input:focus-visible) {
    outline: 3px solid var(--as-color-navy-deep);
    outline-offset: 2px;
}

/* Ältere Browser ohne :has() — Fokus trotzdem sichtbar */
.as-rechner__plan:focus-within,
.as-rechner__seg-item:focus-within {
    outline: 3px solid var(--as-color-navy-deep);
    outline-offset: 2px;
}

/* ---------- Ergebnispanel ---------- */
.as-rechner__result {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.125rem 2rem 1.875rem;
    background: var(--as-gradient-dark);
    color: var(--as-color-white);
    min-width: 0;
}

.as-rechner__kicker {
    margin: 0 0 10px;
    font-family: var(--as-font-sans);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #a9c9e4;
}

.as-rechner__price {
    margin: 0;
    font-family: var(--as-font-sans);
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--as-color-white);
    font-variant-numeric: tabular-nums;
}

.as-rechner__cur {
    margin-left: 4px;
    font-size: 26px;
    font-weight: 600;
    vertical-align: 0.28em;
    color: #cfe1f0;
}

.as-rechner__price-sub {
    margin: 10px 0 0;
    font-size: 14.5px;
    color: #cfe1f0;
}

.as-rechner__rows {
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.as-rechner__rows li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 0;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14.5px;
}

.as-rechner__k {
    color: #cfe1f0;
}

.as-rechner__v {
    font-family: var(--as-font-sans);
    font-weight: 600;
    white-space: nowrap;
    color: var(--as-color-white);
    font-variant-numeric: tabular-nums;
}

.as-rechner__v--save {
    color: #7ddba1;
}

.as-rechner__staffel {
    margin: 16px 0 0;
    padding: 11px 13px;
    border-radius: var(--as-radius-sm);
    background: rgba(255, 255, 255, 0.09);
    font-size: 13.5px;
    line-height: 1.5;
    color: #e6f0f8;
}

.as-rechner__result-cta {
    margin-top: 20px;
}

.as-rechner__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 15px 20px;
    border: 0;
    border-radius: var(--as-radius-btn);
    font-family: var(--as-font-sans);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    color: var(--as-color-white);
    background: var(--as-color-accent-brand);
    box-shadow: 0 6px 18px rgba(5, 106, 180, 0.35);
    transition: background 0.18s var(--as-ease), transform 0.18s var(--as-ease);
}

.as-rechner__cta:hover,
.as-rechner__cta:focus {
    background: #0b7cc9;
    color: var(--as-color-white);
    transform: translateY(-1px);
}

.as-rechner__cta:focus-visible {
    outline-color: var(--as-color-white);
}

.as-rechner__cta-icon {
    flex: 0 0 auto;
}

.as-rechner__cta-foot {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
    text-align: center;
    color: #a9c9e4;
}

/* Screenreader-Ansage: vorhanden, aber unsichtbar */
.as-rechner__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ---------- Ohne JS: Staffeltabelle statt Maske ---------- */
.as-rechner__staffeltabelle {
    display: none;
    width: 100%;
    margin-top: 2rem;
    border-collapse: collapse;
    font-size: 15px;
}

.as-rechner__staffeltabelle caption {
    margin-bottom: 10px;
    font-family: var(--as-font-sans);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    color: var(--as-color-navy);
}

.as-rechner--bg-dark .as-rechner__staffeltabelle caption,
.as-rechner--bg-dark .as-rechner__staffeltabelle th[scope="row"] {
    color: var(--as-color-white);
}

.as-rechner--bg-dark .as-rechner__staffeltabelle th,
.as-rechner--bg-dark .as-rechner__staffeltabelle td {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--as-color-light);
}

.as-rechner__staffeltabelle th,
.as-rechner__staffeltabelle td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--as-color-border);
    color: var(--as-color-text);
}

.as-rechner__staffeltabelle thead th {
    font-family: var(--as-font-sans);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #5c6b7e;
    background: #f2f8fd;
}

.as-rechner__staffeltabelle tbody th {
    font-weight: 600;
    color: var(--as-color-navy);
}

.as-rechner__staffeltabelle td {
    font-variant-numeric: tabular-nums;
}

.as-rechner__foot {
    margin: 20px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: #5c6b7e;
}

.as-rechner--bg-dark .as-rechner__foot {
    color: #cfe1f0;
}

/* ============================================================
   Responsiv
   ============================================================ */
@media (max-width: 991.98px) {
    .as-rechner__calc {
        grid-template-columns: minmax(0, 1fr);
    }

    .as-rechner__inputs,
    .as-rechner__result {
        min-width: 0;
        padding: 1.5rem 1.125rem;
    }

    .as-rechner__price {
        font-size: 40px;
    }
}

@media (max-width: 767.98px) {
    .as-rechner__plans {
        grid-template-columns: 1fr;
    }

    .as-rechner__seg {
        gap: 5px;
    }

    .as-rechner__seg-item {
        padding: 9px 2px 7px;
    }

    .as-rechner__yrs {
        font-size: 13.5px;
    }

    .as-rechner__off {
        font-size: 11px;
    }
}

@media (max-width: 519.98px) {
    .as-rechner__seg {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .as-rechner__yrs {
        font-size: 14px;
    }

    .as-rechner__off {
        font-size: 11.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .as-rechner__cta,
    .as-rechner__plan,
    .as-rechner__seg-item {
        transition: none;
    }

    .as-rechner__cta:hover,
    .as-rechner__cta:focus {
        transform: none;
    }
}
