/* ===================================================================
 * Tarifseite — Section `tarif-wahl` (seit 2026-11-04)
 *
 * Betreiber: „die auswahl macht keinen sinn, weil das kein shop noch ist …
 * das ist eine section. das infos dann darunter.. dezent." Dazu die Grafik
 * „woraus sich der Tarif zusammensetzt — dynamisch".
 *
 * Geladen nur, wo die Seite `tarif-wahl` traegt (functions.php), Handle
 * `james-care-tarif` steht in jc_erlaubte_styles().
 *
 * ⛔ Hard Rules: Flaechen ohne Rundung, keine Schatten, kein Hex (nur Tokens),
 *    hoechstens ein grosser Rotblock je Viewport — hier gibt es KEINEN: Rot
 *    steht nur am eingeschalteten Piktogramm, am laufenden Signal und am
 *    Paketpreis.
 * 📌 Bewegung ueber die Motion-Tokens; bei `prefers-reduced-motion` setzt
 *    tokens.css sie auf 1ms, Aufbau und Signal entfallen ganz (Ende Abschnitt 1).
 * =================================================================== */

.jc-tarifwahl__lead {
    margin-bottom: var(--jc-space-lg);
}

.jc-tarifwahl [hidden] {
    display: none !important;
}

/* -------------------------------------------------------------------
 * 1. Die Grafik
 *
 * Betreiber 2026-11-04: technisch perfekt, „aber mehr animiert". Takt und Klassen
 * setzt assets/js/tarif-zeichnung.js, hier steht, wie es aussieht:
 *   --wartet    Grafik noch nicht im Bild: verborgen
 *   --zeichnet  Kette baut sich Glied fuer Glied auf (`--g`), Linien wachsen mit
 *   (keine)     fertig. Danach laeuft das Signal (`is-signal`/`is-sendet`), am
 *               Ziel faerbt sich das Kaestchen (`is-empfang`).
 *   is-nachzeichnen  Haekchen gesetzt: dieser Baustein baut sich kurz neu auf
 *
 * ⛔ Brand Guide § 18 Motion: „Animiert werden nur Farbe, Deckkraft und kleine
 *    Wege — nie Groesse, nie Rotation. Nichts blinkt: Blinken gehoert dem Notruf."
 *    Darum: Die Linie waechst per `clip-path` (sie wird aufgedeckt, nicht gestreckt),
 *    kein scale(), keine Dauerschleife in CSS. Geprueft in tests/tarif-zeichnungen-test.php.
 * 📌 Ohne JavaScript und bei `prefers-reduced-motion`: alles fertig, kein Signal.
 * ----------------------------------------------------------------- */

.jc-tarifbau {
    --jc-tarifbau-bild: 64px;
    --jc-tarifbau-strich: var(--jc-gray-300);
    --jc-tarifbau-takt: 720ms;    /* Abstand zweier Glieder beim Aufbau    */
    --jc-tarifbau-lauf: 1100ms;   /* Signal ueber eine Verbindung (= LAUF) */
    --jc-tarifbau-punkt: 6px;     /* Signal: Quadrat wie der Eyebrow-Punkt */
    margin: 0 0 var(--jc-space-xl);
    padding: 0;
}

/* Pause-Knopf fuer das Signal (WCAG 2.2.2), oben rechts; Aussehen wie .jc-kette__karussell */
.jc-tarifbau {
    position: relative;
}

.jc-tarifbau__pause {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: var(--jc-hairline) solid var(--jc-border-control);
    border-radius: 50%;
    background: var(--jc-surface);
    color: var(--jc-text);
    cursor: pointer;
}

.jc-tarifbau__pause[hidden] {
    display: none;
}

.jc-tarifbau__pause svg {
    width: 14px;
    height: 14px;
}

.jc-tarifbau__play-zeichen,
.jc-tarifbau__pause.is-pausiert .jc-tarifbau__pause-zeichen {
    display: none;
}

.jc-tarifbau__pause.is-pausiert .jc-tarifbau__play-zeichen {
    display: block;
}

.jc-tarifbau__pause:hover,
.jc-tarifbau__pause:focus-visible {
    border-color: var(--jc-text);
}

