/*
Theme Name: Xagor City
Theme URI: https://xagor.studio/
Author: Xagor Studio
Description: Full-screen pixel-RPG portfolio theme for Xagor City.
Version: 0.2.0
Requires at least: 6.5
Requires PHP: 8.0
Text Domain: xagor-city-theme
*/

:root {
  --xg-bg: #0e0d12;
  --xg-panel: #17151f;
  --xg-panel-2: #252231;
  --xg-cream: #f3ecd7;
  --xg-paper: #eadab5;
  --xg-ink: #30251f;
  --xg-accent: #c39f5e;
  --xg-accent-deep: #8c6b3f;
  --xg-border: #6f5940;
  --xg-shadow: #09080d;
  --xg-mobile-bar: 182px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--xg-bg); }
body { color: var(--xg-cream); font-family: "Courier New", Courier, monospace; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img { max-width: 100%; }

.xg-app {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(195,159,94,.09), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(94,72,108,.14), transparent 30%),
    linear-gradient(180deg, #17151f 0%, #0d0c11 100%);
}

.xg-screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}
.xg-screen.is-active { display: flex; }

.xg-panel {
  width: min(760px, 94vw);
  position: relative;
  z-index: 3;
  border: 4px solid #4c4355;
  outline: 3px solid #0a090d;
  background: rgba(20,18,27,.96);
  box-shadow: 0 18px 0 rgba(0,0,0,.28), 0 34px 80px rgba(0,0,0,.44);
  padding: 30px;
  image-rendering: pixelated;
}
.xg-panel::before,
.xg-panel::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--xg-accent);
  box-shadow: 0 0 0 3px #17131a;
}
.xg-panel::before { left: 8px; top: 8px; }
.xg-panel::after { right: 8px; bottom: 8px; }

