/**
 * CM Live Card - Recording Page Styles
 *
 * Uses --cmc-theme-* CSS variables from CM Core Library for theme style inheritance.
 *
 * @package CM_Live_Card
 * @since 1.0.0
 * @updated 1.1.0 - Migrated to --cmc-theme-* variables
 */

/* Variables — scoped to component using theme inheritance */
.cm-live-card-recorder {
    --cmc-theme-lc-primary: var(--cmc-plugin-primary);
    --cmc-theme-lc-primary-hover: color-mix(in srgb, var(--cmc-plugin-primary) 100%, #000 20%);
    --cmc-theme-lc-secondary: color-mix(in srgb, var(--cmc-theme-text-color) 50%, var(--cmc-theme-background-color));
    --cmc-theme-lc-success: var(--cmc-theme-success-color);
    --cmc-theme-lc-error: var(--cmc-theme-error-color);
    --cmc-theme-lc-warning: var(--cmc-theme-warning-color);
    --cmc-theme-lc-white: var(--cmc-theme-background-color);
    --cmc-theme-lc-black: var(--cmc-theme-text-color);
    --cmc-theme-lc-gray-100: color-mix(in srgb, var(--cmc-theme-text-color) 5%, var(--cmc-theme-background-color));
    --cmc-theme-lc-gray-200: color-mix(in srgb, var(--cmc-theme-text-color) 11%, var(--cmc-theme-background-color));
    --cmc-theme-lc-gray-600: color-mix(in srgb, var(--cmc-theme-text-color) 50%, var(--cmc-theme-background-color));
    --cmc-theme-lc-gray-800: color-mix(in srgb, var(--cmc-theme-text-color) 85%, var(--cmc-theme-background-color));
    --cmc-theme-lc-overlay-opacity: 0.8;
    --cmc-theme-lc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --cmc-theme-lc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --cmc-theme-lc-transition: all 0.3s ease;
}

/* Error page inherits same variables */
.cm-live-card-error {
    --cmc-theme-lc-primary: var(--cmc-plugin-primary);
    --cmc-theme-lc-success: var(--cmc-theme-success-color);
    --cmc-theme-lc-error: var(--cmc-theme-error-color);
    --cmc-theme-lc-warning: var(--cmc-theme-warning-color);
    --cmc-theme-lc-white: var(--cmc-theme-background-color);
    --cmc-theme-lc-gray-100: color-mix(in srgb, var(--cmc-theme-text-color) 5%, var(--cmc-theme-background-color));
    --cmc-theme-lc-gray-600: color-mix(in srgb, var(--cmc-theme-text-color) 50%, var(--cmc-theme-background-color));
    --cmc-theme-lc-gray-800: color-mix(in srgb, var(--cmc-theme-text-color) 85%, var(--cmc-theme-background-color));
    --cmc-theme-lc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* Container */
.cm-live-card-recorder {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--cmc-theme-lc-black);
    border-radius: 16px;
    overflow: hidden;
}

/* Background Image */
.cm-live-card-recorder__background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.cm-live-card-recorder__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gift Message */
.cm-live-card-recorder__gift-message {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--cmc-theme-lc-shadow-lg);
}

.cm-live-card-recorder__recipient {
    font-size: 14px;
    color: var(--cmc-theme-lc-primary);
    margin: 0 0 8px;
    font-weight: 600;
}

.cm-live-card-recorder__message {
    font-size: 15px;
    color: var(--cmc-theme-lc-gray-800);
    margin: 0;
    line-height: 1.5;
}

/* UI Overlay */
.cm-live-card-recorder__ui {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 30px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, var(--cmc-theme-lc-overlay-opacity)) 0%, transparent 100%);
}

/* States */
.cm-live-card-recorder__state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Loading State */
.cm-live-card-recorder__loader {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--cmc-theme-lc-white);
    border-radius: 50%;
    animation: cm-spin 1s linear infinite;
}

@keyframes cm-spin {
    to { transform: rotate(360deg); }
}

.cm-live-card-recorder__state--loading p {
    color: var(--cmc-theme-lc-white);
    margin: 0;
    font-size: 14px;
}

