/* =========================================
   Playright - Main Styles (3D Version)
   ========================================= */

/* CSS Custom Properties */
:root {
    /* Color Palette */
    --color-primary: #7C3AED;
    --color-primary-light: #A78BFA;
    --color-primary-dark: #5B21B6;
    --color-secondary: #10B981;
    --color-accent: #F59E0B;

    /* Background Colors */
    --color-bg-dark: #0a0a0f;
    --color-modal-bg: #1E293B;
    --color-border: rgba(255, 255, 255, 0.1);
    --color-glow: rgba(124, 58, 237, 0.5);

    /* Text Colors */
    --color-text: #F8FAFC;
    --color-text-muted: #94A3B8;

    /* UI Colors */
    --color-overlay: rgba(0, 0, 0, 0.85);

    /* Typography */
    --font-pixel: 'Press Start 2P', cursive;
    --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;

    /* Z-index Layers */
    --z-canvas: 1;
    --z-ui: 100;
    --z-modal: 1000;
    --z-loading: 2000;
}

/* CSS Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg-dark);
    color: var(--color-text);
    line-height: 1.6;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: var(--font-pixel);
    font-weight: normal;
    line-height: 1.4;
}

a {
    color: #ffffff;
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent);
}

/* Room Container & Canvas */
#room-container {
    position: fixed;
    inset: 0;
    z-index: var(--z-canvas);
}

#room-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#room-canvas:active {
    cursor: grabbing;
}

/* Crosshair */
.crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: var(--z-ui);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

body.looking .crosshair {
    opacity: 1;
}

/* Object Label */
.object-label {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 30px);
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--color-text);
    pointer-events: none;
    z-index: var(--z-ui);
    opacity: 0;
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}

.object-label.visible {
    opacity: 1;
}

/* Speech Bubble */
.speech-bubble {
    position: fixed;
    background: white;
    border: 2px solid var(--color-bg-dark);
    padding: 12px;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--color-bg-dark);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -100%);
    /* Center horizontally, sit above point */
    transition: opacity var(--transition-normal);
    z-index: var(--z-ui);
    max-width: 200px;
    text-align: center;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    margin-top: -20px;
    /* Offset from head */
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: var(--color-bg-dark) transparent transparent transparent;
}

.speech-bubble.visible {
    opacity: 1;
}

/* Top Controls */
.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: var(--z-ui);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 18px;
}

.control-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.control-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-glow);
}

/* Audio Toggle States */
#audio-toggle .icon-sound-off {
    display: none;
}

#audio-toggle.muted .icon-sound-on {
    display: none;
}

#audio-toggle.muted .icon-sound-off {
    display: inline;
}

/* Theme Toggle States */
#theme-toggle .icon-night {
    display: none;
}

[data-theme="night"] #theme-toggle .icon-day {
    display: none;
}

[data-theme="night"] #theme-toggle .icon-night {
    display: inline;
}

/* Instructions */
.instructions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-ui);
    text-align: center;
}

.instructions p {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.instruction-item {
    display: inline-block;
    margin: 0 10px;
}

.instructions kbd {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-family: var(--font-pixel);
    font-size: 8px;
}

/* Branding */
.branding {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: var(--z-ui);
}

.brand-text {
    display: block;
    font-family: var(--font-pixel);
    font-size: 14px;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.brand-tagline {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--color-bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-loading);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    font-family: var(--font-pixel);
    font-size: 24px;
    color: #ffffff;
    margin-bottom: 30px;
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-bar {
    width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 15px;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.loading-text {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--color-text-muted);
}

/* Skip Link */
.skip-link {
    position: fixed;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--color-primary);
    color: var(--color-text);
    font-family: var(--font-pixel);
    font-size: 10px;
    z-index: var(--z-loading);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-family: var(--font-pixel);
    font-size: 10px;
    text-transform: uppercase;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
}

.btn-primary:hover {
    background: var(--color-primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--color-glow);
}

/* Form Elements */
input,
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--color-border);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.form-group {
    margin-bottom: 16px;
}

/* Keyframes */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .instructions {
        display: none;
    }

    .top-controls {
        display: none;
    }

    .branding {
        bottom: 15px;
        left: 15px;
    }

    .brand-text {
        font-size: 10px;
    }

    /* Smaller speech bubble on mobile */
    .speech-bubble {
        max-width: 120px;
        width: auto;
        font-size: 8px;
        padding: 6px 8px;
        /* Let JS handle positioning */
        margin-left: 0;
    }

}

/* =========================================
   Dialogue UI Styles
   ========================================= */
.dialogue-ui {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    pointer-events: auto;
    /* Ensure clickable */
    width: 90%;
    max-width: 400px;
}

.dialogue-option {
    background: var(--color-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-family: var(--font-pixel);
    font-size: 10px;
    /* Smaller pixel font */
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    text-align: center;
    animation: slideUp 0.3s ease-out;
    text-transform: uppercase;
    line-height: 1.4;
}

.dialogue-option:hover {
    transform: scale(1.05);
    background: var(--color-primary-dark);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .dialogue-ui {
        bottom: 80px;
        /* Lower on mobile */
    }

    .dialogue-option {
        font-size: 8px;
        padding: 10px 16px;
    }
}