/* ═══════════════════════════════════════════════════════════════════════════
   THRONEBOUND REALMS — integration/fallback.css
   Styles for the integration FALLBACKS only: the built-in HUD (tbh-*), the
   built-in character creator (tbg-*) and the built-in overlay used when
   launch/modal.js is absent. A dedicated hud/render module brings its own
   css/realms.css; these rules never target its elements.
   Tokens come from integration.css (--parch-*, --ink-*, --gold-*, --gem …).
   ═══════════════════════════════════════════════════════════════════════════ */
.tbh { font-family: var(--font-body); color: var(--parch-100); }
.tbh-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 6px;
  padding: calc(6px + var(--safe-t)) calc(6px + var(--safe-r)) 0 calc(6px + var(--safe-l));
  pointer-events: none;
}
.tbh-top > * { pointer-events: none; min-width: 0; }
.tbh-top button, .tbh-top a { pointer-events: auto; }
.tbh-left { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.tbh-right { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.tbh-centre { display: flex; justify-content: center; }
.tbh-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: min(46vw, 320px);
  padding: 5px 9px; border-radius: 999px;
  background: rgba(11, 17, 28, .82); border: 1px solid var(--gold-600);
  color: var(--parch-100); font: 600 12px/1.2 var(--font-body);
  box-shadow: var(--shadow-sm); cursor: pointer; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tbh-chip > span { overflow: hidden; text-overflow: ellipsis; }
.tbh-chip:focus-visible { outline: 2px solid var(--gem); outline-offset: 2px; }
.tbh-glyph { font-size: 13px; flex: 0 0 auto; }
.tbh-skill { flex-direction: column; align-items: stretch; border-radius: 10px; gap: 3px; padding: 6px 10px; max-width: min(60vw, 360px); }
.tbh-skill .tbh-glyph { display: inline; }
.tbh-skill-text { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbh-bar { display: block; height: 5px; border-radius: 3px; background: rgba(255,255,255,.14); overflow: hidden; min-width: 90px; }
.tbh-bar-fill { display: block; height: 100%; width: 0; background: var(--skill, var(--gold-500)); transition: width .3s ease; }
.tbh-sub { font-size: 11px; color: var(--parch-300); text-shadow: 0 1px 2px #000; padding-left: 4px; }
.tbh-banner {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 0 0 10px 10px;
  background: rgba(11, 17, 28, .82); border: 1px solid var(--fac, #8a8a8a); border-top: 0;
  color: var(--fac, #8a8a8a); font: 700 12px/1.2 var(--font-display); letter-spacing: .04em; cursor: pointer; white-space: nowrap;
}
.tbh-banner.is-lit { box-shadow: 0 0 14px color-mix(in srgb, var(--fac) 55%, transparent); }
.tbh-banner.is-dormant { filter: saturate(.3); }
.tbh-banner.is-off { color: var(--parch-300); border-color: rgba(255,255,255,.25); }
.tbh-gems { border-color: var(--gem); color: #c8fff9; }
.tbh-gems .tbh-glyph { color: var(--gem); }
.tbh-gems.is-stale { filter: saturate(.3); }
.tbh-serve .tbh-dot { width: 8px; height: 8px; border-radius: 50%; background: #666; flex: 0 0 auto; }
.tbh-serve.is-serving .tbh-dot, .tbh-serve.is-answering .tbh-dot { background: var(--good); box-shadow: 0 0 6px var(--good); }
.tbh-serve.is-answering .tbh-dot { animation: tbh-pulse 1s infinite alternate; }
.tbh-serve.is-paused .tbh-dot, .tbh-serve.is-loading .tbh-dot, .tbh-serve.is-downloading .tbh-dot { background: var(--gold-500); }
.tbh-serve.is-fatal .tbh-dot { background: var(--bad); }
.tbh-discord { background: var(--discord); border-color: #2f3690; color: #fff; }
@keyframes tbh-pulse { from { opacity: .5; } to { opacity: 1; } }
.tbh-bottom {
  position: absolute; left: 0; right: 0; bottom: calc(6px + var(--safe-b));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
  padding: 0 calc(8px + var(--safe-r)) 0 calc(8px + var(--safe-l)); pointer-events: none;
}
.tbh-prompt {
  pointer-events: none; margin: 0 auto; padding: 6px 12px; border-radius: 8px;
  background: rgba(11, 17, 28, .82); border: 1px solid var(--parch-400); color: var(--parch-50);
  font: 600 13px/1.2 var(--font-body); text-shadow: 0 1px 2px #000;
}
.tbh-menu {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500) 55%, var(--gold-600));
  border: 1px solid var(--wood-700); color: var(--ink-900); font: 700 20px/1 var(--font-body); cursor: pointer; box-shadow: var(--shadow-sm);
}
@media (pointer: coarse) { .tbh-bottom { bottom: calc(150px + var(--safe-b)); } .tbh-menu { margin-left: auto; } }
.tbh-toasts {
  position: absolute; left: 50%; bottom: calc(56px + var(--safe-b)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; max-width: min(92vw, 440px);
}
@media (pointer: coarse) { .tbh-toasts { bottom: calc(200px + var(--safe-b)); } }
.tbh-toast {
  padding: 6px 12px; border-radius: 8px; background: rgba(11, 17, 28, .9); border: 1px solid var(--parch-400);
  color: var(--parch-50); font: 600 13px/1.25 var(--font-body); text-align: center; animation: tbh-in .18s ease-out; transition: opacity .35s ease;
}
.tbh-toast.is-good { border-color: var(--good); }
.tbh-toast.is-bad { border-color: var(--bad); }
.tbh-toast.is-gem { border-color: var(--gem); color: #c8fff9; }
.tbh-toast.is-out { opacity: 0; }
@keyframes tbh-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* panels (rendered inside launch/modal.js cards) */
.tbh-big { font: 700 24px/1.1 var(--font-display); margin: 4px 0; }
.tbh-fine { font-size: 12.5px; line-height: 1.4; color: var(--ink-500, #6b5535); margin: 6px 0; }
.tbh-warn { color: var(--bad); font-weight: 600; }
.tbh-log { font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(0,0,0,.08); padding: 6px 8px; border-radius: 6px; max-height: 120px; overflow: auto; white-space: pre-wrap; margin: 6px 0 0; }
.tbh-skills { display: flex; flex-direction: column; gap: 6px; }
.tbh-skill-row { display: grid; grid-template-columns: 24px 1fr auto; grid-template-areas: "g n l" "g b b" "g x x"; gap: 2px 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid rgba(0,0,0,.08); }
.tbh-skill-row .tbh-glyph { grid-area: g; font-size: 18px; }
.tbh-skill-name { grid-area: n; font-weight: 700; }
.tbh-skill-lvl { grid-area: l; font: 700 14px/1 var(--font-display); }
.tbh-skill-row .tbh-bar { grid-area: b; background: rgba(0,0,0,.12); }
.tbh-skill-xp { grid-area: x; font-size: 11.5px; color: var(--ink-500, #6b5535); }
.tbh-inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 5px; margin: 6px 0; }
.tbh-slot { position: relative; height: 56px; border: 2px solid #8a7a5a; border-radius: 6px; background: rgba(255,255,255,.35); font: 600 10.5px/1.15 var(--font-body); color: var(--ink-900, #2c2013); padding: 3px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.tbh-slot.is-empty { background: rgba(0,0,0,.06); border-style: dashed; cursor: default; }
.tbh-slot-qty { position: absolute; right: 3px; bottom: 2px; font-size: 10px; color: var(--gold-600); }
.tbh-fac { padding: 8px 10px; margin: 6px 0; border-left: 4px solid var(--fac); background: rgba(0,0,0,.05); border-radius: 0 6px 6px 0; }
.tbh-fac.is-current { background: color-mix(in srgb, var(--fac) 14%, transparent); }
.tbh-fac-name { font: 700 15px/1.2 var(--font-display); color: var(--fac); }
.tbh-portrait { display: block; margin: 0 auto 8px; image-rendering: pixelated; border: 2px solid var(--gold-600); border-radius: 8px; background: #101826; }
.tbh-menu-list { display: grid; gap: 8px; }
.tbh-menu-list .tbri-btn { width: 100%; }
.tbh-recipes { display: flex; flex-direction: column; gap: 5px; margin: 4px 0; }
.tbh-recipe { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px; border: 1px solid var(--parch-400, #b99f66); border-radius: 6px; background: rgba(255,255,255,.4); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.tbh-recipe.is-locked { opacity: .5; }
.tbh-recipe.is-short { border-style: dashed; }
.tbh-recipe-name { font-weight: 700; }
.tbh-recipe .tbh-fine { margin: 0; }
/* built-in overlay when launch/modal.js is absent */
.tbh-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(6, 9, 16, .72); overflow: auto; }
.tbh-card h2 { margin: 0 0 6px; font: 700 20px/1.2 var(--font-display); }

/* built-in character creator */
.tbg-portrait { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 10px; }
.tbg-portrait-img { image-rendering: pixelated; width: 96px; height: 96px; border: 2px solid var(--gold-600); border-radius: 8px; background: #101826; }
.tbg-sheet { image-rendering: pixelated; width: 128px; height: 48px; background: #101826; border-radius: 6px; }
.tbg-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 12px; margin-top: 10px; }
.tbg-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tbg-val { flex: 1 1 auto; text-align: center; font-size: 13px; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .tbh-toast, .tbh-bar-fill, .tbh-serve.is-answering .tbh-dot { animation: none; transition: none; } }

/* narrow phones: banner drops under the chips instead of colliding with them */
@media (max-width: 520px) {
  .tbh-top { grid-template-columns: 1fr 1fr; }
  .tbh-centre { grid-column: 1 / -1; order: 3; justify-content: flex-start; margin-top: 2px; }
  .tbh-banner { border-radius: 10px; border-top: 1px solid var(--fac, #8a8a8a); font-size: 11px; padding: 3px 10px; }
  .tbh-chip { font-size: 11px; padding: 4px 8px; max-width: 48vw; }
  .tbh-skill { max-width: 48vw; }
  .tbh-sub { font-size: 10px; }
}
