/* Part 3 of 7 of the game's stylesheet (was style.css; the parts load in order, so rule
   order is exactly as before). Mostly: Chronicle book and journal (table of contents, chapters, reader), sprite sheets, map progression, status labels, Sanctuary base UI. */

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 600px) {
    .modal-box.book-theme {
        padding: 20px !important;
        border-width: 4px !important;
        width: 95% !important;
        max-height: 85dvh;
    }
    .book-theme h1 { font-size: 22px !important; margin-bottom: 10px !important; }
    .book-theme h2 { font-size: 16px !important; margin-bottom: 15px !important; }
    #story-text-container { font-size: 14px !important; }
    .book-theme #story-text-container::first-letter { font-size: 2.8em !important; }
}

/* --- 1. ANIMATIONS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 2. LAYOUT CONTAINER --- */

/* --- 3. SIDEBAR (Dense List) --- */

/* Scrollbar Styling */

/* Act Separator (Visual Break) */

/* Chapter Button */

/* --- 4. RIGHT SIDE (Reader) --- */

/* Outline Box */

/* Next/Prev Controls */

/* --- 5. MOBILE RESPONSIVENESS (Slim Mode) --- */

/* Sidebar: Darker, almost black leather feel */

/* Page Container: Deep charcoal, slightly lighter than sidebar */

/* The actual text color: slightly warm off-white, easier to read than pure gray */

/* Make the active button glow subtle gold */

/* Improve the "Key Points" box to look like a footnote area */

/* --- 1. ANIMATIONS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeInUp 0.3s ease-out forwards;
}

/* --- 2. LAYOUT CONTAINER --- */
.journal-layout { 
    border-top: 1px solid #333; 
    flex-direction: row; /* Stays as a row even on mobile */ 
    overflow: hidden; 
    display: grid; 
    grid-template-columns: 55px 1fr; /* Thin gutter for icons/numbers */ 
    height: 100%; 
    width: 100%; 
}

/* --- 3. SIDEBAR (Dark Leather Look) --- */

