/* ============================================================
   HOUSE OF AWE — Main Stylesheet
   Desktop-first with mobile enhancements.
   ============================================================ */

:root {
    --bg-color: #3b1e54;
    --accent-color: #ffd200;
    --ui-bg: rgba(0, 0, 0, 0.6);
    --ui-border: rgba(255, 255, 255, 0.15);
    --text-dim: #e2e8f0;
    --transition-fast: 0.2s ease;
    --transition-med: 0.3s ease;

    /* Shared Fonts */
    --font-mono: 'JetBrains Mono', 'Share Tech Mono', monospace;
    --font-glass: 'Glass Antiqua', cursive;
    --font-serif: 'Libre Baskerville', serif;

    /* Safe-area shorthand (iOS notch / home bar) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Minimum touch target size (Apple HIG) */
    --touch-min: 44px;
}

/* ---- Reset / Base ---- */
body {
    margin: 0;
    font-family: 'Lato', sans-serif;
    overflow-y: auto !important;
}

/* iOS PWA / standalone: prevent elastic bounce-scroll and fix full-bleed height */
html {
    height: -webkit-fill-available;
}

/* Restrictive styles only for the 3D Experience page */
body.experience-mode {
    background-color: var(--bg-color);
    overflow: hidden !important;
    color: var(--text-dim);
    overscroll-behavior: none;
    /* Ensure true full-height on all iOS versions */
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    position: fixed;
    width: 100%;
    /* Prevent text selection during 3D interaction */
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection inside inputs/textareas even in experience mode */
body.experience-mode input,
body.experience-mode textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Canvas container — touch-action:none here so Three.js gets all pointer events,
   applied to the canvas itself rather than the whole body so overlays still work */
#canvas-container {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    touch-action: none;
}

/* Instructions bar: lift above the home indicator */
#instructions {
    position: absolute;
    bottom: max(20px, calc(var(--safe-bottom) + 12px));
    left: 50%;
    transform: translateX(-50%);
    background: var(--ui-bg);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-dim);
    pointer-events: none;
    text-align: center;
    transition: opacity var(--transition-med);
    width: 80%;
    max-width: 400px;
    border: 1px solid var(--ui-border);
    z-index: 110;
}


/* ---- Top Controls: minimum touch-target size ---- */
#top-left-controls button,
#top-controls button {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}


/* ---- Loading Screen ---- */
#loading {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #111111;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    color: white;
    /* Safe area padding so content doesn't hide behind notch */
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    box-sizing: border-box;
}

#loading button {
    font-family: 'Baumans', cursive !important;
    font-weight: 400 !important;
    font-size: 24px !important;
    letter-spacing: 0.1em !important;
    text-transform: uppercase !important;
    background: transparent !important;
    color: white !important;
    border: 1px solid white !important;
    padding: 15px 40px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important;
    display: block !important;
    min-height: var(--touch-min) !important;
}

#loading button:hover {
    background: white !important;
    color: black !important;
}

#loading button>* {
    pointer-events: none;
}

/* Stack vertically on small screens */
@media (max-width: 500px) {
    #loading {
        gap: 1.5rem;
    }
}


/* ---- Tooltip ---- */
#tooltip {
    position: absolute;
    background: rgba(255, 255, 255, 0.92);
    color: #1a202c;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
    transform: translate(-50%, calc(-100% - 10px));
    z-index: 100;
}


#curtain {
    position: fixed;
    inset: 0;
    background: #111111;
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s ease;
}

#curtain.active {
    opacity: 1;
    pointer-events: auto;
}


/* ---- Back Button ---- */
#back-btn {
    position: fixed;
    top: calc(24px + var(--safe-top));
    left: max(20px, var(--safe-left));
    padding: 10px 20px;
    background: var(--ui-bg);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 2px;
    z-index: 120;
    transition: transform var(--transition-med), background var(--transition-med), border-color var(--transition-med);
    display: none;
    min-height: var(--touch-min);
}

#back-btn:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
}