.jc-tarifbau__weg {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Ein Glied — mobil: Bild links, Text rechts, Glieder untereinander. */
.jc-tarifbau__glied {
    position: relative;
    display: grid;
    grid-template-columns: calc(var(--jc-tarifbau-bild) * 1.18) minmax(0, 1fr);
    column-gap: var(--jc-space-sm);
    align-content: start;
    padding-block: calc(var(--jc-tarifbau-bild) * 0.18) var(--jc-space-md);
}

.jc-tarifbau__glied > :not(.jc-tarifbau__bild):not(.jc-tarifbau__linie) {
    grid-column: 2;
}

.jc-tarifbau__glied > .jc-tarifbau__bild {
    grid-column: 1;
    grid-row: 1 / span 6;
    align-self: start;
}

/* Das Bild: quadratischer Rahmen, Piktogramm darin. */
.jc-tarifbau__bild {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: var(--jc-tarifbau-bild);
    height: var(--jc-tarifbau-bild);
    background: var(--jc-paper);
    border: var(--jc-hairline) solid var(--jc-text);
    color: var(--jc-accent);
    transition: border-color var(--jc-motion-progress) var(--jc-motion-ease),
                color var(--jc-motion-progress) var(--jc-motion-ease),
                background-color var(--jc-motion-progress) var(--jc-motion-ease);
}

.jc-tarifbau__svg {
    position: relative;   /* ueber dem Wuerfel */
    width: 62%;
    height: 62%;
    overflow: visible;
}

/*
 * Der Drahtwuerfel (seit 06.11., Betreiber: „plastischer … ein helleres Drahtmodell
 * von einem Wuerfel"). Das Kaestchen selbst hat keinen Rahmen mehr: Seine Flaeche ist
 * die Vorderseite des Wuerfels, die Rueckseite steht 18 % nach rechts oben ueber.
 * Kanten hell (Grau statt Schrift), Ober- und Seitenflaeche leicht getoent — das
 * macht ihn plastisch. Rot nur am Piktogramm und beim Empfang des Signals.
 */
.jc-tarifbau__bild--wuerfel {
    border: 0;
    background: transparent;
}

/* ⚠️ Ausnahme von Hard Rule 7 (Flaechen ohne Rundung) auf Ansage des Betreibers 06.11.:
   *„das ganze etwas 3d box leicht angerundet"* — gilt nur fuer diese Grafik: Wuerfel
   (rx im SVG), Zusatz-Kaestchen und die kleinen Dienst-Kaestchen. */
.jc-tarifbau {
    --jc-tarifbau-rund: 6px;
}

.jc-wuerfel {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 118%;
    height: 118%;
    overflow: visible;
    pointer-events: none;
}

.jc-wuerfel path {
    /* ⛔ Kein `vector-effect: non-scaling-stroke`: Chrome rechnet `pathLength` dann in
       Bildschirm-Pixeln, die gezogenen Kanten bleiben je nach Groesse halb leer. Die
       Strichstaerke steht darum in Wuerfel-Einheiten (118 = Bild × 1,18). */
    transition: fill var(--jc-motion-progress) var(--jc-motion-ease),
                stroke var(--jc-motion-progress) var(--jc-motion-ease);
}

.jc-wuerfel__front {
    fill: var(--jc-paper);
    fill-opacity: 0.88;     /* die Rueckseite scheint schwach durch */
}

.jc-wuerfel__oben {
    fill: var(--jc-gray-100);
    stroke: none;
}

.jc-wuerfel__seite {
    fill: var(--jc-gray-200);
    stroke: none;
}

.jc-wuerfel__kante {
    stroke: var(--jc-gray-500);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
}

.jc-wuerfel__kante:not(.jc-wuerfel__front) {
    fill: none;
}

/* Aus: nur ein gestrichelter Umriss, keine Flaechen. */
.is-aus > .jc-tarifbau__bild--wuerfel .jc-wuerfel__kante {
    stroke: var(--jc-gray-300);
}

.is-aus > .jc-tarifbau__bild--wuerfel :is(.jc-wuerfel__kante--hinten, .jc-wuerfel__kante--vorn) { stroke-dasharray: 0.025 0.025; }
.is-aus > .jc-tarifbau__bild--wuerfel .jc-wuerfel__kante--d { stroke-dasharray: 0.14 0.14; }

.is-aus > .jc-tarifbau__bild--wuerfel :is(.jc-wuerfel__oben, .jc-wuerfel__seite) {
    fill: transparent;
}

.jc-tarifbau__titel {
    display: block;
    padding-top: 6px;
    font-size: var(--jc-size-ui);
    font-weight: var(--jc-weight-semibold);
    line-height: var(--jc-lh-ui);
    color: var(--jc-text);
    transition: color var(--jc-motion-progress) var(--jc-motion-ease);
}

.jc-tarifbau__text {
    display: block;
    margin-top: 2px;
    font-size: var(--jc-size-meta);
    line-height: 1.45;
    color: var(--jc-text-meta);
}

/* „mit Notrufzentrale" — nur, solange der Baustein aus ist. */
.jc-tarifbau__mit {
    display: block;
    margin-top: 6px;
    font-size: var(--jc-size-label);
    font-weight: var(--jc-weight-semibold);
    letter-spacing: var(--jc-tracking-label);
    text-transform: uppercase;
    color: var(--jc-gray-500);
}

.is-an > .jc-tarifbau__mit {
    display: none;
}

/* Aus: gestrichelter Rahmen, Piktogramm und Titel zurueckgenommen. */
.jc-tarifbau__glied.is-aus > .jc-tarifbau__bild,
.jc-tarifbau__dienst.is-aus > .jc-tarifbau__bild {
    border-style: dashed;
    border-color: var(--jc-tarifbau-strich);
    color: var(--jc-gray-500);
}

.jc-tarifbau__glied.is-aus > .jc-tarifbau__titel,
.jc-tarifbau__dienst.is-aus .jc-tarifbau__titel {
    color: var(--jc-text-meta);
}

/* Der Zusatz an einem Glied (Geo-Zone an der Uhr). */
.jc-tarifbau__zusatz {
    display: block;
    margin-top: var(--jc-space-xs);
    padding: 8px 10px;
    border: var(--jc-hairline) solid var(--jc-gray-500);
    border-radius: var(--jc-tarifbau-rund);
    transition: border-color var(--jc-motion-progress) var(--jc-motion-ease);
}

.jc-tarifbau__zusatz.is-aus {
    border-style: dashed;
    border-color: var(--jc-tarifbau-strich);
}

/* Kurze gestrichelte Verbindung vom Glied zur Zusatz-Box (mittig darueber). */
.jc-tarifbau__zusatz {
    position: relative;
    margin-top: var(--jc-space-md);
}

.jc-tarifbau__zusatz::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    height: var(--jc-space-md);
    border-left: var(--jc-hairline) dashed var(--jc-tarifbau-strich);
}

