/* ============================================================
   basestyle.css — LVNE Structural Foundation (v3.1 Enhanced)
   ============================================================
   Layout, positioning, sizing, responsive rules only.
   Visual styling lives in theme CSS files.
   ============================================================ */

/* ── Fallback defaults ── */
:root {
    --font-primary: Arial, sans-serif;
    --font-display: Georgia, serif;
    --color-bg: #222;
    --color-surface: rgba(30, 30, 30, 0.9);
    --color-text: #ddd;
    --color-accent: #6cf;
    --color-accent-alt: #f6c;
    --color-border: #6cf;
    --color-overlay-bg: rgba(0, 0, 0, 0.7);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --transition-speed: 0.3s;
}

/* ── Reset & Global ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-primary);
    overflow: hidden;
    background-color: var(--color-bg);
    color: var(--color-text);
    /* AAA text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 100px;
    opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

/* ── Screen System ── */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

/* ── Home Screen ── */
.home-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-size: cover;
    background-position: center;
    position: relative;
}

.glass-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.content {
    position: relative;
    z-index: 1;
    text-align: center;
}

h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--color-accent);
}

/* ── Buttons ── */
.button {
    font-family: var(--font-display);
    font-size: 1.5rem;
    padding: 1rem 2rem;
    margin: 1rem;
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
}

.button:hover {
    opacity: 0.9;
}

.home-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

/* ── Menu Icon ── */
.menu-icon {
    position: fixed;
    top: 10px;
    left: 10px;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    color: var(--color-accent);
    transition: all var(--transition-speed) ease;
    will-change: transform;
}

/* ── Overlays ── */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-overlay-bg);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.overlay-content {
    position: relative;
    padding: 20px;
    width: 80%;
    height: 80%;
    margin: 5% auto;
    background-color: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    will-change: transform;
}

.overlay-header {
    background-color: var(--color-surface);
    color: var(--color-accent);
    padding: 10px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-accent);
    transition: all var(--transition-speed) ease;
    will-change: transform;
}

/* ── Settings Controls ── */
.settings-option {
    margin-bottom: 15px;
}

.settings-option label {
    display: block;
    margin-bottom: 5px;
    color: var(--color-text);
    font-family: var(--font-display);
}

input[type="range"] {
    width: 100%;
    height: 10px;
    background: var(--color-surface);
    outline: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ── Character Sprites ── */
#characterSpriteContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: inset(0 0 calc(37% - 10px) 0);
    z-index: 1;
    pointer-events: none;
}

.character-sprite {
    position: absolute;
    bottom: 30%;
    max-height: 65%;
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    will-change: transform, opacity;
    /* GPU-accelerated compositing */
    transform: translateZ(0);
    backface-visibility: hidden;
}

.character-sprite.active {
    opacity: 1;
}

.left-sprite {
    left: 2%;
}

.left-sprite.active {
    animation: slideInLeft 0.5s ease-out;
}

.right-sprite {
    right: 2%;
}

.right-sprite.active {
    animation: slideInRight 0.5s ease-out;
}

.center-sprite {
    left: 50%;
    transform: translateX(-50%);
}

.center-sprite.active {
    animation: slideInCenter 0.5s ease-out;
}

/* ── Story Screen ── */
.story-container {
    position: relative;
    z-index: 2;
}

/* ── Dialogue System ── */
.dialogue-container {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 98%;
    height: 35%;
    position: fixed;
    bottom: 2%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    background-color: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    padding-bottom: 8px;
    will-change: transform;
}

.dialogue-header {
    background-color: var(--color-surface);
    color: var(--color-accent);
    padding: 10px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialogue-content {
    flex: 1;
    padding: 15px 20px 25px;
    color: var(--color-text);
    font-size: clamp(14px, 4vw, 18px);
    line-height: 1.6;
    overflow-y: auto;
}

#typedText {
    margin: 0;
}

.dialogue-options {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 6px 16px 12px;
    margin-top: auto;
}

/* ── SVG Navigation Controls ── */
.nav-icon-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48px;
    height: 48px;
    cursor: pointer;
    background: transparent;
    border: none;
    position: relative;
    padding: 0;
    transition: all var(--transition-speed) ease;
    will-change: transform, opacity;
}