/* Scrollbars */
.journal-sidebar::-webkit-scrollbar,
.journal-page-container::-webkit-scrollbar { width: 6px; }
.journal-sidebar::-webkit-scrollbar-track,
.journal-page-container::-webkit-scrollbar-track { background: #000; }
.journal-sidebar::-webkit-scrollbar-thumb,
.journal-page-container::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ACT SEPARATORS (Gold Headers) */

/* CHAPTER BUTTONS */

/* Active State (Glow) */

.toc-num {
    min-width: 25px;
    color: #444;
    text-align: center;
    font-family: serif;
    font-weight: bold;
}

/* --- SPECIAL BUTTON STYLES --- */
/* Interludes (Purple/Magic) */

/* Final/Boss (Red) */


/* --- 4. RIGHT SIDE (Reader Page) --- */
.journal-page-container { /* Deep Charcoal */
    scroll-behavior: smooth;
    box-shadow: inset 10px 0 20px -10px rgba(0,0,0,0.5); /* Book binding shadow */
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.journal-header h3 {
    margin-top: 0;
    font-size: 1.8rem;
    font-family: 'Cinzel', serif;
    color: var(--accent-gold, var(--gold-bright));
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
    margin-bottom: 25px;
}
.journal-header h3 div {
    font-size:1em !important;
    margin-bottom: 10px;
}

.journal-body {
    font-family: 'Crimson Pro', serif;
    font-size: 1.15rem; /* Slightly larger for reading */
    line-height: 1.8;
    color: #dcdcdc; /* Warm off-white */
}
.journal-body p { margin-bottom: 20px; }

/* Footer (Key Points) */
.journal-footer {
    margin-top: 40px;
    padding: 20px;
    background: #0f0f0f;
    border: 1px solid #333;
    border-left: 2px solid #555;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #888;
}

/* Nav Controls */
.journal-controls {
    justify-content: space-between;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.nav-btn {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    transition: all 0.2s;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-btn:hover {
    border-color: var(--accent-gold, var(--gold-bright));
    color: var(--accent-gold, var(--gold-bright));
    background: rgba(255, 255, 255, 0.05);
}

/* --- 5. MOBILE RESPONSIVENESS --- */

/* --- SPECIAL BUTTON STYLES --- */

/* 1. ACT HEADER BUTTON (Clickable, looks like a banner) */

/* 2. INTERLUDE / PRELUDE / PROLOGUE */

/* 3. FINAL CHAPTER (Optional) */
/* 1. ACT HEADER BUTTON (Clickable, Gold) */

/* Ensure the Number/Symbol IS visible for Acts now */

/* --- 5. MOBILE RESPONSIVENESS (Slim Mode) --- */

/* --- 5. MOBILE RESPONSIVENESS (Slim Mode & Readable Text) --- */
@media (max-width: 800px) {
    /* 1. Sidebar adjustments (Keep existing logic) */
    .toc-num { font-size: 1.2rem; }

    /* Act Button Styling for Mobile */

    /* --- 2. TEXT READABILITY FIXES (New) --- */
    
    .journal-page-container { 
        padding: 20px 15px; /* Reduce padding significantly (was 40px 50px) */
    }

    .journal-header h3 {
        font-size: 1.4rem; /* Smaller header so it doesn't wrap awkwardly */
        margin-bottom: 15px;
        padding-bottom: 10px;
        line-height: 1.3;
    }

    .journal-body {
        font-size: 1rem; /* slightly smaller body text */
        line-height: 1.6; /* tighter line height for small screens */
    }

    .journal-body p {
        margin-bottom: 15px; /* Less space between paragraphs */
    }

    .journal-footer {
        margin-top: 25px;
        padding: 15px;
        font-size: 0.85rem;
    }

    /* Controls: Stack them */
    .journal-controls { 
        flex-direction: column; 
        gap: 12px; 
        margin-top: 30px;
    }
    .nav-btn { 
        width: 100%; 
        text-align: center; 
        padding: 12px; /* Easier to tap with fingers */
    }
}
/* --- IMPROVED CHRONICLE SIDEBAR --- */

/* 1. The ACT HEADER (Distinct from chapters) */

/* 2. REGULAR CHAPTERS (Indented) */

/* 3. MOBILE ADJUSTMENTS */

/* --- SPRITE SHEET SYSTEM --- */
:root {
    --icon-size: 32px; /* The size of one icon in the grid */
    --sheet-url: url('../assets/sprites.webp'); /* Rename your file to this for simplicity */
    --sheet-url2: url('../assets/sprites2.webp');
}

/* Base Icon Class */
.pixel-icon {
    display: inline-block;
    width: var(--icon-size);
    height: var(--icon-size);
    background-image: var(--sheet-url2);
    background-repeat: no-repeat;
     /* Keeps it crisp */
    vertical-align: middle;
    
    /* Calculate position based on row/col index */
    /* format: --x (column), --y (row) */
    background-position: calc(var(--x) * -1 * var(--icon-size)) calc(var(--y) * -1 * var(--icon-size));
}

/* Size Modifiers */
.icon-sm { transform: scale(0.75); } /* For text inlines */
.icon-lg { transform: scale(1.5); }  /* For headers */
.icon-xl { transform: scale(2.5); }  /* For main combat display if used for enemies */

/* Button integration fix */

/* Align icons in the bottom navigation dock */
.dock-item .pixel-icon {
    display: block;      /* Stack icon above text */
    margin: 0 auto 4px;  /* Center horizontally, add space below */
    transform: scale(1.2); /* Make them slightly larger */
    display: block;
    margin: 0 auto 2px;
    /* THE FIX: Scale based on original size */
    /* If it's a 32px icon, scale(0.8) makes it ~25px */
    /* If it's a 64px character, scale(0.4) makes it ~25px */
    transform: scale(0.8);
    transform-origin: center;
    /* Ensure tall icons don't push text down */
    max-height: 32px;
}

/* Ensure the text is still visible and nice */

/* Add to src/style.css */

/* Giant Icon for Sanctuary */
.icon-giant {
    transform: scale(3); 
    margin: 10px;
}

/* Fix alignment for icons inside text buttons */
.btn-action .pixel-icon {
    vertical-align: middle;
    margin-top: -4px;
    margin-right: 8px;
}

/* --- MOBILE-FIRST MAP PROGRESSION --- */

/* 1. Flip the order so ID 0 (Sanctuary) is at the bottom */
#loc-container {
    padding-bottom: 30px; /* Space for the bottom nav */
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    width: 100%;
    /* Ensure the container height doesn't shift wildly when cards expand */
    min-height: 500px;
}

/* 2. Distinct Style for Sanctuary (Home Base) */
.location-card[data-id="0"] {
    /*background: linear-gradient(90deg, rgba(var(--accent-gold-rgb), 0.15), rgba(0, 0, 0, 0.4)) !important;*/
    border: 2px solid var(--accent-gold) !important;
    /*border-left: 8px solid var(--accent-gold) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(var(--accent-gold-rgb), 0.2) !important;
    margin-top: 20px;
    border-radius: 12px !important;*/
    /* 1. Add a solid background color BEFORE the gradient to block the line */
    background-color: #121418 !important;
    background-image: linear-gradient(90deg, rgba(76, 209, 55, 0.15), #1e2227) !important;
    /* 2. Higher z-index to ensure it stays above the path line */
    z-index: 5 !important;
    /* 3. Give it a stronger shadow to separate it from the "path" visually */
    box-shadow: 0 10px 20px rgba(0,0,0,0.6) !important;
}

/* 3. Combat Zone Styling (The Dangerous Path) */
.location-card:not([data-id="0"]) {
    border-left-width: 4px;
    /* Optional: Slight slant to make combat nodes look more aggressive
    clip-path: polygon(0% 0%, 100% 0%, 98% 100%, 0% 100%);*/
}

/* 4. Desktop Fix: Maintain the layout inside the grid */

/* --- SCATTERED FLOATING TEXT --- */
.float-txt {
    /* We now use JS to set random left/top offsets to "scatter" these */
    transition: all 0.1s ease-out;
    top: 40%;
    left: 50%;
    z-index: 100;
    /* We use 'forwards' to keep the end state of the animation */
    animation: floatArc 2.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
    position: absolute;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    font-family: inherit;
}

/* --- THE CHRONICLE PATH FIX --- */

/* 3. Location Cards (Z-Index 2) */

/* Sanctuary Specific Override */
/* --- THE CHRONICLE PATH (REFINED) --- */

/* Ensure selected cards don't change their vertical footprint */

/* --- MAP VIEW SPECIFIC FIX --- */

/* Target only the location container inside the Map panel */
#view-map #loc-container {
    display: flex !important;
    /*flex-direction: column-reverse !important;*/ /* Keep Sanctuary at bottom */
    gap: 12px;
    padding: 20px;
    /*padding-top: 60px; */   /* Buffer so Zone 6 doesn't hit the header */
    overflow-y: auto;     /* Allow scrolling only here */
    height: 100%;
}

/* Ensure the Map header stays fixed while cards scroll under it */
#view-map h3 {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-dark); /* Match your background to hide scrolling cards */
    margin: 0;
    padding: 15px;
}

/* Fix the Sanctuary spacing without affecting combat */
#view-map .location-card[data-id="0"] {
    margin-top: 0 !important;
    margin-bottom: 15px !important; /* Pushes it away from the dock */
}

#btn-salve {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}

#btn-salve:active {
    transform: scale(0.9) translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* Make sure the main crest buttons align text correctly */

/* Stance Auras */
.aura-dawn { box-shadow: 0 0 15px var(--fury) !important; border-color: var(--fury) !important; }
.aura-twilight { box-shadow: 0 0 15px #dcdde1 !important; border-color: #dcdde1 !important; }
.aura-eclipse { box-shadow: 0 0 15px var(--magic) !important; border-color: var(--magic) !important; }

/* Animation for switching */
.btn-resonance:active { transform: scale(0.95); }
/* [UPDATE] Add these styles to style.css */
#death-curtain {
    color: var(--text-main);
    text-align: center;
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, #1a1a1a 0%, #000 100%);
    z-index: 9999; /* Higher than all other UI elements */
    opacity: 0;
    pointer-events: none;
    display: none; /* Controlled by JavaScript flex logic */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 2s ease-in-out;
}

#death-curtain.curtain-active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

#death-text-container {
    text-align: center;
    animation: fadeIn 3.5s ease-in;
}

