/**
 * PlayInsight Demos - Embed Styles
 *
 * Responsive styles for embedded Unity WebGL demos.
 *
 * @package PlayInsight_Demos
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */

.pi-demo-wrapper {
    --pi-color-primary: #f59e0b;
    --pi-color-primary-dark: #d97706;
    --pi-color-bg: #0f0f0f;
    --pi-color-bg-card: #1a1a1a;
    --pi-color-bg-elevated: #252525;
    --pi-color-text: #ffffff;
    --pi-color-text-muted: #a3a3a3;
    --pi-color-border: #333333;
    --pi-radius: 8px;
    --pi-radius-lg: 12px;
    --pi-transition: 0.2s ease;
}

/* ==========================================================================
   Wrapper
   ========================================================================== */

.pi-demo-wrapper {
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Size variants */
.pi-demo-wrapper.pi-demo-size-small {
    max-width: 960px !important;
    width: 100% !important;
}

.pi-demo-wrapper.pi-demo-size-medium {
    max-width: 1280px !important;
    width: 100% !important;
}

.pi-demo-wrapper.pi-demo-size-large {
    max-width: 1920px !important;
    width: 100% !important;
}

.pi-demo-wrapper.pi-demo-size-full {
    max-width: 100% !important;
    width: 100% !important;
}

/* ==========================================================================
   Container (Aspect Ratio Box)
   ========================================================================== */

.pi-demo-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Default 16:9, overridden inline */
    background: var(--pi-color-bg);
    border-radius: var(--pi-radius-lg);
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Iframe
   ========================================================================== */

.pi-demo-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pi-demo-iframe.loaded {
    opacity: 1;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.pi-demo-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--pi-color-text-muted);
    z-index: 5;
    transition: opacity 0.3s ease;
}

.pi-demo-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.pi-demo-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--pi-color-border);
    border-top-color: var(--pi-color-primary);
    border-radius: 50%;
    animation: pi-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes pi-spin {
    to {
        transform: rotate(360deg);
    }
}

.pi-demo-loading p {
    margin: 0;
    font-size: 14px;
}

/* ==========================================================================
   Controls
   ========================================================================== */

.pi-demo-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--pi-color-bg-card);
    border-radius: 0 0 var(--pi-radius-lg) var(--pi-radius-lg);
    margin-top: -8px; /* Overlap with container bottom radius */
    flex-wrap: wrap;
    gap: 12px;
}

.pi-demo-controls-left {
    display: flex;
    gap: 8px;
}

.pi-demo-controls-hint {
    color: var(--pi-color-text-muted);
    font-size: 13px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.pi-demo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--pi-color-text);
    background: var(--pi-color-bg-elevated);
    border: 1px solid var(--pi-color-border);
    border-radius: var(--pi-radius);
    cursor: pointer;
    transition: all var(--pi-transition);
    font-family: inherit;
}

.pi-demo-btn:hover {
    border-color: var(--pi-color-primary);
    color: var(--pi-color-primary);
}

.pi-demo-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--pi-color-primary);
}

.pi-demo-btn:active {
    transform: scale(0.98);
}

/* Primary button variant */
.pi-demo-btn-primary {
    background: linear-gradient(135deg, var(--pi-color-primary) 0%, var(--pi-color-primary-dark) 100%);
    border-color: transparent;
    color: #000;
}

.pi-demo-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    color: #000;
}

/* ==========================================================================
   Fullscreen State
   ========================================================================== */

.pi-demo-wrapper.pi-demo-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 999999;
    background: #000;
    border-radius: 0;
}

.pi-demo-wrapper.pi-demo-fullscreen .pi-demo-container {
    height: calc(100% - 56px); /* Account for controls */
    padding-bottom: 0;
    border-radius: 0;
}

.pi-demo-wrapper.pi-demo-fullscreen .pi-demo-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .pi-demo-controls {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .pi-demo-controls-left {
        justify-content: center;
    }

    .pi-demo-controls-hint {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .pi-demo-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* ==========================================================================
   WordPress Theme Compatibility
   ========================================================================== */

/* Reset common theme interference */
.pi-demo-wrapper,
.pi-demo-wrapper * {
    box-sizing: border-box;
}

.pi-demo-wrapper img {
    max-width: none;
}

.pi-demo-wrapper iframe {
    max-width: 100%;
}

/* Ensure controls don't inherit weird styles */
.pi-demo-btn {
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.4;
}
