/* ============================================================
   App shell — responsive layout
   Mobile (<1024): top app bar + content + fixed bottom tab bar
   Desktop (>=1024): left rail + top utility bar + content
   ============================================================ */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: 1fr;
  background: var(--surface-800);
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-bottom: 24px;
}

/* ---------- Top bar (mobile + desktop utility) ---------- */
.topbar {
  background: var(--surface-900);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter);
  gap: 12px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--hairline);
  z-index: 30;
  position: sticky; top: 0;
}
.topbar .menu-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  border-radius: var(--r-md);
}
.topbar .menu-btn:hover { background: var(--hairline); }
.topbar .menu-btn svg { width: 22px; height: 22px; }

.topbar .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--topbar-h);
  /* Give the logo a fixed minimum width so it sits centered inside its
     own slot rather than hugging the hamburger to the left. */
  min-width: 140px;
  padding: 0 14px;
  text-decoration: none;
}
.topbar .logo .stake-wordmark {
  height: 28px; width: auto;
  display: block;
}
/* ODIN logo is pre-trimmed to its ink bbox (~2.93:1 ratio).
   Vertical centering comes from the explicit `height: var(--topbar-h)`
   on `.logo` so we don't depend on the wrapping flex row's height. */
.topbar .logo .odin-mark {
  height: 36px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
@media (min-width: 1024px) {
  .topbar .logo .odin-mark { height: 38px; }
}

.topbar .balance {
  display: none;
  align-items: center; gap: 10px;
  background: var(--surface-900);
  border-radius: var(--r-md);
  padding: 5px 5px 5px 14px;
  color: var(--text-primary);
  font-size: var(--text-sm); font-weight: 600;
}
.topbar .balance .bal-amt {
  font-variant-numeric: tabular-nums;
}
.topbar .balance .currency {
  color: var(--text-muted); font-size: var(--text-xs); font-weight: 700;
  letter-spacing: 0.02em;
}
.topbar .balance .wallet-btn {
  background: var(--brand-blue);
  color: #fff;
  padding: 7px 16px;
  border-radius: var(--r-md);
  font-size: var(--text-xs); font-weight: 700;
}
.topbar .balance .wallet-btn:hover { background: var(--brand-blue-hover); }

.topbar .search-wrap { display: none; flex: 1; max-width: 480px; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }
.topbar .icon-only {
  width: 36px; height: 36px;
  display: none;
  align-items: center; justify-content: center;
  color: var(--text-muted);
  border-radius: var(--r-md);
}
.topbar .icon-only:hover { background: var(--surface-700); color: var(--text-primary); }
.topbar .avatar {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1475E1, #03E625);
  color: #07140A;
  border-radius: 50%;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: filter var(--t-fast) var(--ease);
}
.topbar .avatar:hover { filter: brightness(1.08); }
@media (min-width: 1024px) { .topbar .avatar { display: inline-flex; } }
.topbar .icon-only svg { width: 20px; height: 20px; }

/* Mobile: hide rail & desktop-only items */
.rail { display: none; }

/* ---------- Mobile bottom tab bar ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface-900);
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
  z-index: 40;
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  position: relative;
  padding: 4px 0;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--text-primary); }
.tabbar a[aria-current="page"]::after {
  content: "";
  position: absolute; top: -8px; left: 20%; right: 20%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
}
.tabbar a .badge {
  position: absolute; top: -2px; right: 28%;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--brand-blue); color: #fff;
  border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 16px;
}

/* ============================================================
   Desktop layout (≥ 1024)
   ============================================================ */
@media (min-width: 1024px) {
  :root { --gutter: 20px; }

  .app {
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
      "rail topbar"
      "rail main";
  }
  .topbar { grid-area: topbar; }
  .rail   { grid-area: rail; }
  .app-main { grid-area: main; padding-bottom: 0; }

  /* Topbar tweaks */
  .topbar { padding: 0 var(--gutter-lg); }
  .topbar .menu-btn { display: none; }
  .topbar .logo { display: none; }
  .topbar .search-wrap { display: flex; }
  .topbar .balance { display: flex; }
  .topbar .icon-only { display: inline-flex; }

  /* Left rail */
  .rail {
    display: flex; flex-direction: column;
    background: var(--surface-900);
    border-right: 1px solid var(--hairline);
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    z-index: 20;
  }
  .rail::-webkit-scrollbar { width: 6px; }
  .rail::-webkit-scrollbar-thumb { background: var(--surface-700); border-radius: 3px; }

  .rail .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-h);
    padding: 0 var(--gutter-lg);
    border-bottom: 1px solid var(--hairline);
    text-decoration: none;
  }
  .rail .logo .stake-wordmark {
    height: 32px; width: auto;
    display: block;
  }
  .rail .logo .odin-mark {
    height: 36px;
    width: auto;
    display: block;
  }

  /* Mode tabs in rail — uses official Stake SVG pills */
  .rail-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 12px;
    background: var(--surface-900);
  }
  .rail-mode {
    display: block;
    text-decoration: none;
    border-radius: var(--r-md);
    overflow: hidden;
    transition: filter var(--t-fast) var(--ease);
  }
  .rail-mode:hover { filter: brightness(1.08); }
  .rail-mode-art { display: block; width: 100%; height: auto; }
  .rail-mode.active { filter: none; }
  .rail-mode:not(.active):hover { filter: brightness(1.15); }

  .rail-nav { padding: 4px 8px 24px; display: flex; flex-direction: column; gap: 2px; }
  .rail-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    min-height: 38px;
  }
  .rail-link:hover { background: var(--surface-700); color: var(--text-primary); }
  .rail-link[aria-current="page"] {
    background: var(--surface-700);
    color: var(--text-primary);
  }
  .rail-link svg { width: 18px; height: 18px; flex: none; }
  .rail-link .chev { display: none; } /* drop the chevron — real Stake doesn't have it */
  .rail-section + .rail-link { margin-top: 4px; }

  .rail-section {
    padding: 12px 20px 4px;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .rail-bottom {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--hairline);
    display: flex; flex-direction: column; gap: 2px;
  }

  /* Hide mobile tab bar on desktop */
  .tabbar { display: none; }

  /* Wider gutters */
  .section-head { padding: 0 var(--gutter-lg); }
  .card-grid    { padding: 0 var(--gutter-lg); }
  .card-row     { padding: 0 var(--gutter-lg); }
  .chip-row     { padding: 0 var(--gutter-lg); }
  .mode-tiles   { padding: 0 var(--gutter-lg); }
  .vip-tiers    { padding: 0 var(--gutter-lg); }
  .oauth-row    { padding: 0 var(--gutter-lg); }
  .or-divider   { padding: 20px var(--gutter-lg) 12px; }
  .divider      { margin: 24px var(--gutter-lg); }
  .stats-row    { padding: 0 var(--gutter-lg); }
}

