/* ============================================================
   Knightmares - dark fantasy pixel-art RPG aesthetic
   ============================================================ */

:root {
  /* Base */
  --bg:         #14141e;
  --bg-2:       #1a1a26;
  --surface:    #232333;
  --surface-2:  #2c2c3f;
  --surface-3:  #35354c;
  --line:       #4a4a64;
  --line-soft:  #313146;

  /* Foreground */
  --ink:        #e4e4f0;
  --ink-2:      #c8c8d8;
  --ink-dim:    #8a8aa0;
  --ink-faint:  #5e5e76;

  /* Accents from the avatar */
  --blood:      #c93545;          /* maroon blood drips */
  --blood-deep: #7a1f2a;
  --steel:      #aab4c4;          /* knight armor */
  --steel-glow: #c8d2e2;
  --ember:      #ff7a3a;          /* glowing eyes */
  --ember-deep: #c84a18;
  --gold:       #e0b048;
  --shadow:     #07070d;

  /* Sizes */
  --r:          0px;              /* pixel-sharp, no rounding */
  --pad:        16px;
  --bar-h:      48px;

  /* Fonts */
  --pixel-h:    'Press Start 2P', 'Pixelify Sans', monospace;
  --pixel-b:    'VT323', 'Share Tech Mono', monospace;
  --sans:       'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--pixel-b);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 1200px 600px at 50% 0%, rgba(201, 53, 69, 0.08), transparent 60%),
    radial-gradient(ellipse 800px 600px at 80% 100%, rgba(255, 122, 58, 0.06), transparent 60%);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
input { user-select: text; }
a { color: var(--ember); text-decoration: none; }
a:hover { color: var(--gold); }

/* Pixel halftone grid behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(74, 74, 100, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 74, 100, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 30%, black 30%, transparent 100%);
}

/* ============================================================
   Layout shell
   ============================================================ */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Top bar */
.topbar {
  position: sticky; top: 0;
  z-index: 100;
  background: rgba(20, 20, 30, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--blood);
  padding: 16px 0;
  margin-bottom: 48px;
}
.topbar .row {
  display: flex; align-items: center; gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.topbar .brand {
  font-family: var(--pixel-h);
  font-size: 16px;
  color: var(--blood);
  text-shadow: 2px 2px 0 var(--shadow);
  letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand .logo {
  width: 32px; height: 32px;
  background: url('../img/knight.jpg') center/cover;
  border: 2px solid var(--blood);
  image-rendering: pixelated;
}
.topbar nav {
  display: flex; gap: 4px;
  margin-left: auto;
}
.topbar nav a {
  font-family: var(--pixel-h);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 10px 14px;
  border: 2px solid transparent;
  text-decoration: none;
  transition: all 120ms;
}
.topbar nav a:hover { color: var(--ember); border-color: var(--ember-deep); background: rgba(255, 122, 58, 0.08); }
.topbar nav a.on { color: var(--blood); border-color: var(--blood); background: rgba(201, 53, 69, 0.12); }
.topbar .wallet-pill {
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 10px 14px;
  border: 2px solid var(--blood);
  background: rgba(201, 53, 69, 0.1);
  color: var(--blood);
  cursor: pointer;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.topbar .wallet-pill:hover { background: var(--blood); color: var(--shadow); }
.topbar .wallet-pill.bound { color: var(--ember); border-color: var(--ember); background: rgba(255, 122, 58, 0.08); }
.topbar .wallet-pill .dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: currentColor;
}

.topbar .x-link {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 2px solid var(--line);
  color: var(--ink-dim);
  text-decoration: none;
  transition: all 120ms;
}
.topbar .x-link:hover { border-color: var(--blood); color: var(--blood); }
.topbar .x-link svg { width: 14px; height: 14px; fill: currentColor; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: center;
  margin-bottom: 64px;
  position: relative;
}
.hero-portrait {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: url('../img/knight.jpg') center/cover;
  image-rendering: pixelated;
  border: 4px solid var(--blood);
  box-shadow:
    8px 8px 0 var(--shadow),
    inset 0 0 0 2px rgba(0,0,0,0.3),
    0 0 60px -10px rgba(201, 53, 69, 0.4);
}
.hero-portrait::before {
  content: '';
  position: absolute;
  inset: -12px;
  border: 2px solid var(--line);
  pointer-events: none;
  z-index: -1;
}
.hero-content {
  display: flex; flex-direction: column;
  gap: 18px;
}
.hero-tag {
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blood);
  display: flex; align-items: center; gap: 12px;
}
.hero-tag::before {
  content: ''; width: 24px; height: 2px; background: var(--blood);
}
.hero h1 {
  font-family: var(--pixel-h);
  font-size: 38px;
  line-height: 1.1;
  margin: 0;
  color: var(--ink);
  text-shadow:
    3px 3px 0 var(--shadow),
    0 0 40px rgba(201, 53, 69, 0.3);
  letter-spacing: -0.01em;
}
.hero h1 .ember { color: var(--ember); text-shadow: 3px 3px 0 var(--shadow); }
.hero .lede {
  font-family: var(--pixel-b);
  font-size: 22px;
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 36ch;
  margin: 0;
}
.hero .lede em { color: var(--ember); font-style: normal; }
.hero-cta { display: flex; gap: 12px; margin-top: 8px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: var(--pixel-h);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 22px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  cursor: pointer;
  transition: all 120ms;
  position: relative;
  text-decoration: none;
  display: inline-block;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-dim);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--shadow);
}
.btn:active { transform: translate(0, 0); box-shadow: none; }
.btn.primary {
  background: var(--blood);
  color: var(--ink);
  border-color: var(--blood-deep);
  text-shadow: 1px 1px 0 var(--shadow);
}
.btn.primary:hover { background: var(--blood-deep); }
.btn.ember {
  background: var(--ember);
  color: var(--shadow);
  border-color: var(--ember-deep);
  font-weight: 700;
}
.btn.ember:hover { background: var(--ember-deep); color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============================================================
   Card / panel
   ============================================================ */
.panel {
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 28px;
  position: relative;
}
.panel + .panel { margin-top: 24px; }
.panel.crimson { border-color: var(--blood-deep); border-top-color: var(--blood); border-top-width: 4px; }
.panel.ember   { border-color: var(--ember-deep); border-top-color: var(--ember); border-top-width: 4px; }

.panel h2 {
  font-family: var(--pixel-h);
  font-size: 14px;
  letter-spacing: 0.06em;
  margin: 0 0 16px;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--shadow);
}
.panel h2 .blood { color: var(--blood); }
.panel h2 .ember { color: var(--ember); }
.panel h3 {
  font-family: var(--pixel-h);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 22px 0 8px;
  color: var(--ember);
}
.panel p {
  font-family: var(--pixel-b);
  font-size: 20px;
  line-height: 1.45;
  margin: 0 0 12px;
  color: var(--ink-2);
}
.panel p strong { color: var(--ember); }
.panel p em { font-style: normal; color: var(--blood); }

