/* ═══════════════════════════════════════════════════════════════════════════
   Terminal → Stock screen (`.tms`), built against the Fey "Web Stock detail"
   reference: header, hero chart + side panel, KPI strip. See
   src/shell/pages/terminal/stock.ts.

   It used to run much longer — Analyst estimates, Earnings, Financials, Insider
   trading and Peer analysis all had section styles here. Those sections were
   equity research and are gone; roughly 590 lines of rules went with them.

   Split out of terminal.css only for size — it uses the same `--tm-*` tokens,
   which are declared on `.app--mode-terminal` there.
   ══════════════════════════════════════════════════════════════════════════ */

.tms {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 44px;
}

/* The directional wash. The reference tints the whole page faintly by the
   instrument's direction — red on a down day, green on an up day. Fixed, behind
   everything, very low alpha so it reads as light rather than colour. */
.tms::before {
	content: '';
	position: fixed;
	inset: 0 0 auto;
	height: 62%;
	z-index: 0;
	pointer-events: none;
	background: radial-gradient(70% 100% at 50% -18%, rgba(255, 107, 94, 0.1) 0%, rgba(255, 107, 94, 0.03) 40%, transparent 74%);
}

.tms--up::before {
	background: radial-gradient(70% 100% at 50% -18%, rgba(62, 207, 142, 0.1) 0%, rgba(62, 207, 142, 0.03) 40%, transparent 74%);
}

.tms > * {
	position: relative;
	z-index: 1;
}

.tms-ico {
	display: grid;
	place-items: center;
	line-height: 0;
}

.tms-fig {
	display: block;
	width: 100%;
}

.tms-fig > svg {
	display: block;
	width: 100%;
}

/* ── header ───────────────────────────────────────────────────────────────── */

.tms-head {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
	/* Above the hero: `.tms > *` puts every block on z-index 1, which would let
	   the chart paint over the contract picker hanging out of this header. */
	z-index: 20;
}

/* Holds the brand mark (MARK_SIZE.head), not the old `‹` chevron — so it is
   sized to the image and paints nothing of its own. */
.tms-back {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: none;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	transition: opacity 0.16s, transform 0.22s var(--tm-ease);
}

/* The old hover washed a grey panel BEHIND the glyph. A lime tile hides that
   entirely, so the affordance moves onto the mark itself. */
.tms-back:hover {
	opacity: 0.86;
}

.tms-back:active {
	transform: scale(0.94);
}

.tms-logo {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	flex: none;
	border-radius: 11px;
	color: #fff;
	font-size: 17px;
	font-weight: 700;
}

.tms-id {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.tms-id__t {
	font-size: 16.5px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--tm-ink);
}

.tms-id__n {
	font-size: 14.5px;
	color: var(--tm-ink-3);
}

/* ── contract picker ──────────────────────────────────────────────────────────
   The identity block is the control that changes it. It has to look pressable
   without becoming a button-shaped box next to the mark, so it carries no fill
   at rest — the caret is the whole affordance until you reach for it. */

.tms-pickwrap {
	position: relative;
}

.tms-pick {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-left: -8px;
	padding: 6px 10px 6px 8px;
	border: 1px solid transparent;
	border-radius: 14px;
	background: none;
	font: inherit;
	text-align: left;
	color: inherit;
	cursor: pointer;
	transition: background 0.2s var(--tm-ease), border-color 0.2s var(--tm-ease);
}

.tms-pick:hover,
.tms-pickwrap.is-open .tms-pick {
	background: rgba(255, 255, 255, 0.04);
	border-color: var(--tm-line);
}

.tms-pick__caret {
	color: var(--tm-ink-4);
	transition: transform 0.24s var(--tm-ease), color 0.16s;
}

.tms-pick:hover .tms-pick__caret {
	color: var(--tm-ink-2);
}

.tms-pickwrap.is-open .tms-pick__caret {
	transform: rotate(180deg);
	color: var(--tm-ink-2);
}

.tms-switch {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	z-index: 40;
	display: none;
	width: 340px;
	max-height: 62vh;
	overflow-y: auto;
	padding: 6px;
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: rgba(17, 18, 20, 0.92);
	backdrop-filter: blur(30px) saturate(1.4);
	-webkit-backdrop-filter: blur(30px) saturate(1.4);
	box-shadow: 0 30px 70px -26px rgba(0, 0, 0, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.045);
	scrollbar-width: none;
}

.tms-switch::-webkit-scrollbar {
	width: 0;
}

.tms-pickwrap.is-open .tms-switch {
	display: block;
}

.tms-switch__row {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: 0;
	border-radius: 11px;
	background: none;
	font: inherit;
	text-align: left;
	color: inherit;
	cursor: pointer;
}

.tms-switch__row:hover,
.tms-switch__row:focus-visible {
	background: rgba(255, 255, 255, 0.06);
	outline: none;
}

.tms-switch__tile {
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	flex: none;
	border-radius: 8px;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}

