/* styles.css */

body {
    height: 100%;
    min-height: 100vh;
    margin: 0;
    font-family: sans-serif;
    user-select: none;
}

h2 {
    margin-bottom: 30px;
    font-size: 30px;
    color: #36453B;
}

h3 {
    margin-bottom: 0px;
}

/* Loading screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #36453B;
    color: #EFEBD8;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
    opacity: 1;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Top bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #6B8E23;
    color: #EFEBD8;
    padding: 5px;
    border-bottom: 2px solid #36453B;
}

.top-bar .title {
    font-size: 2em;
}

.top-bar .date {
    flex-grow: 1;
    text-align: center;
    font-size: 1.5em;
}

.top-bar .top-buttons button {
    margin-left: 10px;
    padding: 5px 10px;
    border-radius: 10px;
    background-color: #A7D9B4;
    color: #36453B;
    border: 1px solid #36453B;
    box-shadow: 0 0 0 0 transparent; 
    transition: background-color 0.2s ease-in-out;
}

.top-bar .top-buttons button:hover {
    background-color: #EFEBD8;
}

#journalBtn.newEntry, 
.tab-button.newEntry,
.journal-item.newEntry {
    background-color: #FFD700;
    animation: pulse-glow 1.8s infinite alternate;
    animation-delay: -0.9s;
    transform: translateZ(0);
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 8px 4px #FFD700B3;
    }
    100% {
        box-shadow: 0 0 12px 6px #FFD700FF;
    }
}

/* Main layout */
.game-layout {
    display: flex;
    height: calc(100% - 50px);
    min-height: calc(100vh - 50px);
}

/* Resources panel */
.resources {
    width: 25%;
    text-align: center;
    color: #36453B;
    background: linear-gradient(to bottom, #A7D9B4, #6B8E23);
    padding: 10px;
    box-sizing: border-box;
    border-right: 1px solid #36453B;
}

#money {
    display: block;
    font-size: 1.5em;
    margin-top: 50px;
}

/* The Inventory header */
.resources h2:last-of-type {
    margin-top: 50px;
    margin-bottom: 30px;
}

.inventory-box {
    background-color: #36453B;
    border: 1px solid #A7D9B4;
    height: 300px;
    padding: 10px; 
    margin-top: 15px;
    border-radius: 5px;
}

.inventory-container {
    width: 100%;
    text-align: left;
    color: #EFEBD8;
}

.inventory-items {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    justify-items: center;
}

.inventory-item {
    padding: 3px;
}

.inventory-item.up-glow-animation {
    animation: upGlowAndFade 1s ease-out forwards;
}

.inventory-item.down-glow-animation {
    animation: downGlowAndFade 1s ease-out forwards;
}

@keyframes upGlowAndFade {
    0% {
        background-color: transparent;
        box-shadow: 0 0 0px #A7D9B400;
    }
    50% {
        background-color: #A7D9B4B3;
        box-shadow: 0 0 15px #A7D9B4FF;
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0px #A7D9B400;
    }
}

@keyframes downGlowAndFade {
    0% {
        background-color: transparent;
        box-shadow: 0 0 0px #FF000000;
    }
    50% {
        background-color: #FF0000B3;
        box-shadow: 0 0 15px #FF0000FF;
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0px #FF000000;
    }
}