.jc-tarifbau__zusatz.is-an::before {
    border-left-style: solid;
    border-left-color: var(--jc-gray-500);
}

.jc-tarifbau__zusatz-marke {
    display: block;
    margin-bottom: 4px;
    font-size: var(--jc-size-label);
    font-weight: var(--jc-weight-semibold);
    letter-spacing: var(--jc-tracking-label);
    text-transform: uppercase;
    color: var(--jc-accent);
    transition: color var(--jc-motion-progress) var(--jc-motion-ease);
}

.jc-tarifbau__zusatz.is-aus .jc-tarifbau__zusatz-marke {
    color: var(--jc-text-meta);
}

.jc-tarifbau__zusatz-titel {
    display: block;
    font-size: var(--jc-size-meta);
    font-weight: var(--jc-weight-semibold);
    color: var(--jc-text);
}

.jc-tarifbau__zusatz.is-aus .jc-tarifbau__zusatz-titel {
    color: var(--jc-text-meta);
}

/* Der Ring um die Uhr = die Geo-Zone, nur mit Demenztarif. Blendet nur ein —
   er waechst nicht (Motion: nie Groesse). */
.jc-tarifbau__ring {
    opacity: 0;
    transition: opacity var(--jc-motion-reveal) var(--jc-motion-ease);
}

.mit-zusatz .jc-tarifbau__ring {
    opacity: 1;
}

/*
 * Die Verbindung — mobil (senkrecht).
 *
 * Jedes Glied zieht von seinem Bild bis zu seinem unteren Rand einen Strich
 * (`::after`) — im Zustand des NAECHSTEN Glieds: gestrichelt, wenn das aus ist.
 * Der Text eines Glieds kann hoeher sein als sein Bild; so reicht der Strich
 * trotzdem bis zum naechsten Bild. Das letzte sichtbare Glied zieht keinen.
 * 📌 Ohne `:has()` (alte Browser) bleibt jeder Strich durchgezogen — harmlos.
 */
.jc-tarifbau__linie {
    display: none;
}

.jc-tarifbau__glied::after {
    content: "";
    position: absolute;
    z-index: 0;
    left: calc(var(--jc-tarifbau-bild) / 2 - 0.75px);
    top: var(--jc-tarifbau-bild);
    bottom: 0;
    width: 1.5px;
    background: var(--jc-gray-500);
}

.jc-tarifbau__glied:has(+ .jc-tarifbau__glied.is-aus)::after {
    width: 0;
    background: none;
    border-left: var(--jc-hairline) dashed var(--jc-tarifbau-strich);
}

.jc-tarifbau__glied:not(:has(~ .jc-tarifbau__glied:not([hidden])))::after {
    display: none;
}

/* Das Signal mobil: laeuft im `::before` des SENDENDEN Glieds nach unten. Das
   Quadrat sitzt am unteren Ende des Elements, das eine Strichlaenge verschoben
   startet — so braucht der Weg keine Pixelangabe und keine Layout-Eigenschaft. */
.jc-tarifbau__glied::before {
    content: "";
    position: absolute;
    z-index: 0;
    left: calc((var(--jc-tarifbau-bild) - var(--jc-tarifbau-punkt)) / 2);
    top: var(--jc-tarifbau-bild);
    bottom: 0;
    width: var(--jc-tarifbau-punkt);
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(var(--jc-accent), var(--jc-accent)) bottom / 100% var(--jc-tarifbau-punkt) no-repeat;
}

/* Die Schicht darunter: laeuft immer mit. Seit 06.11. mittig (Betreiber: „etwas
   zentraler"), je Dienst eine Karte mit Zeichen, Erklaerung und Punkten. */
.jc-tarifbau__schicht {
    margin-top: var(--jc-space-xs);
    padding-top: var(--jc-space-md);
    border-top: var(--jc-hairline) solid var(--jc-line);
}

.jc-tarifbau__schicht-titel {
    display: block;
    margin-bottom: var(--jc-space-sm);
    font-size: var(--jc-size-label);
    font-weight: var(--jc-weight-semibold);
    letter-spacing: var(--jc-tracking-label);
    text-transform: uppercase;
    color: var(--jc-text-meta);
    text-align: center;
}

