/* Problem → solution section after the hero: one care-home room, today and with the Bewegungsinsel.
   Default = static (no script, reduced motion, very short screens): both pictures one after the other and the legend.
   The script adds .is-scrolling for the scroll-driven version. Light and dark theme via the site tokens in style.css. */
.problem-section {
    --problem-orange: #E07A3A;
    --problem-orange-text: #C8622A;
    --problem-still: #CFCAC3;
    --problem-ink: #2B2927;
    padding: clamp(2rem, 5vw, 4rem) 0 clamp(2.5rem, 5vw, 4.5rem);
    background: var(--surface-2);
    color: var(--text-color);
    scroll-margin-top: 4rem;
}
:root[data-theme="dark"] .problem-section { --problem-still: #4A4744; --problem-orange-text: #E8935C; --problem-ink: #3D3A37; }

.problem-scene { --nav-h: 76px; --p: 0; }
.problem-progress, .problem-pin, .problem-ring, .problem-hint, .problem-screen, .problem-bubbles, .problem-caption { display: none; }
.problem-frame { position: relative; }
.problem-cam { display: grid; gap: 12px; }
.problem-img { display: block; width: 100%; height: auto; aspect-ratio: 1672 / 941; object-fit: cover; border-radius: clamp(14px, 2vw, 24px); background: #E9E4DE; }

/* Static: a caption under both pictures. Scrolling: a chip on the picture. */
.problem-badge { display: block; margin-top: 0.6rem; font-size: 0.78rem; font-weight: 600; color: var(--secondary-text); }

/* Legend: shown in the static version; read by screen readers in the scrolling version. */
.problem-roles {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(1rem, 2vw, 1.75rem);
    margin: clamp(1.25rem, 2.5vw, 2rem) 0 0;
    padding: 0;
}
.problem-role { padding-top: 0.9rem; border-top: 2px solid var(--border-soft); }
.problem-role__who { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--secondary-text); }
.problem-role__pain, .problem-role__change { margin: 0.7rem 0 0; line-height: 1.3; }
.problem-role__pain { font-size: clamp(1.1rem, 1.4vw, 1.3rem); font-weight: 800; letter-spacing: -0.03em; color: var(--text-color); }
.problem-role__change { font-size: 1rem; font-weight: 500; color: var(--secondary-text); }
.problem-role br { display: none; }
.problem-role .problem-bubble__trial { font-size: 0.82rem; color: var(--text-color); }

/* ---- Scrolling version ---- */
.problem-scene.is-scrolling { height: 280vh; }
.problem-scene.is-scrolling .problem-sticky {
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    height: calc(100svh - var(--nav-h));
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(0.75rem, 2vh, 1.25rem);
    padding-bottom: clamp(0.5rem, 3vh, 2rem);
}

/* Heute | Mit der Bewegungsinsel: a pill switch. The thumb slides with the change and turns from dark to orange;
   the labels jump to that state. The script sets --thumb-x and --thumb-w from the two labels. */
.problem-scene.is-scrolling .problem-progress {
    position: relative;
    display: flex;
    align-self: center;
    padding: 4px;
    border-radius: 999px;
    background: var(--surface-0);
    border: 1px solid var(--border-soft);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
}
.problem-progress__thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: var(--thumb-w, 0px);
    transform: translateX(var(--thumb-x, 0px));
    border-radius: 999px;
    background: var(--problem-ink);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
@supports (background: color-mix(in srgb, red 50%, blue)) {
    .problem-progress__thumb { background: color-mix(in srgb, var(--problem-orange) calc(var(--p) * 100%), var(--problem-ink)); }
}
.problem-progress__label {
    position: relative;
    z-index: 1;
    padding: 0.5rem 1.05rem;
    border: 0;
    border-radius: 999px;
    background: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    white-space: nowrap;
    color: var(--secondary-text);
    cursor: pointer;
    transition: color 0.3s ease;
}
.problem-progress__label:hover { color: var(--text-color); }
.problem-progress__label:focus-visible { outline: 3px solid var(--problem-orange); outline-offset: 2px; }
/* White copy of the labels, visible only inside the thumb: each letter turns white exactly where the thumb is. */
.problem-progress__ink {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    padding: 4px;
    pointer-events: none;
    clip-path: inset(4px calc(100% - var(--thumb-x, 0px) - var(--thumb-w, 0px)) 4px var(--thumb-x, 0px) round 999px);
}
.problem-progress__ink .problem-progress__label { color: #FFFFFF; cursor: default; }
@media (max-width: 380px) { .problem-progress__label { padding: 0.45rem 0.8rem; font-size: 0.85rem; } }

.problem-scene.is-scrolling .problem-frame {
    flex: none;
    width: min(100%, calc((100svh - var(--nav-h) - 120px) * 1.7768));
    margin: 0 auto;
    aspect-ratio: 1672 / 941;
    overflow: hidden;
    overflow: clip; /* focusing a dot must not scroll the picture */
    border-radius: clamp(14px, 2vw, 24px);
    background: #E9E4DE;
    container-type: inline-size;
}
.problem-scene.is-scrolling .problem-cam {
    position: absolute;
    inset: 0;
    display: block;
    transform: scale(var(--zoom, 1));
    transform-origin: 50% 45%;
}
.problem-scene.is-scrolling .problem-img { position: absolute; inset: 0; height: 100%; border-radius: 0; }
.problem-scene.is-scrolling .problem-img--problem { filter: saturate(0.85) brightness(0.98); }
.problem-scene.is-scrolling .problem-badge {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 4;
    margin: 0;
    padding: 4px 10px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.85);
    font-size: 0.72rem;
    color: #3A3836;
}

/* The solution picture shows through a soft circle that grows from the island's screen. */
.problem-scene.is-scrolling .problem-layer {
    --ix: 46.7%;
    --iy: 36.5%;
    --ir: 0px;
    --feather: 80px;
    position: absolute;
    inset: 0;
    -webkit-mask-image: radial-gradient(circle at var(--ix) var(--iy), #000 calc(var(--ir) - var(--feather)), transparent var(--ir));
    mask-image: radial-gradient(circle at var(--ix) var(--iy), #000 calc(var(--ir) - var(--feather)), transparent var(--ir));
}
.problem-scene.is-scrolling .problem-ring {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 2px;
    border: 2px solid var(--problem-orange);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}
/* The real tour on the island's screen keeps moving slowly, as on the real island. */
.problem-scene.is-scrolling .problem-screen {
    display: block;
    position: absolute;
    inset: 0;
    clip-path: polygon(37.29% 26.35%, 56.16% 25.56%, 56.16% 47.5%, 37.44% 46.65%);
}
.problem-screen img {
    position: absolute;
    left: 37.29%;
    top: 25.56%;
    width: 18.87%;
    height: 21.94%;
    object-fit: cover;
    transform-origin: 71% 57%;
    animation: problem-travel 16s linear infinite;
    animation-play-state: paused;
}
.problem-scene.is-live .problem-screen img { animation-play-state: running; }
/* Always forward along the path, like a walk. At the end it fades to the same still frame that is in the picture
   underneath, so the next lap starts without a jump. */
@keyframes problem-travel {
    0% { transform: scale(1); opacity: 1; }
    88% { opacity: 1; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* People: a dot (grey = still, orange = moving) that follows the person from one picture to the other. */
.problem-scene.is-scrolling .problem-pin {
    display: grid;
    place-items: center;
    position: absolute;
    left: var(--x1);
    top: var(--y1);
    z-index: 2;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.3);
    transition: left 0.8s ease, top 0.8s ease, opacity 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.problem-scene.is-scrolling .problem-pin.is-shown { opacity: 1; transform: none; }
.problem-scene.is-scrolling .problem-pin.is-shown:hover,
.problem-scene.is-scrolling .problem-pin.is-shown.is-active { transform: scale(1.2); }
.problem-scene.is-scrolling .problem-pin[data-state="solution"] { left: var(--x2); top: var(--y2); }
.problem-pin__dot {
    position: relative;
    width: 16px;
    height: 16px;
    border: 3px solid #FFFFFF;
    border-radius: 50%;
    background: #6B6661;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: background-color 0.4s ease;
}
.problem-pin[data-state="solution"] .problem-pin__dot { background: var(--problem-orange); }
.problem-pin[data-state="solution"] .problem-pin__dot::after {
    content: "";
    position: absolute;
    inset: -9px;
    border-radius: 50%;
    border: 2px solid rgba(224, 122, 58, 0.6);
    animation: problem-ring 2.4s ease-out infinite;
}
@keyframes problem-ring { 0% { transform: scale(0.6); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
.problem-pin:focus-visible { outline: 3px solid var(--problem-orange); outline-offset: 2px; }

/* Speech bubbles. Sized to the picture (container units), explicit lines, so the layout is the same at every width.
   Per picture: 1 = today, 2 = with the island; the tail sits exactly on the person's head. */
.problem-scene.is-scrolling .problem-bubbles { display: block; position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.problem-bubble {
    --ax: var(--ax1);
    --ay: var(--ay1);
    --tail: var(--tail1);
    position: absolute;
    left: var(--ax);
    bottom: calc(100% - var(--ay) + 12px);
    width: max-content;
    padding: 0.6em 0.85em 0.7em;
    border-radius: 1.1em;
    background: #FFFFFF;
    color: var(--problem-ink);
    box-shadow: 0 0 0 1px rgba(43, 41, 39, 0.06), 0 0.15em 0.35em rgba(43, 41, 39, 0.08), 0 0.8em 2em rgba(43, 41, 39, 0.16);
    font-size: 13px;
    font-size: 1.12cqi;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    white-space: nowrap;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(calc(var(--tail) * -1)) translateY(10px) scale(0.9);
    transform-origin: var(--tail) 100%;
    transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease,
        background-color 0.4s ease, left 0.8s ease, bottom 0.8s ease;
}
.problem-bubble[data-state="solution"] { --ax: var(--ax2); --ay: var(--ay2); --tail: var(--tail2); }
/* Tail: a turned square half under the bubble, so no seam shows where they meet. */
.problem-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--tail);
    width: 0.95em;
    height: 0.95em;
    background: inherit;
    border-right: 1.5px solid rgba(43, 41, 39, 0.06);
    border-bottom: 1.5px solid rgba(43, 41, 39, 0.06);
    border-bottom-right-radius: 0.25em;
    box-shadow: 0.2em 0.2em 0.45em rgba(43, 41, 39, 0.08);
    transform: translate(-50%, -55%) rotate(45deg);
    clip-path: polygon(100% -20%, 120% 120%, -20% 100%);   /* only the half outside the bubble */
    transition: background-color 0.4s ease, border-color 0.4s ease;
}
.problem-bubble.is-shown { opacity: 1; transform: translateX(calc(var(--tail) * -1)); }
.problem-bubble.is-shown.is-active { z-index: 2; transform: translateX(calc(var(--tail) * -1)) scale(1.05); }
/* With the island: a warm tint, a fine orange outline and a soft orange glow. */
.problem-bubble[data-state="solution"] {
    background: #FFF8F3;
    box-shadow: 0 0 0 1.5px rgba(224, 122, 58, 0.75), 0 0.15em 0.35em rgba(224, 122, 58, 0.12), 0 0.8em 2em rgba(201, 98, 42, 0.22);
}
.problem-bubble[data-state="solution"]::after { border-color: rgba(224, 122, 58, 0.75); }
.problem-bubble__who,
.problem-caption__who {
    display: flex;
    align-items: center;
    gap: 0.45em;
    margin-bottom: 0.35em;
    font-size: 0.68em;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #8A847E;
    transition: color 0.4s ease;
}
/* The role's dot, as on the picture: grey today, orange with the island. */
.problem-bubble__who::before,
.problem-caption__who::before {
    content: "";
    flex: none;
    width: 0.62em;
    height: 0.62em;
    border-radius: 50%;
    background: #B5AFA8;
    transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
.problem-bubble[data-state="solution"] .problem-bubble__who::before,
.problem-caption[data-state="solution"] .problem-caption__who::before { background: var(--problem-orange); box-shadow: 0 0 0 0.22em rgba(224, 122, 58, 0.2); }
.problem-bubble[data-state="solution"] .problem-bubble__who,
.problem-caption[data-state="solution"] .problem-caption__who { color: var(--problem-orange-text); }
.problem-bubble__say { display: block; }
.problem-bubble[data-state="problem"] .problem-bubble__say--solution,
.problem-bubble[data-state="solution"] .problem-bubble__say--problem { display: none; }
.problem-bubble__say, .problem-caption__say { animation: problem-text-in 0.45s ease; }
@keyframes problem-text-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.problem-bubble__trial {
    display: flex;
    width: max-content;
    align-items: center;
    gap: 0.4em;
    margin-top: 0.5em;
    padding: 0.22em 0.65em 0.24em 0.5em;
    border-radius: 999px;
    background: rgba(224, 122, 58, 0.12);
    font-size: 0.74em;
    font-weight: 600;
    color: #9A4A1C;
}
.problem-bubble__trial::before { content: ""; flex: none; width: 0.6em; height: 0.6em; border-radius: 50%; border: 1.5px solid var(--problem-orange); }

/* Phones and tablets: one bubble at a time under the picture, its tail on the person; the camera follows. */
.problem-caption {
    position: relative;
    min-height: 5.2em;
    padding: 0.8em 1em 0.9em;
    border-radius: 18px;
    background: #FFFFFF;
    color: var(--problem-ink);
    box-shadow: 0 0 0 1px rgba(43, 41, 39, 0.06), 0 2px 5px rgba(43, 41, 39, 0.06), 0 10px 26px rgba(43, 41, 39, 0.1);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    transition: box-shadow 0.4s ease, background-color 0.4s ease, opacity 0.3s ease;
}
.problem-caption::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: clamp(18px, var(--tail-x, 50%), calc(100% - 18px));
    width: 14px;
    height: 14px;
    background: inherit;
    border-left: 1.5px solid rgba(43, 41, 39, 0.06);
    border-top: 1.5px solid rgba(43, 41, 39, 0.06);
    border-top-left-radius: 3px;
    transform: translate(-50%, 55%) rotate(45deg);
    clip-path: polygon(-20% 100%, -20% -20%, 100% -20%);
    transition: left 0.4s ease, background-color 0.4s ease, border-color 0.4s ease;
}
.problem-caption[data-state="solution"] {
    background: #FFF8F3;
    box-shadow: 0 0 0 1.5px rgba(224, 122, 58, 0.75), 0 2px 5px rgba(224, 122, 58, 0.1), 0 10px 26px rgba(201, 98, 42, 0.16);
}
.problem-caption[data-state="solution"]::before { border-color: rgba(224, 122, 58, 0.75); }
.problem-caption.is-empty { opacity: 0; }
.problem-caption__say { display: block; }
.problem-caption br { display: none; }
.problem-caption .problem-bubble__trial { font-size: 0.8em; }

.problem-scene.is-scrolling .problem-hint {
    display: none;
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 4;
    padding: 4px 10px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.85);
    font-size: 0.72rem;
    font-weight: 600;
    color: #3A3836;
    transition: opacity 0.4s ease;
}
.problem-scene.is-scrolling.is-touch .problem-hint { display: block; }
.problem-scene.is-scrolling.is-hint-done .problem-hint { opacity: 0; }

.problem-scene.is-scrolling .problem-roles {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 960px) {
    .problem-roles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Caption mode (set by the script when the picture would be narrower than 900 px): one bubble under the picture. */
.problem-scene.is-scrolling.is-caption .problem-frame,
.problem-scene.is-scrolling.is-caption .problem-caption { width: min(100%, calc((100svh - var(--nav-h) - 260px) * 1.7768)); }
.problem-scene.is-scrolling.is-caption .problem-caption { display: block; margin: 0 auto; }
.problem-scene.is-scrolling.is-caption .problem-bubbles { display: none; }
.problem-scene.is-scrolling.is-caption .problem-cam { transform-origin: 0 0; transition: transform 0.9s cubic-bezier(0.65, 0, 0.35, 1); }
@media (max-width: 640px) {
    .problem-scene.is-scrolling.is-caption .problem-frame,
    .problem-scene.is-scrolling.is-caption .problem-caption { width: 100%; }
    .problem-scene.is-scrolling .problem-hint,
    .problem-scene.is-scrolling .problem-badge { font-size: 0.66rem; padding: 3px 8px; bottom: 8px; }
    .problem-scene.is-scrolling .problem-badge { left: 8px; }
    .problem-scene.is-scrolling .problem-hint { right: 8px; }
}
@media (max-width: 560px) {
    .problem-roles { grid-template-columns: 1fr; gap: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
    .problem-pin__dot::after { animation: none !important; }
}

/* "In Erprobung" lines elsewhere on the homepage (how it works, staff tab): same open orange ring as above. */
.movement-trial,
.testimonial-trial {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.9rem 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}
.movement-trial::before,
.testimonial-trial::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #E07A3A;
}