/* Research section */
.research {
    width: 25%;
    text-align: center;
    color: #EFEBD8;
    background: linear-gradient(to bottom, #A7D9B4, #6B8E23);
    padding: 10px;
    box-sizing: border-box;
    border-left: 1px solid #36453B;
    border-right: 1px solid #36453B;
}

/* Empty message styling */
.empty-tab-message {
    padding: 15px;
    margin-top: 20px;
    background-color: #36453B;
    color: #EFEBD8;
    border: 2px solid #6B8E23;
    border-radius: 8px;
    text-align: center;
    font-size: 1.1em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Tasks section */
.tasks {
    width: 25%;
    text-align: center;
    color: #EFEBD8;
    background: linear-gradient(to bottom, #A7D9B4, #6B8E23);
    padding: 10px;
    box-sizing: border-box;
    border-left: 1px solid #36453B;
    border-right: 1px solid #36453B;
}

/* Tabs and tab buttons */
#researchBtns,
#taskBtns {
    width: 60%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 5px;
    margin: 0 auto;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    justify-content: center;
}

.tab-button {
    border-radius: 20px;
    border-color: #36453B;
    background-color: #A7D9B4;
    box-shadow: 0 0 0 0 transparent; 
    transition: background-color 0.2s ease-in-out;
}

.tab-button.active-button {
    background-color: #EFEBD8;
}

.tab-button.selected-button {
    background-color: #B85C2E;
}

/* Progress buttons */
.progress-button {
    background-color: #A7D9B4;
    border: 1px solid #36453B;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    position: relative;
    overflow: hidden; 
    border-radius: 10px;
    color: #36453B;
    display: block;
    margin: 5px;
    min-width: 150px;
    text-align: center;
    transition: background-color 0.3s ease;
}

.unavailable-action {
    background-image: repeating-linear-gradient(
        -45deg,
        #A7D9B480 0px,
        #A7D9B480 5px,
        #EFEBD8 5px,
        #EFEBD8 10px
    );
    cursor: not-allowed;
}

.progress-button:hover {
    background-color: #EFEBD8;
}

.progress-button .progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background-color: #B85C2E;
    z-index: 1;
}

.progress-button .progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background-color: #B85C2E;
    z-index: 1;
}

.progress-button.in-progress .progress-fill {
    width: 100%;
}

.progress-button span {
    position: relative;
    z-index: 2;
    color: #36453B;
}

/* Selected buttons */
.progress-button.selected-button {
    background-color: #EFEBD8;
    border-color: #36453B;
}

.progress-button.selected-button:hover {
    background-color: #A7D9B4;
}

/* Completion progress bars */
.completion-progress-bar-container {
    width: 100%;
    background-color: #E0E0E0;
    border-radius: 5px;
    border-color: #36453B;
    border-width: 1px;
    border-style: solid;
    margin-top: 5px;
    height: 15px;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.completion-progress-bar-fill {
    height: 100%;
    background-color: #4CAF50;
    width: 0%;
    border-radius: 5px;
    color: white;
}

/* Log section */
.log {
    width: 25%;
    text-align: center;
    color: #A7D9B4;
    background: linear-gradient(to bottom, #A7D9B4, #6B8E23);
    padding: 10px;
    box-sizing: border-box;
    border-left: 1px solid #36453B;
}

button {
    cursor: pointer;
}

/* Game overlay */
.game-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(54, 69, 59, 0.8);
    z-index: 999;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    opacity: 0;
}

.game-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: all;
}

/* Journal styling */
.journal-container {
    display: none;
    position: fixed;
    top: 10%;
    left: 35%;
    width: 30%;
    max-height: 70vh;

    background-color: #36453B;
    border: 2px solid #6B8E23;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    overflow-y: auto;
    color: #A7D9B4;

    z-index: 1000;
    opacity: 0;
    pointer-events: none;
}

.journal-container.active {
    display: block;
    opacity: 1;
    pointer-events: all;
}

.journal-title {
    text-align: center;
}

#journalEntriesContainer {
    display: flex;
    flex-direction: column;
    align-items: center; 
}

.journal-item {
    width: fit-content;
    max-width: 80%;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: default;
}

#entryTextContainer {
    display: none;
    position: absolute;
    top: 10%;
    left: 10%;
    height: 80%;
    width: 80%;
    z-index: 2000;

    color: #FFFFFF;
    background-color: #000000;
}

#entryTextContainer.active {
    display: block;
}

/* Settings menu styling */
.settings-container {
    position: fixed;
    top: 10%;
    left: 35%;
    width: 30%;
    max-height: 70vh;
    display: none;

    background-color: #36453B;
    border: 2px solid #6B8E23;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    overflow-y: auto;
    color: #A7D9B4;
    z-index: 1000;

    opacity: 0;
    pointer-events: none;
}

.settings-container.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.settings-container label {
    color: #A7D9B4;
    font-weight: bold;
}

.settings-container button {
    border-radius: 5px;
    font-weight: bold;
}

