/* ===== LCARS Fonts ===== */
@import url('assets/fonts/stylesheet.css');

/* ===== LCARS Color Palette ===== */
:root {
    --lcars-blue-light: #A4B9FF;
    --lcars-blue-medium: #6986FF;
    --lcars-blue-dark: #4361FF;
    --lcars-sand-light: #FFEEA9;
    --lcars-sand-medium: #FFD147;
    --lcars-sand-dark: #FFBD26;
    --lcars-earth-light: #C5B3A8;
    --lcars-earth-medium: #987E6F;
    --lcars-earth-dark: #755849;
    --lcars-purple-medium: #625B6F;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Impact', 'Arial Black', sans-serif;
}

/* ===== Canvas Container ===== */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
}

#canvas-container canvas {
    display: block;
}

/* ===== Overlay Text ===== */
#overlay-text {
    position: fixed;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Huc', 'Impact', sans-serif;
    font-weight: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: clamp(2rem, 6vw, 4.5rem);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    white-space: nowrap;
    text-shadow: none;
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#overlay-text.active {
    animation: textPulse 0.5s ease-in-out infinite alternate;
}

@keyframes textPulse {
    0% {
        transform: translateX(-50%) scale(1);
    }

    100% {
        transform: translateX(-50%) scale(1.05);
    }
}

/* ===== Start Screen Container ===== */
#start-container {
    position: fixed;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 100;
    width: 100%;
}

/* ===== Main Start Button ===== */
#start-button {
    background: rgba(204, 0, 0, 0.8);
    /* LCARS Red-ish */
    color: #FFD147;
    border: 2px solid rgba(255, 209, 71, 0.6);
    padding: 25px 50px;
    font-family: 'Huc', sans-serif;
    font-size: clamp(24px, 4vw, 36px);
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 12px;
    /* Slightly more rounded than small buttons */
    transition: all 0.3s ease;
    width: auto;
    max-width: 90vw;
    box-shadow: 0 0 20px rgba(204, 0, 0, 0.4);
}

#start-button:hover {
    background: rgba(204, 0, 0, 1);
    border-color: #FFD147;
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(204, 0, 0, 0.6);
}

#start-button:active {
    transform: scale(0.98);
}

#start-button.pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.02);
        opacity: 0.9;
    }
}

/* ===== Sound Hint ===== */
#sound-hint {
    color: #FFBD26;
    /* Darker sand/orange */
    font-family: 'TrekOpsCondensed', sans-serif;
    font-size: 18px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.8;
    text-align: center;
}

/* ===== Legal Disclaimer ===== */
.legal-disclaimer {
    font-family: 'Arial', sans-serif;
    font-size: 10px;
    color: #FFEEA9;
    /* LCARS sand light */
    opacity: 0.5;
    text-align: center;
    max-width: 600px;
    line-height: 1.4;
    margin-top: 20px;
    text-transform: none;
    pointer-events: none;
}

/* ===== Camera Hint ===== */
#camera-hint {
    position: fixed;
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    color: #FFEEA9;
    font-family: 'TrekOpsCondensed', sans-serif;
    font-size: 18px;
    letter-spacing: 1px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
    white-space: nowrap;
}

#camera-hint.visible {
    opacity: 0.7;
}

#camera-hint.fade-out {
    opacity: 0;
    transition: opacity 1.5s ease;
}

/* ===== Sound Toggle ===== */
#sound-toggle {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 200;
    background: transparent;
    border: none;
    color: #FFD147;
    cursor: pointer;
    padding: 8px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#sound-toggle.visible {
    opacity: 0.7;
}

#sound-toggle:hover {
    opacity: 1;
}

/* ===== Cinematic Mode Buttons (WIP) ===== */
#cinematic-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    color: #FFD147;
    border: 1px solid rgba(255, 209, 71, 0.4);
    padding: 18px 30px;
    font-family: 'Huc', sans-serif;
    font-size: 25px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 8px;
    transition: opacity 0.5s ease;
}

#cinematic-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 209, 71, 0.7);
}

#exit-cinematic-btn {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    color: #FFEEA9;
    border: 1px solid rgba(255, 238, 169, 0.3);
    padding: 15px 38px;
    font-family: 'Huc', sans-serif;
    font-size: 22px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 6px;
    transition: opacity 0.3s ease;
}

#exit-cinematic-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 238, 169, 0.6);
}

/* ===== LCARS Dance Menu ===== */
#dance-menu {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scale(0.88);
    transform-origin: right center;
    z-index: 100;
    transition: opacity 0.5s ease;
    overflow: visible;
    padding: 55px 40px 55px 30px;

    /* Black rounded card with outline on 3 sides (not right) */
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 209, 71, 0.4);
    border-right: none;
    border-radius: 20px 0 0 20px;
}

/* ===== LCARS Boot Animation ===== */
@keyframes lcars-slide-in {
    0% {
        transform: translateY(-50%) scale(0.88) translateX(calc(100% + 60px));
        opacity: 1;
    }

    100% {
        transform: translateY(-50%) scale(0.88) translateX(0);
        opacity: 1;
    }
}

@keyframes lcars-slide-in-mobile {
    0% {
        transform: translateX(-50%) translateX(calc(100vw));
        opacity: 1;
    }

    100% {
        transform: translateX(-50%);
        opacity: 1;
    }
}

#dance-menu.lcars-booting {
    animation: lcars-slide-in 0.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 1 !important;
}

/* During boot, individual elements start invisible */
.lcars-boot-hidden {
    opacity: 0;
}

