/* styles.css */

html, body,
div, span, p, a, h1, h2, h3, h4, h5, h6,
button, input, textarea, select, label,
ul, li, ol, table, th, td {
  /*font-family: "Press Start 2P", monospace;*/
  font-family: "Modern Antiqua", serif;
  font-weight: 600;
  font-style: normal;
}

body {
  /*font-family: Arial, sans-serif;*/
  background-color: #f2f2f2;
  margin: 0;
  padding: 0;
}

h1 {
  text-align: center;
}

/* Buttons / inputs inherit font but ensure they do not use system fonts */
button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  -webkit-font-smoothing: none;
}

form {
  margin-top: 20px;
}

form label {
  display: block;
  margin-bottom: 5px;
}

form input[type="text"],
form input[type="password"] {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  box-sizing: border-box; /* Include padding and border in the total width */
}

form button {
  padding: 10px 20px;
  background-color: #4CAF50;
  color: #fff;
  border: none;
  cursor: pointer;
}

form button:hover {
  background-color: #45a049;
}

ul {
  list-style-type: none;
  padding: 0;
}

ul li {
  margin-bottom: 10px;
}

a {
  text-decoration: none;
  color: #0645AD;
}

a:hover {
  text-decoration: underline;
}

p {
    margin: 5px;
}

.error-message {
  color: red;
}

.game-window {
    position: relative;
    /*width: 1200px; /* Adjust the width as needed */
    height: 3200px; /* Adjust the height as needed */
    background-size: cover; 
    background-repeat: no-repeat; 
    background-position: center center;
}

.character-container {
    position: relative;
    width: 400px; /* Adjust the width as needed */
    height: 300px; /* Adjust the height as needed */
}

.move-container {
    position: relative;
    width: 400px; /* Adjust the width as needed */
    height: 300px; /* Adjust the height as needed */
}

.character-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 10px;
    padding-top: 1px;
}

.move-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 10px;
    height: 400px;
}

.game-container {
  width: 100%;
  height: 100vh;
  background-color: #ddd; /* Fallback background color */
  background-size: cover; /* Scale the image to cover the entire container */
  background-position: center; /* Center the image horizontally and vertically */
  display: flex;
  flex-direction: column;
  align-items: left;
  justify-content: center;
  padding: 10px;
}

.chat-box {
    height: 250px; /* Set a maximum height for the chat box */
    overflow-y: auto; /* Enable vertical scrolling when content exceeds the height */
    border: 1px solid #ccc;
    padding: 10px;
    background-color: white;
}

/* Optional: You can style the individual chat messages as well */
.chat-box p {
    margin: 0px;
}

/* Add styles for the header container */
.header-container {
  background-color: #333; /* Header background color */
  color: #fff; /* Header text color */
  padding: 5px;
  display: flex; /* Use flexbox to position items */
  align-items: center; /* Vertically center items in the header */
  justify-content: space-between; /* Space out the items in the header */
}

/* Add styles for the navigation links */
.header-container nav ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.header-container nav ul li {
  display: inline-block;
  margin-right: 15px; /* Add some space between the links */
}

.header-container nav ul li a {
  text-decoration: none;
  color: #fff;
}

.header-container nav ul li a:hover {
  text-decoration: underline;
}

/* Add styles for the header content */
.header {
  text-align: right; /* Align the content to the right */
}

.welcome-container {
    color: white;
    margin-bottom: 1px; /* Adjust margin as needed */
    }
    
.move_location_list {
    height: 300px;
    overflow-y: auto;
}

.char-image {
    width: 100px;
    padding: 1px;
    border: 1px;
    border-radius: 2px;
}

.enemy-image {
    width: 400px;
    padding: 1px;
    border: 10px;
    border-color: black;
    border-radius: 2px;
}

.combat-options {
    display: flex;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* make canvas background black so you don't see a white page behind it during fades */
  background-color: black;
}

#game-container {
  position: relative;
  width: fit-content;
  margin: auto;
}

/* The overlay sits above the canvas and covers everything in the container.
   We keep it in the layout (display:block) so opacity transitions always work. */
#fade-overlay {
  position: absolute;
  inset: 0;                       /* top:0; right:0; bottom:0; left:0; */
  background: #000;               /* solid black */
  opacity: 0;                     /* hidden by default */
  pointer-events: none;           /* allow clicks through when hidden */
  transition: opacity 1s ease;    /* matches the JS fallback timing (1s) */
  z-index: 9999;                  /* above canvas & in-game UI; increase if needed */
  will-change: opacity;
}