/* Buttons */
.cm-live-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--cmc-theme-lc-transition);
    text-decoration: none;
}

.cm-live-card-btn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-live-card-btn__icon svg {
    width: 20px;
    height: 20px;
}

.cm-live-card-btn--record {
    background: var(--cmc-theme-lc-error);
    color: var(--cmc-theme-lc-white);
}

.cm-live-card-btn--record:hover {
    background: color-mix(in srgb, var(--cmc-theme-error-color) 100%, #000 15%);
    transform: scale(1.05);
}

.cm-live-card-btn--stop {
    background: var(--cmc-theme-lc-white);
    color: var(--cmc-theme-lc-error);
}

.cm-live-card-btn--stop:hover {
    background: var(--cmc-theme-lc-gray-100);
}

.cm-live-card-btn--secondary {
    background: rgba(255, 255, 255, 0.2);
    color: var(--cmc-theme-lc-white);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.cm-live-card-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cm-live-card-btn--primary {
    background: var(--cmc-theme-lc-primary);
    color: var(--cmc-theme-lc-white);
}

.cm-live-card-btn--primary:hover {
    background: var(--cmc-theme-lc-primary-hover);
    transform: scale(1.02);
}

.cm-live-card-btn--download {
    background: var(--cmc-theme-lc-success);
    color: var(--cmc-theme-lc-white);
    font-size: 18px;
    padding: 18px 36px;
}

.cm-live-card-btn--download:hover {
    background: color-mix(in srgb, var(--cmc-theme-success-color) 100%, #000 15%);
    transform: scale(1.05);
}

/* Hint text */
.cm-live-card-recorder__hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    margin: 0;
}

/* Countdown */
.cm-live-card-recorder__countdown {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cm-pulse 1s ease-in-out infinite;
}

.cm-live-card-recorder__countdown-number {
    font-size: 64px;
    font-weight: bold;
    color: var(--cmc-theme-lc-white);
}

@keyframes cm-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Progress Ring */
.cm-live-card-recorder__progress-ring {
    position: relative;
    width: 120px;
    height: 120px;
}

.cm-live-card-recorder__progress-svg {
    transform: rotate(-90deg);
}

.cm-live-card-recorder__progress-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.cm-live-card-recorder__progress-bar {
    fill: none;
    stroke: var(--cmc-theme-lc-error);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

.cm-live-card-recorder__progress-time {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--cmc-theme-lc-white);
}

.cm-live-card-recorder__time-current {
    font-size: 36px;
    font-weight: bold;
}

.cm-live-card-recorder__time-separator,
.cm-live-card-recorder__time-total {
    font-size: 18px;
    opacity: 0.6;
}

/* Waveform */
.cm-live-card-recorder__waveform {
    width: 200px;
    height: 40px;
    margin-top: 10px;
}

.cm-live-card-recorder__waveform canvas {
    width: 100%;
    height: 100%;
}

/* Preview Controls */
.cm-live-card-recorder__preview-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* Processing */
.cm-live-card-recorder__processing {
    text-align: center;
    color: var(--cmc-theme-lc-white);
}

.cm-live-card-recorder__processing-animation {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.cm-live-card-recorder__processing-animation span {
    width: 12px;
    height: 12px;
    background: var(--cmc-theme-lc-white);
    border-radius: 50%;
    transition: var(--cmc-theme-lc-transition);
}

.cm-live-card-recorder__processing-text {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px;
}

.cm-live-card-recorder__processing-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto 12px;
}

.cm-live-card-recorder__processing-bar {
    height: 100%;
    background: var(--cmc-theme-lc-primary);
    width: 0%;
    transition: width 0.3s ease;
}

.cm-live-card-recorder__processing-step {
    font-size: 14px;
    margin: 0;
    opacity: 0.7;
}

/* Complete */
.cm-live-card-recorder__complete {
    text-align: center;
    color: var(--cmc-theme-lc-white);
}

.cm-live-card-recorder__complete-icon {
    margin-bottom: 16px;
}

.cm-live-card-recorder__complete-icon svg {
    stroke: var(--cmc-theme-lc-success);
}

.cm-live-card-recorder__complete h3 {
    font-size: 24px;
    margin: 0 0 8px;
}

.cm-live-card-recorder__complete p {
    margin: 0 0 24px;
    opacity: 0.8;
}

.cm-live-card-recorder__share-hint {
    font-size: 13px;
    opacity: 0.6;
    margin-top: 16px !important;
}

/* Gift Complete */
.cm-live-card-recorder__state--gift-complete .cm-live-card-recorder__complete-icon svg {
    stroke: var(--cmc-theme-lc-primary);
}

/* Error */
.cm-live-card-recorder__error {
    text-align: center;
    color: var(--cmc-theme-lc-white);
}

.cm-live-card-recorder__error-icon {
    margin-bottom: 16px;
}

.cm-live-card-recorder__error-icon svg {
    stroke: var(--cmc-theme-lc-error);
}

.cm-live-card-recorder__error h3 {
    font-size: 20px;
    margin: 0 0 8px;
}

.cm-live-card-recorder__error-message {
    margin: 0 0 20px;
    opacity: 0.8;
}

/* Error Page (outside recorder) */
.cm-live-card-error {
    max-width: 500px;
    margin: 60px auto;
    text-align: center;
    padding: 40px 20px;
    background: var(--cmc-theme-lc-white);
    border-radius: 16px;
    box-shadow: var(--cmc-theme-lc-shadow-lg);
}

.cm-live-card-error__icon {
    margin-bottom: 20px;
}

.cm-live-card-error__icon svg {
    stroke: var(--cmc-theme-lc-gray-600);
}

.cm-live-card-error--token_expired .cm-live-card-error__icon svg {
    stroke: var(--cmc-theme-lc-warning);
}

.cm-live-card-error--token_already_used .cm-live-card-error__icon svg {
    stroke: var(--cmc-theme-lc-success);
}

.cm-live-card-error h2 {
    font-size: 24px;
    color: var(--cmc-theme-lc-gray-800);
    margin: 0 0 12px;
}

.cm-live-card-error p {
    color: var(--cmc-theme-lc-gray-600);
    margin: 0 0 24px;
    line-height: 1.6;
}

.cm-live-card-error__expired-date {
    font-size: 14px;
    color: var(--cmc-theme-lc-warning);
}

/* Responsive */
@media (max-width: 640px) {
    .cm-live-card-recorder {
        border-radius: 0;
        min-height: 100vh;
    }

    .cm-live-card-recorder__ui {
        padding: 20px 15px;
    }

    .cm-live-card-btn {
        padding: 12px 24px;
        font-size: 15px;
    }

    .cm-live-card-btn--download {
        padding: 16px 32px;
        font-size: 16px;
    }

    .cm-live-card-recorder__countdown {
        width: 100px;
        height: 100px;
    }

    .cm-live-card-recorder__countdown-number {
        font-size: 48px;
    }

    .cm-live-card-recorder__progress-ring {
        width: 100px;
        height: 100px;
    }

    .cm-live-card-recorder__time-current {
        font-size: 28px;
    }
}

/* Screen reader only */
.cm-live-card-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;
}

/* Focus visible */
.cm-live-card-btn:focus-visible,
.cm-live-card-error .cm-live-card-btn:focus-visible {
    outline: 3px solid var(--cmc-theme-lc-primary);
    outline-offset: 2px;
}

.cm-live-card-btn--record:focus-visible {
    outline-color: var(--cmc-theme-lc-white);
}

.cm-live-card-btn--stop:focus-visible {
    outline-color: var(--cmc-theme-lc-error);
}

.cm-live-card-btn--secondary:focus-visible {
    outline-color: var(--cmc-theme-lc-white);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cm-live-card-recorder__loader {
        animation: none;
        border-top-color: var(--cmc-theme-lc-white);
    }

    .cm-live-card-recorder__countdown {
        animation: none;
    }

    .cm-live-card-recorder__processing-animation span {
        transition: none;
    }

    .cm-live-card-btn {
        transition: none;
    }

    .cm-live-card-recorder__progress-bar {
        transition: none;
    }

    .cm-live-card-recorder__processing-bar {
        transition: none;
    }
}

/* Fullscreen mode (optional) */
.cm-live-card-recorder--fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    border-radius: 0;
    z-index: 9999;
}
