/* ==========================================================================
   HEADS-UP DISPLAY (HUD) GRID & LAYOUT — Roman Antiquity Theme
   ========================================================================== */

.hud-layer {
    position: absolute;
    inset: 0;
    z-index: 1000;
    pointer-events: none;

    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-w);
    grid-template-rows: var(--topbar-h) 1fr var(--bottombar-h);
    padding: var(--gap);
    padding-bottom: calc(var(--gap) * 0.5);
    gap: var(--gap);
}


/* Re-enable pointer events for specific panel interface components */
.hud-layer * {
    pointer-events: auto;
}

.hud-panel {
    background: var(--panel-bg);
    /* Layered Roman stone border — double line effect */
    border: 1px solid var(--border-accent);
    outline: 1px solid rgba(200, 150, 90, 0.08);
    outline-offset: 3px;
    border-radius: 2px;
    padding: 14px 16px;
    box-shadow:
        0 4px 28px rgba(0, 0, 0, 0.75),
        var(--panel-inset),
        inset 1px 0 0 rgba(240, 230, 206, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Stone texture: subtle crosshatch via repeating gradient */
    background-image:
        linear-gradient(rgba(200, 150, 90, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(200, 150, 90, 0.025) 1px, transparent 1px);
    background-size: 24px 24px;
    background-color: var(--panel-bg);
    z-index: 1000;
}

/* Right sidebar panels: flexible scaling */
#right-sidebar .hud-panel {
    flex: 1 1 auto;
    min-height: 200px;
    overflow: hidden;
}

/* Top Dashboard Navigation / Status Bar */
#top-bar {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    overflow: visible !important;
    /* Imperial purple-red top stripe */
    border-top: 3px solid var(--accent-primary);
    background-image:
        linear-gradient(to bottom, rgba(200, 150, 90, 0.08) 0%, transparent 60%),
        linear-gradient(rgba(200, 150, 90, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(200, 150, 90, 0.02) 1px, transparent 1px);
    background-size: auto, 24px 24px, 24px 24px;
    background-color: var(--panel-bg);
    padding: 0 20px;
}

/* Sidebars Base Positioning */
#left-sidebar {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0.5s;
    position: relative;
    z-index: 12;
    height: 100%;
    min-height: 0;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#right-sidebar {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0.5s;
    height: 100%;
    min-height: 0;
    position: relative;
    z-index: 12;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* Show sidebars when case is active/selected */
#left-sidebar.active,
#right-sidebar.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* Bottom Control Deck */
#bottom-bar {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 15;
}

/* Panel Toggle Buttons */
/* Panel Toggle Buttons */
.panel-toggle-btn {
    position: fixed;
    z-index: 20;
    background: var(--panel-bg);
    border: 1px solid var(--border-accent);
    color: var(--accent-primary);
    width: 18px;
    height: 44px;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.panel-toggle-btn:hover {
    background: rgba(200, 150, 90, 0.18);
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

#toggle-left-btn {
    left: 0;
    bottom: 180px;
    /* Centered vertically with the mobile d-pad */
    border-left: none;
    border-radius: 0 4px 4px 0;
}

#toggle-right-btn {
    right: 0;
    bottom: 180px;
    /* Centered vertically with the minimap radar */
    border-right: none;
    border-radius: 4px 0 0 4px;
}

@media (max-width: 639px) {
    #toggle-right-btn {
        bottom: 180px;
        /* Adjusted for the raised mobile minimap position */
    }
}

#left-sidebar.panel-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-18px);
    visibility: hidden;
}

#right-sidebar.panel-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(18px);
    visibility: hidden;
}

/* Mobile Close Button Styling */
.modal-close-btn {
    background: rgba(20, 12, 4, 0.4);
    border: 1px solid var(--accent-error);
    color: var(--accent-error);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    cursor: pointer;
    font-size: 1rem;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: var(--accent-error);
    color: #fff;
    transform: scale(1.1);
}

@media (max-width: 639px) {
    .modal-close-btn {
        background: rgba(20, 12, 4, 1);
    }
}

/* ==========================================================================
   RESPONSIVE HUD LAYOUT (Breakpoint: < 640px)
   ========================================================================== */

@media (max-width: 639px) {

    /* Hide desktop-specific sidebars and toggle controls */
    #left-sidebar,
    #right-sidebar,
    .panel-toggle-btn {
        /* display: none; */
    }


    /* Transform sidebars into full-screen overlays when active on mobile */
    #left-sidebar.active,
    #right-sidebar.active {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 5000;
        background: var(--panel-bg);
        padding: 20px;
        flex-direction: column;
    }
}


/* ==========================================================================
   CONTROL GROUP RIGHT — HUD UTILITY BUTTONS
   ========================================================================== */


