/* Market page panel «الخريطة الحرارية» (site/panels/mk-heatmap.js). Everything is scoped under .mkp-heatmap; colours come from the design tokens only.
   The colour scale is the home heat map's: the tone colour (--oa-gain / --oa-loss) mixed into the card colour in five steps, so it follows the light and dark themes. */
.mkp-heatmap { --hm-hair: 2px; --hm-sw-w: 18px; --hm-sw-h: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--oa-space-3); min-width: 0; }
.mkp-heatmap > * { min-width: 0; }
.mkp-heatmap-warn { margin: 0; padding: var(--oa-space-3) var(--oa-space-4); border: 1px solid var(--oa-loss); border-radius: var(--oa-radius-card); background: var(--oa-card); color: var(--oa-ink); font-size: var(--oa-text-small); line-height: 1.8; }
.mkp-heatmap-pills { display: flex; flex-wrap: wrap; gap: var(--oa-space-2); }
.mkp-heatmap-pill { flex: none; min-height: var(--oa-size-control); padding: 0 var(--oa-space-4); border: 1px solid var(--oa-line); border-radius: var(--oa-radius-pill); background: var(--oa-card); color: var(--oa-ink); font: inherit; font-size: var(--oa-text-small); cursor: pointer; }
.mkp-heatmap-pill.is-on { border-color: var(--oa-brand); background: var(--oa-brand); color: var(--oa-on-brand); font-weight: 700; }
.mkp-heatmap-pill:focus-visible, .mkp-heatmap-tile:focus-visible, .mkp-heatmap-open:focus-visible { outline: var(--hm-hair) solid var(--oa-brand); outline-offset: var(--hm-hair); }
.mkp-heatmap-meta:empty { display: none; }

/* the map: a box with a fixed shape; the tiles are placed in percent, so it needs no script on resize except the phone / wide switch */
.mkp-heatmap-box { position: relative; min-width: 0; }
.mkp-heatmap-map { position: relative; width: 100%; aspect-ratio: var(--hm-ratio, 2.1); border: 1px solid var(--oa-line); border-radius: var(--oa-radius-card); background: var(--oa-card); overflow: hidden; }
.mkp-heatmap-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: var(--oa-space-4); text-align: center; color: var(--oa-muted); font-size: var(--oa-text-small); line-height: 1.8; }
.mkp-heatmap-tile { --hm: var(--oa-muted); --hm-mix: 10%; isolation: isolate; position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; box-sizing: border-box; padding: var(--hm-hair); overflow: hidden; container-type: size;
  border: 1px solid var(--oa-card); border-radius: var(--hm-hair); background-clip: padding-box; background: var(--oa-card); color: var(--oa-ink) !important; text-decoration: none; text-align: center; cursor: pointer; }
