/* ======================
   FEATURE BUBBLES
   ====================== */
.feature-bubbles {
    position: relative;
    width: min(100%, 18rem);
    height: clamp(220px, 50vh, 450px);
    margin-top: var(--space-md);
    overflow: visible;
    z-index: var(--z-content);
}

.feature-bubble {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    text-align: center;
    font-family: 'Cormorant', Georgia, serif;
    font-size: var(--text-small);
    font-weight: 300;
    line-height: 1.3;
    letter-spacing: var(--ls-caption);
    word-break: break-word;
    overflow: hidden;
    cursor: pointer;
    will-change: transform;
    color: var(--text-primary);
    border: 0.5px solid rgb(0 0 0 / var(--bubble-border-opacity, 0.15));
    background: rgba(247, 245, 242, 0.35);
    transition: filter var(--duration-fast) ease, border-color var(--duration-fast) ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.bubble-label {
    display: block;
    max-width: 70%;
    word-break: break-word;
}

/* Sphere body shading — light from upper-right (where the arc is), shadow lower-left */
.feature-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    background: radial-gradient(
        circle at 58% 18%,
        rgb(255 255 255 / 0.4) 0%,
        rgb(255 255 255 / 0.05) 45%,
        rgb(40 60 120 / 0.35) 100%
    );
    pointer-events: none;
}

/* Specular arc — concentric smaller circle, arc visible in upper-right */
.feature-bubble::after {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: var(--radius-full);
    background: transparent;
    border: 3px solid rgb(0 0 0 / 0.1);
    -webkit-mask: conic-gradient(from 10deg, transparent 0deg, rgb(0 0 0 / 0.4) 25deg, black 55deg, transparent 55deg);
    mask: conic-gradient(from 10deg, transparent 0deg, rgb(0 0 0 / 0.4) 25deg, black 55deg, transparent 55deg);
    pointer-events: none;
    z-index: var(--z-base);
}

.feature-bubble.claiming {
    opacity: 0.5;
    pointer-events: none;
}

.feature-bubble.charging {
    transition: background var(--duration-instant) ease;
    touch-action: none;
}

@keyframes priority-glow {
    0%, 100% { box-shadow: 0 0 10px 3px rgba(80, 200, 120, 0.4); }
    50% { box-shadow: 0 0 22px 8px rgba(80, 200, 120, 0.7); }
}

.feature-bubble.priority {
    animation: priority-glow 1.5s ease-in-out infinite;
    border-color: rgba(80, 200, 120, 0.6);
}

@keyframes svg-priority-glow {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(80, 200, 120, 0.4)); }
    50% { filter: drop-shadow(0 0 14px rgba(80, 200, 120, 0.7)); }
}

svg.breathing-dot.priority {
    animation: svg-priority-glow 1.5s ease-in-out infinite;
}

/* QR scanner viewfinder */
#qr-reader {
    position: fixed;
    top: calc(var(--title-y) + 4rem);
    left: 50%;
    transform: translateX(-50%);
    width: 70vw;
    max-width: 320px;
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transition: opacity var(--duration-normal) ease;
    border: 2px solid var(--warm-grey);
    box-shadow: 0 0 0 4px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.4);
}

#qr-reader.active {
    opacity: 1;
    pointer-events: auto;
    z-index: calc(var(--z-overlay) + 1);
}

#qr-reader-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    display: none;
}

#qr-reader-backdrop.active {
    display: block;
}

#qr-reader video {
    object-fit: cover;
    width: 100% !important;
    height: 100% !important;
    border-radius: 10px;
    transform: scale(1.4);
}

/* Blinking red record dot */
.qr-rec-dot {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 12px;
    height: 12px;
    background: #e33;
    border-radius: var(--radius-full);
    z-index: calc(var(--z-overlay) + 3);
    animation: rec-blink 1s ease-in-out infinite;
    box-shadow: 0 0 6px 2px rgba(230, 50, 50, 0.5);
}

@keyframes rec-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* Shutter blades */
.qr-shutter {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    background: var(--text-primary);
    z-index: calc(var(--z-overlay) + 2);
    pointer-events: none;
}

.qr-shutter-top {
    top: 0;
    transform: translateY(-101%);
}

.qr-shutter-bottom {
    bottom: 0;
    transform: translateY(101%);
}

.qr-shutter.close {
    transform: translateY(0);
    transition: transform var(--duration-fast) cubic-bezier(0.15, 0, 0.3, 1);
}

/* Hide all the library's UI elements */
#qr-reader__scan_region,
#qr-reader__dashboard,
#qr-reader__dashboard_section,
#qr-reader__dashboard_section_csr,
#qr-reader__dashboard_section_swaplink,
#qr-reader img,
#qr-reader br {
    display: none !important;
}

.listen-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--space-xl);
    padding-top: calc(var(--title-y) + var(--space-3xl));
    text-align: center;
    z-index: 2;
    position: relative;
    width: 100%;
}

/* State A: Passive listener */
.passive-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity var(--duration-slow) ease;
    position: relative;
    width: 100%;
}

.passive-state.hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.audio-meters {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: calc(-1 * var(--space-xs));
}

.audio-meter {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
}

.meter-segment {
    width: 20px;
    height: 3px;
    background: var(--text-primary);
    opacity: 0;
    transition: opacity var(--duration-instant) ease-out;
}

.meter-segment.active {
    opacity: 1;
}

/* Participate button */
.participate-btn {
    font-family: 'Cormorant', Georgia, serif;
    font-size: var(--text-button);
    font-weight: 300;
    letter-spacing: var(--ls-heading);
    text-transform: lowercase;
    background: none;
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 0.875rem 2.5rem;
    cursor: pointer;
    transition: all var(--duration-medium) ease;
    margin-top: var(--space-2xl);
}