.control-group-right {
    display: flex;
    gap: 10px;
    align-items: center;
}


.hud-row-btn {
    background: rgba(200, 150, 90, 0.1);
    color: var(--accent-secondary);
    border: 1px solid var(--border-gold);
    font-weight: 700;
    font-family: 'Cinzel', serif;
    padding: 4px 8px;
    border-radius: 2px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-size: 0.72rem;
    display: flex;

    width: auto;
    min-width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}


.hud-row-btn:hover {
    background: rgba(200, 150, 90, 0.15);
    color: var(--accent-primary);
    border-color: var(--border-gold);
    box-shadow: 0 0 12px rgba(200, 150, 90, 0.2);
}

/* Active State */
.hud-row-btn.active {
    color: var(--accent-secondary);
    border-color: var(--border-gold);
    background: rgba(232, 197, 106, 0.12);
}


/* Verse block */
.verse-block {
    padding: 10px 0;
    border-bottom: 1px solid rgba(92, 74, 42, 0.1);
    display: flex;
    gap: 14px;
    align-items: baseline;
    animation: verseIn 0.35s ease both;
}

@keyframes verseIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

.verse-block.anchor-verse {
    background: rgba(184, 134, 11, 0.06);
    margin: 0 -10px;
    padding: 10px 10px;
    border-radius: 2px;
    border-bottom: 1px solid rgba(184, 134, 11, 0.15);
}

.verse-num {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 600;
    min-width: 20px;
    text-align: right;
    padding-top: 2px;
    flex-shrink: 0;
}

.verse-text {
    font-size: 1.1rem;
    line-height: 1.75;
    color: var(--text-main);
    margin-top: 12px;
}

.verse-block.prev-verse .verse-text {
    color: var(--sepia);
}

/* Load more strip */
.load-more-strip {
    padding: 14px 0 18px;
    text-align: center;
    border-top: 1px dashed var(--parchment-dark);
    margin: 10px auto;
}

.load-more-strip:hover {
    background: rgba(200, 150, 90, 0.08);
    cursor: pointer;
}

/* Load previous button strip */
.load-prev-strip {
    padding: 14px 0 10px;
    text-align: center;
    border-bottom: 1px dashed var(--parchment-dark);
}

.load-prev-strip:hover {
    background: rgba(200, 150, 90, 0.08);
    cursor: pointer;
}

/* ═══════════════════════════════════════════
   UI TOGGLE BUTTONS
═══════════════════════════════════════════ */
.ui-toggle {
    width: var(--btn-sz);
    height: var(--btn-sz);
    min-width: 44px;
    min-height: 44px;
    background: rgba(8, 6, 4, 0.85);
    border: 1px solid var(--border);
    color: var(--accent);
    cursor: pointer;
    font-size: 1.15em;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    box-shadow: var(--glow-sm);
    pointer-events: auto;
}

.ui-toggle:hover {
    background: rgba(100, 255, 218, 0.15);
    box-shadow: var(--glow-md);
}

.ui-toggle:active {
    transform: scale(.9);
}

.ui-toggle.active {
    background: rgba(100, 255, 218, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}



/* ═══════════════════════════════════════════
       MOBILE  CONTROLS
    ═══════════════════════════════════════════ */

.mobile-only {
    display: none;
}

@media (max-width: 639px) {
    .mobile-only {
        display: flex;
    }


}






#mobile-ctrl {
    position: fixed;
    bottom: 120px;
    /* Raised to clear the mobile nav bar */
    left: 40px;
    width: 160px;
    height: 160px;
    z-index: 5;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(100, 255, 218, 0.05);
    border-radius: 50%;
}



.mobile-movement,
.mobile-actions {
    display: contents;
    /* Ensure absolute children position correctly relative to #mobile-ctrl */
}

#mobile-ctrl .ui-toggle {
    position: absolute;
    pointer-events: auto;
    touch-action: none;
    margin: 0;
}

#ctrl-up {
    top: 0;
    left: calc(50% - (var(--btn-sz) / 2));
}

#ctrl-down {
    bottom: 0;
    left: calc(50% - (var(--btn-sz) / 2));
}

#ctrl-left {
    left: 0;
    top: calc(50% - (var(--btn-sz) / 2));
}

#ctrl-right {
    right: 0;
    top: calc(50% - (var(--btn-sz) / 2));
}

#ctrl-jump {
    top: calc(50% - (var(--btn-sz) / 2));
    left: calc(50% - (var(--btn-sz) / 2));
    background: rgba(100, 255, 218, 0.15);
}

.icon-svg {
    width: 2em;
    height: 2em;
    vertical-align: -1.125em;
    display: inline-block;
}