/* realm-war.css — Realm War UI shell */

/* ── CSS Custom Properties (dark default) ───────────────────────────────────── */
:root {
  --bg:           #0e0f18;
  --surface:      #141525;
  --surface-2:    #1a1b2e;
  --border:       #2a2d4a;
  --text:         #e8e0d5;
  --text-muted:   #7a7d99;
  --accent:       #d4a44a;
  --accent-dark:  #9e7730;
  --accent-text:  #111111;
  --gold:         var(--accent);
  --topbar-h:     52px;
  --sidebar-w:    240px;
  --bottombar-h:  60px;
}

[data-theme="light"] {
  --bg:           #f4ecd6;
  --surface:      #fffdf7;
  --surface-2:    #faf5e8;
  --border:       #d9cdb0;
  --text:         #1a1207;
  --text-muted:   #6b5e40;
  --accent:       #8a6a1a;
  --accent-dark:  #5c4611;
  --accent-text:  #fffdf7;
}

/* ── Base ────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* ── App shell ───────────────────────────────────────────────────────────────── */
#rw-main {
  min-height: 100vh;
  background: var(--bg);
}

/* ── Top bar ─────────────────────────────────────────────────────────────────── */
.rw-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  gap: 12px;
}

.rw-topbar-brand {
  font-weight: 700;
  font-size: 1.05em;
  color: var(--accent);
  letter-spacing: 0.03em;
  white-space: nowrap;
  user-select: none;
}

.rw-topbar-right {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.rw-topbar-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.88em;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  min-height: 34px;
  padding: 5px 10px;
}

.rw-topbar-btn:hover {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent);
}

/* Mobile: icon-only, 44×44 tap target */
@media (max-width: 1023px) {
  .rw-topbar-btn .rw-btn-label {
    display: none;
  }
  .rw-topbar-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    font-size: 1.15em;
  }
}

/* ── Body layout (sidebar + scrollable content) ──────────────────────────────── */
.rw-body {
  display: flex;
  flex-direction: row;
  min-height: calc(100vh - var(--topbar-h));
  margin-top: var(--topbar-h);
  /* pad bottom on mobile so content clears the fixed bottom bar */
  padding-bottom: var(--bottombar-h);
}

@media (min-width: 1024px) {
  .rw-body {
    padding-bottom: 0;
  }
}

/* ── Left sidebar (desktop ≥1024px) ──────────────────────────────────────────── */
.rw-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .rw-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    flex-shrink: 0;
  }
}

/* ── Bottom tab bar (mobile <1024px) ─────────────────────────────────────────── */
.rw-bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottombar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
}

@media (min-width: 1024px) {
  .rw-bottombar {
    display: none;
  }
}

/* ── Nav items (shared: sidebar + bottombar) ─────────────────────────────────── */
.rw-nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.rw-nav-item:hover {
  color: var(--text);
}

/* Sidebar items */
.rw-sidebar .rw-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  font-size: 0.95em;
  border-left: 3px solid transparent;
  width: 100%;
  text-align: left;
}

.rw-sidebar .rw-nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .rw-sidebar .rw-nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.rw-sidebar .rw-nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(212, 164, 74, 0.1);
}

[data-theme="light"] .rw-sidebar .rw-nav-item.active {
  background: rgba(138, 106, 26, 0.1);
}

/* Bottom bar items */
.rw-bottombar .rw-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.68em;
  padding: 4px 2px;
  min-height: 44px;
  text-align: center;
}

.rw-bottombar .rw-nav-item .rw-nav-icon {
  font-size: 1.4em;
  line-height: 1;
}

.rw-bottombar .rw-nav-item:hover {
  background: var(--surface-2);
}

.rw-bottombar .rw-nav-item.active {
  color: var(--accent);
  background: rgba(212, 164, 74, 0.08);
}

[data-theme="light"] .rw-bottombar .rw-nav-item.active {
  background: rgba(138, 106, 26, 0.08);
}

/* ── Main content area ───────────────────────────────────────────────────────── */
.rw-content {
  flex: 1;
  min-width: 0;
  padding: 16px;
}

.rw-content-inner {
  max-width: 760px;
  margin: 0 auto;
}

