/* File: src/styles/base.css */
/* ─────────────────────────────────────────────────────────────────────────────
   base.css
   Reset, root layout, canvas host, glass-pane UI root.
───────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  
  /* Prevent text highlighting globally */
  user-select: none;
  -webkit-user-select: none;
  
  /* Prevent dragging images/elements globally */
  -webkit-user-drag: none;
  
  /* Prevent touch-and-hold context menus on touchscreens/Steam Deck */
  -webkit-touch-callout: none;
}

/* Allow text selection ONLY in specific debug/log elements if needed */
.allow-select {
  user-select: text;
  -webkit-user-select: text;
}

html, body {
  width: 100%;
  height: 100%;
  background: #030805;
  overflow: hidden;
  font-family: 'ShareTechMono', monospace;
  /* Default cursor, overridden by CursorManager */
  cursor: default;
}

/* ── Game wrapper — fills the viewport, centres the canvas ─────────────────── */
#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
  max-height: 100%;
  /* Ensure canvas doesn't capture default touch actions like scrolling */
  touch-action: none;
}

/* ── Prevent iOS tap-highlight flash ─────────────────────────────────────── */
#game-wrapper,
#game-wrapper * {
  -webkit-tap-highlight-color: transparent;
}

/* ── Glass Pane ─────────────────────────────────────────────────────────────
   Transparent overlay that sits above the canvas.
   Default: pointer-events:none so clicks pass through to canvas.
   Interactive overlays override per-element.
─────────────────────────────────────────────────────────────────────────── */
#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  font-family: 'ShareTechMono', monospace;
  zoom: var(--ui-scale); 
}

/* ── Hide transient DOM overlays when paused ─────────────────────────────── */
#ui-root.is-paused #tutorial-checklist,
#ui-root.is-paused #dialog-hint,
#ui-root.is-paused #world-interact-prompt,
#ui-root.is-paused .ui-toasts,
#ui-root.is-paused .ui-achievements {
  display: none !important;
}

/* ── Pre-load label ─────────────────────────────────────────────────────── */
#pre-load {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #2d4a1e;
  font-size: 13px;
  letter-spacing: 0.1em;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   IN-GAME CUSTOM SCROLLBAR  (GameScroll utility)
   Replaces browser-native scrollbars in all overlay panels.
   ──────────────────────────────────────────────────────────────────────────
   .gs-inner  — wrapper that slides via transform:translateY when scrolling
   .gs-track  — scrollbar strip at right edge of scroll container
   .gs-thumb  — draggable position indicator inside the track
══════════════════════════════════════════════════════════════════════════ */

.gs-inner {
  /* Natural block layout; grows with content, no explicit height */
  width: 100%;
}

/* ── Scrollbar track ────────────────────────────────────────────────────────
   Was: rgba(255,255,255,0.08) — nearly invisible on any background.
   Now: a visible dark panel with a clear green border so users immediately
   recognise the scrollable region has a scrollbar.
────────────────────────────────────────────────────────────────────────── */
.gs-track {
  position: absolute;
  right: 2px;
  top: 6px;
  bottom: 6px;
  width: 8px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(60, 110, 30, 0.60);
  border-radius: 4px;
  z-index: 200;
  cursor: pointer;
  display: none;                    /* shown by JS only when content overflows */
  transition: background 0.15s, border-color 0.15s, width 0.15s;
}

.gs-track:hover {
  width: 10px;
  right: 1px;
  background: rgba(0, 0, 0, 0.70);
  border-color: rgba(100, 180, 40, 0.80);
}

/* ── Scrollbar thumb ──────────────────────────────────────────────────────── */
.gs-thumb {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 0;
  min-height: 28px;
  background: rgba(90, 184, 40, 0.85);
  border-radius: 3px;
  cursor: grab;
  transition: background 0.12s, box-shadow 0.12s;
  box-shadow: 0 0 6px rgba(90, 184, 40, 0.60), inset 0 1px 0 rgba(255,255,255,0.20);
}

.gs-thumb:hover {
  background: rgba(143, 206, 80, 1);
  box-shadow: 0 0 12px rgba(143, 206, 80, 0.75), inset 0 1px 0 rgba(255,255,255,0.25);
}

.gs-thumb:active {
  cursor: grabbing;
  background: rgba(165, 230, 90, 1);
}

/* ── Bottom fade — "more content below" indicator ───────────────────────────
   Was: a subtle 55% black gradient that blended into the dark UI.
   Now: a strong gradient with a clearly visible "▾ more" label so it's
   immediately obvious the panel is scrollable.
────────────────────────────────────────────────────────────────────────── */
.gs-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.65) 50%,
    rgba(0, 0, 0, 0.90) 100%
  );
  pointer-events: none;
  z-index: 150;
  display: none;                    /* shown by JS when not yet at bottom */
}

/* Bouncing arrow + "more" label */
.gs-fade::after {
  content: '▾  more';
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'ShareTechMono', monospace;
  font-size: 10px;
  font-weight: bold;
  color: rgba(143, 206, 80, 0.90);
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px rgba(90, 184, 40, 0.80);
  animation: gs-bounce 1.4s ease-in-out infinite;
  white-space: nowrap;
}