/* .show makes the overlay visible and blocks input */
#fade-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* -------------- PIXEL UI ----------------------*/
/* ---------- global pixel-crisp helper ---------- */
.pixelated {
  image-rendering: pixelated; /* for scaled PNGs */
  -ms-interpolation-mode: nearest-neighbor;
}

/* ---------- reset native button visuals ---------- */
.pixel-btn,
.pixel-close {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-block;
  outline: none;
}

/* ---------- textured primary button (single image) ----------
   - button.png is a 3-frame horizontal sprite: normal | hover | pressed
   - each frame width = 64px, height = 20px (adjust to your asset)
------------------------------------------------------------ */
.pixel-btn {
  display: inline-block;
  background-image: url('/static/ui/button_sprite.png');
  background-repeat: no-repeat;
  background-size: 300% 100%; /* fit sprite height to element */
  background-position: 0 0;   /* show first frame */
  image-rendering: pixelated;
  user-select: none;
  white-space: nowrap;             /* avoid line breaks inside button */
  text-align: center;
  line-height: 32px;
  font-weight: 700;
  color: black;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  padding-left: 18px;              /* adjust to fit your sprite margins */
  padding-right: 18px;
}

/* hover / active using background-position shift */
.pixel-btn:hover { background-position: 50% 0; }  /* show hover frame */
.pixel-btn:active { background-position: 100% 0; } /* show pressed frame */

/* disabled state */
.pixel-btn[disabled] {
  opacity: 0.6;
  cursor: default;
  filter: grayscale(40%);
}

/* allow icon + text (optional) */
.pixel-btn .btn-icon { width: 16px; height: 16px; display:inline-block; vertical-align: middle; margin-right:6px; }

/* ---------- panel / menu with 9-slice border-image ---------- */
/* Create a 9-slice PNG called panel_9slice.png where center is tileable */
.menu-panel {
  padding: 1px;              /* inner padding */
  border: 26px solid transparent; 
  border-style: solid;
  border-image: url('/static/ui/panel_test-export.png') 26 fill round; /* slice == 12 */
  background-color: rgba(0,0,0,0.6); /* center fallback */
  image-rendering: pixelated;
  box-sizing: border-box;
  color: #fff;
}

/* Firefox */
* {
  scrollbar-width: thin;             /* makes scrollbar thinner */
  scrollbar-color: #888 #111;        /* thumb color, track color */
}

/* Chrome, Edge, Safari */
*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
*::-webkit-scrollbar-track {
  background: #111;                  /* track background */
}
*::-webkit-scrollbar-thumb {
  background-color: #888;            /* thumb (the draggable bar) */
  border-radius: 6px;
  border: 2px solid #111;            /* space between thumb & track */
}
*::-webkit-scrollbar-thumb:hover {
  background-color: #aaa;            /* lighter when hovered */
}


/*-------------------------------------------------------------*/

#hud-bar {
  position: absolute;
  bottom: 10px;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 5px;
  z-index: 10;
  transition: opacity 3s ease;
}
/*
#hud-bar button {
  background-color: black;
  color: white;
  padding: 10px 20px;
  border: none;
  font-weight: bold;
  cursor: pointer;
  opacity: 0;
  transition: opacity 3s ease;
}
*/

/* Overlay that covers only the game container (not full page) */
#menu-overlay {
  position: absolute;   /* INSIDE #game-container */
  inset: 0;             /* top:0; right:0; bottom:0; left:0 */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* allow clicks outside popup to pass through to elements below */
  z-index: 2000;        /* above canvas/hud */
  /* background dims only the canvas area visually; but pointer-events are off so chat is usable */
  background: rgba(0, 0, 0, 0.45);
  transition: opacity 0.18s ease;
}

/* hide semantics via class */
#menu-overlay.hidden {
  display: none;
  opacity: 0;
}

#popup-menu {
  pointer-events: auto;          /* make the dialog interactive */
  background: rgba(12,12,12,0.98);
  color: #fff;
  /*border-radius: 10px;
  padding: 12px;*/
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  box-sizing: border-box;
  position: relative;
  z-index: 2100;                 /* above overlay */
  /* Constrain to the canvas area (100% is the container size) with padding buffer */
  max-width: calc(100% - 40px);
  max-height: calc(100% - 40px);
  overflow-y: auto;
}

#menu-content {
  display: flex;
  max-height: 100%;       /* respect popup container */
  max-width: 95vw;
  overflow-y: auto;       /* enable scrolling */
  box-sizing: border-box;
  position: relative;
}

