/**
 * Gamma Embed - Frontend Styles
 * Responsive and accessible styles for embedded Gamma presentations
 */

/* Container wrapper */
.gamma-embed-wrapper {
    margin: 1.5em 0;
    width: 100%;
}

.gamma-embed-container {
    margin: 0 auto;
    width: 100%;
}

/* Content scale wrapper */
.gamma-embed-scale-wrapper {
    overflow: hidden;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gamma-embed-scale-inner {
    transform-origin: top left;
}

/* Responsive embed container */
.gamma-embed-responsive {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Default 16:9 */
    height: 0;
    overflow: hidden;
    background: #f0f0f1;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* When scaled, the scale-wrapper handles the aspect ratio, so responsive div should fill it */
.gamma-embed-responsive.gamma-embed-scaled {
    box-shadow: none;
    border-radius: 8px;
    padding-bottom: 0;
    height: 100%;
}

/* Aspect ratio variations */
.gamma-embed-ratio-16-9 .gamma-embed-responsive {
    padding-bottom: 56.25%; /* 16:9 */
}

.gamma-embed-ratio-4-3 .gamma-embed-responsive {
    padding-bottom: 75%; /* 4:3 */
}

.gamma-embed-ratio-1-1 .gamma-embed-responsive {
    padding-bottom: 100%; /* 1:1 */
}

.gamma-embed-ratio-9-16 .gamma-embed-responsive {
    padding-bottom: 177.78%; /* 9:16 */
    max-width: 400px;
    margin: 0 auto;
}

/* Iframe styling */
.gamma-embed-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #f0f0f1;
}

/* Loading spinner overlay */
.gamma-embed-responsive::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: gamma-spin 0.8s linear infinite;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.gamma-embed-responsive.loaded::before {
    opacity: 0;
    pointer-events: none;
}

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

/* Action button container */
.gamma-embed-actions {
    margin-top: 1em;
    text-align: center;
}

/* Action button base styles - Inherits theme colors */
.gamma-embed-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    padding: 0.75em 1.5em;
    font-size: 1em;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.gamma-embed-action-button:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Primary button style - Uses theme link/accent color with solid fallbacks */
.gamma-embed-button-primary {
    background: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #0073aa));
    color: #ffffff;
    border: 2px solid var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #0073aa));
}

.gamma-embed-button-primary:hover,
.gamma-embed-button-primary:focus {
    background: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #005a87));
    border-color: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #005a87));
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gamma-embed-button-primary:active {
    transform: translateY(0);
}

/* Secondary button style - Outline with theme colors */
.gamma-embed-button-secondary {
    background: transparent;
    color: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #0073aa));
    border: 2px solid var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #0073aa));
}

.gamma-embed-button-secondary:hover,
.gamma-embed-button-secondary:focus {
    background: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #0073aa));
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.gamma-embed-button-secondary:active {
    transform: translateY(0);
}

/* Minimal button style - Text only with theme colors */
.gamma-embed-button-minimal {
    background: transparent;
    color: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #0073aa));
    border: none;
    padding: 0.5em 1em;
}

.gamma-embed-button-minimal:hover,
.gamma-embed-button-minimal:focus {
    color: var(--wp--preset--color--primary, var(--wp--preset--color--vivid-cyan-blue, #005a87));
    text-decoration: underline;
}

/* Button icon */
.gamma-embed-button-icon {
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
}

/* Button disabled state */
.gamma-embed-action-button:disabled,
.gamma-embed-action-button[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* Spinner for loading state */
.gamma-embed-spinner {
    display: inline-flex;
    align-items: center;
    margin-left: 0.5em;
}

.gamma-embed-spinner svg {
    width: 1em;
    height: 1em;
}

/* Error message */
.gamma-embed-error {
    padding: 1em;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gamma-embed-wrapper {
        margin: 1em 0;
    }

    .gamma-embed-action-button {
        width: 100%;
        max-width: 300px;
    }

    .gamma-embed-ratio-9-16 .gamma-embed-responsive {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .gamma-embed-action-button {
        font-size: 0.9em;
        padding: 0.6em 1.2em;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .gamma-embed-responsive {
        background: #2d2d2d;
    }

    .gamma-embed-error {
        background: #451a1a;
        border-color: #991b1b;
        color: #fecaca;
    }
}

/* High contrast mode support */
@media (forced-colors: active) {
    .gamma-embed-action-button {
        border: 2px solid currentColor;
    }

    .gamma-embed-iframe {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gamma-embed-action-button {
        transition: none;
    }

    .gamma-embed-action-button:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .gamma-embed-responsive {
        display: none;
    }

    .gamma-embed-actions {
        display: none;
    }

    .gamma-embed-wrapper::before {
        content: '[Gamma Presentation - View online]';
        display: block;
        padding: 1em;
        background: #f0f0f1;
        text-align: center;
    }
}

/* LearnDash compatibility */
.learndash-wrapper .gamma-embed-wrapper {
    margin: 1.5em 0;
}

.learndash-wrapper .gamma-embed-action-button {
    font-family: inherit;
}

/* Ensure proper stacking context */
.gamma-embed-wrapper {
    position: relative;
    z-index: 1;
}