.tms-switch__t {
	flex: none;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--tm-ink);
}

.tms-switch__n {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 13px;
	color: var(--tm-ink-3);
}

.tms-switch__x {
	flex: none;
	padding: 3px 7px;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.055);
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 10.5px;
	letter-spacing: 0.02em;
	color: var(--tm-ink-4);
}

/* Present on every row so the codes never shift when the tick moves. */
.tms-switch__check {
	flex: none;
	color: var(--tm-lime);
	opacity: 0;
}

.tms-switch__row.is-on .tms-switch__check {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.tms-pick,
	.tms-pick__caret {
		transition: none;
	}
}

/* ── hero ─────────────────────────────────────────────────────────────────── */

.tms-hero {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 430px;
	gap: 34px;
	align-items: start;
}

.tms-hero__main {
	min-width: 0;
}

.tms-quote {
	display: flex;
	align-items: baseline;
	gap: 14px;
	flex-wrap: wrap;
}

.tms-quote__px {
	font-size: 40px;
	font-weight: 700;
	letter-spacing: -0.038em;
	color: var(--tm-ink);
	line-height: 1;
}

.tms-quote__cents {
	color: var(--tm-ink-4);
}

.tms-quote__chg {
	font-size: 15px;
	font-weight: 500;
}

.tms-chart {
	position: relative;
	margin-top: 18px;
}

.tms-chart > .tms-fig > svg {
	height: 340px;
}

/* The previous-close callout, sitting just left of the dashed marker. */
.tms-chart__prev {
	position: absolute;
	top: 6px;
	right: 13.5%;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 2px;
	text-align: right;
	pointer-events: none;
}

.tms-chart__prev-l {
	font-size: 11.5px;
	color: var(--tm-ink-4);
}

.tms-chart__prev-v {
	font-family: var(--tm-mono);
	font-size: 12px;
	color: var(--tm-ink-3);
}

.tms-ranges {
	display: flex;
	align-items: center;
	gap: 2px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.tms-range {
	min-width: 44px;
	padding: 8px 12px;
	border: 0;
	border-radius: 9px;
	background: none;
	color: var(--tm-ink-3);
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 500;
	cursor: pointer;
	transition: color 0.16s, background 0.22s var(--tm-ease);
}

.tms-range:hover {
	color: var(--tm-ink);
	background: rgba(255, 255, 255, 0.045);
}

.tms-range.is-on {
	background: rgba(255, 255, 255, 0.085);
	color: var(--tm-ink);
	font-weight: 600;
}

/* ── side panel ───────────────────────────────────────────────────────────── */

.tms-side {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* The stacked-card look: the panel sits over two offset "sheets" to its right. */
.tms-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 452px;
	padding: 22px 24px 20px;
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: #0c0d0e;
	box-shadow: 6px 0 0 -1px #0e0f10, 6px 0 0 0 rgba(255, 255, 255, 0.05), 12px 0 0 -2px #0c0d0e,
		12px 0 0 -1px rgba(255, 255, 255, 0.04);
}

.tms-panel__top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.tms-panel__title {
	font-size: 14.5px;
	font-weight: 500;
	color: var(--tm-ink-2);
}

.tms-panel__expand {
	display: grid;
	place-items: center;
	color: var(--tm-ink-4);
	line-height: 0;
	cursor: pointer;
}

.tms-panel__expand:hover {
	color: var(--tm-ink);
}

.tms-panel__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 26px 0;
}

.tms-panel__list {
	display: flex;
	flex-direction: column;
	gap: 15px;
}

.tms-panel__foot {
	font-size: 12.5px;
	color: var(--tm-ink-4);
}

.tms-ind,
.tms-fact {
	display: flex;
	align-items: flex-start;
	gap: 11px;
	font-size: 15px;
	line-height: 1.45;
	color: var(--tm-ink-2);
}

.tms-ind__mark {
	display: grid;
	place-items: center;
	flex: none;
	margin-top: 1px;
	line-height: 0;
}

.tms-fact .tms-ico {
	flex: none;
	margin-top: 2px;
	color: var(--tm-ink-4);
}

.tms-ind__text strong,
.tms-fact strong {
	color: var(--tm-ink);
	font-weight: 600;
}

.tms-ptabs {
	display: flex;
	align-items: center;
	gap: 4px;
}

.tms-ptab {
	padding: 8px 15px;
	border: 0;
	border-radius: 9px;
	background: none;
	color: var(--tm-ink-3);
	font-family: inherit;
	font-size: 14.5px;
	font-weight: 500;
	cursor: pointer;
	transition: color 0.16s, background 0.22s var(--tm-ease);
}

.tms-ptab:hover {
	color: var(--tm-ink);
	background: rgba(255, 255, 255, 0.045);
}

.tms-ptab.is-on {
	background: rgba(255, 255, 255, 0.085);
	color: var(--tm-ink);
	font-weight: 600;
}

/* ── KPI strip ────────────────────────────────────────────────────────────── */

