/* =========================================================================
   SYMPTOMS: symptom cards on a drum the reader turns.
   On PC/tablet the drum and the picture of the two women share one 3D space:
   the near half of the drum is in front of the picture, the far half passes
   behind it, and the near cards sit at the women's shoulders. Staff stand on
   a flat layer above everything, just outside the drum. js/symptoms_scroll.js
   measures and places the parts. Without scripts the cards are a plain grid.
   ========================================================================= */
@media (max-width: 700px) {
    #symptoms .section__title { font-size: clamp(22px, 5.8vw, 32px); }
}

.symptoms.section {
    position: relative;
    overflow: hidden;
}

/* Overlay the end of the preceding feature background so its blur never has a hard edge. */
@media (min-width: 768px) {
    .symptoms.section {
        /* Start the fade before the preceding section ends, without moving the heading. */
        z-index: 3;
        margin-top: -300px;
        padding-top: 300px;
        background-color: transparent;
        background-image: linear-gradient(
            to bottom,
            rgba(253, 253, 253, 0) 0,
            rgba(253, 253, 253, 0.92) 180px,
            #fdfdfd 240px
        );
    }
}

.symptoms .section__header { position: relative; z-index: 6; margin-bottom: 24px; }

.symptoms-drum { position: relative; }
.symptoms-drum__lead {
    margin: 0 0 12px;
    color: var(--color-main);
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    font-weight: 500;
    line-height: 1.6;
    text-align: center;
}

