/* ============================================================
   Woodpecker 3.0 — Session / Replay screen (chart full-bleed)
   Canvas dominates. BUY/SELL in the thumb zone, never shrunk.
   ============================================================ */

/* The internal HUD created by ReplayChart is replaced by .sess-hud */
.chart-canvas-wrap .chart-hud { display: none; }

/* Full-bleed stage: body gets .is-session to hide topbar & bottom-nav */
.sess-stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 1;
}
.sess-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.sess-canvas-wrap .chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* --- HUD overlay (top-left), Tier C mono --- */
.sess-hud {
  position: absolute;
  top: var(--s-4);
  left: var(--s-4);
  z-index: var(--z-hud);
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  font-family: var(--font-mono);
}
.sess-hud__line1 { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--text); }
.sess-hud__line2 { font-size: var(--fs-xs); color: var(--text-dim); display: flex; gap: 8px; align-items: center; }
.sess-hud__dots { letter-spacing: 1px; }

/* --- Top-right action buttons (tools / finish) --- */
.sess-top-actions {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  z-index: var(--z-hud);
  display: flex;
  gap: var(--s-2);
}
.sess-top-actions .icon-btn {
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-soft);
}

/* --- Bottom stack: transport pill + BUY/SELL --- */
.sess-bottom {
  flex: none;
  padding: 0 var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* Transport pill (floating, centered) */
.sess-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  align-self: center;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px;
  box-shadow: var(--shadow-2);
}
.sess-transport__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 42px;
  min-width: 42px;
  padding: 0 var(--s-2);
  border-radius: var(--r-pill);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  font-family: var(--font-mono);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.sess-transport__btn:hover { background: var(--surface); color: var(--text); }
.sess-transport__btn:active { transform: scale(0.94); }
.sess-transport__btn--play { color: var(--accent); }
.sess-transport__btn--play.is-playing { background: var(--accent-soft); }
.sess-transport__sep { width: 1px; height: 22px; background: var(--border-soft); }
.sess-transport__tf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 42px;
  padding: 0 14px 0 12px;
  border-radius: var(--r-pill);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  border-left: 1px solid var(--border-soft);
}
.sess-transport__tf .arrow { color: var(--text-dim); }

/* BUY / SELL — thumb zone, full width, never shrunk */
.sess-actions {
  display: flex;
  gap: var(--s-2);
}
.sess-action {
  flex: 1;
  height: 56px;
  border-radius: var(--r-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  color: #fff;
  transition: transform var(--dur-fast), opacity var(--dur-fast), box-shadow var(--dur-fast);
  box-shadow: var(--shadow-1);
}
.sess-action:active { transform: scale(0.97); }
.sess-action--buy { background: var(--long); }
.sess-action--sell { background: var(--short); }
.sess-action__sub { font-size: var(--fs-xs); font-weight: var(--fw-regular); opacity: 0.85; }

/* --- Empty state (no active session) --- */
.sess-empty {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--s-2);
  padding: var(--s-6);
  background: var(--bg);
}
.sess-empty__icon { color: var(--text-faint); margin-bottom: var(--s-3); }
.sess-empty h2 { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.sess-empty p { color: var(--text-muted); font-size: var(--fs-sm); max-width: 320px; }
.sess-empty .btn { margin-top: var(--s-4); }

/* Recap modal specifics */
.recap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.recap-stat { text-align: center; padding: var(--s-3); background: var(--surface); border-radius: var(--r-md); }
.recap-stat__label { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.recap-stat__value { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: var(--fw-bold); margin-top: 4px; }

/* Trade count badge on HUD */
.sess-hud__count {
  font-size: var(--fs-xs);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: var(--fw-semi);
}

/* Hosted chart bridge: local shell, published Session runtime. */
.session-bridge {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #0B0E13;          /* exact match of the hosted engine bg — no flash */
  overflow: hidden;
  animation: bridge-in var(--dur) var(--ease-out);
}
@keyframes bridge-in { from { opacity: 0; } to { opacity: 1; } }

.hosted-session-frame {
  display: block;
  width: 100vw;
  height: 100dvh;
  border: 0;
  background: #0B0E13;
}

/* Signature loader while the published engine boots. */
.session-bridge__loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  background: #0B0E13;
  transition: opacity var(--dur-slow) var(--ease);
}
.session-bridge__loader.is-hidden { opacity: 0; pointer-events: none; }
.session-bridge__mark { color: var(--accent); opacity: 0.92; animation: mascot-breathe 3.4s ease-in-out infinite; transform-origin: 50% 50%; }
.session-bridge__label { font-size: var(--fs-xs); color: var(--text-dim); letter-spacing: var(--tracking-wide); }

/* Brand-aligned back button (above the loader, always reachable). */
.session-bridge__back {
  position: fixed;
  z-index: 3;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg-elev) 74%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-2);
  transition: border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.session-bridge__back:hover { border-color: var(--accent-line); color: var(--accent); }
.session-bridge__back:active { transform: scale(0.94); }

/* v3 control bar overlaid on the engine (drives it via button clicks).
   Container passes clicks through gaps to the chart; controls catch them. */
.sess-bridge-bar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  transform: translateX(-50%);
  pointer-events: none;
}
.sess-bridge-bar .sess-transport,
.sess-bridge-bar .sess-actions { pointer-events: auto; }

.sess-bridge-bar .sess-transport {
  height: 42px;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-md);
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg-elev) 74%, transparent);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sess-bridge-bar .sess-transport__btn,
.sess-bridge-bar .sess-transport__tf {
  height: 34px;
  min-width: 34px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: transparent;
}

.sess-bridge-bar .sess-transport__btn--back {
  color: var(--text-dim);
}

.sess-bridge-bar .sess-transport__btn--tools {
  color: var(--text-muted);
}

.sess-bridge-bar .sess-transport__btn:hover,
.sess-bridge-bar .sess-transport__tf:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.sess-bridge-bar .sess-transport__btn--play {
  min-width: 42px;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
}

.sess-bridge-bar .sess-transport__btn--play.is-playing {
  background: var(--accent-soft);
}

.sess-bridge-bar .sess-transport__btn--tf-step {
  min-width: 44px;
  gap: 3px;
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent-line) 65%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 62%, transparent);
}

.sess-bridge-bar .tf-step-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: var(--fw-bold);
  color: var(--accent);
  transform: translateY(1px);
}

.sess-bridge-bar .sess-transport__sep {
  height: 18px;
  background: color-mix(in srgb, var(--border-soft) 72%, transparent);
}

.sess-bridge-bar .sess-transport__tf {
  padding: 0 10px;
  border-left: 0;
  color: var(--text);
  min-width: 50px;
}

@media (max-width: 560px) {
  /* Centered floating pill at every width. The previous full-width +
     space-between + margin-left:auto on the timeframe button fought each
     other: margin-left:auto swallowed all free space, so space-between had
     nothing to distribute and the first six controls clustered hard-left
     while the timeframe control was marooned far-right (a 96px chasm on a
     390px phone) — visibly off-center. Keep the pill compact and centered
     (justify-content: center is inherited from .sess-transport), with
     slightly larger touch targets than desktop. */
  .sess-bridge-bar .sess-transport {
    height: 46px;
    padding: 5px;
    gap: 2px;
  }

  .sess-bridge-bar .sess-transport__btn,
  .sess-bridge-bar .sess-transport__tf {
    height: 36px;
    min-width: 36px;
  }

  .sess-bridge-bar .sess-transport__btn--play {
    min-width: 42px;
  }

  .sess-bridge-bar .sess-transport__btn--tf-step {
    min-width: 44px;
  }
}
