/* Owli app shell — built on Botnest tokens (botnest-colors.css).
   Vibrant chrome, calm content. Dawn default, night one attribute away. */

@font-face {
  font-family: "Alegreya Sans";
  src: url("../fonts/AlegreyaSans-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("../fonts/AlegreyaSans-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("../fonts/AlegreyaSans-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Alegreya Sans", "freight-sans-pro", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bn-bg);
  color: var(--bn-text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; cursor: pointer; }
input {
  font: inherit;
  color: var(--bn-text);
  background: var(--bn-surface);
  border: 1px solid var(--bn-border);
  border-radius: 8px;
  height: 38px;
  padding: 0 12px;
  width: 100%;
}
input:focus-visible {
  outline: none;
  border-color: var(--bn-focus-ring);
  box-shadow: var(--bn-focus-glow);
}
label { display: block; font-weight: 500; margin: 12px 0 4px; color: var(--bn-text-2); }

.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border-radius: 8px; border: 1px solid transparent;
  font-weight: 700;
  background: var(--bn-action); color: var(--bn-on-action);
  transition: background 150ms ease, transform 150ms ease;
}
.btn:hover { background: var(--bn-action-hover); }
.btn:active { background: var(--bn-action-press); transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--bn-focus-glow); }
.btn.secondary {
  background: transparent; color: var(--bn-link);
  border-color: var(--bn-border-strong);
}
.btn.secondary:hover { background: var(--bn-action-subtle); }
.btn.success { background: var(--bn-success-fill); color: var(--bn-on-success); }
.btn.danger { background: var(--bn-danger-fill); color: var(--bn-on-danger); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- auth screen ---------- */
#auth-screen {
  min-height: 100dvh;
  display: grid; place-items: center;
  background: var(--bn-grad-hero);
  position: relative;
}
#auth-screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--bn-grad-aurora-rose);
}
.auth-card {
  position: relative; z-index: 1;
  width: min(400px, calc(100vw - 32px));
  background: var(--bn-surface);
  border: 1px solid var(--bn-border-subtle);
  border-radius: 16px;
  box-shadow: var(--bn-shadow-3);
  padding: 28px;
}
.auth-brand { text-align: center; margin-bottom: 12px; }
.auth-brand canvas { image-rendering: pixelated; }
.auth-brand h1 {
  font-size: 34px; margin: 6px 0 0; letter-spacing: 2px; font-weight: 700;
}
.auth-brand p { margin: 2px 0 0; color: var(--bn-text-3); }
.auth-tabs { display: flex; gap: 4px; margin: 18px 0 6px; background: var(--bn-inset); border-radius: 8px; padding: 4px; }
.auth-tabs button {
  flex: 1; border: none; background: transparent; border-radius: 6px;
  height: 32px; font-weight: 700; color: var(--bn-text-2);
}
.auth-tabs button.active { background: var(--bn-surface); color: var(--bn-text); box-shadow: var(--bn-shadow-1); }
.form-msg { min-height: 22px; font-size: 13px; margin-top: 10px; }
.form-msg.error { color: var(--bn-danger-text); }
.form-msg.ok { color: var(--bn-success-text); }
.auth-card .btn { width: 100%; margin-top: 16px; }

/* ---------- app shell: left rail + hamburger ---------- */
:root { --rail-w: 224px; }

#app-shell { min-height: 100dvh; }

.bn-icon {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

.icon-btn {
  border: 1px solid var(--bn-border); background: var(--bn-glass);
  color: var(--bn-text-2); border-radius: 8px; width: 38px; height: 38px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bn-action-subtle); }

#hamburger {
  position: fixed; top: 12px; left: 12px; z-index: 60;
  backdrop-filter: blur(6px);
  box-shadow: var(--bn-shadow-1);
}

#rail {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  width: var(--rail-w);
  background: var(--bn-grad-aurora);
  border-right: 1px solid var(--bn-border-subtle);
  color: var(--bn-chrome-text);
  display: flex; flex-direction: column;
  padding: 14px 12px;
  transform: translateX(0);
  transition: transform 200ms ease;
}
body.rail-closed #rail { transform: translateX(-100%); }

.rail-head {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 46px 4px 20px; /* sits below the fixed hamburger */
}
.rail-head img { display: block; border-radius: 50%; }
.rail-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rail-title .kicker {
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--bn-chrome-text-dim);
}
.rail-title .appname {
  font-size: 22px; font-weight: 700; line-height: 1.1;
  color: var(--bn-chrome-text); letter-spacing: 0.01em;
}
.rail-theme-btn {
  border: none; background: transparent; color: var(--bn-chrome-text-dim);
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; margin-top: 2px;
}
.rail-theme-btn:hover { background: var(--bn-action-subtle); color: var(--bn-chrome-text); }
.rail-theme-btn:focus-visible { outline: none; box-shadow: var(--bn-focus-glow); }

#rail nav { display: flex; flex-direction: column; gap: 4px; }
#rail nav button {
  display: flex; align-items: center; gap: 12px;
  border: none; background: transparent; color: var(--bn-chrome-text-dim);
  font-weight: 700; font-size: 15px;
  padding: 10px 12px; border-radius: 8px; text-align: left;
  width: 100%;
}
#rail nav button:hover { background: var(--bn-action-subtle); color: var(--bn-chrome-text); }
#rail nav button.active {
  background: var(--bn-surface); color: var(--bn-text);
  box-shadow: var(--bn-shadow-1);
}
#rail nav button:focus-visible { outline: none; box-shadow: var(--bn-focus-glow); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.rail-foot .who { color: var(--bn-chrome-text-dim); font-size: 13px; padding: 0 12px; }

#rail-scrim {
  display: none; position: fixed; inset: 0; z-index: 45;
  background: var(--bn-overlay);
}