.xg-kicker {
  text-align: center;
  color: #baa98c;
  font-size: 11px;
  letter-spacing: .18em;
  margin-bottom: 10px;
}
.xg-logo {
  text-align: center;
  font-size: clamp(36px, 7vw, 78px);
  line-height: .95;
  letter-spacing: .1em;
  font-weight: 900;
  text-shadow: 4px 4px 0 #000, 7px 7px 0 rgba(195,159,94,.18);
  margin: 0 0 18px;
}
.xg-subtitle { text-align: center; opacity: .78; margin: 0 auto 26px; max-width: 520px; line-height: 1.5; }
.xg-menu { display: grid; gap: 12px; max-width: 390px; margin: 0 auto; }
.xg-menu-hint { margin-top: 20px; text-align: center; color: #777083; font-size: 10px; letter-spacing: .08em; }

.xg-btn {
  cursor: pointer;
  position: relative;
  display: block;
  width: 100%;
  border: 3px solid #0b0a0e;
  outline: 2px solid #5c5168;
  background: #302b3d;
  color: var(--xg-cream);
  padding: 14px 18px 16px;
  text-decoration: none;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .1em;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.28);
  transition: transform .08s ease, filter .08s ease, outline-color .08s ease;
}
.xg-btn > span { position: relative; z-index: 2; }
.xg-btn:hover, .xg-btn:focus-visible { filter: brightness(1.18); transform: translateY(-2px); outline-color: #817292; }
.xg-btn:active { transform: translateY(2px); }
.xg-btn.is-primary { background: #735937; outline-color: var(--xg-accent); }
.xg-btn.is-primary::after {
  content: "";
  position: absolute;
  inset: 4px 5px 8px;
  border-top: 2px solid rgba(255,255,255,.08);
  pointer-events: none;
}
.xg-btn.is-quiet { background: #24212d; color: #afa8bb; }
.xg-btn[disabled] { opacity: .34; cursor: not-allowed; transform: none; filter: none; }

/* Loading */
.xg-loading-screen {
  background:
    linear-gradient(rgba(10,9,14,.22), rgba(10,9,14,.68)),
    radial-gradient(circle at 50% 42%, #2a2530 0, #15131b 45%, #09080c 100%);
}
.xg-loading-vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px #000; pointer-events: none; }
.xg-loading-wrap { width: min(650px, 88vw); text-align: center; z-index: 2; }
.xg-loading-mark {
  width: 74px; height: 74px; margin: 0 auto 22px;
  display: grid; place-items: center;
  font-size: 44px; font-weight: 900; color: var(--xg-accent);
  border: 4px solid #4a3d2e; outline: 2px solid #0a090d;
  background: #1a171d; text-shadow: 3px 3px 0 #000;
  animation: xg-pulse 1.2s steps(2,end) infinite;
}
@keyframes xg-pulse { 50% { transform: translateY(-2px); filter: brightness(1.25); } }
.xg-loading-logo { font-size: clamp(24px, 5vw, 48px); font-weight: 900; letter-spacing: .1em; margin-bottom: 30px; text-shadow: 3px 3px 0 #000; }
.xg-loading-line { min-height: 24px; opacity: .78; margin: 16px 0 0; font-size: 13px; }
.xg-progress-shell { height: 24px; border: 3px solid #0b0a0e; background: #282334; padding: 4px; box-shadow: 0 0 0 2px #5e536f; }
.xg-progress { height: 100%; width: 0; background: repeating-linear-gradient(90deg, #d0b278 0 16px, #9d7946 16px 20px); transition: width .16s linear; }
.xg-loading-percent { margin-top: 8px; opacity: .55; font-size: 11px; }

/* Main menu */
.xg-menu-screen::before,
.xg-menu-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.xg-menu-screen::before {
  background:
    linear-gradient(rgba(12,11,16,.35), rgba(12,11,16,.78)),
    url("assets/art/xagor-city-street.png") center/cover no-repeat;
  filter: blur(1px) saturate(.75) brightness(.62);
  transform: scale(1.02);
}
.xg-menu-screen::after { background: radial-gradient(circle at 50% 45%, transparent 0 28%, rgba(0,0,0,.58) 80%); }
.xg-main-panel { max-width: 670px; }

/* Character select */
.xg-character-screen { background: #15131a var(--xg-select-bg) center/cover no-repeat; }
.xg-character-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(9,8,12,.88), rgba(9,8,12,.46) 50%, rgba(9,8,12,.88)); }
.xg-character-panel { max-width: 900px; padding: 28px 32px 30px; }
.xg-character-heading { margin: 0; text-align: center; font-size: clamp(22px, 4vw, 42px); letter-spacing: .08em; text-shadow: 3px 3px 0 #000; }
.xg-character-intro { max-width: 620px; text-align: center; margin: 10px auto 22px; color: #aaa2b2; line-height: 1.45; font-size: 13px; }
.xg-characters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 18px 0 24px; }
.xg-character {
  min-height: 216px;
  display: grid;
  grid-template-columns: 136px 1fr;
  align-items: center;
  gap: 16px;
  position: relative;
  cursor: pointer;
  color: var(--xg-cream);
  background: linear-gradient(180deg, #24212d 0%, #1c1922 100%);
  border: 3px solid #0a090d;
  outline: 2px solid #4d4555;
  padding: 16px;
  text-align: left;
  box-shadow: inset 0 -7px 0 rgba(0,0,0,.22);
}
.xg-character:hover { outline-color: #796a86; transform: translateY(-2px); }
.xg-character.is-selected { outline-color: var(--xg-accent); background: linear-gradient(180deg, #342d3a, #231d28); }
.xg-character.is-selected::after {
  content: "SELECTED";
  position: absolute; top: 8px; right: 8px;
  padding: 4px 6px; background: var(--xg-accent); color: #201912;
  border: 2px solid #221b15; font-size: 9px; font-weight: 900; letter-spacing: .1em;
}
.xg-character-frame {
  width: 128px; height: 160px; overflow: hidden;
  display: grid; place-items: end center;
  border: 3px solid #0c0b0e; outline: 2px solid #5a4a3a;
  background: radial-gradient(circle at 50% 42%, #4c4553, #25212d 68%);
}
.xg-character-portrait { width: 112px; height: 112px; object-fit: contain; image-rendering: pixelated; transform: scale(1.14); transform-origin: bottom center; }
.xg-character-copy { display: block; }
.xg-character-name { display: block; font-size: clamp(20px, 2.8vw, 32px); letter-spacing: .1em; margin-bottom: 8px; }
.xg-character-role { display: block; color: #b9a985; font-size: 10px; line-height: 1.45; letter-spacing: .08em; }
.xg-character-select-label { position: absolute; right: 14px; bottom: 12px; color: #6d6576; font-size: 9px; letter-spacing: .12em; }
.xg-character-actions { grid-template-columns: 1fr auto; max-width: 560px; }
.xg-character-actions .xg-btn.is-quiet { width: 120px; }

/* Game */
.xg-game-view { padding: 0; background: #0a0910; flex-direction: column; }
.xg-game-shell { position: relative; width: 100%; height: 100%; min-height: 0; overflow: hidden; background: #111019; }
.xg-game-stage { position: absolute; inset: 0; background: #111019; }
.xg-game-stage canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
.xg-hud { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.xg-hud-top { position: absolute; top: 14px; left: 14px; display: flex; gap: 10px; }
.xg-chip {
  pointer-events: auto;
  border: 2px solid #0a090d;
  outline: 1px solid #625669;
  background: rgba(21,18,27,.9);
  color: #efe8d4;
  padding: 8px 10px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.28), 3px 3px 0 rgba(0,0,0,.22);
  font-size: 11px;
  letter-spacing: .06em;
}
.xg-brand-chip span { color: #9b8c78; }
.xg-help { position: absolute; right: 14px; bottom: 14px; cursor: pointer; }
.xg-interaction-hint {
  position: absolute; left: 50%; bottom: 34px; transform: translate(-50%, 10px);
  opacity: 0; transition: opacity .14s ease, transform .14s ease;
  background: rgba(18,16,22,.9); border: 2px solid #0b0a0d; outline: 1px solid #79694f;
  padding: 8px 12px; color: #e6d3aa; font-size: 11px; letter-spacing: .1em;
}
.xg-interaction-hint.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Dialogue */
.xg-dialogue {
  position: absolute;
  left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(800px, calc(100vw - 40px)); min-height: 150px;
  display: none; z-index: 12;
  grid-template-columns: 136px 1fr;
  border: 4px solid #3f2f24;
  outline: 3px solid #171117;
  background: var(--xg-paper);
  color: var(--xg-ink);
  box-shadow: 0 0 0 2px #b78c54, 9px 10px 0 rgba(0,0,0,.34);
  padding: 0;
}
.xg-dialogue.is-open { display: grid; }
.xg-dialogue-portrait-wrap {
  position: relative; overflow: hidden;
  border-right: 4px solid #5b4030;
  background: linear-gradient(180deg, #665260, #332b37);
  display: grid; place-items: end center;
}
.xg-dialogue-portrait { width: 124px; height: 124px; object-fit: contain; image-rendering: pixelated; transform: scale(1.08); transform-origin: bottom center; }
.xg-dialogue-body { padding: 17px 20px 38px; position: relative; }
.xg-dialogue-name { color: #8b4f37; font-weight: 900; letter-spacing: .11em; margin-bottom: 10px; font-size: 15px; }
.xg-dialogue-text { line-height: 1.55; font-weight: 700; font-size: 15px; }
.xg-dialogue-next { position: absolute; right: 16px; bottom: 12px; border: 0; background: transparent; color: #5a3b28; cursor: pointer; font-weight: 900; letter-spacing: .08em; }
.xg-dialogue-next span { display: inline-block; animation: xg-next .7s steps(2,end) infinite; }
@keyframes xg-next { 50% { transform: translateX(3px); } }

/* Mobile console deck */
.xg-mobile-controls { display: none; }
.xg-mobile-brand { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; color: #706a7e; line-height: 1; }
.xg-mobile-brand span { display: block; letter-spacing: .18em; font-weight: 900; font-size: 10px; }
.xg-mobile-brand small { font-size: 6px; letter-spacing: .1em; }
.xg-mobile-pad { width: 114px; height: 114px; position: relative; }
.xg-control-btn {
  position: absolute; width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 2px solid #0a0910;
  background: #343041;
  color: #c6bfce;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.28), 0 0 0 1px #474153;
  user-select: none; touch-action: none; padding: 0;
}
.xg-control-btn:active { transform: translateY(2px); filter: brightness(1.15); }
.xg-control-btn.xg-up { top: 0; left: 37px; }
.xg-control-btn.xg-left { top: 37px; left: 0; }
.xg-control-btn.xg-right { top: 37px; right: 0; }
.xg-control-btn.xg-down { bottom: 0; left: 37px; }
.xg-dpad-center { position: absolute; width: 40px; height: 40px; left: 37px; top: 37px; background: #302c3a; border: 2px solid #0a0910; box-shadow: inset 0 0 0 1px #474153; }
.xg-mobile-meta { position: absolute; left: 50%; bottom: 19px; transform: translateX(-50%); color: #615b6e; font-size: 7px; letter-spacing: .14em; }
.xg-mobile-actions { display: flex; gap: 14px; align-items: center; }
.xg-action-btn {
  width: 60px; height: 60px; border-radius: 50%;
  border: 3px solid #241b14;
  background: #efe1be; color: #2b211a;
  display: grid; place-items: center;
  font-weight: 900; font-size: 18px;
  box-shadow: inset 0 -7px 0 #b8915b, 0 0 0 2px #b99a6e, 3px 5px 0 rgba(0,0,0,.22);
  touch-action: none;
}
.xg-action-btn:active { transform: translateY(3px); box-shadow: inset 0 -4px 0 #b8915b, 0 0 0 2px #b99a6e; }
.xg-action-btn.xg-b { transform: translateY(13px); }
.xg-action-btn.xg-b:active { transform: translateY(16px); }

/* Quick access */
.xg-quick-access { min-height: 100vh; background: #f7f2e7; color: #161419; padding: 56px 24px; overflow: auto; }
.xg-quick-inner { max-width: 1040px; margin: 0 auto; }
.xg-quick-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 18px; }
.xg-card { border: 2px solid #211e27; padding: 18px; background: #fffdf6; }

@media (max-width: 900px) {
  .xg-character-panel { width: min(720px, 94vw); }
  .xg-character { grid-template-columns: 112px 1fr; min-height: 188px; }
  .xg-character-frame { width: 104px; height: 138px; }
  .xg-character-portrait { width: 100px; height: 100px; }
}

@media (max-width: 760px) {
  :root { --xg-mobile-bar: 186px; }
  body { overflow: hidden; }
  .xg-screen { padding: 12px; }
  .xg-panel { padding: 20px 16px; border-width: 3px; }
  .xg-main-panel { width: calc(100vw - 26px); }
  .xg-logo { font-size: clamp(36px, 12vw, 56px); }
  .xg-menu-hint { display: none; }

  .xg-character-screen { align-items: center; }
  .xg-character-panel { max-height: calc(100vh - 24px); overflow-y: auto; scrollbar-width: none; }
  .xg-character-panel::-webkit-scrollbar { display: none; }
  .xg-character-heading { font-size: 23px; }
  .xg-character-intro { font-size: 11px; margin-bottom: 15px; }
  .xg-characters { gap: 10px; margin: 14px 0 18px; }
  .xg-character { display: block; min-height: 0; padding: 10px 8px 34px; text-align: center; }
  .xg-character-frame { width: 100%; height: 118px; margin-bottom: 8px; }
  .xg-character-portrait { width: 104px; height: 104px; }
  .xg-character-name { font-size: 18px; }
  .xg-character-role { font-size: 7px; min-height: 30px; }
  .xg-character-select-label { right: 0; left: 0; bottom: 10px; }
  .xg-character.is-selected::after { font-size: 7px; }
  .xg-character-actions { grid-template-columns: 1fr; max-width: 100%; }
  .xg-character-actions .xg-btn.is-quiet { width: 100%; }

  .xg-game-view { display: none; padding: 0; }
  .xg-game-view.is-active { display: flex; }
  .xg-game-shell { height: calc(100dvh - var(--xg-mobile-bar)); flex: 0 0 calc(100dvh - var(--xg-mobile-bar)); border-bottom: 3px solid #292434; }
  .xg-mobile-controls {
    display: flex;
    position: relative;
    width: 100%;
    height: var(--xg-mobile-bar);
    flex: 0 0 var(--xg-mobile-bar);
    z-index: 20;
    align-items: center;
    justify-content: space-between;
    padding: 35px 25px calc(14px + env(safe-area-inset-bottom));
    background:
      linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px) 0 0/8px 8px,
      linear-gradient(180deg, #1b1926 0%, #14121c 100%);
    border-top: 2px solid #312c3e;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  }
  .xg-dialogue { bottom: 14px; width: calc(100vw - 22px); min-height: 124px; grid-template-columns: 98px 1fr; border-width: 3px; }
  .xg-dialogue-portrait-wrap { border-right-width: 3px; }
  .xg-dialogue-portrait { width: 94px; height: 94px; }
  .xg-dialogue-body { padding: 13px 12px 32px; }
  .xg-dialogue-name { font-size: 12px; margin-bottom: 6px; }
  .xg-dialogue-text { font-size: 12px; line-height: 1.42; }
  .xg-dialogue-next { font-size: 10px; right: 10px; bottom: 8px; }
  .xg-hud-top { top: 8px; left: 8px; gap: 6px; }
  .xg-chip { font-size: 8px; padding: 6px 7px; }
  .xg-help { right: 8px; bottom: 8px; }
  .xg-interaction-hint { bottom: 20px; font-size: 9px; }
}

@media (max-width: 390px) {
  :root { --xg-mobile-bar: 174px; }
  .xg-mobile-controls { padding-left: 18px; padding-right: 18px; }
  .xg-mobile-pad { transform: scale(.9); transform-origin: left center; }
  .xg-mobile-actions { gap: 8px; transform: scale(.92); transform-origin: right center; }
  .xg-mobile-brand { top: 10px; }
}
