/* 2026-11-16 UX pass: progressive disclosure + clearer navigation.
   Uses the app's own tokens (--panel, --border, --accent, --muted, --radius, --touch) so light/dark both work. */

/* long lists are collapsed by ux.js; the DOM keeps every row (search/sort/filters still see them) */
[data-cx-hide] { display: none !important; }

.cx-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch, 44px);
  margin: 0.6rem auto 0;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 999px;
  background: var(--panel2, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.cx-more:hover { border-color: var(--accent); color: var(--accent); }
.cx-more:focus-visible, details.cx-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cx-more[hidden] { display: none; }

/* collapsible section (native <details>: keyboard + screen-reader friendly, no JS needed) */
details.cx-fold {
  margin: 0.85rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius, 16px);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
details.cx-fold > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--touch, 44px);
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 0.95rem;
}
details.cx-fold > summary::-webkit-details-marker { display: none; }
details.cx-fold > summary::after {
  content: "";
  margin-left: auto;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--ease, 160ms ease);
}
details.cx-fold[open] > summary::after { transform: rotate(-135deg); }
details.cx-fold > summary .cx-hint { font-weight: 400; font-size: 0.82rem; color: var(--muted); }
details.cx-fold > .cx-fold-body { padding: 0 1rem 1rem; }
details.cx-fold > .cx-fold-body > :first-child { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { details.cx-fold > summary::after { transition: none; } }

/* sidebar: group labels (primary vs secondary navigation) */
.side-group {
  margin: 0.9rem 0.35rem 0.15rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.side-nav > .side-group:first-child { margin-top: 0.1rem; padding-top: 0; border-top: 0; }

/* the equity curve is the one chart that summarises everything: give it room */
#mini-chart.chart.mini { min-height: 190px; }
#perf-chart.chart { min-height: 260px; }

/* header: too many controls competed for attention. Always visible: title, mode (Paper/Testnet/Live), the two
   safety buttons, language, theme (+ search on wide screens). Behind "Options": market toggle (Futures/Spot),
   access chip, refresh and auto-refresh. On phones language, theme and search move behind it as well. */
#cx-hdr-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--touch, 44px);
  padding: 0.4rem 0.8rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
#cx-hdr-toggle::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform var(--ease, 160ms ease);
}
#cx-hdr-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
#cx-hdr-toggle[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(-1px); }
#cx-hdr-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body:not(.cx-hdr-open) #market-switch,
body:not(.cx-hdr-open) .top-actions .access-switch,
body:not(.cx-hdr-open) .top-actions #btn-refresh,
body:not(.cx-hdr-open) .top-actions label.auto { display: none !important; }
@media (max-width: 640px) {
  #cx-hdr-toggle { margin-left: auto; margin-right: 0.15rem; }
  body:not(.cx-hdr-open) .topbar-search,
  body:not(.cx-hdr-open) .top-actions .lang-toggle,
  body:not(.cx-hdr-open) .top-actions #btn-theme { display: none !important; }
}

/* a fold inside a card's key/value list: lighter than the page-level fold */
details.cx-fold.cx-fold-inline { margin: 0.5rem 0 0; box-shadow: none; border-radius: var(--radius-sm, 12px); background: transparent; }
details.cx-fold.cx-fold-inline > summary { min-height: 38px; padding: 0.4rem 0.75rem; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
details.cx-fold.cx-fold-inline > .cx-fold-body { padding: 0 0.75rem 0.6rem; }

/* custom period filter: explains the epoch boundary (see initPeriodEpoch in ux.js) */
.cx-epoch-hint { margin: 0.4rem 0 0; font-size: 0.85rem; line-height: 1.45; color: var(--muted); }
.cx-epoch-hint.warn { color: var(--warn); font-weight: 600; }
.cx-epoch-hint[hidden] { display: none; }

/* owner-only tabs are not offered to members/visitors (the API refuses them anyway) */
body:not(.is-owner) .side-link[data-tab="settings"],
body:not(.is-owner) .side-link[data-tab="dev"],
body:not(.is-owner) .side-link[data-tab="signal-sub"],
body:not(.is-owner) .side-link[data-tab="custom"],
body:not(.is-owner) .side-link[data-tab="watchlist"],
body:not(.is-owner) .side-link[data-tab="users"] { display: none !important; }

/* phones: tiny controls found by the QA scan (13px checkboxes, 20px info buttons, 23px badge) get a usable size */
@media (max-width: 760px) {
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .mode-info, .ce-i { min-width: 32px; min-height: 32px; }
  .acct-badge { min-height: 32px; }
}