/* Section heading */
.section-head {
  display: flex; align-items: baseline; gap: 18px;
  margin: 48px 0 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}
.section-head h2 {
  font-family: var(--pixel-h);
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.section-head h2 .blood { color: var(--blood); }
.section-head .tag {
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ember);
  text-transform: uppercase;
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.stat {
  background: var(--bg-2);
  border: 2px solid var(--line);
  padding: 18px;
  text-align: center;
}
.stat .lbl {
  font-family: var(--pixel-h);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.stat .val {
  font-family: var(--pixel-h);
  font-size: 22px;
  color: var(--ember);
  margin-bottom: 4px;
  text-shadow: 2px 2px 0 var(--shadow);
}
.stat .val.blood { color: var(--blood); }
.stat .val.steel { color: var(--steel); }
.stat .sub {
  font-family: var(--pixel-b);
  font-size: 16px;
  color: var(--ink-faint);
}

/* Tier pills */
.tier {
  display: inline-block;
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border: 2px solid currentColor;
  text-transform: uppercase;
}
.tier.noble    { color: var(--ember); background: rgba(255, 122, 58, 0.1); }
.tier.knight   { color: var(--steel); background: rgba(170, 180, 196, 0.08); }
.tier.outcast  { color: var(--blood); background: rgba(201, 53, 69, 0.1); }

/* Forge / staking UI */
.forge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.forge-input {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 16px;
}
.forge-input label {
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.forge-input .input-row {
  display: flex;
  border: 2px solid var(--line);
  background: var(--bg);
}
.forge-input .input-row input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 14px 16px;
  font-family: var(--pixel-b);
  font-size: 22px;
  color: var(--ember);
}
.forge-input .input-row .max {
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 0 16px;
  background: var(--surface-2);
  border-left: 2px solid var(--line);
  color: var(--ink-dim);
  cursor: pointer;
}
.forge-input .input-row .max:hover { color: var(--ember); }
.forge-input .helper {
  font-family: var(--pixel-b);
  font-size: 16px;
  color: var(--ink-faint);
  display: flex; justify-content: space-between;
}

/* Halving meter */
.halving-meter {
  height: 28px;
  background: var(--bg);
  border: 2px solid var(--line);
  position: relative;
  margin: 14px 0;
  overflow: hidden;
}
.halving-meter .fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, var(--blood-deep), var(--blood), var(--ember));
  transition: width 600ms ease-out;
}
.halving-meter .label {
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--pixel-h);
  font-size: 10px;
  color: var(--ink);
  letter-spacing: 0.08em;
  text-shadow: 1px 1px 0 var(--shadow);
  z-index: 2;
}