.jc-tarifbau__schicht-liste {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    max-width: 920px;
    display: grid;
    gap: var(--jc-space-sm);
}

.jc-tarifbau__dienst {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--jc-space-sm);
    align-items: start;
    padding: var(--jc-space-sm);
    border: var(--jc-hairline) solid var(--jc-line);
    border-radius: var(--jc-tarifbau-rund);
    transition: border-color var(--jc-motion-progress) var(--jc-motion-ease);
}

.jc-tarifbau__dienst.is-aus {
    border-style: dashed;
}

.jc-tarifbau__zeichen {
    display: flex;
    gap: 6px;
}

.jc-tarifbau__bild--klein {
    width: 44px;
    height: 44px;
    border-color: var(--jc-gray-300);
    border-radius: var(--jc-tarifbau-rund);
}

/* In den kleinen Kaestchen das Piktogramm groesser, sonst geht es unter (Schild, Headset). */
.jc-tarifbau__bild--klein .jc-tarifbau__svg {
    width: 76%;
    height: 76%;
}

/* Jamie: das Signet der Wortmarke (drei Wellen), in Rot wie die Piktogramme. */
.jc-tarifbau__jamie {
    width: 58%;
    height: 58%;
}

.jc-tarifbau__dienst .jc-tarifbau__titel {
    padding-top: 2px;
}

/* Punkte: roter Quadratpunkt wie jede Liste im Theme (Hard Rule 10). */
.jc-tarifbau__punkte {
    display: grid;
    gap: 4px;
    margin-top: var(--jc-space-xs);
}

.jc-tarifbau__punkt {
    position: relative;
    display: block;
    padding-left: calc(var(--jc-listenpunkt) + 10px);
    font-size: var(--jc-size-meta);
    line-height: 1.45;
    color: var(--jc-text-body);
}

.jc-tarifbau__punkt::before {
    content: "";
    position: absolute;
    left: 0;
    top: calc(0.72em - var(--jc-listenpunkt) / 2);
    width: var(--jc-listenpunkt);
    height: var(--jc-listenpunkt);
    background: var(--jc-accent);
}

.jc-tarifbau__dienst.is-aus .jc-tarifbau__punkt::before {
    background: var(--jc-gray-300);
}

/* --- Breit: die Kette waagrecht ------------------------------------ */
@media (min-width: 900px) {
    .jc-tarifbau {
        --jc-tarifbau-bild: 76px;
    }

    .jc-tarifbau__weg {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
    }

    .jc-tarifbau__glied {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 var(--jc-space-xs);
        text-align: center;
    }

    .jc-tarifbau__glied::after,
    .jc-tarifbau__glied::before {
        display: none;
    }

    .jc-tarifbau__glied > .jc-tarifbau__bild {
        align-self: center;
    }

    .jc-tarifbau__titel {
        padding-top: var(--jc-space-sm);
    }

    .jc-tarifbau__zusatz {
        margin-top: var(--jc-space-md);
        align-self: center;
    }

    /* Waagrecht: Jedes Glied ab dem zweiten traegt seine EINGEHENDE Linie,
       so haengt ihr Zustand am Glied, zu dem sie fuehrt. Vom rechten Rand des
       vorigen Bilds zum linken dieses Bilds; die Spalten sind gleich breit und
       ohne Luecke — 50 % = halbe Spalte. Grundstrich gestrichelt, darueber der
       durchgezogene (`::before`), der sich beim Einschalten von links aufbaut. */
    .jc-tarifbau__linie {
        display: block;
        position: absolute;
        z-index: 0;
        top: calc(var(--jc-tarifbau-bild) / 2);
        left: calc(-50% + var(--jc-tarifbau-bild) * 0.68);   /* hinter der Seitenflaeche des vorigen Wuerfels */
        right: calc(50% + var(--jc-tarifbau-bild) / 2);
        width: auto;
        height: 0;
        border-left: 0;
        border-top: var(--jc-hairline) dashed var(--jc-tarifbau-strich);
    }

    .jc-tarifbau__linie::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: -1px;
        height: 1.5px;
        background: var(--jc-gray-500);
        clip-path: inset(0);
        transition: clip-path var(--jc-motion-progress) var(--jc-motion-ease);
    }

    .is-aus > .jc-tarifbau__linie::before {
        clip-path: inset(0 100% 0 0);
    }

    /* Das Signal: ein kleines rotes Quadrat laeuft ruhig ueber die Verbindung, die
       zu diesem Glied fuehrt (`is-signal`, gesetzt vom Skript) — der Weg eines
       Alarms. Sitzt am rechten Ende und startet eine Strichlaenge nach links. */
    .jc-tarifbau__linie::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: calc(var(--jc-tarifbau-punkt) / -2);
        height: var(--jc-tarifbau-punkt);
        opacity: 0;
        pointer-events: none;
        background: linear-gradient(var(--jc-accent), var(--jc-accent)) right / var(--jc-tarifbau-punkt) 100% no-repeat;
    }

    .jc-tarifbau__schicht-liste {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--jc-space-md);
    }

    .jc-tarifbau__dienst {
        padding: var(--jc-space-md);
    }
}


