/* The dungeon HUD - portrait, bars, compass, floor - and the movement controls.
 *
 * One of the stylesheets split out of the old style.css. index.html links them
 * in the order they had in that file, so the cascade is unchanged - keep
 * that order when adding a rule, or a later sheet may win where it used to lose. */

/* ---------- exploration HUD ---------- */

#dungeon-hud { position: absolute; inset: 0; z-index: 12; pointer-events: none; }

#player-hud {
  position: absolute;
  top: 18px;
  left: 18px;
  width: min(370px, calc(100vw - 250px));
  min-width: 285px;
  min-height: 104px;
  padding: 10px;
  display: flex;
  gap: 13px;
}

#player-avatar {
  width: 78px;
  flex: 0 0 78px;
  aspect-ratio: 1;
  align-self: flex-start;
  padding: 0;
  display: grid;
  place-items: center;
  color: #f1c66f;
  background: linear-gradient(135deg, transparent 22%, rgba(200,153,72,0.16) 22% 28%, transparent 28%), #171b1e;
  border: 3px solid #08090a;
  outline: 2px solid var(--gold-dark);
  font-size: 40px;
  line-height: 1;
  text-shadow: 3px 3px 0 #000;
}
#player-avatar[data-job="Mage"],
#player-avatar[data-job="Rogue"],
#player-avatar[data-job="Warrior"] {
  color: transparent;
  text-shadow: none;
  background-color: #111518;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}
#player-avatar[data-job="Mage"] { background-image: url("../assets/characters/mage.png"); }
#player-avatar[data-job="Rogue"] { background-image: url("../assets/characters/rogue.png"); }
#player-avatar[data-job="Warrior"] { background-image: url("../assets/characters/warrior.png"); }

