/* ──────────────────────────────────────────────────────────────────
   Recording overlay (REC-045)

   Full-screen mobile-only overlay that takes over the viewport for a
   single recording attempt: recording → paused → uploading →
   upload-success → (uploaded, overlay tears down).
   Failed → user dismisses via the close button.

   Activation: .recording-screen.is-active. The mobile / phase guard
   is on the Alpine binding side; CSS just reacts to the class.

   Token palette comes from theme.css (--color-accent / --color-accent-dark
   / --color-accent-soft / --color-bg / --color-text / --color-text-muted /
   --color-primary).
   ──────────────────────────────────────────────────────────────────── */

/* Overlay is always laid out so we can ease opacity in/out. visibility +
   pointer-events keep it inert when not active; the visibility transition
   is delayed only on the way out, so click events don't leak in mid-fade. */
.recording-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 320ms ease,
        background-color 320ms ease,
        visibility 0s linear 320ms;
}

.recording-screen.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
        opacity 320ms ease,
        background-color 320ms ease,
        visibility 0s;
}

/* ── Top bar ─────────────────────────────────────────────────────── */
.recording-topbar {
    position: relative;
    flex: 0 0 auto;
    padding: 1.25rem 1.25rem 0;
    text-align: center;
    min-height: 2.5rem;
}

.recording-title {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.recording-close {
    position: absolute;
    right: 0.75rem;
    top: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
}

.recording-close:active {
    background: rgba(0, 0, 0, 0.05);
}

/* ── Stage (center column) ───────────────────────────────────────── */
.recording-stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
}

/* ── Orb + ripples ───────────────────────────────────────────────── */
.recording-orb-wrap {
    position: relative;
    width: 11rem;
    height: 11rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recording-orb {
    position: relative;
    width: 6.5rem;
    height: 6.5rem;
    border-radius: 50%;
    background: var(--color-accent-soft);
    border: 2px solid var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: recording-breathe 2.4s ease-in-out infinite;
    box-shadow: 0 8px 24px rgba(168, 79, 48, 0.18);
}

.recording-orb-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.recording-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6.5rem;
    height: 6.5rem;
    margin-top: -3.25rem;
    margin-left: -3.25rem;
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    opacity: 0;
    animation: recording-ripple 2.4s ease-out infinite;
}

.recording-ripple-2 { animation-delay: 0.8s; }
.recording-ripple-3 { animation-delay: 1.6s; }

@keyframes recording-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

@keyframes recording-ripple {
    0%   { transform: scale(1);   opacity: 0.55; }
    100% { transform: scale(1.9); opacity: 0;    }
}

/* Paused: freeze the orb/ripple animations. */
.recording-screen.is-paused .recording-orb,
.recording-screen.is-paused .recording-ripple,
.recording-screen.is-paused .recording-dot {
    animation-play-state: paused;
}

/* ── Timer + badge ───────────────────────────────────────────────── */
.recording-timer-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.recording-timer {
    font-size: 2rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    letter-spacing: 0.02em;
}

.recording-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--color-accent-dark);
    font-weight: 500;
}

.recording-screen.is-paused .recording-badge {
    color: var(--color-text-muted);
}

.recording-dot {
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--color-accent);
    animation: recording-blink 1.2s ease-in-out infinite;
}

.recording-screen.is-paused .recording-dot {
    background: var(--color-text-muted);
}

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

/* ── Uploading phase ─────────────────────────────────────────────── */
.recording-uploading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    max-width: 18rem;
}

.recording-progress {
    width: 100%;
    height: 0.5rem;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.recording-progress-bar {
    height: 100%;
    background: var(--color-accent);
    border-radius: 999px;
    transition: width 0.18s linear;
}

.recording-uploading-caption {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* ── Success flash ───────────────────────────────────────────────── */
.recording-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: recording-success-in 0.18s ease-out;
}

.recording-screen.phase-success {
    background: var(--color-accent-soft);
}

.recording-success-check {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 2.5rem;
    line-height: 4.5rem;
    text-align: center;
}

.recording-success-label {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.recording-success-duration {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

@keyframes recording-success-in {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1);    }
}

/* ── Failed phase ────────────────────────────────────────────────── */
.recording-failed {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    width: 100%;
    max-width: 22rem;
}

.recording-failed-audio {
    width: 100%;
}

.recording-failed-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.recording-btn-retry,
.recording-btn-download,
.recording-btn-share {
    width: 100%;
}

/* ── Controls row ────────────────────────────────────────────────── */
.recording-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding: 1rem 1.5rem calc(1.75rem + env(safe-area-inset-bottom, 0px));
}

.recording-btn-pause,
.recording-btn-stop {
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}

.recording-btn-pause {
    width: 3.25rem;
    height: 3.25rem;
    background: var(--color-text-muted);
    font-size: 1.1rem;
}

.recording-btn-pause:active {
    background: var(--color-text);
}

.recording-btn-stop {
    width: 4rem;
    height: 4rem;
    background: var(--color-accent);
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(191, 96, 64, 0.35);
}

.recording-btn-stop:active {
    background: var(--color-accent-dark);
}

/* ── Screen-reader only ──────────────────────────────────────────── */
.recording-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .recording-orb,
    .recording-ripple,
    .recording-dot,
    .recording-success {
        animation: none;
    }
    .recording-ripple {
        opacity: 0.25;
    }
}
