/* ============================================
   LAYER 2 QUEST - Styles
   90s Pixel Art Playful Adventure
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --dungeon-dark: #1A1A2E;
    --stone-wall: #2D2D44;
    --quest-gold: #F0E68C;
    --mana-blue: #7EC8E3;
    --heart-red: #FF6B6B;
    --potion-green: #98D8A0;
    --parchment: #E8E0D0;
    --shadow-gray: #7A7A9A;
    --frame-slate: #4A4A6A;

    --font-pixel: 'Press Start 2P', monospace;
    --font-body: 'Nunito', sans-serif;

    --status-bar-height: 48px;
    --inventory-height: 64px;
    --map-width: 360px;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--dungeon-dark);
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.75;
    image-rendering: pixelated;
}

/* --- Title Screen --- */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dungeon-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    transition: opacity 0.5s ease;
}

#title-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#title-screen .pixel-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#title-text {
    font-family: var(--font-pixel);
    font-size: 36px;
    color: var(--quest-gold);
    letter-spacing: 0.05em;
    text-shadow:
        0 0 20px rgba(240, 230, 140, 0.4),
        0 0 40px rgba(240, 230, 140, 0.2);
    animation: title-pulse 2s ease-in-out infinite;
    z-index: 1;
    text-align: center;
    padding: 0 20px;
}

#title-subtitle {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--shadow-gray);
    margin-top: 32px;
    z-index: 1;
    animation: blink-text 1.5s step-end infinite;
}

@keyframes title-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1.0; }
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Pixel stars for title */
.pixel-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    animation: star-twinkle 3s ease-in-out infinite;
}

@keyframes star-twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* --- Game Interface --- */
#game-interface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#game-interface.hidden {
    display: none;
}

#game-interface.revealing .slide-from-left {
    animation: slide-in-left 500ms ease-out forwards;
}

#game-interface.revealing .slide-from-right {
    animation: slide-in-right 500ms ease-out 200ms forwards;
}

@keyframes slide-in-left {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-in-right {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- Status Bar --- */
#status-bar {
    height: var(--status-bar-height);
    min-height: var(--status-bar-height);
    background: var(--dungeon-dark);
    border-bottom: 1px solid var(--frame-slate);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10;
}

.status-label {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--mana-blue);
    display: block;
    margin-bottom: 2px;
}

.status-name {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--quest-gold);
}

.status-level {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--quest-gold);
}

.status-left,
.status-right {
    flex: 0 0 auto;
    text-align: center;
}

.status-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
}

.status-center .status-label {
    margin-bottom: 0;
    white-space: nowrap;
}

.xp-bar {
    width: 160px;
    height: 16px;
    background: var(--stone-wall);
    border: 2px solid var(--frame-slate);
    position: relative;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--potion-green), var(--mana-blue));
    transition: width 0.6s ease;
    display: flex;
}

.xp-segment {
    flex: 1;
    border-right: 1px solid rgba(26, 26, 46, 0.4);
}

.xp-segment:last-child {
    border-right: none;
}

.xp-text {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--parchment);
    white-space: nowrap;
}

/* --- Main Content Area --- */
#main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* --- Left Panel: Map --- */
#map-panel {
    width: var(--map-width);
    min-width: var(--map-width);
    background: var(--dungeon-dark);
    border-right: 2px solid var(--frame-slate);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-100%);
}

#map-panel.revealed {
    opacity: 1;
    transform: translateX(0);
}

.map-title {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--quest-gold);
    text-align: center;
    padding: 8px;
    border-bottom: 1px solid var(--frame-slate);
    letter-spacing: 0.05em;
}

.overworld-map {
    flex: 1;
    position: relative;
    overflow: hidden;
    transition: transform 0.4s ease;
    transform-origin: center center;
}

.map-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.map-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.3;
}

/* Map terrain */
.map-terrain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.pixel-mountain {
    position: absolute;
    width: 0;
    height: 0;
}

.mountain-1 {
    bottom: 60%;
    left: 5%;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 30px solid var(--stone-wall);
    opacity: 0.3;
}