.setting-item button {
    background-color: #A7D9B4;
    color: #36453B;
    border: 1px solid #6B8E23;
}

.setting-item button:hover {
    background-color: #EFEBD8;
}

.setting-item-grid button {
    background-color: #A7D9B4;
    color: #36453B;
    border: 1px solid #6B8E23;
}

.setting-item-grid button:hover {
    background-color: #EFEBD8;
}

.settings-container input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #6B8E23;
    outline: none;
    opacity: 0.8;
    transition: opacity .2s;
    border-radius: 4px;
}

.settings-container input[type="range"]:hover {
    opacity: 1;
}

.settings-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #A7D9B4;
    cursor: grab;
    border-radius: 50%;
    border: 1px solid #36453B;
}

.settings-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #A7D9B4;
    cursor: grab;
    border-radius: 50%;
    border: 1px solid #36453B;
}

.settings-container input[type="checkbox"]:checked {
    accent-color: #A7D9B4;
}

#emulateWindowSize {
    font-size: 1em;
    padding: 8px 12px;
    border: 1px solid #A7D9B4;
    border-radius: 5px;
    background-color: #36453B;
    color: #EFEBD8;
    cursor: pointer;
    
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* Add a custom SVG arrow */
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="%23EFEBD8" d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1em;
    padding-right: 30px;
    transition: all 0.2s ease;
}

#emulateWindowSize:hover {
    background-color: #6B8E23;
    border-color: #EFEBD8;
}

#emulateWindowSize:focus {
    border-color: #B85C2E;
    outline: none;
    box-shadow: 0 0 0 2px rgba(184, 92, 46, 0.5);
}

#emulateWindowSize option {
    background-color: #36453B;
    color: #EFEBD8;
    font-size: 16px;
    border-radius: 0;
}

/* Settings specifics */
.settings-title {
    text-align: center;
}

.restart-warning {
    display: none;
    text-align: center;
    color: red;
}

.restart-warning.active {
    display: block;
}

#analBtn {
    height: 30px;
}

#delete-save-btn {
    height: 30px;
    background-color: #B22222;
    color: #EFEBD8;
}

#delete-save-btn:hover {
    background-color: #EFEBD8;
    color: #B22222;
}

.close-btn {
    border-radius: 5px;
    font-weight: bold;
    background-color: #B85C2E;
    color: #EFEBD8;
}

.close-btn:hover {
    background-color: #E67A4F;
    border-color: #A7D9B4;
}

/* Music/SFX/Autosave/Threshold */
.setting-item-grid {
    display: grid;
    grid-template-columns: 90px 2fr 50px 90px;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px dashed #6B8E23;
}

#windowElement {
    flex-direction: row;
    justify-content: flex-start;
    gap: 20px;
}

/* Sync & Saving */
.setting-item {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 20px 0;
    gap: 5px;
    border-bottom: 1px dashed #6B8E23;
}

.close-button-container {
    padding: 20px 0;
    display: flex;
    justify-content: space-around;
}

.help-text-entry {
    position: absolute;
    background-color: #EFEBD8;
    color: #36453B;
    padding: 8px 12px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-size: 0.9em;
    pointer-events: none;
    z-index: 1001;
}

.help-arrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.help-arrows line {
    stroke: #A7D9B4;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
}

/* SVG Arrowhead Marker */
.help-arrows defs marker {
    overflow: visible;
}

/* Button tooltips */
.custom-tooltip {
    position: absolute;
    background-color: #36453B;
    border: 2px solid #6B8E23;
    color: #EFEBD8;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    max-width: 300px;
    word-wrap: break-word;
    pointer-events: none;
    z-index: 1000;

    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.1s ease, transform 0.1s ease, visibility 0.1s ease;
}

/* resource bars */
.resource-bar-container {
    margin-top: 30px;
}

.bar-background {
    width: 100%; 
    height: 40px;
    background-color: #36453B;
    border: 1px solid #A7D9B4;
    border-radius: 5px;
    position: relative; 
}

.bar-fill {
    height: 100%;
    border-radius: 4px; 
    transition: width 0.3s ease-out, background-color 0.3s ease-out; 
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #EFEBD8;
    font-size: 0.8em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3); 
    pointer-events: none; 
}