.nav-icon-btn.nav-back { justify-self: start; }
.nav-icon-btn.nav-next-skip { justify-self: end; }

.nav-icon-btn:disabled, .auto-btn:disabled {
    opacity: 0.35 !important;
    pointer-events: none;
    cursor: default;
    color: inherit;
    border-color: inherit;
}

.nav-icon-btn svg {
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.icon-layer {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Skip/Next Morphing State */
.show-skip .icon-next { opacity: 0; transform: scale(0.8) translateX(10px); }
.show-skip .icon-skip { opacity: 1; transform: scale(1) translateX(0); }
.show-next .icon-next { opacity: 1; transform: scale(1) translateX(0); }
.show-next .icon-skip { opacity: 0; transform: scale(0.8) translateX(-10px); }

/* Center Auto Button */
.auto-btn {
    justify-self: center;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 100px;
    cursor: pointer;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    transition: all var(--transition-speed) ease;
    will-change: transform;
}



/* ── Effect Overlays ── */
.effect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    display: none;
}

.overlay-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
}

#overlayFrame {
    width: 100%;
    height: calc(100% - 40px);
    border: none;
}

/* ── End Screen ── */
.end-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--color-bg);
}

.end-glass-panel {
    background: var(--glass-bg, rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-lg);
    padding: 3rem 4rem;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    max-width: 90%;
    animation: fadeIn 1s ease-out;
    will-change: transform, opacity;
}

.end-message {
    font-family: var(--font-display);
    font-size: 3rem;
    margin: 0 0 0.5rem 0;
    color: var(--color-accent);
}

.end-subtext {
    font-size: 1.1rem;
    opacity: 0.7;
    margin-bottom: 2.5rem;
}

.end-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

/* ── Structural Animations ── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInCenter {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }

    .button {
        font-size: 1.2rem;
        padding: 0.8rem 1.6rem;
    }

    .dialogue-container {
        width: 95%;
        height: 40vh;
        bottom: 1.5%;
    }

    .dialogue-content {
        padding: 12px 15px 23px;
    }

    .dialogue-options { padding: 3px 15px 10px; }
    
    .nav-icon-btn { width: 44px; height: 44px; }
    .auto-btn { font-size: 0.7rem; padding: 6px 14px; }

    .overlay-content {
        width: 90%;
        height: 85%;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.8rem; }

    .button {
        font-size: 1rem;
        padding: 0.6rem 1.2rem;
    }

    .home-menu { gap: 1rem; }

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

    .dialogue-container {
        width: 98%;
        height: 45vh;
        bottom: 1%;
    }

    .dialogue-content {
        padding: 10px 12px 20px;
    }

    .dialogue-options {
        padding: 4px 12px 8px;
    }

    .nav-icon-btn { width: 40px; height: 40px; }
    .nav-icon-btn svg { width: 22px; height: 22px; }
    .auto-btn { font-size: 0.65rem; padding: 6px 12px; }
}

@media (max-height: 480px) and (orientation: landscape) {
    h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .button {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
        margin: 0.3rem;
    }

    .home-menu {
        gap: 0.8rem;
        margin-top: 0.5rem;
    }

    .menu-icon {
        top: 5px;
        left: 5px;
        padding: 4px;
    }

    .dialogue-container {
        width: 98%;
        height: 42%;
        bottom: 2%;
    }

    .dialogue-header {
        font-size: 14px;
        padding: 4px 10px;
    }

    .dialogue-content {
        padding: 5px 12px;
        font-size: 13px;
        line-height: 1.4;
    }

    .dialogue-options {
        padding: 4px 10px 6px;
        gap: 12px;
    }
    
    .dialogue-options::-webkit-scrollbar { display: none; }
    
    .nav-icon-btn { width: 36px; height: 36px; }
    .nav-icon-btn svg { width: 18px; height: 18px; }
    .auto-btn { font-size: 0.7rem; padding: 4px 12px; }

    .overlay-content {
        width: 95%;
        height: 90%;
        margin: 2% auto;
        padding: 10px;
    }

    #characterSpriteContainer {
        clip-path: inset(0 0 calc(44% - 10px) 0);
    }
}