/* ── Top fade — "more content above" indicator ───────────────────────────── */
.gs-fade-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(
    to top,
    transparent 0%,
    rgba(0, 0, 0, 0.55) 60%,
    rgba(0, 0, 0, 0.80) 100%
  );
  pointer-events: none;
  z-index: 150;
  display: none;                    /* shown by JS when scrolled down */
}

.gs-fade-top::before {
  content: '▴  scroll up';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'ShareTechMono', monospace;
  font-size: 9px;
  font-weight: bold;
  color: rgba(143, 206, 80, 0.70);
  letter-spacing: 0.10em;
  white-space: nowrap;
}

@keyframes gs-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0);   opacity: 0.70; }
  50%       { transform: translateX(-50%) translateY(4px); opacity: 1.00; }
}

/* Ensure scroll containers never show native browser scrollbars */
.settings-body,
.inv-body-scroll,
.sp-body-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.settings-body::-webkit-scrollbar,
.inv-body-scroll::-webkit-scrollbar,
.sp-body-scroll::-webkit-scrollbar { display: none; }

/* ════════════════════════════════════════════════════════════
   HANDHELD / SMALL SCREEN OPTIMIZATIONS
════════════════════════════════════════════════════════════ */

/* 1. Hide verbose descriptions and subtext */
.is-handheld .eb-empty-sub,             /* "pick up to auto-equip" */
.is-handheld .inv-hint,                 /* Inventory bottom hints */
.is-handheld .gsr-desc,                 /* Settings panel descriptions */
.is-handheld .settings-pane-desc,       /* Settings header paragraphs */
.is-handheld .db-welcome-footnote,      /* Encyclopedia footnotes */
.is-handheld .eb-inv-hint,              /* "[I] inventory" on equip bar */
.is-handheld .stat-hint,                /* "+2 slots" in equipment */
.is-handheld .card-tagline,             /* Zombie card taglines */
.is-handheld #vital-hp-value,           /* Vitals x/y numbers */
.is-handheld #vital-nut-value,
.is-handheld #vital-en-value {
  display: none !important;
}

/* 2. Tighten up the Inventory Layout so it doesn't overflow */
.is-handheld .inv-body {
  flex-wrap: nowrap;             /* Allow columns to wrap if needed */
  justify-content: center;
  padding: 8px 10px;
}
.is-handheld .inv-equip-col {
  width: 180px;                /* Shrink equipment column */
  margin-right: 8px;
}
.is-handheld .inv-storage-col {
  width: 236px;                /* Shrink storage (48px slots -> 42px) */
}
.is-handheld .storage-slot {
  width: 42px; height: 42px;
}
.is-handheld .inv-craft-col {
  min-width: 100%;             /* Force crafting to wrap below on very tiny screens */
  border-left: none;
  border-top: 1px solid #1a3412;
  margin-top: 8px;
  padding-top: 8px;
}

/* 3. Tighten HUD and Vitals */
.is-handheld .ui-hud {
  width: 200px;                /* Make HUD ~30% narrower */
  min-width: 200px;
}
.is-handheld .hud-player-type {
  margin-left: 0 !important;   /* Unindent class name */
}
.is-handheld .vital-row {
  gap: 4px;
}

/* ══════════════════════════════════════════════════════════════════════════
   INPUT GLYPHS (Keyboard & Gamepad Buttons)
══════════════════════════════════════════════════════════════════════════ */

.input-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'ShareTechMono', monospace;
  font-weight: bold;
  font-size: 0.9em;
  line-height: 1.2;
  vertical-align: middle;
  box-sizing: border-box;
  margin: 0 4px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.5);
  text-shadow: none;
}

.input-glyph-kbm {
  background: #eee;
  color: #111;
  border: 1px solid #aaa;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 3px 6px;
  min-width: 1.6em;
  height: 1.6em;
}

.input-glyph-gp {
  background: #444;
  color: #fff;
  border: 1px solid #222;
  border-bottom-width: 2px;
}

.input-glyph-gp-round {
  border-radius: 50%;
  width: 1.6em;
  height: 1.6em;
  padding: 0;
}

.input-glyph-gp-pill {
  border-radius: 1em;
  padding: 3px 8px;
  height: 1.6em;
}

.input-glyph-gp-dpad {
  border-radius: 4px;
  padding: 3px 5px;
  height: 1.6em;
  background: #333;
}

/* ── Globally strip Input Hints when disabled in settings ───────────────── */
.hide-input-hints .input-glyph,
.hide-input-hints .input-hint-text,
.hide-input-hints .eb-inv-hint,
.hide-input-hints .inv-hint,
.hide-input-hints .inv-close-hint,
.hide-input-hints #inv-pickup-hint,
.hide-input-hints .pp-key,
.hide-input-hints .pp-hint-secondary,
.hide-input-hints .pp-cancel-hint,
.hide-input-hints .tmo-dismiss-footer,
.hide-input-hints #tmo-hint {
  display: none !important;
}