/* ==========================================================================
   BattleYield — dapp (app.html) page styles
   Page-specific layout only: status strip, scoreboard grid, position card,
   action tabs, exits, feed, wallet menu. No new colours — tokens only.
   Motion: transform/opacity only (+ the sanctioned .bar width transition).
   ========================================================================== */

/* ---------- dense dapp rhythm ------------------------------------------ */
.app-main { padding-block: var(--s-5) var(--s-8); }
.app-stack { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }   /* minmax(0) — an implicit auto column would grow to the widest table */
.app-stack > * { min-width: 0; }
.app-main .section { padding-block: var(--s-3); }
.app-main .section-head { margin-bottom: var(--s-4); }
.section-head-row { grid-template-columns: 1fr auto; align-items: end; }
.section-head-row > div { display: grid; gap: var(--s-2); }
.reason { min-height: 1.2em; font-size: var(--t-xs); color: var(--c-dim); }
.reason:empty { display: none; }
.reason.is-error { color: var(--c-danger-text); }
.app-main hr { margin-block: var(--s-2); }

/* ---------- topbar extras ----------------------------------------------- */
.topbar .badge { flex: 0 0 auto; }
.topbar .chip { flex: 0 0 auto; }
.topbar .gauge .bar { width: 72px; }
@media (min-width: 1100px) { .topbar .gauge .bar { width: 120px; } }
/* the countdown chip and the fee gauge repeat values shown in the status strip / token section:
   drop them before they push the wallet button off-screen (nothing else in the bar can shrink) */
@media (max-width: 1099px) { #tb-count-chip { display: none !important; } }
@media (max-width: 899px) { #fee-gauge { display: none !important; } }
.wallet-wrap { position: relative; flex: 0 1 auto; min-width: 0; }
#btn-wallet { max-width: 44vw; min-width: 0; }
#btn-wallet .wallet-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 260px; max-width: calc(100vw - 32px);
  padding: var(--s-2);
  display: grid; gap: 2px;
  background: var(--c-panel-3);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  z-index: var(--z-tooltip);
  animation: toast-in var(--d-fast) var(--ease-out);
}
.wallet-menu .menu-head { padding: var(--s-2) var(--s-3); font-size: var(--t-xs); color: var(--c-dim); text-transform: uppercase; letter-spacing: var(--ls-eyebrow); font-family: var(--f-display); font-weight: 600; }
.wallet-menu .menu-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; text-align: left;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--c-text);
  min-height: 40px;
}
.wallet-menu .menu-item:hover, .wallet-menu .menu-item:focus-visible { background: var(--c-panel-2); text-decoration: none; }
.wallet-menu .menu-item img { width: 22px; height: 22px; border-radius: 5px; flex: 0 0 auto; }
.wallet-menu .menu-item.danger { color: var(--c-danger-text); }
.wallet-menu .menu-addr { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--c-dim); word-break: break-all; }

/* ---------- war status strip -------------------------------------------- */
.status-panel { padding: var(--s-5); }
.status-grid { display: grid; gap: var(--s-4); grid-template-columns: 1fr; align-items: stretch; }
@media (min-width: 900px) { .status-grid { grid-template-columns: 1.25fr minmax(0, 1fr) minmax(0, 1fr); } }
.status-count .stat-value { font-size: clamp(1.5rem, 1rem + 1.5vw, 2.25rem); white-space: nowrap; }
.status-actions { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-3); }
.war-track { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-top: var(--s-4); }
.war-track i { display: block; height: 6px; border-radius: var(--r-pill); background: var(--c-line); }
.war-track i.is-done { background: var(--c-dim); }
.war-track i.is-current { background: var(--c-text); animation: pulse 1.6s var(--ease-in-out) infinite; }
.war-track i.is-aftermath { background: var(--c-line-strong); }