.mountain-2 {
    bottom: 55%;
    left: 15%;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 22px solid var(--stone-wall);
    opacity: 0.25;
}

.pixel-river {
    position: absolute;
    bottom: 35%;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--mana-blue);
    opacity: 0.15;
}

/* Map Nodes */
.map-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.3s ease;
    z-index: 5;
}

.map-node:hover {
    transform: scale(1.15);
    filter: brightness(1.3);
}

.map-node.visited .node-icon {
    filter: brightness(1.4) drop-shadow(0 0 6px var(--quest-gold));
}

.map-node.active {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px var(--mana-blue));
}

#node-optimistic {
    top: 18%;
    left: 12%;
}

#node-zk {
    top: 10%;
    left: 48%;
}

#node-bridge {
    top: 42%;
    left: 68%;
}

#node-sidechain {
    top: 70%;
    left: 35%;
}

.node-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pixel-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.pixel-icon-small {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

.pixel-icon-tiny {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.node-label {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--parchment);
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
    text-shadow: 1px 1px 0 var(--dungeon-dark);
}

/* 2-frame pixel animation at 2fps */
.pixel-anim-a {
    animation: pixel-frame-toggle 1s step-end infinite;
}

.pixel-anim-b {
    animation: pixel-frame-toggle 1s step-end infinite reverse;
}

@keyframes pixel-frame-toggle {
    0%, 49.9% { opacity: 1; }
    50%, 100% { opacity: 0.4; }
}

/* --- Right Panel: Dungeon --- */
#dungeon-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
}

#dungeon-panel.revealed {
    opacity: 1;
    transform: translateX(0);
}

.dungeon-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.dungeon-scroll::-webkit-scrollbar {
    width: 8px;
}

.dungeon-scroll::-webkit-scrollbar-track {
    background: var(--dungeon-dark);
}

.dungeon-scroll::-webkit-scrollbar-thumb {
    background: var(--frame-slate);
    border: 1px solid var(--stone-wall);
}

/* --- Dialogue Boxes --- */
.dialogue-box {
    background: var(--stone-wall);
    border: 3px solid var(--frame-slate);
    border-radius: 0;
    margin-bottom: 20px;
    padding: 0;
    position: relative;
    /* Pixel-art border effect */
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.05),
        inset -2px -2px 0 rgba(0, 0, 0, 0.2),
        4px 4px 0 rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dialogue-box.visible {
    opacity: 1;
    transform: translateY(0);
}

.dialogue-header {
    background: var(--dungeon-dark);
    border-bottom: 2px solid var(--frame-slate);
    padding: 6px 12px;
}

.dialogue-label {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--mana-blue);
    letter-spacing: 0.05em;
}

.dialogue-content {
    padding: 16px;
}

.dialogue-content p {
    margin-bottom: 12px;
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.75;
}

.dialogue-content p:last-child {
    margin-bottom: 0;
}

.dialogue-content strong {
    color: var(--quest-gold);
    font-weight: 700;
}

.dialogue-indicator {
    text-align: center;
    padding: 4px;
    color: var(--quest-gold);
    font-size: 10px;
    animation: bounce-indicator 1s ease-in-out infinite;
}

@keyframes bounce-indicator {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

/* Typewriter effect */
.typewriter-text {
    color: var(--quest-gold);
    font-weight: 600;
}

.typewriter-text.typing {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--quest-gold);
    animation: blink-cursor 0.6s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { border-color: var(--quest-gold); }
    50% { border-color: transparent; }
}

/* --- Protocol Sections --- */
.protocol-section {
    margin-bottom: 32px;
    padding-top: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.section-title {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--quest-gold);
    letter-spacing: 0.05em;
    line-height: 1.4;
}

/* --- Knowledge Items --- */
.knowledge-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(240, 230, 140, 0.08);
    border: 2px solid var(--quest-gold);
    margin-top: 12px;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.knowledge-item.collected {
    opacity: 1;
    transform: translateY(0);
}

.knowledge-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.knowledge-label {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--quest-gold);
    letter-spacing: 0.05em;
}