/* Show stat buttons only when the AP alert is active */
#ap-alert[style*="display: block"] ~ .stat-grid-container .stat-btn,
#ap-alert[style*="display: block"] ~ .hero-group .stat-btn {
    display: inline-block;
}

.res-timer {
    display: inline-block;
    margin-left: 4px;
    font-family: monospace; /* Monospace prevents button width "jitter" as numbers change */
    opacity: 0.8;
    font-size: 0.55rem;
    font-weight: bold;
    color: #4cd137; /* Clean green for active/ready states */
}

.active-res {
    background: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 10px var(--accent-glow);
    transform: scale(1.05);
}

.active-res .res-timer {
    color: #fff;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.btn-resonance .pixel-icon {
    transform: scale(0.8); /* Slightly smaller for combat buttons */
    vertical-align: middle;
    margin-right: 4px;

}

.btn-resonance {
    font-size:0.75em;
    display: flex; flex-shrink: 0;
    justify-content: center;
    vertical-align: middle;
    overflow: hidden;
}







/* --- BULLETPROOF SANCTUARY UI --- */

/* FIX: The Icon Overflow */
#ui-sanc-icon {
    margin: 10px auto !important;
    max-width: 90%; /* Forces it to stay inside the screen */
    height: auto !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    display: none !important;
}

#sanctuary-ui .sanc-header {
    width: 100%;
    padding: 15px;
    text-align: center;
    background: rgba(0,0,0,0.4);
    border-bottom: 2px solid var(--border-color);
    box-sizing: border-box;
}

#sanctuary-ui .sanc-scroll-body {
    flex: 1;
    overflow-y: auto !important;
    padding: 10px 15px 50px 15px;
    width:100%;
    background: #0f0f12;
}

