/* chart-shortcuts.css — command palette, toast, help cheatsheet, mobile dock,
 * and mobile-friendly chart layout. Loads after styles.css; reuses its tokens. */

/* ===================== command palette ===================== */
.ks-palette {
  position: fixed; inset: 0; z-index: 120; display: grid; justify-items: center;
  align-content: start; padding-top: 12vh;
  background: rgba(6, 8, 13, 0.62); backdrop-filter: blur(3px);
}
.ks-palette[hidden] { display: none; }
.ks-pal-card {
  width: min(620px, 94vw); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 13px;
  box-shadow: var(--shadow); overflow: hidden;
  animation: ksPop 0.12s ease-out;
}
@keyframes ksPop { from { opacity: 0; transform: translateY(-8px) scale(0.985); } to { opacity: 1; transform: none; } }
.ks-pal-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ks-pal-ico { display: inline-grid; place-items: center; height: 26px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.ks-pal-input { width: 100%; height: 34px; padding: 0 6px; border: 0 !important; background: transparent !important; color: var(--text-strong); font-size: 15px; outline: none; }
.ks-pal-input::placeholder { color: var(--muted-2); }
.ks-pal-list { overflow-y: auto; padding: 6px; display: grid; gap: 2px; }
.ks-pal-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.ks-pal-row.sel { background: var(--accent-soft); border-color: var(--accent-line); }
.ks-pal-badge { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--panel-3); color: var(--cyan); font-size: 11px; font-weight: 800; }
.ks-pal-badge.ks-cmd { color: var(--amber); }
.ks-pal-badge.ks-raw { color: var(--green); }
.ks-pal-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ks-pal-main b { font-size: 13px; color: var(--text-strong); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-pal-main i { font-style: normal; font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-pal-chg { font-family: var(--mono); font-size: 12px; }
.ks-pal-chg.up { color: var(--green); }
.ks-pal-chg.down { color: var(--red); }
.ks-pal-row kbd, .ks-help kbd { font-family: var(--mono); font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; background: var(--panel-2); white-space: nowrap; }
.ks-pal-empty { padding: 20px; text-align: center; color: var(--muted-2); }
.ks-pal-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); color: var(--muted-2); font-size: 11px; }
.ks-pal-foot b { color: var(--muted); font-family: var(--mono); font-weight: 700; }

/* ===================== toast ===================== */
.ks-toast {
  position: fixed; left: 50%; bottom: 52px; transform: translate(-50%, 14px); z-index: 130;
  padding: 9px 16px; border-radius: 999px; background: var(--panel-3); color: var(--text-strong);
  border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s;
}
.ks-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== help cheatsheet ===================== */
.ks-help { position: fixed; inset: 0; z-index: 125; display: grid; place-items: center; background: rgba(6, 8, 13, 0.62); backdrop-filter: blur(3px); }
.ks-help[hidden] { display: none; }
.ks-help-card { width: min(540px, 94vw); max-height: 82vh; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow); }
.ks-help-card header { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); }
.ks-help-card h3 { margin: 0; font-size: 14px; }
.ks-help-x { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); font-size: 18px; border-radius: 6px; }
.ks-help-x:hover { background: var(--panel-3); color: var(--text); }
.ks-help-grid { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; padding: 16px; align-items: center; }
.ks-help-grid span { color: var(--muted); font-size: 12.5px; }

/* ===================== mobile floating dock ===================== */
.ks-mobile-dock { display: none; }
.ks-mobile-dock button {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 18px; box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent;
}
.ks-mobile-dock button:active { background: var(--accent); color: #fff; transform: scale(0.94); }

@media (max-width: 900px) {
  body.ks-on-charts .ks-mobile-dock {
    position: fixed; right: 12px; bottom: 46px; z-index: 60;
    display: flex; flex-direction: column; gap: 8px;
  }
  /* let the chart toolbar scroll instead of clipping */
  .ce-topbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .ce-topbar::-webkit-scrollbar { display: none; }
}

/* ===================== mobile chart layout ===================== */
@media (max-width: 760px) {
  .chart-app { height: calc(100vh - 150px); min-height: 420px; }
  .ce-topbar { gap: 3px; padding: 0 6px; height: 42px; }
  .ce-tbtn span:not(.ce-ico):not(.ce-caret) { display: none; } /* icon-only buttons */
  #ceCompareBtn, #ceReplayBtn, #ceSessionsBtn { display: none; }
  .ce-sym-name { font-size: 14px; }
  .ce-symbol-btn kbd { display: none; }
  .ks-pal-card { width: 96vw; }
  .ks-palette { padding-top: 8vh; }
}

/* larger touch targets + smoother panning on touch devices */
@media (pointer: coarse) {
  .ce-pane-cv { touch-action: none; }
  .ce-timeaxis { touch-action: none; }
  .ce-tf, .ce-tbtn, .ce-tool { min-height: 34px; }
}

/* ---- mobile support for the new chart features ---- */
@media (max-width: 760px) {
  /* multi-chart grids stack into a single scrollable column on phones */
  .ce-chart.ce-grid { grid-template-columns: 1fr !important; grid-template-rows: none !important; grid-auto-rows: 56vw; overflow-y: auto; }

  /* drawing object editor becomes a bottom sheet so it never runs off-screen */
  .ce-draw-editor {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: 100% !important; border-radius: 14px 14px 0 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 30px rgba(0,0,0,0.4);
  }
  .ce-de-coord input, .ce-de-text { font-size: 16px; }      /* avoid iOS zoom-on-focus */
  .ce-de-w, .ce-de-sw { min-height: 30px; }

  /* keep "Reset to current" reachable above the mobile dock */
  .ce-scroll-rt { right: 64px; bottom: 12px; }
  .ce-autoscale { bottom: 12px; }

  /* layout + popout buttons stay in the (scrollable) toolbar; popout is desktop-mainly */
  #cePopoutBtn { display: none; }
}

/* popover sizing on small screens */
@media (max-width: 760px) {
  .ce-popover { max-width: 86vw; }
}