.player-hud-content { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.player-hud-title, .stat-row { display: flex; align-items: center; }
.player-hud-title { justify-content: space-between; color: #f4e8c9; font-size: 17px; text-shadow: 2px 2px 0 #000; }
#player-level { color: var(--gold); font-size: 14px; }
.stat-row { gap: 7px; font-size: 12px; }
.stat-label { width: 20px; color: var(--muted); }
.stat-track {
  position: relative;
  height: 12px;
  min-width: 30px;
  flex: 1;
  overflow: hidden;
  background: #08090a;
  border: 2px solid #3b3328;
  box-shadow: inset 2px 2px 0 #000;
}
.stat-fill { display: block; width: 0; height: 100%; transition: width 180ms steps(6, end); }
.hp-fill { background: linear-gradient(180deg, #dc5555 0 42%, var(--crimson) 42% 100%); }
.xp-fill { background: linear-gradient(180deg, #edc163 0 42%, var(--gold) 42% 100%); }
.stat-value { width: 66px; text-align: right; color: #f0e3c3; white-space: nowrap; }
/* What the run is worth so far. Gold until it is at risk, then it reads as a
   warning, because that is exactly what it is. */
/* Transient notice, centred above the controls and out of the way of the view. */
#system-message {
  position: absolute; left: 50%; top: 186px; transform: translate(-50%, -8px);
  padding: 10px 18px; color: #f4e8c9; font-size: 13px; letter-spacing: 0.6px;
  background: rgba(11, 13, 16, 0.92); pointer-events: none;
  opacity: 0; transition: opacity 220ms ease, transform 220ms ease; z-index: 60;
}
#system-message.visible { opacity: 1; transform: translate(-50%, 0); }

.pouch-row { font-size: 12px; }
/* "RUN GOLD" - gold found this run, not yet banked. It was "BAG", which is
   also the inventory's name. This row has no bar, so the label takes its
   own width instead of the 20px the two-letter bar labels share. */
.pouch-row .stat-label { width: auto; white-space: nowrap; }
#hud-pouch { color: var(--muted); white-space: nowrap; letter-spacing: 0.5px; }
#hud-pouch[data-carrying="yes"] { color: #ffd700; text-shadow: 0 0 6px rgba(255, 215, 0, 0.35); }

#compass {
  position: absolute;
  top: 18px;
  left: 50%;
  width: 92px;
  height: 92px;
  transform: translateX(-50%);
  border-radius: 50%;
  box-shadow: 0 0 0 3px #08090a, 0 0 0 6px var(--gold-dark), 5px 6px 0 rgba(0, 0, 0, 0.5);
}
#minimap {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 0;
  width: 68px;
  height: 68px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #090c0d;
  box-shadow: inset 0 0 0 1px rgba(200,153,72,0.3);
  image-rendering: pixelated;
}
.cardinal { position: absolute; color: var(--parchment); font-size: 12px; line-height: 1; text-shadow: 1px 2px 0 #000; }
.cardinal { z-index: 1; pointer-events: none; }
.cardinal.north { top: 8px; left: 50%; transform: translateX(-50%); }
.cardinal.east { right: 8px; top: 50%; transform: translateY(-50%); }
.cardinal.south { bottom: 8px; left: 50%; transform: translateX(-50%); }
.cardinal.west { left: 8px; top: 50%; transform: translateY(-50%); }

#compass-needle {
  position: absolute;
  top: 28px;
  left: 42px;
  width: 8px;
  height: 36px;
  transform-origin: 50% 18px;
  transition: transform 140ms steps(4, end);
}
#compass-needle::before, #compass-needle::after {
  content: "";
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
#compass-needle::before { top: 0; border-bottom: 18px solid #f1c66f; }
#compass-needle::after { bottom: 0; border-top: 18px solid #715a36; }

#floor-status {
  position: absolute;
  top: 126px;
  left: 50%;
  min-width: 178px;
  padding: 7px 11px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 3px 9px;
  transform: translateX(-50%);
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 2px #08090a, 4px 5px 0 rgba(0,0,0,0.45);
  font-size: 10px;
  letter-spacing: 0.1em;
}

/* Centred with left: 50%, the panel only ever has half the screen to grow
   into. On a phone that used to break "FLOOR 11" and "DANGER" mid-label, and
   an open miasma badge pushed it under the controls. Whole items wrap to a
   second row instead, so it grows taller rather than wider. */
#floor-status > * { white-space: nowrap; }

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* A badge in the floor panel: an icon that a tap turns into text, not a
   framed button. #ui-overlay takes no clicks, so it asks for them itself, and
   ::after widens the target to a thumb's height without making the panel any
   taller. The widening sits behind everything else in the panel, so it only
   ever catches taps on empty space: when a phone wraps the panel to two rows,
   the lower badge's reach would otherwise cover the upper badge's icon. */
#floor-status { isolation: isolate; }
.hud-badge {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0 2px;
  gap: 6px;
  font: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  outline: 0;
  box-shadow: none;
  pointer-events: auto;
}
.hud-badge::after { content: ''; position: absolute; inset: -12px -4px; z-index: -1; }
/* No filter or transform on hover: either gives the hovered badge its own
   layer, which lifts its widened target back over its neighbour's icon. */
.hud-badge:hover:not(:disabled) { background: none; color: inherit; }
#miasma-status:hover:not(:disabled) { color: #c4ecb3; }
.hud-badge:focus-visible { outline: 2px solid #f1c66f; outline-offset: 2px; }
.hud-badge-text { display: none; white-space: nowrap; }
.hud-badge[aria-expanded="true"] .hud-badge-icon { display: none; }
.hud-badge[aria-expanded="true"] .hud-badge-text { display: inline; }

#miasma-status { color: #9fcf8f; }
#miasma-status[data-thick="2"] { color: #7fc76a; }
#miasma-status[data-thick="3"] { color: #5fd14a; text-shadow: 0 0 6px rgba(95,209,74,0.5); }
.miasma-icon { display: block; width: 20px; height: 16px; fill: currentColor; }
.miasma-icon-light { fill: #e3f5d8; }

/* One to five skulls, lit up to the tier; the rest stay as dim outlines of
   the scale, so the row is the same width on every floor. */
#danger-status { color: #b9b39a; }
#danger-status[data-tier="2"] { color: #d7a54c; }
#danger-status[data-tier="3"] { color: #d97835; }
#danger-status[data-tier="4"] { color: #d64a3d; }
#danger-status[data-tier="5"] { color: #ff4a3a; text-shadow: 0 0 7px rgba(255,74,58,0.55); }
.danger-skulls { display: flex; gap: 3px; }
.danger-skulls svg { display: block; width: 14px; height: 14px; fill: currentColor; opacity: 0.22; }
.danger-skulls svg.lit { opacity: 1; }
#danger-status[data-tier="5"] .danger-skulls svg.lit { filter: drop-shadow(0 0 3px rgba(255,74,58,0.6)); }
/* Tier 0: UNKNOWN, while a timed event reaches the floor (gameManager.dangerHere).
   The word stands where the skulls do, opened or not. */
#danger-status[data-tier="0"] { color: #c9a86a; }
/* In a dragon's den the reading jumps; the badge flares once as it does. */
#danger-status[data-den="true"] { animation: danger-den-flare 900ms ease-out 1; }
@keyframes danger-den-flare {
  0% { transform: scale(1); filter: brightness(1); }
  25% { transform: scale(1.12); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}
@media (prefers-reduced-motion: reduce) { #danger-status[data-den="true"] { animation: none; } }
#danger-status[data-tier="0"] .danger-skulls { display: none; }
#danger-status[data-tier="0"] .hud-badge-text { display: inline; }

/* ---------- control clusters ---------- */

#exploration-ui, #combat-ui {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.controls { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 0 24px 24px; }
.control-group { display: flex; align-items: flex-end; gap: 12px; pointer-events: auto; }
#exploration-ui button { min-width: 68px; min-height: 68px; padding: 12px 15px; }
#btn-forward { min-width: 78px !important; min-height: 78px !important; }
#btn-return-city { min-width: 68px; }
.door-icon {
  position: relative;
  width: 25px;
  height: 31px;
  border: 3px solid var(--parchment);
  border-radius: 12px 12px 1px 1px;
  box-shadow: inset 0 0 0 3px #3b2b1f;
}
.door-icon::after { content: ""; position: absolute; right: 4px; top: 15px; width: 3px; height: 3px; background: var(--gold); }
