/* =============================================================
   Vamsha Vruksham · base.css
   Design tokens, resets, typography, splash and toast.
   ============================================================= */

:root {
  --sky-1: #d3e1c1;   --sky-2: #e6dfbe;
  --earth-1: #9b7d4a; --earth-2: #c9a868;  --earth-3: #6b4a24;
  --bark: #3a2311;   --bark-deep: #1f1408; --bark-mid: #5a3b1e;
  --leaf-d: #3a5a28; --leaf:   #5b8836;  --leaf-l: #88b24a;
  --leaf-hi: #c2d982;
  --gold:   #c9a961; --gold-hi: #e4c987; --gold-lo: #8a6a3d;
  --cream:  #fef6e8; --cream-hi:#fffaf0;
  --parchment: #efe1b8;
  --male:   #8ea3b5; --female: #c9a0a8;
  --hi-red: #b93232; --hi-amber: #dba642;

  --f-display: 'Cinzel', 'Noto Serif Telugu', Georgia, serif;
  --f-body:    'Cormorant Garamond', 'Noto Serif Telugu', Georgia, serif;
  --f-te:      'Noto Serif Telugu', 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: var(--f-body);
  color: var(--bark-deep);
  background: radial-gradient(ellipse at 50% 30%, #ecdcb6 0%, #d9c58e 50%, #b8a06a 100%);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: var(--bark-deep); }
:focus-visible { outline: 2px solid var(--hi-red); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--gold); color: var(--bark-deep); }

/* App shell */
#app { position: fixed; inset: 0; overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
#canvas:active { cursor: grabbing; }
#world { will-change: transform; }

/* Banner (title scroll) */
#banner {
  position: fixed; top: 68px; left: 50%;
  transform: translateX(-50%);
  z-index: 4; pointer-events: none;
  padding: 6px 30px;
  background: linear-gradient(180deg, #5a3b1e 0%, #3a2311 100%);
  border: 2px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(31,20,8,0.35), inset 0 2px 0 rgba(255,240,200,0.08);
  font-family: var(--f-te);
  font-size: 18px;
  color: var(--cream-hi);
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
}
#banner .en { display: none; font-family: var(--f-display); font-size: 16px; letter-spacing: 0.15em; text-transform: uppercase; }
body.lang-en #banner .te { display: none; }
body.lang-en #banner .en { display: inline; }

/* Legend */
#legend {
  position: fixed; bottom: 18px; right: 18px; z-index: 10;
  padding: 10px 16px;
  background: rgba(254, 246, 232, 0.92);
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-size: 13px;
  color: var(--bark-deep);
  display: flex; gap: 14px; align-items: center;
  box-shadow: 0 2px 10px rgba(31,20,8,0.18);
}
#legend span::before { content: "·"; margin-right: 6px; color: var(--gold-lo); font-weight: 700; }
#legend span:first-child::before { display: none; }
body.panel-open #legend { display: none; }

/* Toast */
#toasts {
  position: fixed; bottom: 18px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 100; pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 22px;
  background: var(--bark-deep);
  color: var(--cream-hi);
  border: 1px solid var(--gold);
  border-radius: 999px;
  font-size: 15px;
  box-shadow: 0 6px 20px rgba(31,20,8,0.4);
  animation: toastIn 280ms cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 90vw; text-align: center;
}
.toast.error { background: var(--hi-red); border-color: #7a2020; }
.toast.fade { animation: toastOut 280ms forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(10px); } }

/* Splash */
#splash {
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; gap: 20px;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #ecdcb6, #b8a06a);
  transition: opacity 500ms;
}
#splash.gone { opacity: 0; pointer-events: none; }
#splash h1 {
  font-family: var(--f-te); font-size: 42px;
  color: var(--bark-deep);
  margin: 0;
  text-shadow: 0 2px 0 rgba(255,250,240,0.5);
}
#splash .spin {
  width: 38px; height: 38px;
  border: 3px solid var(--gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error card (used when bootstrap JSON fails to load) */
#error-card {
  position: fixed; inset: 0; z-index: 9999;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(31,20,8,0.8);
}
#error-card.show { display: flex; }
#error-card .card {
  background: var(--cream-hi);
  border: 2px solid var(--hi-red);
  border-radius: 10px;
  padding: 30px 34px;
  max-width: 480px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
#error-card h2 { margin: 0 0 10px; color: var(--hi-red); font-family: var(--f-display); letter-spacing: 0.1em; }
#error-card p { margin: 0 0 16px; line-height: 1.5; }
#error-card code { display: block; padding: 8px 12px; background: #f4e9d1; border-radius: 4px; font-size: 13px; margin-bottom: 16px; word-break: break-all; }
#error-card button {
  padding: 8px 20px; background: var(--bark); color: var(--cream-hi);
  border-radius: 999px; font-family: var(--f-display); font-size: 12px;
  letter-spacing: 0.15em; text-transform: uppercase;
}