/* --- Aufbau und Signal ---------------------------------------------- */

/* Reihenfolge: `--g` = wann das Glied dran ist, in Takten; `--n` = das wievielte
   Stueck des Piktogramms. Aus CSS, damit das HTML kein Byte schwerer wird. */
.jc-tarifbau__glied:nth-child(2) { --g: 1; }
.jc-tarifbau__glied:nth-child(3) { --g: 2; }
.jc-tarifbau__glied:nth-child(4) { --g: 3; }
.jc-tarifbau__glied:nth-child(5) { --g: 4; }
.jc-tarifbau__zusatz { --g: 0.7; }
.jc-tarifbau__schicht { --g: 4.3; }
.jc-tarifbau__dienst:nth-child(2) { --g: 4.7; }

.jc-tarifbau__svg > :nth-child(2) { --n: 1; }
.jc-tarifbau__svg > :nth-child(3) { --n: 2; }
.jc-tarifbau__svg > :nth-child(4) { --n: 3; }
.jc-tarifbau__svg > :nth-child(5) { --n: 4; }
.jc-tarifbau__svg > :nth-child(6) { --n: 5; }

/* Nur Deckkraft. */
@keyframes jc-tarifbau-ein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Deckkraft + ein kleiner Weg. */
@keyframes jc-tarifbau-kommen {
    from { opacity: 0; transform: translateY(calc(var(--jc-motion-shift) / 3)); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Die Linie wird aufgedeckt, nicht gestreckt. Der Rand von -8px laesst den Strich
   quer zur Laufrichtung frei (er ist hoechstens 2px stark, das Element teils 0px hoch). */
@keyframes jc-tarifbau-linie-x {
    from { clip-path: inset(-8px 100% -8px 0); }
    to   { clip-path: inset(-8px 0 -8px 0); }
}

@keyframes jc-tarifbau-linie-y {
    from { clip-path: inset(0 -8px 100% -8px); }
    to   { clip-path: inset(0 -8px 0 -8px); }
}

@keyframes jc-tarifbau-signal {
    0%   { transform: translateX(-100%); opacity: 0; }
    12%  { opacity: 1; }
    88%  { opacity: 1; }
    100% { transform: translateX(0); opacity: 0; }
}

@keyframes jc-tarifbau-signal-senkrecht {
    0%   { transform: translateY(-100%); opacity: 0; }
    12%  { opacity: 1; }
    88%  { opacity: 1; }
    100% { transform: translateY(0); opacity: 0; }
}

/* Antwort am Ziel: Das Kaestchen faerbt sich kurz und klingt ruhig ab. Einmal je
   Durchlauf — kein Blinken. Das Piktogramm ist schon rot, es bleibt, wie es ist. */
@keyframes jc-tarifbau-empfang {
    0%   { background-color: var(--jc-paper); border-color: var(--jc-text); }
    25%  { background-color: var(--jc-tarifbau-getoent); border-color: var(--jc-accent); }
    100% { background-color: var(--jc-paper); border-color: var(--jc-text); }
}

/* Eine Kante wird gezogen (Strich laeuft entlang, keine Groesse). */
@keyframes jc-tarifbau-kante {
    from { stroke-dashoffset: 1; }
    to   { stroke-dashoffset: 0; }
}

/* Empfang: Rot laeuft einmal ueber die Kanten und klingt ab — je Kante versetzt (`--k`). */
@keyframes jc-tarifbau-kante-empfang {
    0%   { stroke: var(--jc-gray-500); }
    30%  { stroke: var(--jc-accent); }
    100% { stroke: var(--jc-gray-500); }
}

@keyframes jc-tarifbau-front-empfang {
    0%   { fill: var(--jc-paper); }
    30%  { fill: var(--jc-tarifbau-getoent); }
    100% { fill: var(--jc-paper); }
}

@keyframes jc-tarifbau-zusatz-an {
    0%   { border-color: var(--jc-gray-300); background-color: transparent; }
    30%  { border-color: var(--jc-accent); background-color: var(--jc-tarifbau-getoent); }
    100% { border-color: var(--jc-gray-500); background-color: transparent; }
}

/* Die Leitung faerbt sich, waehrend das Signal darueber laeuft. */
@keyframes jc-tarifbau-leitung {
    0%   { background-color: var(--jc-gray-500); }
    35%  { background-color: var(--jc-accent); }
    100% { background-color: var(--jc-gray-500); }
}

@keyframes jc-tarifbau-sperre {
    from, to { opacity: 0; }
}

.jc-tarifbau {
    --jc-tarifbau-getoent: color-mix(in srgb, var(--jc-accent) 14%, var(--jc-paper));
}

/* ⛔ Nur am Bildschirm: Gedruckt wird die fertige Grafik, auch ungescrollt. */
@media screen and (prefers-reduced-motion: no-preference) {
    /* Sperre gegen Aufblitzen, solange das Skript noch nicht da ist. Endet nach 4 s
       von selbst (ohne `forwards`) — laedt das Skript nie, steht die Grafik danach
       fertig da. Ohne JavaScript greift sie gar nicht. */
    @media (scripting: enabled) {
        .jc-tarifbau:not(.jc-tarifbau--bereit) :is(.jc-tarifbau__weg, .jc-tarifbau__schicht) {
            animation: jc-tarifbau-sperre 4s backwards;
        }
    }

    .jc-tarifbau--wartet :is(.jc-tarifbau__weg, .jc-tarifbau__schicht) {
        opacity: 0;
    }

    /* Das Kaestchen eines Glieds: nur Deckkraft, damit die Linie lueckenlos anschliesst. */
    .jc-tarifbau--zeichnet .jc-tarifbau__bild {
        animation: jc-tarifbau-ein 420ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--g, 0) * var(--jc-tarifbau-takt));
    }

    /* Der Wuerfel: Flaechen blenden ein, die Kanten werden nacheinander gezogen. */
    .jc-tarifbau--zeichnet .jc-tarifbau__bild--wuerfel {
        animation: none;
    }

    .jc-tarifbau--zeichnet :is(.jc-wuerfel__oben, .jc-wuerfel__seite, .jc-wuerfel__front) {
        animation: jc-tarifbau-ein 420ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--g, 0) * var(--jc-tarifbau-takt) + 260ms);
    }

    .jc-tarifbau--zeichnet .jc-wuerfel__kante {
        animation: jc-tarifbau-kante 300ms linear both;
        animation-delay: calc(var(--g, 0) * var(--jc-tarifbau-takt) + var(--k, 0) * 60ms);
    }

    .is-nachzeichnen > .jc-tarifbau__bild--wuerfel .jc-wuerfel__kante {
        animation: jc-tarifbau-kante 260ms linear both;
        animation-delay: calc(var(--k, 0) * 50ms);
    }

    /* Das Piktogramm darin: Stueck fuer Stueck. Der Ring der Geo-Zone haengt am
       Demenztarif (eigene Regel oben) und bleibt hier aussen vor. */
    .jc-tarifbau--zeichnet .jc-tarifbau__svg > :not(.jc-tarifbau__ring) {
        animation: jc-tarifbau-ein 360ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--g, 0) * var(--jc-tarifbau-takt) + 120ms + var(--n, 0) * 90ms);
    }

    /* Titel und Text kommen kurz nach dem Kaestchen. */
    .jc-tarifbau--zeichnet :is(.jc-tarifbau__glied > .jc-tarifbau__titel,
                               .jc-tarifbau__glied > .jc-tarifbau__text,
                               .jc-tarifbau__glied > .jc-tarifbau__mit,
                               .jc-tarifbau__zusatz,
                               .jc-tarifbau__dienst > :not(.jc-tarifbau__bild)) {
        animation: jc-tarifbau-kommen 420ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--g, 0) * var(--jc-tarifbau-takt) + 200ms);
    }

    .jc-tarifbau--zeichnet .jc-tarifbau__schicht-titel,
    .jc-tarifbau--zeichnet .jc-tarifbau__schicht {
        animation: jc-tarifbau-ein 420ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--g, 0) * var(--jc-tarifbau-takt));
    }

    /* Die Verbindung waechst in den letzten 60 % des Takts und kommt genau dann
       an, wenn das Kaestchen dahinter erscheint. Waagrecht traegt das ZIEL-Glied
       die Linie, senkrecht das Glied, von dem sie ausgeht. */
    .jc-tarifbau--zeichnet .jc-tarifbau__linie {
        animation: jc-tarifbau-linie-x calc(var(--jc-tarifbau-takt) * 0.6) linear both;
        animation-delay: calc((var(--g, 0) - 0.6) * var(--jc-tarifbau-takt));
    }

    .jc-tarifbau--zeichnet .jc-tarifbau__glied::after {
        animation: jc-tarifbau-linie-y calc(var(--jc-tarifbau-takt) * 0.6) linear both;
        animation-delay: calc((var(--g, 0) + 0.4) * var(--jc-tarifbau-takt));
    }

    /* Haekchen gesetzt: nur dieser Baustein baut sich neu auf. Abgewaehlt braucht
       nichts: Rahmen, Farbe und Linie gehen ueber ihre Regeln und Uebergaenge oben. */
    .is-nachzeichnen > .jc-tarifbau__bild .jc-tarifbau__svg > :not(.jc-tarifbau__ring) {
        animation: jc-tarifbau-ein 320ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--n, 0) * 80ms);
    }

    .is-nachzeichnen > .jc-tarifbau__titel {
        animation: jc-tarifbau-kommen 420ms var(--jc-motion-ease) both;
    }

    .jc-tarifbau__glied:has(+ .is-nachzeichnen)::after {
        animation: jc-tarifbau-linie-y 420ms linear both;
    }

    /* Das Signal. */
    .is-signal > .jc-tarifbau__linie::after {
        animation: jc-tarifbau-signal var(--jc-tarifbau-lauf) cubic-bezier(0.45, 0, 0.55, 1) both;
    }

    .jc-tarifbau__glied.is-sendet::before {
        animation: jc-tarifbau-signal-senkrecht var(--jc-tarifbau-lauf) cubic-bezier(0.45, 0, 0.55, 1) both;
    }

    .is-empfang > .jc-tarifbau__bild:not(.jc-tarifbau__bild--wuerfel) {
        animation: jc-tarifbau-empfang 1200ms var(--jc-motion-ease);
    }

    .is-empfang > .jc-tarifbau__bild--wuerfel .jc-wuerfel__kante {
        animation: jc-tarifbau-kante-empfang 900ms var(--jc-motion-ease) both;
        animation-delay: calc(var(--k, 0) * 45ms);
    }

    /* Vorderseite: Rand UND Flaeche — beide Animationen in einer Angabe, sonst
       verdraengt die eine die andere. */
    .is-empfang > .jc-tarifbau__bild--wuerfel .jc-wuerfel__front {
        animation: jc-tarifbau-kante-empfang 900ms var(--jc-motion-ease) both,
                   jc-tarifbau-front-empfang 1200ms var(--jc-motion-ease);
        animation-delay: calc(var(--k, 0) * 45ms), 0ms;
    }

    /* Zusatzfunktion eingeschaltet (Haekchen „optional"): Das Kaestchen leuchtet rot auf
       und klingt ab, der Inhalt kommt, die Verbindung zur Uhr wird gezogen. Die Uhr
       selbst bekommt dazu den Empfang (tarif-zeichnung.js). */
    .jc-tarifbau__zusatz.is-nachzeichnen {
        animation: jc-tarifbau-zusatz-an 1400ms var(--jc-motion-ease) both;
    }

    .jc-tarifbau__zusatz.is-nachzeichnen > * {
        animation: jc-tarifbau-kommen 420ms var(--jc-motion-ease) both;
    }

    .jc-tarifbau__zusatz.is-nachzeichnen > :nth-child(2) { animation-delay: 90ms; }
    .jc-tarifbau__zusatz.is-nachzeichnen > :nth-child(3) { animation-delay: 180ms; }

    .jc-tarifbau__zusatz.is-nachzeichnen::before {
        animation: jc-tarifbau-linie-y 360ms linear both;
    }

    .is-signal > .jc-tarifbau__linie::before {
        animation: jc-tarifbau-leitung var(--jc-tarifbau-lauf) var(--jc-motion-ease);
    }
}

