/* Paper Trench: the Instant Trade panel on the token page (js/instant.js). Loaded after chart.css. */

/* the button that opens it: above the ticket on desktop, under the Buy / Sell bar on a phone */
.it-open { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 34px; padding: 0 12px; border: 1px solid var(--blue); border-radius: 999px; background: var(--blue-soft); color: var(--blue-hi); font: 700 13px/1 var(--font-head); cursor: pointer; }
.it-open .ico { width: 14px; height: 14px; color: var(--warn); }
.it-open:hover, .it-open:focus-visible { background: rgba(77, 124, 255, 0.24); color: #fff; }
.it-open[aria-expanded="true"] { background: var(--blue); color: #fff; }
.term-v2 .term-side > .it-openrow { order: 0; flex: none; padding: 10px 14px 0; }
.tk-mbar .it-open-bar { grid-column: 1 / -1; }
@media (max-width: 999px) { .term-v2 .term-side > .it-openrow { display: none; } }

/* the panel: floats above the page, under the pop-ups and the ticket sheet */
.it { position: fixed; z-index: 44; left: 12px; top: 96px; width: 324px; max-width: calc(100vw - 16px); border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-2); box-shadow: 0 18px 48px -12px rgba(0, 0, 0, 0.85); color: var(--text); font: 400 12px/1.3 var(--font-body); }
.it[hidden] { display: none; }
.it:focus { outline: none; }
.it:focus-visible { border-color: var(--blue); }
.it.dragging { box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.95); }

.it-bar { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 10px; border-bottom: 1px solid var(--line); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.it.dragging .it-bar { cursor: grabbing; }
.it-title { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font: 700 12px/1 var(--font-head); }
.it-title .ico { width: 13px; height: 13px; }
.it-title-t { color: var(--text); }
.it-sets { display: inline-flex; gap: 2px; margin-left: 2px; }
.it-set { height: 22px; padding: 0 7px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: 700 11.5px/22px var(--font-num); cursor: pointer; }
.it-set:hover, .it-set:focus-visible { color: var(--text); background: var(--chip); }
.it-set.on { background: var(--blue-soft); color: var(--blue-hi); }
.it-ib { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.it-ib:hover, .it-ib:focus-visible { background: var(--chip); color: var(--text); }
.it-ib .ico { width: 13px; height: 13px; }
.it-edit[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue-hi); }
.it-cash { margin-left: auto; font: 600 12px/1 var(--font-num); color: var(--text); white-space: nowrap; }

.it-body { display: grid; gap: 8px; padding: 8px 10px 7px; }
.it-h { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; font: 400 11px/1 var(--font-body); color: var(--muted); }
.it-h b { font: 700 12px/1 var(--font-head); }
.it-buy .it-h b { color: var(--up); }
.it-sell .it-h b { color: var(--down); }
.it-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.it-pill, .it-in { width: 100%; min-width: 0; height: 34px; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; font: 600 12.5px/1 var(--font-num); text-align: center; }
.it-pill { cursor: pointer; }
.it-pb { border-color: rgba(47, 208, 138, 0.55); color: var(--up); }
.it-ps { border-color: rgba(255, 92, 108, 0.55); color: var(--down); }
.it-pill.it-pb:hover:not(:disabled):not(.dim), .it-pill.it-pb:focus-visible { border-color: var(--up); background: rgba(47, 208, 138, 0.14); }
.it-pill.it-ps:hover:not(:disabled), .it-pill.it-ps:focus-visible { border-color: var(--down); background: rgba(255, 92, 108, 0.14); }
.it-pill:disabled { opacity: 0.42; cursor: default; }
.it-pill.dim { opacity: 0.38; cursor: help; }
.it-pill.busy { opacity: 1; animation: it-busy 0.9s ease-in-out infinite; }
@keyframes it-busy { 0%, 100% { background: transparent; } 50% { background: rgba(126, 162, 255, 0.28); } }
@media (prefers-reduced-motion: reduce) { .it-pill.busy { animation: none; background: rgba(126, 162, 255, 0.28); } }
.it-in { border-style: dashed; border-radius: 10px; background: var(--bg-3); cursor: text; }
.it-in:focus { outline: none; border-style: solid; border-color: var(--blue); }
.it-blk.off .it-h { opacity: 0.6; }
.it-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.it-note[hidden], .it-editrow[hidden], .it-more[hidden] { display: none; }
.it-editrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.it-edithint { flex: 1 1 100%; font-size: 11px; color: var(--muted); }
.it-reset, .it-done, .it-card { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--chip); color: var(--text); font: 600 11.5px/1 var(--font-head); cursor: pointer; }
.it-reset:hover, .it-reset:focus-visible, .it-card:hover:not(:disabled), .it-card:focus-visible { border-color: var(--blue); }
.it-done { margin-left: auto; border-color: var(--blue); color: var(--blue-hi); }
.it-fine { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; font-size: 11.5px; color: var(--muted); }
.it-q[aria-expanded="true"] { border-color: var(--blue); color: var(--blue-hi); }
.it-more { margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3); font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.it-msg { margin: 0; font-size: 11.5px; text-align: center; color: var(--muted); }
.it-msg:empty { display: none; }
.it-msg-error { color: var(--down); }
.it-msg-warn { color: var(--warn); }

