/* app.css — Betanywhere design tokens + base. AIR + POSTER (brand.md). */

/* ============================================================ TOKENS */
:root {
  --bone: #F4F1EA;
  --ink: #1A1A1C;
  --sunrise: #E2A63D;
  --sky: #BFD9E8;
  --grey: #8B8780;
  --bezel: #E7E3DA;
  --yes: #1FA45B;
  --no: #E0484E;

  --font-display: 'Anton', system-ui, sans-serif;
  --font-ui: 'Archivo', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --col-width: 430px;
  --tabbar-h: 58px;
  --hairline: rgba(26, 26, 28, .12);

  --sheet-ease: cubic-bezier(.32, .72, .3, 1);
}

/* ============================================================ RESET */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  font-weight: 400;
  color: var(--ink);
  background: var(--bone);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

body.body-locked { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ============================================================ UTILITIES */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .005em;
  line-height: .96;
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
}

/* ============================================================ APP SHELL / LAYOUT */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  background: var(--bone);
  overflow: hidden;
}

#screen-root {
  flex: 1 1 auto;
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Atmospheric glows on the bone bg (all viewports). No phone frame: mobile
   layout runs full-bleed below 1024px; a real desktop app takes over above. */
@media (min-width: 1024px) {
  body {
    background:
      radial-gradient(90% 70% at 80% 0%, rgba(226, 166, 61, .08), transparent 60%),
      radial-gradient(70% 60% at 0% 0%, rgba(191, 217, 232, .12), transparent 55%),
      var(--bone);
  }
}

/* ============================================================ BALANCE CHIP */
#balance-chip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 14px;
  z-index: 40;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: rgba(244, 241, 234, .72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 13px;
  box-shadow: 0 4px 16px rgba(26, 26, 28, .10);
}
#balance-chip[hidden] { display: none; }

/* ============================================================ TAB BAR */
#tabbar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(244, 241, 234, .82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--hairline);
  z-index: 30;
}

.tab {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--grey);
  transition: color .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.tab.is-active { color: var(--ink); }

.tab-ic { width: 24px; height: 24px; }

.tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
}

/* Active indicator dot: 4px, centred under the label, 4px below the label
   baseline. Space is always reserved (active + inactive) so toggling causes
   no layout shift; the whole icon+label+dot block stays vertically centred. */
.tab::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  margin-top: 1px; /* + the 3px column gap = 4px below the label baseline */
  border-radius: 999px;
  background: var(--sunrise);
  opacity: 0;
  transition: opacity .16s ease;
}
.tab.is-active::after { opacity: 1; }

/* Sidebar brand mark — desktop only (shown in the ≥1024px block below) */
#sidebar-brand { display: none; }

/* ============================================================ SCREEN STUBS */
.screen { padding: 24px; }

.screen-stub {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.screen-stub .display { font-size: clamp(40px, 13vw, 64px); }
.stub-note {
  color: var(--grey);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ============================================================ BUTTONS */
.btn-yes,
.btn-no,
.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  border-radius: 8px;
  padding: 13px 18px;
  border: none;
  line-height: 1;
  transition: transform .12s ease, box-shadow .16s ease, background .16s ease;
}
.btn-yes:active,
.btn-no:active,
.btn-primary:active,
.btn-ghost:active { transform: scale(.98); }

.btn-yes {
  background: var(--yes);
  color: #fff;
  box-shadow: 0 6px 24px rgba(31, 164, 91, .35);
}

.btn-no {
  background: var(--no);
  color: #fff;
  box-shadow: 0 6px 24px rgba(224, 72, 78, .35);
}

.btn-primary {
  background: var(--ink);
  color: var(--bone);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}

/* prices inside buttons are mono 600 */
.btn-yes .price,
.btn-no .price,
.btn-primary .price,
.btn-ghost .price {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ============================================================ FORM INPUTS */
.field {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  background: var(--bone);
  border: 1px solid rgba(26, 26, 28, .25);
  border-radius: 8px;
  padding: 12px 14px;
  width: 100%;
}
.field:focus {
  outline: none;
  border-color: var(--ink);
}
.field--num,
input[inputmode='numeric'].field,
input[type='number'].field {
  font-family: var(--font-mono);
  font-weight: 500;
}
.field::placeholder { color: var(--grey); }

/* ============================================================ SHEET */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(26, 26, 28, 0);
  transition: background .28s var(--sheet-ease);
}
.sheet-backdrop.is-open { background: rgba(26, 26, 28, .35); }

.sheet-panel {
  width: 100%;
  max-width: var(--col-width);
  max-height: 88dvh;
  background: var(--bone);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(26, 26, 28, .22);
  transform: translateY(100%);
  transition: transform .28s var(--sheet-ease);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-panel.is-open { transform: translateY(0); }

.sheet-handle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: grab;
  touch-action: none;
}
.sheet-grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(26, 26, 28, .2);
}