/* ---- Idea / Notepad Overlay ---- */
#idea-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1100;
    display: none;
    justify-content: center;
    align-items: center;
}

.notepad-paper {
    background: #fef9c3;
    width: 90%;
    max-width: 600px;
    height: 70%;
    padding: 40px;
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
}

.notepad-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 40px;
    bottom: 0;
    width: 2px;
    background: #ef4444;
    opacity: 0.5;
}

textarea.idea-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    resize: none;
    font-family: 'Lato', sans-serif;
    font-size: 1.2rem;
    line-height: 1.8;
    color: #374151;
    outline: none;
    padding-left: 20px;
    background-image: linear-gradient(#999 1px, transparent 1px);
    background-size: 100% 1.8em;
    touch-action: pan-y;
    -webkit-user-select: text;
    user-select: text;
}

.notepad-controls {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-note {
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: opacity var(--transition-fast);
    min-height: var(--touch-min);
}

.btn-note:hover {
    opacity: 0.85;
}

.btn-save {
    background: #3b82f6;
    color: white;
}

.btn-close {
    background: #ef4444;
    color: white;
}


/* ---- Footer: hidden only inside 3D view ---- */
body.experience-mode footer {
    display: none !important;
}

/* ---- Main Header ---- */
#main-header {
    will-change: transform, opacity;
    padding-top: 0.5rem !important;
    margin-top: -3rem !important;
}


/* ---- Narrative Questionnaire System ---- */
#narrative-overlay,
#question-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
    padding: 20px;
}

.narrative-card {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 3rem;
    border-radius: 4px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.narrative-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.narrative-card h2 {
    font-family: 'Share Tech Mono', monospace;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 2rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.narrative-card>p {
    font-family: 'Share Tech Mono', monospace;
}

.narrative-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 1rem;
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    margin-bottom: 2rem;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    border-radius: 4px;
    -webkit-user-select: text;
    user-select: text;
}

.narrative-input:focus {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.narrative-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 12px 32px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    min-height: var(--touch-min);
}

.narrative-btn:hover,
.narrative-btn:active {
    background: #fff;
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.narrative-btn+.narrative-btn {
    margin-top: 0.5rem;
}


/* ---- Questionnaire Reflection Icon Tooltip ---- */
#tooltip[data-type="reflect"] {
    background: rgba(255, 210, 0, 0.9);
    color: #000;
}

/* ---- Question overlay smooth display ---- */
#question-overlay {
    transition: opacity 0.4s ease;
}

/* ---- Reflect button answered state glow ---- */
#reflect-btn:has(svg[stroke="#4ade80"]) {
    animation: pulse-green 3s ease-in-out infinite;
}

@keyframes pulse-green {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }

    50% {
        box-shadow: 0 0 6px 1px rgba(74, 222, 128, 0.2);
    }
}


/* ---- Close Button for Popups ---- */
.close-popup-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10;
    background: none;
    border: none;
    line-height: 1;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 0;
}

.close-popup-btn:hover {
    color: #fff;
}


/* ---- Glass / Blur Overlay ---- */
.pattern-overlay {
    backdrop-filter: blur(10px) brightness(0.8);
    -webkit-backdrop-filter: blur(10px) brightness(0.8);
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 10;
}


/* ---- Music Box Striped Pattern ---- */
.music-strip-animated {
    background-image: repeating-linear-gradient(45deg,
            transparent,
            transparent 25px,
            rgba(0, 0, 0, 0.2) 25px,
            rgba(0, 0, 0, 0.2) 50px);
    background-size: 200% 200%;
    animation: stripe-move 15s linear infinite;
}

@keyframes stripe-move {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 70px 0;
    }
}


/* ---- Shared Animations ---- */
@keyframes pulse-slow {

    0%,
    100% {
        opacity: 0.1;
    }

    50% {
        opacity: 0.3;
    }
}

.animate-pulse-slow {
    animation: pulse-slow 8s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        left: -60%;
    }

    100% {
        left: 160%;
    }
}