@media (min-width: 1440px) {
  :root { --rail-w: 260px; }
}

/* ---------- Browse drawer (mobile) ---------- */
.drawer-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease);
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; inset: 0;
  max-width: 90vw;
  background: var(--surface-900);
  z-index: 81;
  transform: translateX(-100%);
  transition: transform var(--t) var(--ease);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer .drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter);
  height: var(--topbar-h);
  border-bottom: 1px solid var(--hairline);
}
.drawer .drawer-modes { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drawer-mode {
  display: block;
  border-radius: var(--r-md);
  overflow: hidden;
  text-decoration: none;
  transition: filter var(--t-fast) var(--ease);
}
.drawer-mode .rail-mode-art { display: block; width: 100%; height: auto; }
.drawer-mode:not(.active):hover { filter: brightness(1.15); }

@media (min-width: 1024px) {
  .drawer, .drawer-scrim { display: none; }
}

/* ---------- Hero art (desktop tiles next to H1) ---------- */
.hero-art .art-tile {
  width: 180px;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  background: var(--surface-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 80px;
  overflow: hidden;
  position: relative;
}
.hero-art .art-tile.casino { background: radial-gradient(circle at 40% 30%, #1F4D7A, #0F2434 70%); }
.hero-art .art-tile.sports { background: radial-gradient(circle at 60% 30%, #1A4D3A, #0F2820 70%); }
@media (max-width: 1023px) { .hero-art { display: none; } }
