/* ==========================================================================
   Take a breath: guided breathing circle
   ========================================================================== */

.breathe-section__grid {
    display: grid;
    gap: clamp(2.5rem, 2rem + 3vw, 4rem);
    align-items: center;
}

@media (min-width: 900px) {
    .breathe-section__grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.breathe-section__note {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.breathe {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
    background: color-mix(in srgb, var(--color-surface) 75%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-secondary) 35%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    text-align: center;
}

.breathe__stage {
    position: relative;
    display: grid;
    place-items: center;
    width: min(100%, 280px);
    aspect-ratio: 1;
}

.breathe__ring {
    position: absolute;
    inset: 0;
    border: 1px dashed color-mix(in srgb, var(--color-secondary) 70%, transparent);
    border-radius: 50%;
}

.breathe__glow {
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--color-secondary) 35%, transparent), transparent);
    opacity: 0.4;
    transition: opacity var(--breathe-dur, 1s) ease-in-out;
}

.breathe__circle {
    --breathe-scale: 0.55;

    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--color-primary) 55%, var(--color-bg-alt)), var(--color-primary) 70%);
    box-shadow: inset 0 0 40px rgb(0 0 0 / 0.12), 0 20px 40px -20px rgb(31 77 54 / 0.5);
    transform: scale(var(--breathe-scale));
    transition: transform var(--breathe-dur, 1s) cubic-bezier(0.45, 0, 0.55, 1);
}

.breathe.is-in .breathe__circle,
.breathe.is-hold .breathe__circle {
    --breathe-scale: 0.95;
}

.breathe.is-in .breathe__glow,
.breathe.is-hold .breathe__glow {
    opacity: 1;
}

.breathe__count {
    font-family: var(--font-heading);
    font-size: 3rem;
    line-height: 1;
    color: var(--color-bg);
    /* Counter scale keeps the number a steady size while the circle grows */
    transform: scale(calc(1 / var(--breathe-scale)));
    transition: transform var(--breathe-dur, 1s) cubic-bezier(0.45, 0, 0.55, 1);
}

.breathe__phase {
    min-height: 1.5em;
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--text-h3);
    line-height: 1.2;
    color: var(--color-primary);
}

.breathe__legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.breathe__legend li {
    padding: 0.3rem 0.85rem;
    border-radius: var(--radius-pill);
    background: var(--color-bg-alt);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: background-color 0.4s ease, color 0.4s ease;
}

.breathe__legend li.is-current {
    background: var(--color-primary);
    color: var(--color-surface);
}

.breathe__legend span {
    opacity: 0.8;
}

.breathe__icon-play,
.breathe__icon-pause {
    display: inline-flex;
}

.breathe:not(.is-running) .breathe__icon-pause,
.breathe.is-running .breathe__icon-play {
    display: none;
}

/* Reduced motion: the circle stays still, the countdown guides instead */
@media (prefers-reduced-motion: reduce) {
    .breathe__circle,
    .breathe.is-in .breathe__circle,
    .breathe.is-hold .breathe__circle {
        --breathe-scale: 0.8;

        transition: none;
    }
}
