/* Resume World — 8/16-bit Zelda-style overworld for resume.borck.dev
   Canvas 2D tile engine: player movement, follow camera, region discovery,
   landmark detail panels. Data from data/world-data.json. */

:root {
  --ink: #0a0a0b;
  --panel: #12121a;
  --panel-2: #1a1a26;
  --line: #2a2a3a;
  --text: #e8e6e3;
  --muted: #9a9aa8;
  --gold: #ffcf6b;
  --gold-soft: #ffe6a8;
  --cyan: #6ee0d8;
  --green: #7ddc7d;
  --accent: #a855f7;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --pixel: "Press Start 2P", var(--mono);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #0b0e1a;
}

/* ---- HUD ---- */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.hud > * { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  gap: 10px;
}
.brand {
  background: rgba(10, 12, 22, 0.82);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}
.brand .dot { color: var(--muted); }
.brand .t {
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--gold-soft);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
}
.brand .s {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.3px;
}
.hud-actions { display: flex; gap: 8px; }

.btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text);
  background: rgba(18, 20, 34, 0.9);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.5);
  transition: transform 0.08s, border-color 0.12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.5); }
.btn.solid { background: var(--gold); color: #1a1400; border-color: #c9973f; }
.btn.ghost { background: rgba(18, 20, 34, 0.9); }

/* Region tracker (discovered regions as little badges) */
.tracker {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 220px;
}
.tracker-title {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.tracker-list { display: flex; flex-wrap: wrap; gap: 5px; }
.region-chip {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  background: rgba(18,20,34,0.85);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 4px 7px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.region-chip:hover { color: var(--text); border-color: var(--gold); }
.region-chip.found { color: var(--gold-soft); border-color: var(--gold); }
.region-chip.found::before { content: "◆ "; color: var(--gold); }
.region-chip.current { border-color: var(--cyan); color: var(--cyan); }

/* Interaction prompt near the player */
.prompt {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold-soft);
  background: rgba(10,12,22,0.9);
  border: 2px solid var(--gold);
  border-radius: 6px;
  padding: 6px 12px;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  pointer-events: none;
}
.prompt.show { opacity: 1; }
.prompt .key {
  display: inline-block;
  background: var(--gold);
  color: #1a1400;
  border-radius: 3px;
  padding: 0 5px;
  font-weight: 700;
  margin-right: 4px;
}

/* Region title card (big center reveal when entering a region) */
.titlecard {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  width: 90%;
}
.titlecard.show { opacity: 1; }
.titlecard .tc-region {
  font-family: var(--pixel);
  font-size: clamp(16px, 3.4vw, 28px);
  color: var(--gold-soft);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.7);
  letter-spacing: 1px;
}
.titlecard .tc-sub {
  font-family: var(--mono);
  font-size: clamp(10px, 1.6vw, 13px);
  color: var(--text);
  margin-top: 10px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
  background: rgba(10,12,22,0.6);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
}

/* ---- Detail panel ---- */
.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(430px, 92vw);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border-left: 2px solid var(--line);
  box-shadow: -12px 0 40px rgba(0,0,0,0.6);
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel.open { transform: translateX(0); }
.panel-head {
  padding: 18px 20px 14px;
  border-bottom: 2px solid var(--line);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.panel-icon {
  width: 56px; height: 56px;
  image-rendering: pixelated;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.5));
}
.panel-titles { flex: 1; min-width: 0; }
.panel-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 4px;
}
.panel-title {
  font-family: var(--pixel);
  font-size: 13px;
  line-height: 1.5;
  color: var(--gold-soft);
  word-break: break-word;
}
.panel-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}
.panel-close {
  background: none;
  border: 2px solid var(--line);
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.panel-close:hover { color: var(--text); border-color: var(--gold); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 24px;
}
.panel-body p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 12px;
}
.panel-body p:first-child { color: var(--text); }
.panel-body .muted { color: var(--muted); }

.panel-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.panel-links a {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  text-decoration: none;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}
.panel-links a:hover { border-color: var(--gold); background: rgba(255,207,107,0.08); }

/* Region list inside panel when no specific marker */
.region-grid { display: flex; flex-direction: column; gap: 10px; }
.region-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(10,12,22,0.5);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: var(--font);
  color: var(--text);
}
.region-item:hover { border-color: var(--gold); }
.region-item img { width: 40px; height: 40px; image-rendering: pixelated; flex-shrink: 0; }
.region-item .ri-name { font-family: var(--pixel); font-size: 10px; color: var(--gold-soft); line-height: 1.5; }
.region-item .ri-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

/* Overlay screens (welcome / help) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 16, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
.card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  max-width: 540px;
  width: 100%;
  padding: 28px 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}
.card h1 {
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.6;
  color: var(--gold-soft);
  margin-bottom: 6px;
}
.card .card-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.card p { font-size: 14px; line-height: 1.65; color: var(--text); margin-bottom: 14px; }
.card .keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin: 18px 0;
}
.card .keys .k { color: var(--gold-soft); font-weight: 700; white-space: nowrap; }
.card .keys .d { color: var(--muted); }
.card-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* Touch D-pad (shown on touch devices) */
.dpad {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: none;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
  z-index: 15;
}
.dpad button {
  background: rgba(18,20,34,0.85);
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.dpad button:active { background: var(--gold); color: #1a1400; }
.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 3; }
.dpad .act { grid-column: 2; grid-row: 2; font-size: 13px; font-family: var(--mono); font-weight: 700; }
body.touch .dpad { display: grid; }
body.touch .tracker { bottom: 148px; }

/* Scanline/vignette flavour */
.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.06) 0px, rgba(0,0,0,0.06) 1px, transparent 1px, transparent 3px
  );
  z-index: 30;
  mix-blend-mode: multiply;
}

/* Loader */
.loading {
  position: fixed;
  inset: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
}
.loading .bar {
  width: 220px; height: 12px;
  border: 2px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.loading .bar > div {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.2s;
}

@media (max-width: 640px) {
  .brand .t { font-size: 9px; }
  .btn { font-size: 10px; padding: 7px 9px; }
  .panel { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .titlecard, .prompt { transition: none; }
}