/* -------------------------------------------------------------------
 * 2. Die Auswahl mit Paketpreis — EIN Block
 * ----------------------------------------------------------------- */

.jc-tarifwahl__block {
    display: grid;
    border-top: var(--jc-rule-strong) solid var(--jc-accent);
}

.jc-tarifwahl__auswahl {
    min-width: 0;
}

.jc-tarifwahl__kopf {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--jc-space-sm);
    padding-block: var(--jc-space-md) var(--jc-space-sm);
    border-bottom: var(--jc-hairline) solid var(--jc-line);
}

.jc-tarifwahl__titel {
    margin: 0;
    font-family: var(--jc-font-display);
    font-weight: var(--jc-weight-regular);
    font-size: clamp(24px, 2vw, 30px);
    line-height: 1.15;
    color: var(--jc-text);
}

.jc-tarifwahl__toggle .jc-toggle__btn {
    padding-inline: 18px;
}

.jc-tarifwahl__liste {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Eine Zeile: Haekchen · Name/Text · Preis. */
.jc-tarifwahl__zeile {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    column-gap: var(--jc-space-sm);
    align-items: start;
    padding-block: var(--jc-space-md);
    border-bottom: var(--jc-hairline) solid var(--jc-line);
}

.jc-tarifwahl__haken {
    width: 20px;
    height: 20px;
    margin: 4px 0 0;
    accent-color: var(--jc-accent);
    cursor: pointer;
}

.jc-tarifwahl__haken:disabled {
    cursor: default;
}

.jc-tarifwahl__haken:focus-visible {
    outline: 2px solid var(--jc-focus);
    outline-offset: 2px;
}

.jc-tarifwahl__inhalt {
    display: block;
    min-width: 0;
    cursor: pointer;
}

.is-fest .jc-tarifwahl__inhalt {
    cursor: default;
}

.jc-tarifwahl__name {
    font-family: var(--jc-font-display);
    font-size: 24px;
    line-height: 1.15;
    color: var(--jc-text);
    margin-right: var(--jc-space-xs);
}

.jc-tarifwahl__marke {
    display: inline-block;
    vertical-align: 3px;
    font-size: var(--jc-size-label);
    font-weight: var(--jc-weight-semibold);
    letter-spacing: var(--jc-tracking-label);
    text-transform: uppercase;
    color: var(--jc-text-meta);
}

.jc-tarifwahl__text {
    display: block;
    max-width: 62ch;
    margin-top: 4px;
    font-size: var(--jc-size-meta);
    line-height: 1.5;
    color: var(--jc-text-meta);
}

/* „Setzt den Basistarif voraus" — dezent, unter dem Text der Zusaetze. */
.jc-tarifwahl__voraus {
    display: block;
    margin-top: 4px;
    font-size: var(--jc-size-fein);
    line-height: 1.45;
    color: var(--jc-text-meta);
}

.jc-tarifwahl__preis {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    white-space: nowrap;
}

.jc-tarifwahl__betrag {
    font-family: var(--jc-betrag-font);
    font-size: 26px;
    line-height: 1.1;
    letter-spacing: var(--jc-betrag-tracking);
    color: var(--jc-text);
    transition: color var(--jc-motion-hover) var(--jc-motion-ease);
}

.jc-tarifwahl__einheit {
    font-size: var(--jc-size-fein);
    color: var(--jc-text-meta);
}

/* Nicht im Paket: Preis zurueckgenommen — er zaehlt nicht mit. */
.jc-tarifwahl__zeile.is-aus .jc-tarifwahl__betrag {
    color: var(--jc-gray-500);
}

/* Der Paketpreis — dieselbe Sandflaeche wie der Summenblock in Warenkorb und
   Kassa (lehren-gestaltung.md), hier ohne eigene Rotlinie: die traegt der Block. */
.jc-tarifwahl__summe {
    display: flex;
    flex-direction: column;
    gap: var(--jc-space-xs);
    padding: var(--jc-space-md);
    background: var(--jc-surface-summe);
}

.jc-tarifwahl__summe-titel {
    font-size: var(--jc-size-label);
    font-weight: var(--jc-weight-semibold);
    letter-spacing: var(--jc-tracking-label);
    text-transform: uppercase;
    color: var(--jc-text-meta);
}

.jc-tarifwahl__gesamt {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--jc-space-xs);
    margin: 0;
}