/* ---- Utility: Scrollbars ---- */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #151414;
}


/* ---- Fonts ---- */
.serif {
    font-family: 'Courier Prime', monospace;
}

.glass-font {
    font-family: var(--font-glass);
}

.serif-italic {
    font-family: var(--font-serif);
    font-style: italic;
}

.share-tech-font {
    font-family: 'Share Tech Mono', monospace !important;
    font-weight: 400 !important;
}


/* ==============================================================
   MOBILE ENHANCEMENTS  (desktop is unchanged above this point)
   ============================================================== */

/* On narrow phones the room-info panel is too cramped — hide it */
@media (max-width: 599px) {
    #room-info {
        display: none !important;
    }

    /* Lyrics: keep clear of iOS home indicator */
    #lyrics-container {
        bottom: calc(var(--safe-bottom) + 8px) !important;
        font-size: 0.9rem !important;
        max-width: 92% !important;
    }

    /* Compact the top-right icon column */
    #top-controls {
        top: max(20px, var(--safe-top)) !important;
        right: max(16px, var(--safe-right)) !important;
        gap: 10px !important;
    }

    #top-controls button {
        width: 44px !important; /* Minimum touch size */
        height: 44px !important;
    }

    #top-left-controls,
    #back-btn {
        top: max(20px, var(--safe-top)) !important;
        left: max(16px, var(--safe-left)) !important;
    }

    /* Narrative popups: anchored to upper screen so keyboard doesn't cover them */
    #narrative-overlay,
    #question-overlay {
        align-items: flex-start;
        justify-content: center;
        padding: 15vh 16px 0;
    }

    .narrative-card {
        border-radius: 12px;
        padding: 1.5rem 1.25rem 1.25rem;
        max-width: 88vw;
        max-height: 70vh;
        overflow-y: auto;
    }

    /* Narrative inputs: font-size >= 16px prevents iOS zoom-on-focus */
    .narrative-input {
        font-size: 16px;
    }

    /* Narrative button: full width on phone */
    .narrative-btn {
        width: 100%;
    }

    /* JUMP IN button: wider tap area */
    #start-btn-container button {
        padding: 18px 0 !important;
        width: min(300px, 85vw) !important;
        font-size: 1rem !important;
    }
}

/* iPhone landscape: very compact, keep controls accessible */
@media (max-height: 500px) and (orientation: landscape) {
    #top-controls {
        right: max(12px, var(--safe-right));
        top: max(8px, var(--safe-top)) !important;
        gap: 4px !important;
    }

    #top-left-controls {
        top: max(8px, var(--safe-top)) !important;
    }

    .narrative-card {
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 12px;
    }

    #narrative-overlay,
    #question-overlay {
        align-items: center;
        padding: 8px;
    }
}

/* FULLSCREEN FIXES */
#canvas-container,
#room-title-overlay,
#loading,
#top-controls,
#top-left-controls,
#back-btn,
#discover-btn,
#lyrics-container {
    transition: all 0.2s ease;
}


#room-title-overlay {
    position: fixed !important;
    inset: 0 !important;
    height: 100dvh !important;
    width: 100% !important;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
	will-change: opacity;
}

#room-title-text {
    font-family: 'Lato', sans-serif !important;
    font-weight: 300 !important;
    font-size: clamp(3rem, 13vw, 10rem) !important;
    text-align: center;
    padding: 0 5vw;
    text-shadow: 0 0 40px rgba(0,0,0,0.9);
	user-select: none;
    -webkit-user-select: none;
}

#room-title-text .intro-title-word {
    display: block;
    text-transform: uppercase;
}

#room-title-text .intro-title-word-small {
    font-size: 0.38em;
    letter-spacing: 0.18em;
    margin-bottom: 0.2em;
}

#room-title-text .intro-title-word-large {
    font-size: 1em;
    letter-spacing: 0.12em;
}

#room-title-text .intro-title-word-large + .intro-title-word-small {
    margin-top: 0.18em;
}

#loading {
    height: 100dvh !important;
}