/* Shared card look */
.symptom-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 12px 10px 16px;
    color: #194f59;
    background: linear-gradient(150deg, #fff 40%, #f0f7f5);
    border: 1px solid #d8e5e1;
    border-radius: 28px 9px 28px 9px;
    box-shadow: 0 14px 30px -18px rgba(31, 75, 79, .45);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.symptom-card__icon { display: grid; place-items: center; width: 64%; aspect-ratio: 1; }
.symptom-card__icon img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.symptom-card__text { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.45; letter-spacing: .04em; text-align: center; }
.symptom-card:focus-visible,
.symptoms-drum__controls button:focus-visible { outline: 3px solid #237a8c; outline-offset: 5px; }

/* ---------- Without scripts: a readable grid ---------- */
.symptoms-drum__picture { max-width: 640px; margin: 0 auto; }
.symptoms-drum__scene { display: block; width: 100%; height: auto; }
.symptoms-drum__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    max-width: 1000px;
    margin: 24px auto 0;
    padding: 0;
    list-style: none;
}
.symptoms-drum__face { height: 164px; }
.symptoms-drum__staff,
.symptoms-drum__controls { display: none; }

/* ---------- The drum (enabled by js) ---------- */
.symptoms-drum.is-ready .symptoms-drum__viewport {
    position: relative;
    z-index: 3;
    height: var(--stage-h, 640px);
    perspective: 1200px;
    perspective-origin: 50% var(--origin-y, 0px);
    touch-action: pan-y;
    cursor: grab;
    user-select: none;
}
.symptoms-drum.is-ready .symptoms-drum__viewport.is-dragging { cursor: grabbing; }
.symptoms-drum.is-ready .symptoms-drum__viewport::after {
    /* floor shadow so the drum reads as an object standing in the room */
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: min(760px, 90%);
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(0, 71, 91, .16), transparent);
    transform: translateX(-50%);
    pointer-events: none;
}
.symptoms-drum.is-ready .symptoms-drum__world {
    position: absolute;
    left: 50%;
    top: var(--world-top, 300px);
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    transform: translateZ(var(--world-z, -360px));
}
.symptoms-drum.is-ready .symptoms-drum__list {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    width: 0;
    height: 0;
    max-width: none;
    margin: 0;
    transform-style: preserve-3d;
}
.symptoms-drum.is-ready .symptoms-drum__face {
    position: absolute;
    left: calc(var(--face-w, 196px) / -2);
    top: calc(var(--face-h, 220px) / -2);
    width: var(--face-w, 196px);
    height: var(--face-h, 220px);
    transform-style: preserve-3d;
}
/* Opacity below 1 on a face would flatten its 3D, so fading and shading live on the card. */
.symptoms-drum.is-ready .symptom-card {
    opacity: var(--fade, 1);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: box-shadow 300ms ease, border-color 300ms ease;
}
.symptoms-drum.is-ready .symptom-card::after {
    /* side cards turn slightly darker as they face away */
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: #0b3a44;
    opacity: var(--shade, 0);
    pointer-events: none;
}
.symptoms-drum.is-ready .symptom-card__text { font-size: 1.05rem; }
.symptoms-drum__back {
    /* the paper back of each card, seen across the drum */
    position: absolute;
    inset: 0;
    border: 1px solid #ddd3ec;
    border-radius: 9px 28px 9px 28px;
    background: radial-gradient(60% 50% at 30% 30%, rgba(217, 207, 235, .9), transparent 70%), radial-gradient(60% 60% at 75% 75%, rgba(219, 238, 244, .95), transparent 70%), #fbf9fd;
    opacity: var(--fade, 1);
    transform: rotateY(180deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.symptoms-drum__face.is-front .symptom-card { border-color: #7eaaa5; box-shadow: 0 26px 46px -22px rgba(0, 71, 91, .55); }
@media (hover: hover) {
    .symptoms-drum__face.is-front .symptom-card:hover { border-color: #5f948e; }
}

/* The picture of the two women, standing on the drum's axis. */
.symptoms-drum.is-ready .symptoms-drum__picture {
    position: absolute;
    left: calc(var(--pic-w, 900px) / -2);
    top: var(--pic-y, -400px);
    width: var(--pic-w, 900px);
    max-width: none;
    margin: 0;
    transform-style: preserve-3d;
    transform: translateZ(var(--pic-z, 0px));
    pointer-events: none;
}
.symptoms-drum.is-ready .symptoms-drum__scene {
    -webkit-mask-image: radial-gradient(72% 72% at 50% 45%, #000 52%, transparent 100%);
    mask-image: radial-gradient(72% 72% at 50% 45%, #000 52%, transparent 100%);
}

/* Staff: a flat layer above the whole 3D scene, placed by js just outside the drum. */
.symptoms-drum.is-ready .symptoms-drum__staff {
    position: absolute;
    z-index: 5;
    display: block;
    left: var(--x, 0px);
    top: var(--y, 0px);
    width: var(--w, 120px);
    height: var(--h, 400px);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: transform 900ms cubic-bezier(.22, 1, .36, 1) 1300ms, opacity 500ms linear 1300ms;
}
.symptoms-drum__staff img { position: absolute; top: 0; width: auto; max-width: none; height: 100%; }
/* The art was drawn to peek in from the screen edge, so its outer and lower cut edges fade like the watercolor. */
.symptoms-drum.is-ready .symptoms-drum__staff--l {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 28%), linear-gradient(#000 80%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(90deg, transparent, #000 28%), linear-gradient(#000 80%, transparent);
    mask-composite: intersect;
    transform: translateX(40%);
}
.symptoms-drum.is-ready .symptoms-drum__staff--r {
    -webkit-mask-image: linear-gradient(270deg, transparent, #000 22%), linear-gradient(#000 80%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(270deg, transparent, #000 22%), linear-gradient(#000 80%, transparent);
    mask-composite: intersect;
    transform: translateX(-40%);
}
.symptoms-drum__staff--l img { left: 0; }
.symptoms-drum__staff--r img { right: 0; }
/* The staff step out once, on entrance only; selecting a card never moves them. */
.symptoms-drum.is-live .symptoms-drum__staff { opacity: 1; transform: none; }

.symptoms-drum.is-ready .symptoms-drum__controls:not([hidden]) {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 4px;
}
.symptoms-drum__controls button {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    padding: 0;
    color: #285f63;
    background: #fff;
    border: 1px solid #cdded8;
    border-radius: 50%;
    cursor: pointer;
    transition: background 200ms ease;
}
.symptoms-drum__controls button:hover { background: #e6f2ee; }
.symptoms-drum__status {
    min-width: 9em;
    margin: 0;
    color: var(--color-main);
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .symptoms-drum.is-ready .symptoms-drum__staff,
    .symptoms-drum.is-ready .symptom-card,
    .symptoms-drum__controls button { transition: none; }
}