#menu-content .item-tooltip img { vertical-align: middle; }

#menu-content > #inventory-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
  width: auto;
  box-sizing: border-box;
}

#menu-content .equip-panel,
#menu-content .inv-panel {
  box-sizing: border-box;
  border-radius: 6px;
  overflow: auto;
}

#menu-content .equip-panel {
  min-width: 300px;
  min-height: 0;
  max-height: 100%;
  flex: 0 0 auto;
  background: rgba(24,24,24,0.85);
  padding: 8px;
}

#menu-content .inv-panel {
  min-width: 420px;
  min-height: 0;
  max-height: 100%;
  flex: 1 1 420px;
  background: rgba(18,18,18,0.92);
  padding: 8px;
}

/* Divider styling between the two panels */
#menu-content > #inventory-wrapper > div:nth-child(2) {
  width: 2px;
  background: linear-gradient(#222, #111);
  border-radius: 2px;
  align-self: stretch;
  margin: 4px 0;
}

/* Make the popup scrollable on smaller screens */
@media (max-width: 900px) {
  #menu-content > #inventory-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  #menu-content .equip-panel, #menu-content .inv-panel {
    min-width: 100%;
    width: 100%;
  }
  #menu-content > #inventory-wrapper > div:nth-child(2) {
    width: 100%;
    height: 2px;
  }
}

/* If you still use the wrapper with id #inventory-wrapper (from the supplied JS),
   make it responsive: let it grow to content but limit to view */
#inventory-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;

  /* scrolls together with menu-content */
  max-height: 100%;
}

/* Panel styling, with enforced minimums */
#inventory-wrapper .equip-panel,
#inventory-wrapper .inv-panel {
  box-sizing: border-box;
  border-radius: 6px;
  overflow: auto;            /* scroll inside if content too tall */
}

/* Minimums you requested (tweak values to taste) */
#inventory-wrapper .equip-panel {
  min-width: 300px;
  min-height: 320px;
  max-height: 100%;
  flex: 0 0 auto;           /* fixed width area (no shrink) */
}

#inventory-wrapper .inv-panel {
  min-width: 420px;
  min-height: 320px;
  max-height: 100%;
  flex: 1 1 420px;          /* flexible: will grow to fill remaining space */
}

/* Divider visuals */
#inventory-wrapper > div:nth-child(2) {
  align-self: stretch;
  width: 2px;
  background: linear-gradient(#222, #111);
  border-radius: 2px;
  margin: 4px 0;
}

/* Mobile: stack panels vertically if viewport too narrow */
@media (max-width: 900px) {
  #inventory-wrapper {
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem;
  }
  #inventory-wrapper .equip-panel,
  #inventory-wrapper .inv-panel {
    min-width: 100%;
    width: 100%;
  }
  #inventory-wrapper > div:nth-child(2) {
    width: 100%;
    height: 2px;
    margin: 8px 0;
  }
}

#popup-menu #close-menu,
#popup-menu .close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2200;
  cursor: pointer;
}

#popup-menu button#close-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  background: darkred;
  color: white;
  border: none;
  font-weight: bold;
  cursor: pointer;
}

/* Small helper so very large popups stay centered and scroll inside the popup */
#menu-content > * {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

/* ---------- Instance button styling ---------*/
/*
#instance-enter-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10010;
  padding: 0;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: #2b2b2b;           
  color: #fff;
  font-size: 16px;
  line-height: 1;
  overflow: hidden;
  width: 220px;                  
  height: 48px;                
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
*/

/* ---------- Rest button styling ---------- */
/* Rest button base */
#rest-button, #shop-button, #storage-button, #instance-enter-button{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10010;
  padding: 0;
  border-radius: 8px;
  border: 2px solid #1a130c;
  cursor: pointer;
  background: #fff;           /* dark gray background */
  color: #1a130c;
  font-size: 16px;
  line-height: 1;
  overflow: hidden;
  width: 220px;                  /* adjust width as desired */
  height: 48px;                  /* adjust height as desired */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

/* hide helper */
#rest-button.hidden { display: none; }

#shop-button.hidden { display: none !important; pointer-events: none !important; }

/* label sits above progress */
#rest-button .rest-label {
  position: relative;
  z-index: 2;
  pointer-events: none;
  padding: 0 12px;
}

/* progress wrapper (fills entire button but label sits above) */
#rest-button .rest-progress {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  z-index: 1;
  pointer-events: none;
  display: block;
}