/* footer: Bought / Sold / Holding / PnL, then the unit and the PnL card button */
.it-foot { padding: 7px 10px 8px; border-top: 1px solid var(--line); }
.it-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.it-fc { display: grid; gap: 3px; align-content: start; min-width: 0; padding: 0 5px; border-left: 1px solid var(--line); text-align: center; }
.it-fc:first-child { border-left: 0; }
.it-fk { font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim); }
.it-fv { font: 600 12px/1.25 var(--font-num); color: var(--text); overflow-wrap: anywhere; }
.it-fv.up { color: var(--up); }
.it-fv.down { color: var(--down); }
.it-footrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; }
.it-unit { font-size: 11px; color: var(--dim); }
.it-card .ico { width: 12px; height: 12px; }
.it-card:disabled { opacity: 0.5; cursor: default; }

/* phone: a sheet docked to the bottom, no dragging (js/instantcore.js DOCK_MAX_W is the same 640) */
@media (max-width: 640px) {
  .it { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; max-height: 86vh; overflow-y: auto; border-width: 1px 0 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -18px 48px -12px rgba(0, 0, 0, 0.85); }
  .it-bar { padding: 9px 10px 9px 12px; cursor: default; touch-action: auto; }
  .it-set { height: 30px; padding: 0 10px; line-height: 30px; }
  .it-ib { width: 34px; height: 34px; }
  .it-pill, .it-in { height: 42px; font-size: 14px; }
  .it-reset, .it-done, .it-card { height: 34px; }
}

/* Short laptop screens (1366 x 768): a tighter panel, so it fits under the ticket instead of covering its button. */
@media (min-width: 641px) and (max-height: 820px) {
  .it-bar { padding: 4px 8px 4px 10px; }
  .it-body { gap: 5px; padding: 6px 10px 5px; }
  .it-h { margin-bottom: 4px; }
  .it-grid { gap: 5px; }
  .it-pill, .it-in { height: 26px; }
  .it-note { margin-top: 3px; }
  .it-foot { padding: 5px 10px; }
  .it-footrow { margin-top: 4px; }
  .it-reset, .it-done, .it-card { height: 22px; }
}

/* While the panel is open the pop-up messages move out of its way: they would cover the sell pills after every trade. */
@media (min-width: 641px) { body.it-on .toasts { left: 24px; right: auto; align-items: flex-start; } }
@media (max-width: 640px) { body.it-on .toasts { bottom: auto; top: calc(58px + env(safe-area-inset-top, 0px)); } }