/* Simple table */
.simple-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}
.simple-table th, .simple-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--line-soft);
  font-family: var(--pixel-b);
  font-size: 18px;
}
.simple-table th {
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: var(--bg-2);
}
.simple-table td .ember { color: var(--ember); }
.simple-table td .blood { color: var(--blood); }
.simple-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Key-value */
.kv > div {
  display: flex; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-family: var(--pixel-b);
  font-size: 19px;
}
.kv > div:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-dim); }
.kv .v { color: var(--ink); }
.kv .v.ember { color: var(--ember); }
.kv .v.blood { color: var(--blood); }

/* Footer */
.foot {
  margin-top: 80px;
  padding: 32px 0;
  border-top: 2px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.foot .links { display: flex; gap: 16px; }
.foot a { color: var(--ink-dim); text-decoration: none; }
.foot a:hover { color: var(--ember); }

/* Toast */
#toast-stack {
  position: fixed; top: 86px; right: 24px;
  z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 2px solid var(--blood);
  color: var(--ink);
  padding: 12px 18px;
  font-family: var(--pixel-h);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  min-width: 240px;
  box-shadow: 6px 6px 0 var(--shadow);
  animation: tin 200ms ease-out;
}
.toast.ok  { border-color: var(--ember); color: var(--ember); }
.toast.err { border-color: var(--blood); color: var(--blood); }
@keyframes tin {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Utilities */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.dim { color: var(--ink-dim); }
.ember { color: var(--ember); }
.blood { color: var(--blood); }
.steel { color: var(--steel); }
.center { text-align: center; }
.mono { font-family: var(--pixel-b); font-variant-numeric: tabular-nums; }
.pix { font-family: var(--pixel-h); }
.small { font-size: 12px; }
.uppercase { text-transform: uppercase; letter-spacing: 0.14em; }

/* Scrollbar */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border: 2px solid var(--bg-2); }
::-webkit-scrollbar-thumb:hover { background: var(--blood-deep); }

/* Responsive */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .hero h1 { font-size: 28px; }
  .forge-grid { grid-template-columns: 1fr; }
  .topbar nav { display: none; }
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes ember-glow-pulse {
  0%, 100% { box-shadow: 8px 8px 0 var(--shadow), inset 0 0 0 2px rgba(0,0,0,0.3), 0 0 50px -10px rgba(201, 53, 69, 0.35); }
  50%      { box-shadow: 8px 8px 0 var(--shadow), inset 0 0 0 2px rgba(0,0,0,0.3), 0 0 90px -10px rgba(255, 122, 58, 0.6); }
}
.hero-portrait { animation: ember-glow-pulse 4.6s ease-in-out infinite; }

