/* Journal styling — reuses .content-panel from crashSite.css */

.journal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.header-close {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
}

/* Replace fixed viewport calc() sizing with flex-friendly rules so the section
   fills its parent (.game-area) and the entries can scroll internally. */
#journalSection {
    /* let the section be sized by its parent .game-area */
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0; /* critical for inner scrolling to work inside flex containers */
    overflow: hidden;
    /* keep your background / padding */
    background-image: url('../../assets/images/journalbackground.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 20px;
    box-sizing: border-box;
}

#journalSection > .content-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    /* Match Crash Site/Campsite panel inset (tighter than global content-panel padding). */
    padding: 12px;
    scrollbar-gutter: auto;
    box-sizing: border-box;
    border-top-width: 0 !important; /* force remove top border width */
    border-top-style: none !important; /* force remove top border style */
    /* remove top rounding so tabs provide the curved silhouette */
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    /* remove all shadows to eliminate shadow line */
    box-shadow: none !important;
    /* pull up to overlap with tab bottom */
    margin-top: 0px;
    /* ensure content overlaps the tab at connection point */
    position: relative;
    z-index: 3;
}

/* Ensure the section content fills the game-section and allows children to flex */
.game-section .section-content,
.journal-section .section-content {
    display: flex;
    flex-direction: column;
    height: 100%;      /* allow section content to occupy the section's full height */
    min-height: 0;     /* allow flex children to shrink (important for scrollable areas) */
    box-sizing: border-box;
}

/* Make the entries list expand and scroll to the bottom edge */
.journal-entries {
    flex: 1 1 auto;   /* grow and shrink inside the section content */
    min-height: 0;    /* required so the overflowed child can actually scroll */
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px; /* keep your preferred small padding */
}

/* Keep header sized to its content */
#journalSection .journal-header {
    flex: 0 0 auto;
    margin-bottom: 12px;
}

/* Let entries container grow to fill remaining space and scroll internally */
#journalSection .journal-entries {
    flex: 1 1 auto;
    overflow: auto;
    max-height: none; /* override any earlier fixed max-height */
    padding-right: 6px; /* keep space for scrollbar */
}

/* Reuse the same styled scrollbar as the Log section (#logContent) */
.journal-entries::-webkit-scrollbar { width: 12px; }
.journal-entries::-webkit-scrollbar-track { background: #111; }
.journal-entries::-webkit-scrollbar-thumb {
    background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.5);
    border-radius: 6px;
    border: 3px solid #111;
}
.journal-entries::-webkit-scrollbar-thumb:hover {
    background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.8);
}

/* Increase spacing between entries so they don't feel cramped */
.journal-entry {
    margin-bottom: 12px;
    background: rgba(255,255,255,0);
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.12);
    box-shadow: 0 6px 18px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.04), inset 0 1px 0 rgba(255,255,255,0.02);
    padding: 14px;
    border-radius: 8px;
    will-change: box-shadow;
    transform: none;        /* remove GPU transform to avoid clipping */
    transition: box-shadow 160ms ease;
    position: relative;
    z-index: 0;
}

/* Hover: raise z-index and strengthen shadow / border without scaling */
.journal-entry:hover {
    box-shadow: 0 12px 30px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.08), inset 0 1px 0 rgba(255,255,255,0.03);
    border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.18);
    z-index: 2;
}

/* avoid extra space on last item */
.journal-entries .journal-entry:last-child {
    margin-bottom: 0;
}

/* Fine tune title/time/body spacing (keeps content readable) */
.journal-entry-title { margin-bottom: 8px; }
.journal-entry-time { margin-bottom: 10px; }

.journal-entry-title.is-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.35);
    text-underline-offset: 3px;
}

.journal-entry-title.is-clickable:hover {
    text-decoration-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.65);
}

.muted { color: rgba(255,255,255,0.5); }

#journalSection {
    background-image: url('../../assets/images/journalbackground.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-start;
    padding: 20px;
    box-sizing: border-box;
}