main#view {
  min-height: 100dvh;
  margin-left: var(--rail-w);
  padding: 20px 24px 48px;
  max-width: 1024px;
  transition: margin-left 200ms ease;
}
body.rail-closed main#view { margin-left: 0; padding-left: 68px; }

@media (max-width: 760px) {
  /* Mobile: rail is an overlay drawer, closed by default via .rail-closed */
  main#view { margin-left: 0; padding: 66px 12px 40px; }
  body:not(.rail-closed) #rail-scrim { display: block; }
  #rail { box-shadow: var(--bn-shadow-3); }
  body.rail-closed main#view { padding-left: 12px; }
}

h2.page-title { font-size: 22px; margin: 4px 0 14px; }
.subtle { color: var(--bn-text-3); font-size: 13px; }

/* ---------- map cards ---------- */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.map-card {
  border: 1px solid var(--bn-border-subtle);
  border-radius: 12px;
  background: var(--bn-surface);
  overflow: hidden;
  text-align: left; padding: 0;
  transition: transform 180ms ease, box-shadow 180ms ease;
  box-shadow: var(--bn-shadow-1);
}
.map-card:not(.locked):hover { transform: translateY(-2px); box-shadow: var(--bn-shadow-2); }
.map-card canvas { display: block; width: 100%; image-rendering: pixelated; }
.map-card .meta { padding: 10px 12px 12px; }
.map-card .name { font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.map-card .mult { font-size: 12px; color: var(--bn-accent-rose); font-weight: 700; }
.map-card .tagline { font-size: 12.5px; color: var(--bn-text-3); margin-top: 2px; min-height: 32px; }
.map-card .stats { display: flex; justify-content: space-between; font-size: 12.5px; margin-top: 8px; color: var(--bn-text-2); }
.el-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.el-badge {
  font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 8px;
  background: var(--bn-surface-2); color: var(--bn-text-2);
  border: 1px solid var(--bn-border-subtle);
}
.el-badge.mercy { background: var(--bn-success-subtle); color: var(--bn-success-text); border-color: var(--bn-success-border); }
.map-card.locked { opacity: 0.65; cursor: not-allowed; }
.map-card.locked .lock-note { color: var(--bn-warning-text); font-size: 12.5px; font-weight: 500; }

/* ---------- game overlay ---------- */
#game-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bn-overlay);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
}
#game-wrap { position: relative; }
#game-canvas {
  display: block;
  image-rendering: pixelated;
  border-radius: 10px;
  box-shadow: var(--bn-shadow-3);
  touch-action: manipulation;
}
#game-close {
  position: absolute; top: -14px; right: -14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--bn-border-strong);
  background: var(--bn-surface); color: var(--bn-text);
  font-size: 15px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: var(--bn-shadow-2);
}

/* ---------- leaderboard ---------- */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--bn-border); background: var(--bn-surface);
  color: var(--bn-text-2); border-radius: 999px; padding: 5px 14px;
  font-weight: 500; font-size: 13px;
}
.chip.active { background: var(--bn-action); color: var(--bn-on-action); border-color: transparent; }
.board-table { width: 100%; border-collapse: collapse; background: var(--bn-surface); border-radius: 12px; overflow: hidden; box-shadow: var(--bn-shadow-1); }
.board-table th {
  text-align: left; font-size: 12px; text-transform: none; color: var(--bn-text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--bn-border-subtle);
  background: var(--bn-surface-2);
}
.board-table td { padding: 9px 14px; border-bottom: 1px solid var(--bn-border-subtle); font-size: 14px; }
.board-table tr:last-child td { border-bottom: none; }
.board-table tr.you td { background: var(--bn-selected); font-weight: 700; }
.board-table .rank { width: 44px; color: var(--bn-text-3); font-weight: 700; }
.board-table tr:nth-child(1) .rank { color: var(--bn-accent-gold); }
.board-table tr:nth-child(2) .rank { color: var(--bn-text-2); }
.board-table tr:nth-child(3) .rank { color: var(--bn-accent-rose); }
.board-empty { padding: 28px; text-align: center; color: var(--bn-text-3); background: var(--bn-surface); border-radius: 12px; }

/* ---------- settings / admin ---------- */
.panel {
  background: var(--bn-surface); border: 1px solid var(--bn-border-subtle);
  border-radius: 12px; padding: 18px; margin-bottom: 16px; box-shadow: var(--bn-shadow-1);
}
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--bn-border-subtle);
}
.user-row:last-child { border-bottom: none; }
.user-row .u-name { font-weight: 700; }
.user-row .u-mail { color: var(--bn-text-3); font-size: 13px; }
.user-row .spacer { flex: 1; }
.badge {
  font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 10px;
}
.badge.pending { background: var(--bn-warning-subtle); color: var(--bn-warning-text); border: 1px solid var(--bn-warning-border); }
.badge.approved { background: var(--bn-success-subtle); color: var(--bn-success-text); border: 1px solid var(--bn-success-border); }
.badge.rejected { background: var(--bn-danger-subtle); color: var(--bn-danger-text); border: 1px solid var(--bn-danger-border); }
.badge.admin { background: var(--bn-info-subtle); color: var(--bn-info-text); border: 1px solid var(--bn-info-border); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--bn-surface); color: var(--bn-text);
  border: 1px solid var(--bn-border); border-radius: 10px;
  box-shadow: var(--bn-shadow-2);
  padding: 10px 18px; font-weight: 500; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 200ms ease;
}
#toast.show { opacity: 1; }

@media (max-width: 640px) {
  .topbar .who { display: none; }
  .topbar nav button { padding: 7px 9px; font-size: 14px; }
  main#view { padding: 14px 10px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