@media (hover: hover) {
    .participate-btn:hover {
        background: var(--accent);
        color: var(--warm-white);
    }
}

.back-btn {
    position: fixed;
    bottom: var(--space-lg);
    left: var(--space-lg);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    opacity: 0.65;
    transition: opacity var(--duration-normal) ease;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .back-btn:hover {
        opacity: 1;
    }
}

/* State B: Active participant */
.active-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    transition: opacity var(--duration-slow) ease;
    width: 100%;
}

.active-state.visible {
    opacity: 1;
    pointer-events: auto;
    position: relative;
}

.listen-title {
    font-size: var(--text-hero);
    font-weight: 300;
    letter-spacing: var(--ls-heading);
    text-transform: lowercase;
    color: var(--text-muted);
    margin-bottom: 0;
    pointer-events: none;
    position: fixed;
    top: var(--title-y);
    left: 0;
    right: 0;
    text-align: center;
    z-index: var(--z-content);
}

/* Breathing dot — tap to scan (now lives inside physics container).
   No CSS animation on transform — the physics engine positions this element
   via inline transform, and radiusOscillation provides the breathing scale. */
.breathing-dot {
    position: absolute;
    top: 0;
    left: 0;
    width: 90px;
    height: 90px;
    overflow: visible;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.breathing-dot.paused {
    opacity: 0.3;
}

.breathing-dot.scanning {
    animation: scan-pulse 0.8s ease-in-out infinite;
}
.breathing-dot.scanning circle:first-child {
    fill: var(--accent-active);
}

.breathing-dot.success {
    animation: success-glow 1.5s ease-out;
}

.breathing-dot.hiding {
    animation: dot-hide 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes dot-hide {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.scan-hint {
    font-size: var(--text-caption);
    color: var(--text-primary);
    margin-top: var(--space-lg);
    letter-spacing: var(--ls-caption);
    pointer-events: none;
    user-select: none;
}

.scan-gate-hint {
    font-size: var(--text-body);
    text-align: right;
    position: absolute;
    top: var(--space-lg);
    right: 0;
    z-index: var(--z-hint);
    max-width: 65%;
    margin: 0;
    opacity: 0.55;
}

.onboarding-complete-hint {
    opacity: 0.5;
    transition: opacity 1s ease-out;
}

.skip-onboarding-btn {
    position: absolute;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-entry);
    font-family: 'Cormorant', Georgia, serif;
    font-size: var(--text-body);
    font-weight: 400;
    letter-spacing: var(--ls-button);
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--warm-grey);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: var(--space-xs) var(--space-lg);
    transition: all var(--duration-normal) ease;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.skip-onboarding-btn:active {
    background: var(--accent);
    color: var(--warm-white);
}

.solo-hint {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    font-size: var(--text-body);
    color: var(--text-primary);
    letter-spacing: var(--ls-caption);
    text-align: center;
    padding: 0 var(--space-lg);
    z-index: var(--z-controls);
    opacity: 0;
    transition: opacity var(--duration-slow) ease;
    pointer-events: none;
}

.solo-hint.visible {
    opacity: 0.55;
}

.performance-hint {
    font-size: var(--text-body);
    color: var(--text-primary);
    line-height: 1.6;
    margin-top: var(--space-xl);
    padding: 0 var(--space-lg);
    text-align: center;
}

@keyframes scan-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes success-glow {
    0%   { opacity: 1; filter: brightness(1); }
    15%  { opacity: 0.6; filter: brightness(1.3); }
    100% { opacity: 1; filter: brightness(1); }
}

/* Participate modal overlay */
.participate-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    z-index: var(--z-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-medium) ease;
}

.participate-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.participate-modal {
    max-width: var(--modal-width);
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    background: var(--warm-white);
    border: 1px solid var(--warm-grey);
    padding: var(--space-xl);
}

.participate-title {
    font-size: var(--text-body);
    font-weight: 300;
    letter-spacing: var(--ls-button);
    color: var(--text-primary);
}

.participate-hint {
    font-size: var(--text-body);
    color: var(--text-primary);
    line-height: 1.5;
}

.participate-name-input {
    font-family: 'Cormorant', Georgia, serif;
    font-size: var(--text-body);
    font-weight: 300;
    letter-spacing: var(--ls-body);
    color: var(--text-primary);
    background: none;
    border: none;
    border-bottom: 1px solid var(--warm-grey);
    padding: var(--space-xs) 0;
    width: 100%;
    text-align: center;
    outline: none;
    transition: border-color var(--duration-normal) ease;
    -webkit-user-select: text;
    user-select: text;
}

.participate-name-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.participate-name-input:focus {
    border-bottom-color: var(--accent);
}

.permission-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
    width: 100%;
    justify-content: center;
}

.permission-item.hidden {
    display: none;
}

.permission-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-active);
    cursor: pointer;
}

.permission-label {
    font-size: var(--text-body);
    letter-spacing: var(--ls-body);
    color: var(--text-primary);
}

/* Controls at bottom */
.mute-btn {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-xs);
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity var(--duration-normal) ease, color var(--duration-normal) ease;
    z-index: var(--z-controls);
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .mute-btn:hover { opacity: 0.8; }
}

.mute-btn svg {
    width: 23px;
    height: 23px;
    stroke-width: 1.5;
}

.mute-btn.muted { color: var(--error); opacity: 0.8; }

.status {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-caption);
    letter-spacing: var(--ls-button);
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--duration-slow) ease;
    z-index: var(--z-content);
}

.status.visible { opacity: 1; }