/* Make journal headers use the same accent color as story popups */
.journal-header h2,
.journal-entry-title {
    color: #90EE90; /* popup header color */
}

/* --- Journal Tabs --- */
.journal-panel { position: relative; }
.journal-tabs {
    position: relative;
    display: flex;
    gap: 0;
    margin: 0 0 0 0; /* sit above panel */
    padding: 0; /* tabs themselves control interior padding */
    width: 100%; /* match content panel width */
}
/* Remove separate baseline/divider to avoid layered look */
.journal-tabs::after { content: none; }
.journal-tabs::before { content: none; }

.journal-tab {
    flex: 1 1 0;
    text-align: center;
    background: linear-gradient(180deg, rgba(8,8,8,0.96), rgba(4,4,4,0.92));
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.38);
    border-bottom: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.58); /* create a stronger seam above content */
    color: #cfd8cf;
    padding: 12px 28px;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    cursor: pointer;
    font-size: 15px;
    letter-spacing: 0.6px;
    position: relative;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.journal-tab + .journal-tab { margin-left: 0; }
.journal-tab:hover { color: #fff; border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.35); }

/* Active tab: bright glow around */
.journal-tab.active {
        /* Match content-panel background for seamless look */
        background: rgba(6, 6, 6, 0.89);
        color: #ffffff;
        border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.60);
        border-bottom: none;
        /* no shadow to prevent line between tab and content */
        box-shadow: none;
        z-index: 2;
}
/* Inactive tab: subtle/faded glow */
.journal-tab:not(.active) {
        /* Further reduced glow to read clearly as inactive */
        box-shadow:
            0 0 0 1px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.14) inset,
            0 2px 8px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.10);
}

/* Baseline glow removed - active tab connects directly to content */
.journal-tabs::after {
    display: none;
}

.journal-tabpanes { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.journal-pane { display: none; flex: 1 1 auto; min-height: 0; }
.journal-pane.active { display: flex; flex-direction: column; }

/* Objectives History Pane - Two Column Layout */
.objectives-history { 
    flex: 1 1 auto; 
    overflow: hidden; 
    display: flex;
    flex-direction: column;
}

.objectives-two-column {
    display: flex;
    gap: 16px;
    height: 100%;
    overflow: hidden;
}

/* Left Panel - Objectives List */
.objectives-list-panel {
    width: 35%;
    min-width: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    border-right: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.25);
}

.objectives-section-header {
    margin: 0 0 8px 0;
    padding: 6px 8px;
    font-size: 13px;
    color: #90EE90;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.08);
    border-left: 3px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.5);
}

.objectives-list {
    list-style: none;
    margin: 0 0 20px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.objectives-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.14);
    border-radius: 6px;
    transition: all 160ms ease;
}

.objectives-list-item:hover {
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.08);
    border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.28);
}

.objectives-list-item.selected {
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.15);
    border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.5);
    border-left-width: 3px;
    padding-left: 10px;
}

.objectives-list-item .objective-marker {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.9);
    font-size: 16px;
    line-height: 1;
}

.objectives-list-item.completed .objective-marker {
    color: #90EE90;
}

.objectives-list-item .objective-label {
    flex: 1;
    color: #d6e3d6;
    font-size: 13px;
    line-height: 1.4;
}

.objectives-list-item .objective-track-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.3);
    color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.7);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: all 160ms ease;
}

.objectives-list-item .objective-track-btn:hover {
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.15);
    border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.5);
    color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.9);
}

.objectives-list-item .objective-track-btn.tracked {
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.25);
    border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.6);
    color: #90EE90;
}

.objectives-list-item.completed .objective-label {
    color: #90EE90;
    opacity: 0.75;
}

/* Right Panel - Objective Details */
.objectives-detail-panel {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 12px 0 8px;
}

.objective-detail-title {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: #90EE90;
    font-weight: 600;
}

.objective-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.objective-status {
    display: inline-block;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.2);
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.4);
    border-radius: 4px;
    color: #ffd98a;
}