.jc-tarifwahl__gesamt-betrag {
    font-family: var(--jc-betrag-font);
    font-size: clamp(40px, 4vw, 52px);
    line-height: 1;
    letter-spacing: var(--jc-betrag-tracking);
    color: var(--jc-accent);
}

.jc-tarifwahl__detail {
    margin: 0;
    font-size: var(--jc-size-meta);
    line-height: 1.45;
    color: var(--jc-text-body);
}

.jc-tarifwahl__hinweis {
    margin: 0;
    font-size: var(--jc-size-fein);
    line-height: 1.45;
    color: var(--jc-text-meta);
}

.jc-tarifwahl__aktion {
    margin-top: var(--jc-space-sm);
    align-self: stretch;
}

@media (min-width: 900px) {
    .jc-tarifwahl__block {
        grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    }

    .jc-tarifwahl__auswahl {
        padding-right: var(--jc-space-lg);
    }

    .jc-tarifwahl__summe {
        align-self: stretch;
        padding: var(--jc-space-lg) var(--jc-space-md) var(--jc-space-md);
    }
}

@media (max-width: 479px) {
    .jc-tarifwahl__zeile {
        grid-template-columns: 24px minmax(0, 1fr);
    }

    .jc-tarifwahl__preis {
        grid-column: 2;
        flex-direction: row;
        align-items: baseline;
        gap: var(--jc-space-xs);
        margin-top: var(--jc-space-xs);
        text-align: left;
    }

    .jc-tarifwahl__toggle {
        width: 100%;
    }

    .jc-tarifwahl__toggle .jc-toggle__btn {
        flex: 1;
    }
}

