/* ============================================================
   Woodpecker 3.0 — Base / reset / typography / app shell
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

/* Full-bleed session: lock background scroll while the chart owns the viewport */
body.is-session { overflow: hidden; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "tnum";
  text-rendering: optimizeLegibility;
}

/* Numbers align for trading tables / HUD */
.tnum, .mono, code, kbd, .num {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.7; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
ul, ol { list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
input, textarea, select { -webkit-appearance: none; appearance: none; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   App shell skeleton
   ============================================================ */

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Boot fallback (pre-JS) --- */
.boot-fallback {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-5);
  color: var(--text);
  background: var(--bg);
}
.boot-fallback > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.boot-fallback span { color: var(--text-muted); font-size: var(--fs-sm); }
.boot-fallback--error { flex-direction: column; text-align: center; }
.boot-fallback--error strong { color: var(--short); }
.boot-fallback--error span { max-width: 520px; }

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: var(--fw-semi);
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
  color: var(--text);
}
.topbar__brand .wp-mark { width: 18px; height: 18px; color: var(--accent); flex: none; }
.topbar__spacer { flex: 1; }

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}
.status-dot::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: inset 0 0 0 1.5px var(--text-faint);
}
.status-dot--local::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-dim); }
.status-dot--synced::before { background: var(--long); box-shadow: 0 0 8px var(--long); }
.status-dot--connecting::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.status-dot--offline::before { background: var(--short); }
.status-dot--error::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--short); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- Main scroll area --- */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s-5) var(--gutter) calc(var(--nav-h) + var(--s-7));
}
.view { animation: viewIn var(--dur) var(--ease-out); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* --- Screen header (Tier A H1 owns the screen) --- */
.scr-head {
  margin-bottom: var(--s-6);
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
}
.scr-head__titles { flex: 1; min-width: 0; }
.scr-head h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}
.scr-head p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: 3px;
}
.scr-head__aside {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* --- Hairline: the only section separator (Z3) --- */
.hairline {
  height: 1px;
  background: var(--border-soft);
  border: 0;
  margin: 0;
}
.hairline--section { margin: var(--s-6) 0; }

/* ============================================================
   Bottom navigation (Session = central FAB)
   ============================================================ */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav.is-hidden { display: none; }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-dim);
  transition: color var(--dur-fast);
}
.nav-item__label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.nav-item.is-active { color: var(--accent); }
.nav-item:active { transform: scale(0.94); }

/* Center FAB slot */
.nav-fab {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--accent);
}
.nav-fab__btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: var(--shadow-fab);
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-top: -16px;          /* lifted above the bar */
  transition: transform var(--dur) var(--ease);
}
.nav-fab__btn:active { transform: scale(0.93); }
.nav-fab.is-active .nav-fab__btn { background: var(--accent); color: var(--accent-ink); }

/* Desktop: floating centered pill (preserves chart width, Z8) */
@media (min-width: 760px) {
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: min(var(--max-w), 520px);
    margin: 0 auto var(--s-4);
    bottom: var(--s-3);
    border-radius: var(--r-pill);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-2);
    height: 60px;
  }
}

/* ============================================================
   Utility helpers
   ============================================================ */
.flex-1 { flex: 1; }
.row-flex { display: flex; align-items: center; }
.row-flex.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; }
.stack--2 { gap: var(--s-2); }
.stack--3 { gap: var(--s-3); }
.stack--4 { gap: var(--s-4); }
.stack--5 { gap: var(--s-5); }

.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }

.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.bold { font-weight: var(--fw-bold); }
.semi { font-weight: var(--fw-semi); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.long { color: var(--long); }
.short { color: var(--short); }
.accent { color: var(--accent); }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Spinner */
.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spinner--lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