.objective-status.completed {
    background: rgba(144, 238, 144, 0.15);
    border-color: rgba(144, 238, 144, 0.4);
    color: #90EE90;
}

.objective-status.tracked-badge {
    background: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.25);
    border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.6);
    color: #90EE90;
}

/* Objective narrative shown above Steps (Markdown) */
.objective-detail-narrative {
    margin: 0 0 10px 0;
    padding: 0;
    color: #ffffff;
    font-size: 13px;
    line-height: 1.55;
}

.objective-detail-narrative p {
    margin: 0 0 10px 0;
    color: #ffffff;
}

.objective-detail-narrative p:last-child {
    margin-bottom: 0;
}

.objective-detail-section-header {
    margin: 20px 0 8px 0;
    font-size: 14px;
    color: #90EE90;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.objective-detail-steps {
    list-style: none;
    margin: 0 0 12px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.objective-detail-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0;
}

.objective-detail-step .step-marker {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.9);
    font-size: 14px;
    line-height: 1.4;
}

.objective-detail-step.done .step-marker {
    color: #90EE90;
}

.objective-detail-step .step-label {
    flex: 1;
    color: #c9d7c9;
    font-size: 13px;
    line-height: 1.4;
}

.objective-detail-step.done .step-label {
    color: #90EE90;
    opacity: 0.8;
}

.objective-detail-reward {
    padding: 8px 12px;
    background: rgba(255, 217, 138, 0.08);
    border-left: 3px solid rgba(255, 217, 138, 0.5);
    color: #ffd98a;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
}

.objective-detail-times {
    color: #889988;
    font-size: 12px;
    line-height: 1.6;
}

.objective-detail-times p {
    margin: 4px 0;
}

/* Scrollbar styling for both panels */
.objectives-list-panel::-webkit-scrollbar,
.objectives-detail-panel::-webkit-scrollbar {
    width: 10px;
}

.objectives-list-panel::-webkit-scrollbar-track,
.objectives-detail-panel::-webkit-scrollbar-track {
    background: #111;
}

.objectives-list-panel::-webkit-scrollbar-thumb,
.objectives-detail-panel::-webkit-scrollbar-thumb {
    background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.5);
    border-radius: 5px;
    border: 2px solid #111;
}

.objectives-list-panel::-webkit-scrollbar-thumb:hover,
.objectives-detail-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.8);
}

/* Legacy styles - keeping for compatibility */
.objectives-history-section { margin-bottom: 18px; }
.objectives-history-section h3 { margin: 0 0 10px 0; font-size: 16px; color: #90EE90; }
.objectives-empty { font-style: italic; color: #888; margin: 4px 0 0 4px; }

.objectives-history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.objectives-history-item {
    border: 1px solid rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.14);
    background: rgba(255,255,255,0.02);
    padding: 10px 14px;
    border-radius: 8px;
    position: relative;
    transition: box-shadow 160ms ease, border-color 160ms ease;
}
.objectives-history-item.completed { border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.25); background: rgba(0,0,0,0.5); }
.objectives-history-item:hover { box-shadow: 0 8px 22px rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.12); border-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.22); }