.lcars-boot-reveal {
    animation: lcars-element-pop 30ms ease-out forwards;
}

@keyframes lcars-element-pop {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

#dance-menu h3 {
    display: none;
    /* Remove the old header - LCARS doesn't need it */
}

#dance-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 20px;
}

/* Only enable scrolling when viewport is very short */
@media (max-height: 700px) {
    #dance-buttons {
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }
}

/* ===== LCARS Button Row ===== */
.lcars-row {
    display: flex;
    align-items: stretch;
    height: 63px;
    cursor: pointer;
    transition: filter 0.15s ease, opacity 0.15s ease;
}

.lcars-row:hover {
    opacity: 0.85;
}

.lcars-row:active {
    opacity: 0.75;
}

/* ===== LCARS Number (left decorative number) ===== */
.lcars-num {
    font-family: 'Com', 'Impact', sans-serif;
    font-weight: 300;
    font-size: 77px;
    line-height: 100%;
    letter-spacing: -1.3px;
    text-align: right;
    min-width: 80px;
    margin-right: 7px;
    color: currentColor;
    user-select: none;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    transform: translateY(-3px);
}

/* ===== LCARS Bar (main clickable area with dance name) ===== */
.lcars-bar {
    width: 182px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    padding: 0 0 10px 13px;
    margin-right: 22px;
    font-family: 'Huc-lcars', 'Arial', sans-serif;
    font-size: 25px;
    line-height: normal;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #000;
    border: none;
    cursor: pointer;
    user-select: none;
}

.lcars-bar span {
    color: #000;
}

/* ===== LCARS End Cap (extracted SVG shape) ===== */
.lcars-cap {
    flex-shrink: 0;
    width: 48px;
    height: 63px;
    display: flex;
    align-items: center;
    user-select: none;
}

.lcars-cap svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== LCARS Active State ===== */
.lcars-row.active .lcars-cap {
    animation: lcars-blink 1s steps(1) infinite;
}

@keyframes lcars-blink {

    0%,
    50% {
        visibility: visible;
    }

    50.01%,
    100% {
        visibility: hidden;
    }
}

/* ===== Hidden State ===== */
.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ===== LCARS Scrollbar ===== */
#dance-buttons::-webkit-scrollbar {
    width: 6px;
}

#dance-buttons::-webkit-scrollbar-track {
    background: transparent;
}

#dance-buttons::-webkit-scrollbar-thumb {
    background: #FFEEA9;
    border-radius: 999px;
}

#dance-buttons {
    scrollbar-width: thin;
    scrollbar-color: #FFEEA9 transparent;
}

/* ===== LCARS Expand Tab (mobile only) ===== */
.lcars-expand-tab {
    display: none;
    /* Hidden on desktop, shown via media query */
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 768px) {

    /* --- Center the card horizontally --- */
    #dance-menu {
        right: auto;
        left: 50%;
        top: auto;
        transform: translateX(-50%);
        transform-origin: center center;
        bottom: 20px;
        max-height: 85vh;
        padding: 30px 30px 30px 20px;
        overflow: visible;
        border: none;
        border-radius: 20px;
        box-shadow: inset 0 0 0 1px rgba(255, 209, 71, 0.4);
        /* Allow tab to extend above card */
    }



    /* --- Collapsed state: hide non-active buttons --- */
    #dance-menu.collapsed .lcars-row {
        display: none;
    }

    #dance-menu.collapsed .lcars-row.active {
        display: flex;
    }

    /* --- Mobile boot animation --- */
    #dance-menu.lcars-booting {
        animation: lcars-slide-in-mobile 0.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    /* --- Scaled-down button dimensions --- */
    .lcars-row {
        height: 48px;
    }

    .lcars-num {
        font-size: 59px;
        min-width: 60px;
    }

    .lcars-bar {
        width: 140px;
        font-size: 25px;
        line-height: 20px;
        padding: 0 0 10px 10px;
        margin-right: 15px;
    }

    .lcars-cap {
        width: 36px;
        height: 48px;
    }

    #dance-buttons {
        gap: 10px;
    }

    #start-button {
        bottom: 5%;
    }

    #camera-hint {
        bottom: auto;
        top: 12%;
        font-size: 14px;
    }

    #sound-toggle {
        top: 15px;
        right: 15px;
    }

    /* --- Cinematic Button on Mobile --- */
    #cinematic-btn {
        left: 50%;
        transform: translateX(-50%);
        bottom: 20px;
        width: 320px;
        max-width: 90vw;
        text-align: center;
        /* Ensure it's under the dance menu */
    }

    /* --- Update dance menu positioning to stack above button --- */
    #dance-menu {
        bottom: 100px;
        /* Make room for the button */
        border-radius: 8px;
        /* Match button radius */
        width: 320px;
        max-width: 90vw;
        padding: 20px;
        /* Simplify padding */
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease;
    }

    #dance-menu:hover {
        background: rgba(0, 0, 0, 0.9);
        border-color: rgba(255, 209, 71, 0.7);
    }

    /* --- Toggle between LCARS row and Plain Text Label --- */
    .collapsed-label {
        display: none;
        font-family: 'Huc', sans-serif;
        font-size: 25px;
        color: #FFD147;
        text-transform: uppercase;
        text-align: center;
        width: 100%;
        pointer-events: none;
    }

    #dance-menu.collapsed .collapsed-label {
        display: block;
    }

    /* Hide the active row when collapsed (override flex) */
    #dance-menu.collapsed .lcars-row.active {
        display: none;
    }
}