/* the actual fill that grows left->right */
#rest-button .rest-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: #4a4a4a;   /* lighter gray for progress fill */
  transition: none;      /* animated by JS for precise timing */
  z-index: 1;
}

/* Resting visual state */
#rest-button.resting {
  transform: scale(0.98);
  opacity: 0.95;
}

/* Disabled state */
#rest-button[disabled] {
  cursor: not-allowed;
  opacity: 0.85;
}

/* ---------- Combat UI styling ---------- */
/* Combat UI container */
#combat-ui {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
}

/* Boxes */
.combat-box {
  background: rgba(241, 218, 178, 1);
  color: #1a130c;
  padding: 0.5rem;
  border-radius: 3px;
  border: 2px solid #1a130c;
  width: 24%;
  box-sizing: border-box;
}

/* Center controls */
.combat-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Buttons */
.combat-controls button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 1px;
  border: none;
  background: #2b6cb0;
  color: white;
}
.combat-controls button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Health track: gray background + thin outline */
.hp-track {
  position: relative;
  height: 28px;
  background: #2f2f2f;       /* dark gray background track */
  border: 2px solid #6b6b6b; /* outline to mark max hp */
  border-radius: 6px;
  overflow: visible;
  margin-top: 8px;
}

/* The red fill (changes width). Default anchored to left; for enemy add .right-anchor */
.hp-fill {
  position: absolute;
  top: 0;
  left: 0;                   /* left-anchored by default */
  height: 100%;
  width: 100%;
  background: linear-gradient(#e74c3c, #c0392b); /* red gradient */
  border-radius: 4px;
  z-index: 1;
  transform-origin: left center; /* not strictly necessary but good for transforms */
}

/* Right-anchored fill (enemy) */
.hp-fill.right-anchor {
  left: auto;
  right: 0;
  transform-origin: right center;
}

/* Text sitting above the fill (always centered). White text with shadow for readability. */
.hp-text {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  pointer-events: none;
  font-size: 14px;
}

/* Optional name styling */
.combat-name { font-size: 16px; font-weight: 700; margin: 0; }

#inventory-wrapper { font-family: sans-serif; color: #fff; }
#inventory-wrapper img { image-rendering: crisp-edges; }
.equip-row:hover, .inventory-row:hover { background: rgba(255,255,255,0.02); }
#inventory-list, #equip-list { scrollbar-color: #444 transparent; }

/* Item detail modal styles (drop into your main CSS) */
.item-modal-backdrop {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.25);
  z-index: 1990;
}

.item-details-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  background: #0f0f0f;
  color: #1a130c;
  padding: 16px;
  z-index: 2000;
  border-radius: 6px;
  width: 300px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.7);
  font-family: "Georgia", "Times New Roman", serif;
  line-height: 1.25;
  overflow: hidden;
}

/* Header area: icon left, name and subheading right */
.item-modal-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

/* Icon larger than reference */
.item-modal-icon {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.4);
  padding: 6px;
  box-sizing: border-box;
  border: 1px solid #1a130c;
  flex: 0 0 88px;
}

/* Title text to the right of icon */
.item-modal-title {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}

/* subtitle line under name (small, muted) */
.item-modal-subtitle {
  color: #1a130c;
  font-size: 13px;
  margin-top: 6px;
}

/* Stats block - left aligned, smaller, and lighter color */
.item-modal-stats {
  margin-top: 6px;
  color: #1a130c;
  font-size: 13px;
}

/* stat key styling */
.item-modal-stats .stat-key {
  color: #1a130c;
  display: inline-block;
  min-width: 180px;
}

/* stat value styling */
.item-modal-stats .stat-val {
  color: #1a130c;
}

/* small divider */
.item-modal-divider {
  height: 1px;
  background: #1a130c;
  margin: 10px 0;
}

/* highlighted description (italic, gold, slightly smaller) */
.item-modal-desc {
  color: #1a130c;
  font-style: italic;
  font-size: 11px;
  margin-top: 8px;
  white-space: pre-wrap;
}

/* close button (top-right inside modal) */
.item-modal-close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: transparent;
  color: #1a130c;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 14px;
}

/* responsive tweak: shrink width on small screens */
@media (max-width: 420px) {
  .item-details-modal { width: calc(100vw - 24px); padding: 12px; }
  .item-modal-icon { width: 72px; height: 72px; flex: 0 0 72px; }
  .item-modal-title { font-size: 16px; }
  .item-modal-stats .stat-key { min-width: 140px; }
}