.tms-kpis {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.018);
	padding: 18px 0;
}

.tms-kpi {
	padding: 4px 12px;
	text-align: center;
	box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.055);
}

.tms-kpi:last-child {
	box-shadow: none;
}

.tms-kpi__l {
	font-size: 12.5px;
	color: var(--tm-ink-4);
}

.tms-kpi__v {
	margin-top: 8px;
	font-size: 19px;
	font-weight: 700;
	letter-spacing: -0.028em;
	color: var(--tm-ink);
}

/* ── pre-market level sheet ───────────────────────────────────────────────────
   A ladder, not a table: rows are ordered by price and the live one sits where
   it actually trades, so the block reads top-down like the chart's y-axis. The
   only colour spent here is the lime on that live rung and the amber on a naked
   POC's age — everything else separates by weight and by the line specimen in
   the left column. See buildLevels() in stock.ts. */

.tms-lvl {
	border: 1px solid var(--tm-line);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.018);
	padding: 20px 0 4px;
}

.tms-lvl__top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding: 0 22px 16px;
}

.tms-lvl__title {
	margin: 0;
	font-size: 16.5px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--tm-ink);
}

.tms-lvl__meta {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--tm-ink-4);
}

.tms-lvl__row {
	display: grid;
	/* The age chip sits with the name it belongs to, not adrift across the row;
	   the flexible column is the gap before the numbers. */
	grid-template-columns: 26px 74px auto auto minmax(0, 1fr) 116px;
	align-items: center;
	gap: 14px;
	padding: 9px 22px;
	box-shadow: inset 0 -1px 0 var(--tm-line-2);
}

.tms-lvl__list > .tms-lvl__row:last-child {
	box-shadow: none;
}

.tms-lvl__mark {
	display: grid;
	place-items: center;
	line-height: 0;
	color: var(--tm-ink-5);
}

.tms-lvl__row--session .tms-lvl__mark,
.tms-lvl__row--profile .tms-lvl__mark {
	color: var(--tm-ink-3);
}

.tms-lvl__row--naked .tms-lvl__mark {
	color: var(--tm-warn);
}

.tms-lvl__code {
	font-family: var(--tm-mono);
	font-size: 11px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--tm-ink-2);
	white-space: nowrap;
}

.tms-lvl__name {
	font-size: 13.5px;
	color: var(--tm-ink-4);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Present on every row so the columns line up; only visible when it carries an
   age. See the note cell in buildLevels(). */
.tms-lvl__note:empty {
	padding: 0;
	border: none;
}

.tms-lvl__note {
	justify-self: start;
	padding: 2px 8px;
	border: 1px solid rgba(232, 195, 74, 0.3);
	border-radius: 999px;
	font-family: var(--tm-mono);
	font-size: 10.5px;
	letter-spacing: 0.03em;
	color: var(--tm-warn);
	white-space: nowrap;
}

.tms-lvl__away {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 12px;
	color: var(--tm-ink-4);
	text-align: right;
	white-space: nowrap;
}

.tms-lvl__px {
	font-family: var(--tm-mono);
	font-variant-numeric: tabular-nums;
	font-size: 15px;
	font-weight: 600;
	color: var(--tm-ink);
	text-align: right;
}

/* The live rung. A hairline the width of the sheet, because that is what price
   is doing to the levels above and below it. */
.tms-lvl__row--now {
	background: linear-gradient(90deg, rgba(198, 248, 60, 0.09), rgba(198, 248, 60, 0.012) 62%, transparent);
	box-shadow: inset 0 1px 0 rgba(198, 248, 60, 0.34), inset 0 -1px 0 rgba(198, 248, 60, 0.34);
}

.tms-lvl__row--now .tms-lvl__mark,
.tms-lvl__row--now .tms-lvl__code,
.tms-lvl__row--now .tms-lvl__px {
	color: var(--tm-lime);
}

.tms-lvl__row--now .tms-lvl__name {
	color: rgba(198, 248, 60, 0.62);
}

.tms-lvl__foot {
	margin: 0;
	padding: 14px 22px 16px;
	font-size: 12px;
	line-height: 1.55;
	color: var(--tm-ink-5);
	max-width: 74ch;
}

/* ── responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 1240px) {
	.tms-hero {
		grid-template-columns: minmax(0, 1fr);
	}

	.tms-panel {
		min-height: 0;
		box-shadow: none;
	}
}

@media (max-width: 720px) {
	/* The plain-language name is the first thing to go — the code and the price
	   are the sheet; the rest is a gloss. */
	.tms-lvl__row {
		grid-template-columns: 26px 68px minmax(0, 1fr) auto 96px;
		gap: 10px;
		padding: 9px 16px;
	}

	.tms-lvl__name {
		display: none;
	}

	.tms-lvl__note {
		font-size: 10px;
	}

	.tms-lvl__top,
	.tms-lvl__foot {
		padding-left: 16px;
		padding-right: 16px;
	}
}