.objective-history-label { font-weight: 600; color: #d6e3d6; margin-bottom: 6px; }
.objective-history-steps { list-style: none; margin: 0 0 6px 0; padding: 0 0 0 4px; display: flex; flex-direction: column; gap: 3px; }
.objective-history-step { font-size: 13px; color: #c0ccc0; position: relative; padding-left: 16px; }
.objective-history-step::before { content: '•'; position: absolute; left: 0; top: 0; color: #6aa86a; }
.objective-history-step.done { color: #8FFFA0; }
.objective-history-step.done::before { content: '✓'; color: #8FFFA0; }

.objective-history-reward { font-size: 12px; color: #ffd98a; margin-top: 4px; }
.objective-history-times { font-size: 11px; color: #889988; margin-top: 4px; font-style: italic; }

/* Scrollbar styling (reuse journal scrollbar) */
.objectives-history::-webkit-scrollbar { width: 12px; }
.objectives-history::-webkit-scrollbar-track { background: #111; }
.objectives-history::-webkit-scrollbar-thumb { background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.5); border-radius: 6px; border: 3px solid #111; }
.objectives-history::-webkit-scrollbar-thumb:hover { background-color: rgba(var(--glow-r), var(--glow-g), var(--glow-b), 0.8); }

/* Phone-landscape: hide tabs and match Crash Site padding to maximize usable space. */
@media (max-width: 600px),
       (max-width: 900px) and (max-height: 450px),
       (hover: none) and (pointer: coarse) and (max-width: 900px) and (max-height: 600px) {
    #journalSection {
        padding: 1px;
    }

    #journalSection .journal-tabs {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #journalSection > .content-panel.journal-panel {
        padding: 1px;
        border-top-width: 1px !important;
        border-top-style: solid !important;
        border-top-left-radius: 6px;
        border-top-right-radius: 6px;
        margin-top: 0 !important;
    }

    /* --- Objectives (Journal -> Objectives tab): tighter list + smaller detail text --- */
    .objectives-history,
    .objectives-two-column,
    .objectives-list-panel,
    .objectives-detail-panel {
        min-height: 0;
    }

    .objectives-two-column {
        gap: 10px;
        flex: 1 1 auto;
    }

    .objectives-list-panel {
        padding-right: 6px;
    }

    .objectives-section-header {
        margin: 0 0 6px 0;
        padding: 4px 6px;
        font-size: 11px;
        letter-spacing: 0.4px;
    }

    .objectives-list {
        margin: 0 0 12px 0;
        gap: 2px;
    }

    .objectives-list-item {
        gap: 8px;
        padding: 6px 8px;
        border-radius: 6px;
    }

    .objectives-list-item .objective-marker {
        width: 16px;
        font-size: 14px;
    }

    .objectives-list-item .objective-label {
        font-size: 11px;
        line-height: 1.2;
    }

    .objectives-list-item .objective-track-btn {
        padding: 3px 8px;
        font-size: 10px;
        letter-spacing: 0.4px;
    }

    .objectives-detail-panel {
        padding: 0 8px 0 6px;
    }

    .objective-detail-title {
        margin: 0 0 8px 0;
        font-size: 15px;
    }

    .objective-status-row {
        margin-bottom: 12px;
        gap: 6px;
    }

    .objective-status {
        padding: 3px 10px;
        font-size: 10px;
    }

    .objective-detail-narrative {
        font-size: 11px;
        line-height: 1.35;
    }

    .objective-detail-section-header {
        margin: 12px 0 6px 0;
        font-size: 12px;
    }

    .objective-detail-steps {
        gap: 3px;
    }

    .objective-detail-step {
        gap: 8px;
        padding: 3px 0;
    }

    .objective-detail-step .step-marker {
        width: 16px;
        font-size: 12px;
        line-height: 1.2;
    }

    .objective-detail-step .step-label {
        font-size: 11px;
        line-height: 1.25;
    }

    .objective-detail-reward {
        padding: 6px 10px;
        font-size: 11px;
    }

    .objective-detail-times {
        font-size: 10px;
        line-height: 1.35;
    }

    /* --- Journal entries: smaller, denser cards --- */
    #journalSection .journal-header {
        margin-bottom: 8px;
    }

    .journal-entry {
        margin-bottom: 8px;
        padding: 10px;
        border-radius: 8px;
    }

    .journal-entry-title {
        margin-bottom: 4px;
        font-size: 13px;
    }

    .journal-entry-time {
        margin-bottom: 6px;
        font-size: 10px;
        opacity: 0.85;
    }

    .journal-entry-body {
        font-size: 12px;
        line-height: 1.35;
        color: #d6e3d6;
    }
}

html.is-compact #journalSection {
    padding: 1px;
}

html.is-compact #journalSection .journal-tabs {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

html.is-compact #journalSection > .content-panel.journal-panel {
    padding: 1px;
    border-top-width: 1px !important;
    border-top-style: solid !important;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    margin-top: 0 !important;
}