/* FIX: Ensuring Descriptions and Labels are Visible */

#sanctuary-ui .sanc-row-btn {
    display: flex !important;
    width: 100% !important;
    background: #1e2227 !important; /* Force a solid visible dark grey */
    border: 1px solid var(--border-color) !important;
    margin-bottom: 12px !important;
    padding: 10px !important;
    border-radius: 8px;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    color: white !important;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* FIX: The Missing Text */
#sanctuary-ui .sanc-row-info {
    display: flex !important;
    flex-direction: column !important;
    pointer-events: none;
}

#sanctuary-ui .sanc-row-name {
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 14px !important;
    display: block !important;
}

#sanctuary-ui .sanc-row-desc {
    color: #b0b0b0; /* Explicit light grey */
    font-size: 9px !important;
    display: block !important; /* Forces it to show */
    margin-top: 4px !important;
    line-height: 1.4 !important;
}

#sanctuary-ui .sanc-row-price {
    color: var(--accent-gold) !important;
    font-family: var(--font-head);
    font-size: 13px;
    padding-left: 10px;
    padding-right: 10px;
    border-left: 1px solid #333;
    min-width: 70px;
    text-align: right;
}

/* Disabled State: Kill all interactions */
#sanctuary-ui .sanc-row-btn:disabled {
    border-color: #222 !important;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.25 !important;
    filter: grayscale(1) !important;
}

/* Align the icon and the text block on the left */
.sanc-row-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* Ensure the inline icon doesn't blow up in size */
.sanc-icon-inline {
    flex-shrink: 0;
    transform: scale(1.2); /* Make ritual icons slightly more prominent */
    width: 100% !important;
    height: 100% !important;
    /* Keeps pixel art sharp */
    display: block;
}

/* --- BUTTON HOVER & ACTIVE SEQUENCING --- */

/* 1. Base State Transition */

/* 2. Hover State: Lift and Glow */
/* Triggered when mouse is over or finger is touching (before release) */
#sanctuary-ui .sanc-row-btn:not(:disabled):hover {
    border-color: var(--accent-gold) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    transform: translateY(-2px); /* Slight lift effect */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    cursor: pointer;
}

/* 3. Active State: Press and Recede */
/* Triggered during the actual click/press */
#sanctuary-ui .sanc-row-btn:not(:disabled):active {
    transform: translateY(1px) scale(0.98) !important; /* Pushes down below the hover height */
    background: rgba(0, 0, 0, 0.3) !important;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6) !important;
    transition: transform 0.05s; /* Fast response for the click */
}

/* 4. Disabled State: Reset All */

/* Title Screen Button Glow */
#title-screen-overlay .btn-action {
    background: radial-gradient(circle at 50% 10%, #2c313a 0%, #121418 90%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#title-screen-overlay .btn-action:hover:not(:disabled) {
    background: radial-gradient(circle at 50% 10%, #222 0%, #111 90%);
    letter-spacing: 1px;
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Cinematic Title Fade */
@keyframes title-glow {
    0%, 100% { text-shadow: 0 0 20px rgba(var(--accent-gold-rgb), 0.2); }
    50% { text-shadow: 0 0 40px rgba(var(--accent-gold-rgb), 0.5); }
}

#title-screen-overlay h1 {
    animation: title-glow 4s infinite ease-in-out;
}
@media (max-width: 800px) {
#title-screen-overlay h1 {
    font-size: 28px !important;
}
}
#title-screen-overlay {
    background-image: url('../assets/ui/wallpaper1.jpg') !important;
    filter: brightness(150%);
    background-size: cover !important;
    background-position: center !important;
}

/* Fix for the Modal Scrollbar double-up */
#beginner-guide-overlay .modal-box {
    display: flex;
    flex-direction: column;
    max-height: 85vh; /* Prevents the box from leaving the screen */
    padding: 0; /* We will handle padding inside for better scroll control */
    overflow: hidden;
}

.guide-content-scroll {
    overflow-y: auto;
    padding: 25px;
    flex-grow: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) transparent;
}

/* Custom scrollbar for Webkit (Chrome/Safari) */
.guide-content-scroll::-webkit-scrollbar { width: 5px; }
.guide-content-scroll::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 10px; }

/* Cinematic Transition Curtain */
#transition-curtain {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999; /* Highest priority */
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.8s ease-in-out;
}

#transition-curtain.active {
    opacity: 1;
    pointer-events: all;
}

/* Optional: Ember Pulse Effect */
.ember-pulse {
    box-shadow: inset 0 0 100px rgba(var(--accent-gold-rgb), 0.2);
    background: radial-gradient(circle, #1a1c22 0%, #000 100%);
}
#sanctuary-ui #btn-retire {
    margin-bottom: 0px !important;
}