/* ---------- scoreboard --------------------------------------------------- */
.score-stage { position: relative; }
.score-stage > .embers { opacity: 0.7; }
.score-stage > .versus-grid { position: relative; z-index: var(--z-content); }
.score-card { display: grid; align-content: start; }
.score-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.score-head h3 { line-height: 1; }
.score-head > div { flex: 1 1 auto; min-width: 0; }
.score-flag { flex: 0 0 auto; }
.team-cats .score-head { flex-direction: row-reverse; text-align: right; }
@media (max-width: 759px) { .team-cats .score-head { flex-direction: row; text-align: left; } }
.score-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.score-stats .stat { background: rgba(0, 0, 0, 0.18); }
.score-stats .stat-value { font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* live team APY: the derived headline tile spans both columns; its sub line carries the payout ÷ position formula */
.score-stats .stat-apy { grid-column: 1 / -1; }
.score-stats .stat-apy .stat-value { font-size: var(--t-lg); color: var(--c-team, var(--c-text)); }
.score-stats .stat-apy .stat-value.is-tba { color: var(--c-dim); }
.score-stats .stat-apy .stat-sub { white-space: normal; overflow-wrap: anywhere; }
/* 760–899px: three columns on the stage leave ~48px per tile — stack the four stats instead of clipping "61.2M" */
@media (min-width: 760px) and (max-width: 899px) { .score-stats { grid-template-columns: 1fr; } }
.score-center { display: grid; gap: var(--s-4); align-content: center; justify-items: center; text-align: center; min-width: 0; }
@media (min-width: 760px) { .score-center { width: clamp(200px, 22vw, 260px); padding-inline: var(--s-2); } }
.score-center .stat { width: 100%; background: transparent; }
.score-center .stat-value { font-size: var(--t-lg); }
.score-center .badge { max-width: 100%; white-space: normal; text-align: center; }
.score-center .vs { display: none; }
@media (min-width: 760px) { .score-center .vs { display: inline-grid; } }

/* ---------- my position -------------------------------------------------- */
.me-grid { display: grid; gap: var(--s-4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .me-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.me-budget .label { align-items: center; }
.weight-row { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: var(--s-2); }
.weight-row .bar { --bar-fill: var(--c-text); }
.weight-scale { font-size: var(--t-xs); color: var(--c-dim); }
.me-wallet .summary-row b { max-width: 60%; overflow-wrap: anywhere; text-align: right; }

/* ---------- actions ------------------------------------------------------ */
.action-panel { overflow: visible; }
.tabs {
  display: flex; gap: var(--s-2); flex-wrap: nowrap;
  padding: var(--s-4) var(--s-4) var(--s-3);
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--c-line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs .btn { flex: 0 0 auto; }
@media (max-width: 639px) { .tabs { flex-wrap: wrap; overflow: visible; } }   /* 7 small buttons on two rows — no hidden tabs on phones */
.action-form-stack > .fortify-split { margin-block: var(--s-1); }
.tab-panel { padding: var(--s-5) var(--s-4) var(--s-5); display: grid; gap: var(--s-4); }
@media (min-width: 760px) { .tab-panel { padding: var(--s-5); } }
.action-grid { display: grid; gap: var(--s-5); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .action-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); } }
.action-form { display: grid; gap: var(--s-4); min-width: 0; }
.action-side { display: grid; gap: var(--s-3); align-content: start; min-width: 0; }
.field-inline { grid-template-columns: auto auto 1fr; align-items: center; gap: var(--s-3); }
.field-inline .label { margin: 0; }
.input-narrow { width: 120px; }
.input-narrow .input { padding-right: 34px; min-height: 40px; font-size: var(--t-base); }
@media (max-width: 480px) { .field-inline { grid-template-columns: 1fr; } }

.summary { display: grid; gap: 0; font-size: var(--t-sm); color: var(--c-dim); }
.summary-box { padding: var(--s-2) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--c-line); }
.summary-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--c-line); min-width: 0; }
.summary-row:last-child { border-bottom: 0; }
.summary-row b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--c-text); text-align: right; overflow-wrap: anywhere; }
.summary-row b.is-tba { color: var(--c-dim); }

.pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.pick-card {
  display: grid; gap: var(--s-2); justify-items: start; text-align: left;
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--c-line);
  background: var(--c-panel-2);
  color: var(--c-text);
  transition: transform var(--d-fast) var(--ease-out), border-color var(--d-fast), box-shadow var(--d-base) var(--ease-out), opacity var(--d-fast);
}
.pick-card:hover { transform: translateY(-2px); border-color: var(--c-team-line); }
.pick-card[aria-pressed="true"] { border-color: var(--c-team-line); box-shadow: var(--glow-team); background: var(--c-team-soft); }
.pick-card:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.pick-card .emblem-xs { width: 32px; }

.confirm-row {
  display: grid; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid rgba(224, 69, 58, 0.4);
  background: var(--c-danger-soft);
  font-size: var(--t-sm);
  animation: toast-in var(--d-base) var(--ease-out);
}

/* ---------- exits -------------------------------------------------------- */
.exit-list { display: grid; gap: var(--s-2); }
.exit-row {
  display: grid; gap: var(--s-3); grid-template-columns: 1fr; align-items: center;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--c-line); border-radius: var(--r-md);
  background: var(--c-panel-2);
  font-size: var(--t-sm);
}
@media (min-width: 640px) { .exit-row { grid-template-columns: auto minmax(0, 1fr) auto; } }
.exit-id { font-family: var(--f-mono); color: var(--c-dim); }
.exit-amounts { display: grid; gap: 2px; min-width: 0; }
.exit-amounts b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.exit-when { color: var(--c-dim); }
.exit-when.is-ready { color: var(--c-ok); }
.exit-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- war history -------------------------------------------------- */
#wars-table tbody tr.is-future td { color: var(--c-dim); }
#wars-table td .badge { vertical-align: middle; }

/* ---------- feed --------------------------------------------------------- */
.feed-list { display: grid; gap: 1px; background: var(--c-line); border: 1px solid var(--c-line); border-radius: var(--r-md); overflow: hidden; }
.feed-list:empty { display: none; }
.feed-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-3); align-items: center;
  padding: var(--s-3) var(--s-4);
  background: var(--c-panel);
  font-size: var(--t-sm);
  min-width: 0;
}
.feed-item.is-new { animation: reveal var(--d-slow) var(--ease-out); }
.feed-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-team, var(--c-dim)); box-shadow: 0 0 10px 1px var(--c-team-soft, transparent); }
.feed-main { min-width: 0; overflow-wrap: anywhere; }
.feed-verb { font-family: var(--f-display); font-weight: 600; color: var(--c-team, var(--c-text)); margin-right: var(--s-1); }
.feed-main .num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; color: var(--c-text); }
.feed-main .addr-inline { font-family: var(--f-mono); color: var(--c-dim); font-size: var(--t-xs); }
.feed-meta { color: var(--c-dim); font-family: var(--f-mono); font-size: var(--t-xs); white-space: nowrap; text-align: right; }
.feed-meta:hover { color: var(--c-text); }
@media (max-width: 480px) {
  .feed-item { grid-template-columns: auto minmax(0, 1fr); }
  .feed-meta { grid-column: 2; text-align: left; }
}

/* ---------- lock variants ----------------------------------------------- */
.lock.is-compact { padding: var(--s-5); gap: var(--s-3); }
.lock.is-compact .lock-icon { font-size: 1.75rem; }
.lock.is-compact h2 { font-size: var(--t-lg); }
.lock .lock-action { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; }
.lock .lock-wallet { justify-content: center; }   /* pre-launch: connected address · network badge · native balance */

/* ---------- reduced motion ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .war-track i.is-current, .feed-item.is-new, .wallet-menu, .confirm-row { animation: none; }
  .pick-card:hover { transform: none; }
}