/* -------------------------------------------------------------------
 * 3. Darunter dezent: die Datenzeilen der Seite
 *
 * Betreiber: „das infos dann darunter.. dezent". Die Datenzeilen bleiben eine
 * eigene Section (Inhalt, in Directus pflegbar) — gestaltet werden sie hier,
 * wenn sie direkt auf die Auswahl folgen: ohne eigenen Abstand nach oben,
 * kleine Schrift, Hairline statt Rotlinie.
 * ⚠️ Im Visual Editor steht zwischen beiden die Griff-Leiste — dort gilt die
 *    normale Gestalt. Fuer Besucher folgen sie unmittelbar.
 * ----------------------------------------------------------------- */

.jc-tarifwahl {
    padding-bottom: var(--jc-space-lg);
}

.jc-tarifwahl + .jc-section {
    padding-top: 0;
}

.jc-tarifwahl + .jc-section > .jc-data-rows {
    border-top: 0;
}

.jc-tarifwahl + .jc-section > .jc-data-rows .jc-data-row {
    padding-block: var(--jc-space-xs);
    font-size: var(--jc-size-meta);
    line-height: 1.5;
}

.jc-tarifwahl + .jc-section > .jc-data-rows .jc-data-row__label,
.jc-tarifwahl + .jc-section > .jc-data-rows .jc-data-row__value {
    color: var(--jc-text-meta);
}

.jc-tarifwahl + .jc-section > .jc-data-rows .jc-data-row__label {
    font-weight: var(--jc-weight-semibold);
}