/* ── Header / portrait ───────────────────────────────────────────────────────── */
.rw-header {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.rw-portrait {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.rw-lord-info { flex: 1; }

.rw-lord-name {
  font-size: 1.3em;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 2px;
}

.rw-title-label {
  color: var(--text-muted);
  font-size: 0.9em;
}

/* ── Resource bar ────────────────────────────────────────────────────────────── */
.rw-resources {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px 16px;
  margin-bottom: 16px;
}

/* Mobile: horizontal scrolling row */
@media (max-width: 640px) {
  .rw-resources {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    padding: 12px 16px;
    scrollbar-width: none;
  }
  .rw-resources::-webkit-scrollbar { display: none; }
  .rw-stat {
    flex-shrink: 0;
    min-width: 68px;
  }
}

.rw-stat { display: flex; flex-direction: column; gap: 3px; }

.rw-stat-label {
  color: var(--text-muted);
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.rw-stat-val {
  color: var(--text);
  font-size: 1em;
  font-weight: 600;
  white-space: nowrap;
}

.rw-bar-track {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}

.rw-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.rw-bar-fill--hp { background: #5cb85c; }
.rw-bar-fill--xp { background: #5bc0de; }

/* ── Levy banner — FIXED: accent bg + contrasting text, WCAG AA in both themes ── */
.rw-levy-banner {
  background: var(--accent);
  border: 1px solid var(--accent-dark);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.rw-levy-text {
  color: var(--accent-text);
  font-weight: 600;
  font-size: 1em;
}

/* Claim button sits on accent bg — inverted: accent-text bg, accent text */
.rw-levy-banner .rw-btn {
  background: var(--accent-text);
  color: var(--accent);
  border: none;
  transition: opacity 0.15s;
}

.rw-levy-banner .rw-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.rw-levy-streak-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Tab panels ──────────────────────────────────────────────────────────────── */
.rw-tab-panel { display: none; }
.rw-tab-panel.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.rw-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 12px;
}

.rw-card-title {
  color: var(--accent);
  font-size: 1em;
  font-weight: 700;
  margin: 0 0 6px;
}

.rw-card-meta {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-bottom: 10px;
}

.rw-card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rw-card-cd {
  color: var(--text-muted);
  font-size: 0.82em;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.rw-btn {
  padding: 7px 16px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.88em;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.rw-btn:disabled { opacity: 0.4; cursor: default; }

.rw-btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.rw-btn--danger { background: #c9403a; color: #fff; }

/* ── Raid outcome panel ──────────────────────────────────────────────────────── */
.rw-raid-outcome {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-top: 12px;
  text-align: center;
}

.rw-outcome-title { font-size: 1.4em; font-weight: 700; margin-bottom: 8px; }
.rw-outcome-win   { color: #5cb85c; }
.rw-outcome-loss  { color: #c9403a; }
.rw-outcome-detail { color: var(--text-muted); margin-bottom: 14px; }

/* ── Toasts ──────────────────────────────────────────────────────────────────── */
#rw-toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.rw-toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9em;
  color: var(--text);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 280px;
}

.rw-toast--visible { opacity: 1; transform: translateX(0); }
.rw-toast--reward  { border-color: var(--accent); color: var(--accent); }
.rw-toast--error   { border-color: #c9403a; color: #c9403a; }
.rw-toast--info    { border-color: #5bc0de; }

/* ── Unauth / error states ───────────────────────────────────────────────────── */
.rw-unauth, .rw-error {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  margin: 24px auto;
  max-width: 760px;
}

.rw-unauth h2 { color: var(--text-muted); }
.rw-unauth a  { color: var(--accent); }

/* ── Crowns tab ──────────────────────────────────────────────────────────────── */
.rw-crowns-balance {
  font-size: 1.3em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 16px;
}

.rw-crowns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .rw-crowns-grid { grid-template-columns: 1fr; }
}

/* ── Modals ──────────────────────────────────────────────────────────────────── */
.rw-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.rw-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  position: relative;
}

.rw-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.15em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}

.rw-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1em;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  transition: color 0.15s;
  line-height: 1;
}

.rw-modal-close:hover { color: var(--text); }

.rw-modal-body {
  color: var(--text-muted);
  font-size: 0.95em;
  margin-bottom: 16px;
  line-height: 1.6;
}

.rw-modal-row {
  margin-bottom: 12px;
}

.rw-modal-row:last-child { margin-bottom: 0; }

.rw-modal-label {
  display: block;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.rw-modal-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.82em;
  font-family: monospace;
  resize: vertical;
  min-height: 76px;
  display: block;
  margin-bottom: 8px;
}

.rw-modal-textarea:focus {
  outline: 1px solid var(--accent);
}

.rw-modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.rw-version-str {
  font-size: 0.8em;
  color: var(--text-muted);
}

/* ── Footer (parent site) ────────────────────────────────────────────────────── */
.footer {
  margin-top: 0;
  padding: 24px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85em;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
}

.footer-brand {
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.footer-note { margin: 0; }