/* --- Inventory Dock --- */
#inventory-dock {
    height: var(--inventory-height);
    min-height: var(--inventory-height);
    background: var(--dungeon-dark);
    border-top: 2px solid var(--frame-slate);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 10;
}

.inventory-label {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--shadow-gray);
    white-space: nowrap;
}

.inventory-slots {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.inventory-slot {
    width: 48px;
    height: 48px;
    background: var(--stone-wall);
    border: 2px solid var(--frame-slate);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0.25;
    transition: opacity 0.3s ease;
    position: relative;
}

.inventory-slot.acquired {
    opacity: 1;
    animation: bounce-enter 0.5s ease;
}

.inventory-slot .slot-icon {
    width: 16px;
    height: 16px;
}

.inventory-slot .slot-label {
    font-family: var(--font-pixel);
    font-size: 5px;
    color: var(--parchment);
    margin-top: 2px;
}

@keyframes bounce-enter {
    0% { transform: translateY(-20px); opacity: 0; }
    40% { transform: translateY(4px); opacity: 1; }
    60% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}

/* Sparkle effect on acquired items */
.inventory-slot.acquired::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: var(--quest-gold);
    animation: sparkle 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes sparkle {
    0% { opacity: 1; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.5); }
    100% { opacity: 0; transform: scale(0.5); }
}

/* --- Quest Complete --- */
.quest-complete-box {
    border-color: var(--quest-gold);
    box-shadow:
        inset 2px 2px 0 rgba(240, 230, 140, 0.1),
        inset -2px -2px 0 rgba(0, 0, 0, 0.2),
        4px 4px 0 rgba(0, 0, 0, 0.3),
        0 0 20px rgba(240, 230, 140, 0.15);
}

.quest-complete-box .dialogue-label {
    color: var(--quest-gold);
}

/* --- Musical Note Particles --- */
#note-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.note-particle {
    position: absolute;
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--quest-gold);
    opacity: 0;
    animation: note-float 1.2s ease-out forwards;
    pointer-events: none;
}

@keyframes note-float {
    0% {
        opacity: 0.8;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(0.6);
    }
}

/* --- Screen Shake --- */
.screen-shake {
    animation: shake 0.2s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(2px, -1px); }
    50% { transform: translate(-2px, 2px); }
    75% { transform: translate(1px, -2px); }
}

/* --- Map Zoom Focus --- */
.overworld-map.zooming {
    transition: transform 0.4s ease;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    :root {
        --map-width: 100%;
        --status-bar-height: 40px;
        --inventory-height: 56px;
    }

    #title-text {
        font-size: 20px;
    }

    #title-subtitle {
        font-size: 8px;
    }

    #main-content {
        flex-direction: column;
    }

    #map-panel {
        width: 100%;
        min-width: 100%;
        height: 120px;
        min-height: 120px;
        border-right: none;
        border-bottom: 2px solid var(--frame-slate);
        flex-direction: row;
    }

    .map-title {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        padding: 4px;
        font-size: 7px;
        border-bottom: none;
        border-right: 1px solid var(--frame-slate);
    }

    .overworld-map {
        overflow-x: auto;
        overflow-y: hidden;
    }

    .map-node {
        position: relative;
        display: inline-flex;
        margin: 8px 16px;
        top: auto !important;
        left: auto !important;
    }

    #map-panel .overworld-map {
        display: flex;
        flex-direction: row;
        align-items: center;
        white-space: nowrap;
    }

    .map-grid,
    .map-terrain {
        display: none;
    }

    .map-stars {
        display: none;
    }

    .dungeon-scroll {
        padding: 16px;
    }

    .section-title {
        font-size: 11px;
    }

    .status-center .status-label {
        display: none;
    }

    .xp-bar {
        width: 100px;
    }

    .dialogue-content p {
        font-size: 14px;
    }

    .inventory-slot {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    #title-text {
        font-size: 16px;
    }

    .section-title {
        font-size: 9px;
    }

    .xp-bar {
        width: 80px;
    }

    .status-left {
        display: none;
    }
}