div.mkp-heatmap-tile { cursor: default; }
.mkp-heatmap-tile::before { content: ""; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, var(--hm) var(--hm-mix), var(--oa-card)); }   /* the tint is a layer under the text: the tile itself keeps the card colour */
.mkp-heatmap-tile[data-tone="up"] { --hm: var(--oa-gain); --hm-mix: 14%; }
.mkp-heatmap-tile[data-tone="down"] { --hm: var(--oa-loss); --hm-mix: 14%; }
.mkp-heatmap-tile[data-lvl="2"] { --hm-mix: 23%; } .mkp-heatmap-tile[data-lvl="3"] { --hm-mix: 32%; }
.mkp-heatmap-tile[data-lvl="4"] { --hm-mix: 41%; } .mkp-heatmap-tile[data-lvl="5"] { --hm-mix: 50%; }
.mkp-heatmap-tile:hover { border-color: var(--oa-ink); }
.mkp-heatmap-l, .mkp-heatmap-p, .mkp-heatmap-s { display: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.mkp-heatmap-l { font-size: var(--oa-text-caption); font-weight: 700; }
.mkp-heatmap-p { font-family: var(--oa-font-numerals); font-size: var(--oa-text-caption); font-variant-numeric: tabular-nums; }
.mkp-heatmap-s { font-size: var(--oa-text-caption); color: var(--oa-ink); opacity: .85; }
/* what a tile shows depends on its own size */
@container (min-width: 34px) and (min-height: 22px) { .mkp-heatmap-l { display: block; } }
@container (min-width: 44px) and (min-height: 38px) { .mkp-heatmap-p { display: block; } }
@container (min-width: 84px) and (min-height: 62px) { .mkp-heatmap-s { display: block; } .mkp-heatmap-l { font-size: var(--oa-text-small); } .mkp-heatmap-p { font-size: var(--oa-text-small); } }
@container (min-width: 150px) and (min-height: 110px) { .mkp-heatmap-l { font-size: var(--oa-text-h3); } .mkp-heatmap-p { font-size: var(--oa-text-body); } .mkp-heatmap-s { font-size: var(--oa-text-small); } }

.mkp-heatmap-legend { display: flex; align-items: center; justify-content: center; gap: var(--oa-space-3); color: var(--oa-muted); font-size: var(--oa-text-caption); }
.mkp-heatmap-scale { display: inline-flex; gap: var(--hm-hair); }
.mkp-heatmap-scale i { display: block; width: var(--hm-sw-w); height: var(--hm-sw-h); border-radius: var(--hm-hair); background: var(--oa-line); }
.mkp-heatmap-scale i[data-tone="down"] { background: color-mix(in srgb, var(--oa-loss) 14%, var(--oa-card)); }
.mkp-heatmap-scale i[data-tone="up"] { background: color-mix(in srgb, var(--oa-gain) 14%, var(--oa-card)); }
.mkp-heatmap-scale i[data-lvl="2"][data-tone="down"] { background: color-mix(in srgb, var(--oa-loss) 23%, var(--oa-card)); } .mkp-heatmap-scale i[data-lvl="2"][data-tone="up"] { background: color-mix(in srgb, var(--oa-gain) 23%, var(--oa-card)); }
.mkp-heatmap-scale i[data-lvl="3"][data-tone="down"] { background: color-mix(in srgb, var(--oa-loss) 32%, var(--oa-card)); } .mkp-heatmap-scale i[data-lvl="3"][data-tone="up"] { background: color-mix(in srgb, var(--oa-gain) 32%, var(--oa-card)); }
.mkp-heatmap-scale i[data-lvl="4"][data-tone="down"] { background: color-mix(in srgb, var(--oa-loss) 41%, var(--oa-card)); } .mkp-heatmap-scale i[data-lvl="4"][data-tone="up"] { background: color-mix(in srgb, var(--oa-gain) 41%, var(--oa-card)); }
.mkp-heatmap-scale i[data-lvl="5"][data-tone="down"] { background: color-mix(in srgb, var(--oa-loss) 50%, var(--oa-card)); } .mkp-heatmap-scale i[data-lvl="5"][data-tone="up"] { background: color-mix(in srgb, var(--oa-gain) 50%, var(--oa-card)); }
.mkp-heatmap-scale i[data-lvl="0"] { background: color-mix(in srgb, var(--oa-muted) 10%, var(--oa-card)); border: 1px solid var(--oa-line); }

/* tooltip */
.mkp-heatmap-tip { position: absolute; z-index: 5; width: min(17rem, calc(100% - var(--oa-space-2))); padding: var(--oa-space-3); border: 1px solid var(--oa-line); border-radius: var(--oa-radius-card); background: var(--oa-card); color: var(--oa-ink); box-shadow: 0 0 0 var(--hm-hair) var(--oa-line); pointer-events: none; font-size: var(--oa-text-small); }
.mkp-heatmap-tip[hidden] { display: none; }
.mkp-heatmap-tip.is-pinned { pointer-events: auto; }
.mkp-heatmap-tip-h { display: flex; align-items: center; gap: var(--oa-space-2); }
.mkp-heatmap-tip-n { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.mkp-heatmap-tip-n b, .mkp-heatmap-tip-n small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkp-heatmap-tip-n small { color: var(--oa-muted); font-size: var(--oa-text-caption); }
.mkp-heatmap-tip dl { margin: var(--oa-space-2) 0 0; }
.mkp-heatmap-tip dl > div { display: flex; justify-content: space-between; gap: var(--oa-space-3); padding-block: var(--hm-hair); }
.mkp-heatmap-tip dt { color: var(--oa-muted); } .mkp-heatmap-tip dd { margin: 0; font-family: var(--oa-font-numerals); font-variant-numeric: tabular-nums; }
.mkp-heatmap-open { display: flex; align-items: center; justify-content: center; margin-top: var(--oa-space-3); text-decoration: none; }

@media (prefers-reduced-motion: no-preference) { .mkp-heatmap-tile { transition: background-color .25s ease; } }
@media (max-width: 640px) {
  .mkp-heatmap-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--oa-space-4) * -1); padding-inline: var(--oa-space-4); }
  .mkp-heatmap-pills::-webkit-scrollbar { display: none; }
  .mkp-heatmap { --hm-sw-w: 14px; }
}

/* 29 Nov 2026: a large tile names its stock or sector on two lines instead of cutting it after one */
@container (min-width: 84px) and (min-height: 62px) { .mkp-heatmap-l { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; overflow-wrap: anywhere; } }

/* paid parts (heatmap_custom): the week / month buttons and «قائمتي» carry the VIP badge of oa-lock.css while locked */
.mkp-heatmap-periods { margin-block: var(--oa-space-1); }
.mkp-heatmap-lock { display: inline-flex; vertical-align: middle; margin-inline-start: var(--oa-space-1); }

/* sector / group blocks over the tiles (4 Dec 2026): a frame and a small name tag, never in the way of the pointer */
.mkp-heatmap-grp { position: absolute; z-index: 2; box-sizing: border-box; border: var(--hm-hair) solid var(--oa-card); pointer-events: none; container-type: size; }
.mkp-heatmap-grp > span { display: none; position: absolute; inset-block-start: 0; inset-inline-start: 0; max-width: 100%; padding: 0 var(--oa-space-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-end-end-radius: var(--hm-hair); background: var(--oa-card); color: var(--oa-ink); font-size: var(--oa-text-caption); font-weight: 700; line-height: 1.5; opacity: .92; }
@container (min-width: 70px) and (min-height: 40px) { .mkp-heatmap-grp > span { display: block; } }