.sheet-content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 20px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ============================================================ TOAST */
#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
@media (min-width: 1024px) {
  /* sit above the desktop content area, clear of the left sidebar */
  #toast-root { bottom: 32px; left: 232px; }
}

.toast {
  background: var(--ink);
  color: var(--bone);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .01em;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(26, 26, 28, .25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.is-open { opacity: 1; transform: translateY(0); }

/* ============================================================ DESKTOP APP (≥1024px)
   A genuine desktop layout: fixed left sidebar + flexible main area. No phone
   frame, no letterboxing. Mobile layout is untouched below this breakpoint. */
@media (min-width: 1024px) {
  /* shell becomes a row: sidebar (the nav) on the left, main on the right.
     DOM order is #screen-root then #tabbar, so row-reverse puts the nav left. */
  #app {
    flex-direction: row-reverse;
    height: 100dvh;
    overflow: visible;
    background: transparent;
  }

  /* ---- LEFT SIDEBAR (was #tabbar) ---- */
  #tabbar {
    flex: 0 0 232px;
    width: 232px;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding: 0 16px;
    background: var(--bone);
    border-top: none;
    border-right: 1px solid var(--hairline);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  #sidebar-brand {
    display: flex;
    align-items: center;
    height: 72px;
    padding: 0 6px;
    margin-bottom: 8px;
    flex: 0 0 auto;
  }
  #sidebar-brand img { width: 40px; height: 40px; display: block; }

  /* vertical nav items: icon + label in a row, 44px tall */
  .tab {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    height: 44px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--grey);
  }
  .tab-ic { width: 22px; height: 22px; flex: 0 0 auto; }
  .tab-label {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
  }
  /* active = ink text + 3px accent bar on the left edge */
  .tab.is-active { color: var(--ink); }
  .tab::after {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    margin: 0;
    border-radius: 0 3px 3px 0;
    background: var(--sunrise);
    opacity: 0;
  }
  .tab.is-active::after { opacity: 1; }
  .tab:hover { color: var(--ink); }

  /* balance chip relocates into the sidebar bottom area */
  #balance-chip {
    position: absolute;
    top: auto;
    bottom: 20px;
    left: 16px;
    right: auto;
    width: 200px;
    text-align: left;
  }

  /* ---- MAIN AREA ---- */
  #screen-root {
    flex: 1 1 auto;
    height: 100dvh;
    overflow-y: auto;
  }

  /* other screens: left-aligned content column, not letterboxed phone width */
  .bets, .account, .bd, .ls {
    max-width: 680px;
    margin: 0;
    padding-top: 48px;
    padding-bottom: 48px;
  }
  .bets { padding-left: 48px; padding-right: 48px; }
  .account { padding-left: 48px; padding-right: 48px; }
  .bd, .ls { padding-left: 48px; padding-right: 48px; }

  /* ---- SHEETS become centred modal dialogs ---- */
  .sheet-backdrop { align-items: center; }
  .sheet-panel {
    width: 480px;
    max-width: 480px;
    max-height: 80vh;
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(26, 26, 28, .28);
    transform: translateY(24px) scale(.98);
  }
  .sheet-panel.is-open { transform: translateY(0) scale(1); }
  .sheet-handle { display: none; }
  .sheet-content { padding-top: 24px; }

  /* toast already repositioned above */
}

/* ============================================================ REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