@keyframes ember-text-flicker {
  0%, 100%   { text-shadow: 3px 3px 0 var(--shadow), 0 0 18px rgba(255, 122, 58, 0.4); opacity: 1; }
  44%        { text-shadow: 3px 3px 0 var(--shadow), 0 0 28px rgba(255, 122, 58, 0.85); opacity: 1; }
  47%, 52%   { text-shadow: 3px 3px 0 var(--shadow), 0 0 6px rgba(255, 122, 58, 0.25);  opacity: 0.88; }
  60%        { text-shadow: 3px 3px 0 var(--shadow), 0 0 24px rgba(255, 122, 58, 0.65); opacity: 1; }
}
.hero h1 .ember,
.hero-content .lede em,
.panel .ember:not(.tier),
.section-head .tag {
  animation: ember-text-flicker 3.8s ease-in-out infinite;
}

@keyframes blood-bar {
  0%, 100% { transform: scaleX(1); opacity: 0.85; }
  50%      { transform: scaleX(1.4); opacity: 1; }
}
.hero-tag::before { animation: blood-bar 2.4s ease-in-out infinite; transform-origin: left center; }

@keyframes brand-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 53, 69, 0); }
  50%      { box-shadow: 0 0 12px 1px rgba(201, 53, 69, 0.55); }
}
.topbar .brand .logo { animation: brand-pulse 3.2s ease-in-out infinite; }

@keyframes panel-edge-flicker {
  0%, 100% { border-top-color: var(--ember); box-shadow: 0 -1px 0 0 var(--ember-deep); }
  50%      { border-top-color: var(--ember-deep); box-shadow: 0 -3px 14px -2px rgba(255, 122, 58, 0.4); }
}
.panel.ember { animation: panel-edge-flicker 5s ease-in-out infinite; }

@keyframes panel-edge-blood {
  0%, 100% { border-top-color: var(--blood); box-shadow: 0 -1px 0 0 var(--blood-deep); }
  50%      { border-top-color: var(--blood-deep); box-shadow: 0 -3px 14px -2px rgba(201, 53, 69, 0.45); }
}
.panel.crimson { animation: panel-edge-blood 5.4s ease-in-out infinite; }

/* Halving meter, animated fire flow on top of the gradient fill */
.halving-meter .fill {
  background-size: 200% 100%;
  animation: fire-flow 6s linear infinite;
}
@keyframes fire-flow {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* Button shine sweep on hover */
.btn { overflow: hidden; }
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.16) 50%, transparent 70%);
  transform: translateX(-150%);
  transition: transform 540ms ease;
  pointer-events: none;
}
.btn:hover::after { transform: translateX(150%); }
.btn.primary::after,
.btn.ember::after { background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%); }

/* Stat value subtle ember tick */
@keyframes stat-tick {
  0%, 90%, 100% { transform: translateY(0); }
  95%           { transform: translateY(-1px); }
}
.stat .val { animation: stat-tick 7s ease-in-out infinite; }

/* Section heading sweep */
@keyframes head-line-grow {
  from { transform: scaleX(0.3); opacity: 0.5; }
  to   { transform: scaleX(1);   opacity: 1; }
}
.section-head { position: relative; }
.section-head::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, var(--blood), transparent);
  transform-origin: left;
  animation: head-line-grow 1.4s ease-out;
}

/* Wallet pill dot pulse */
@keyframes dot-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 currentColor; }
  50%      { transform: scale(1.3); box-shadow: 0 0 0 3px rgba(201, 53, 69, 0.18); }
}
.topbar .wallet-pill .dot { animation: dot-pulse 1.8s ease-in-out infinite; }
.topbar .wallet-pill.bound .dot { animation: dot-pulse 2.6s ease-in-out infinite; }

/* X link hover lift */
.topbar .x-link { transition: transform 180ms ease, color 180ms ease, border-color 180ms ease; }
.topbar .x-link:hover { transform: translateY(-1px) rotate(-2deg); }

/* Scroll-reveal: fade panels in when they enter the viewport */
.panel.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 600ms ease-out, transform 600ms ease-out;
}
.panel.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* Honor / tier hover micro-anim */
.tier { transition: transform 160ms ease; }
.tier:hover { transform: translateY(-2px); }

/* Hover on cards bump shadow */
.panel { transition: transform 220ms ease, box-shadow 220ms ease; }
.panel:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4);
}
