/* S-06 Marketing: budget-mix planner. Four sliders drive a donut, a conditional
   funnel and a media plan. Everything is drawn in the sheet vocabulary: solid ink,
   ink-2, hatch and outline stand for the four channels everywhere. */

.mk {
  container-type: inline-size;
  display: grid;
  gap: 20px;
  padding: 22px;
  background:
    linear-gradient(var(--grid-minor) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--sheet);
}
/* corner brackets */
.mk::before, .mk::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border: 0 solid var(--ink);
}
.mk::before { left: 5px; top: 5px; border-width: 1px 0 0 1px; }
.mk::after { right: 5px; bottom: 5px; border-width: 0 1px 1px 0; }
@media (max-width: 600px) {
  .mk { padding: 18px 14px 16px; gap: 18px; }
}

/* ------------------------------------------------------------ top strip */
.mk__top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.mk__tag {
  flex: none;
  padding: 6px 10px 5px;
  background: var(--ink); color: var(--paper);
  font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}
.mk__dim {
  flex: 1; min-width: 14px; height: 8px;
  color: var(--ink-3);
  background:
    linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat,
    linear-gradient(currentColor, currentColor) left center / 1px 100% no-repeat,
    linear-gradient(currentColor, currentColor) right center / 1px 100% no-repeat;
}
.mk__sum { flex: none; font: 500 11px/1 var(--mono); letter-spacing: .06em; color: var(--ink-3); }
@container (max-width: 330px) {
  .mk__dim, .mk__sum { display: none; }
}

/* ----------------------------------------------------- donut + sliders */
.mk__main { display: grid; gap: 14px 26px; align-items: stretch; }
@container (min-width: 580px) {
  .mk__main { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; }
}
.mk__donut { position: relative; height: 236px; min-width: 0; }
@container (min-width: 580px) {
  .mk__donut { height: 280px; }
}
@media (max-width: 600px) {
  .mk__donut { height: 214px; }
}
.mk-dn, .mk-fn { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }

/* channel fills, shared by donut segments, funnel slices and swatches */
.mk-dn__seg, .mk-sl { stroke-width: 1.25; stroke-linejoin: round; }
.mk-dn__seg.mk-f0, .mk-sl.mk-f0 { fill: var(--ink); stroke: var(--ink); }
.mk-dn__seg.mk-f1, .mk-sl.mk-f1 { fill: var(--ink-2); stroke: var(--ink-2); }
.mk-dn__seg.mk-f2, .mk-sl.mk-f2 { fill: url(#mk-hatch); stroke: var(--ink); }
.mk-dn__seg.mk-f3, .mk-sl.mk-f3 { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.5; }
.mk-hatch__bg { fill: var(--sheet); }
.mk-hatch__ln { stroke: var(--ink); stroke-width: 1.7; }

.mk-sw {
  display: inline-block; flex: none; width: 18px; height: 11px;
  border: 1px solid var(--ink);
}
.mk-sw.mk-f0 { background: var(--ink); }
.mk-sw.mk-f1 { background: var(--ink-2); border-color: var(--ink-2); }
.mk-sw.mk-f2 { background: repeating-linear-gradient(-45deg, var(--ink) 0 1.2px, var(--sheet) 1.2px 3.6px); }
.mk-sw.mk-f3 { background: var(--sheet); border-width: 1.5px; }

/* the channel being dragged: red frame around its segment / slices */
.mk-dn__hl, .mk-fn__hl {
  fill: none; stroke: var(--red); stroke-width: 2;
  opacity: 0; transition: opacity .18s;
}
.mk-dn__hl.is-on, .mk-fn__hl.is-on { opacity: 1; }

.mk-dn__dial { fill: none; stroke: var(--ink-3); stroke-width: 1; opacity: .7; }
.mk-dn__lead polyline { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.mk-dn__lead circle { fill: var(--ink); }
.mk-dn__lead { transition: opacity .2s; }
.mk-dn__n { font: 500 10px var(--mono); letter-spacing: .04em; text-transform: uppercase; fill: var(--ink-3); }
.mk-dn__v { font: 600 12.5px var(--mono); letter-spacing: .02em; fill: var(--ink); }
.mk-dn__lead.is-hot .mk-dn__v, .mk-dn__lead.is-hot .mk-dn__n { fill: var(--red); }
.mk-dn__cn { font: 500 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; fill: var(--ink-3); text-anchor: middle; }
.mk-dn__cv { font: 600 24px var(--display); letter-spacing: -.02em; fill: var(--ink); text-anchor: middle; }
.mk-dn__cu { font-size: .6em; letter-spacing: 0; }

/* sliders */
.mk__ctl { display: grid; gap: 2px; min-width: 0; align-content: center; }
.mk-ch { display: grid; min-width: 0; }
.mk-ch__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mk-ch__lab { display: inline-flex; align-items: center; gap: 10px; font: 600 15px/1.2 var(--font); cursor: pointer; }
.mk-ch__val { min-width: 4ch; text-align: right; font: 600 14px/1 var(--mono); letter-spacing: .02em; }
.mk-ch.is-hot .mk-ch__val { color: var(--red); }

.mk-rw { position: relative; }
.mk-rw::before { /* ruler ticks every 10 % */
  content: ""; position: absolute; left: 13px; right: 13px; top: calc(50% + 10px); height: 5px;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) right / 1px 100% no-repeat,
    repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 10%);
  pointer-events: none;
}
.mk-rng {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 40px; margin: 0; padding: 0;
  background: transparent; cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.mk-rng:focus { outline: none; }
.mk-rng::-webkit-slider-runnable-track {
  height: 3px; border-radius: 0;
  background: linear-gradient(90deg, var(--ink) var(--v), var(--line-strong) var(--v));
}
.mk-rng::-moz-range-track { height: 3px; background: var(--line-strong); }
.mk-rng::-moz-range-progress { height: 3px; background: var(--ink); }
.mk-rng::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -11.5px; border-radius: 50%;
  border: 0; background: var(--ink);
  box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--ink);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.mk-rng::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: var(--ink);
  box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--ink);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.mk-rng:hover::-webkit-slider-thumb, .mk-rng:active::-webkit-slider-thumb { transform: scale(1.1); }
.mk-rng:hover::-moz-range-thumb, .mk-rng:active::-moz-range-thumb { transform: scale(1.1); }
.mk-rng:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 5px var(--red); }
.mk-rng:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 5px var(--red); }
.mk-ch.is-hot .mk-rng::-webkit-slider-thumb { background: var(--red); box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--red); }
.mk-ch.is-hot .mk-rng::-moz-range-thumb { background: var(--red); box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--red); }

.mk-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 44px; margin-top: 8px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: 2px;
  background: transparent; color: var(--ink);
  font: 500 11.5px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, color .2s;
}
.mk-btn:hover { background: var(--ink); color: var(--paper); }
.mk-btn__ic { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; flex: none; }
.mk-btn__ic i { display: block; width: 3px; height: 100%; background: currentColor; transition: height .3s var(--ease); }
.mk-btn:hover .mk-btn__ic i:nth-child(odd) { height: 70%; }

/* ---------------------------------------------------------- zone captions */
.mk__cap {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  font: 500 10.5px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.mk__cap::before { content: ""; width: 7px; height: 7px; flex: none; background: var(--ink); }
.mk__cap::after { content: ""; flex: 1; min-width: 12px; height: 1px; background: var(--line-strong); }

/* ------------------------------------------------------------------ funnel */
.mk__funnel { position: relative; height: 146px; }
.mk-fn__axis { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 9 3 1.5 3; opacity: .55; }
.mk-fn__con { fill: rgba(31, 53, 99, .06); stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.mk-fn__ext { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 1 3; transition: opacity .2s; }
.mk-fn__lab { font: 500 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; fill: var(--ink); }
.mk-sl { stroke-width: 1; }
.mk-sl.mk-f3 { stroke-width: 1.25; }

/* -------------------------------------------------------------- media plan */
.mk-t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.mk-t th, .mk-t td { padding: 9px 10px 9px 8px; border-bottom: 1px solid var(--line); text-align: left; font-weight: 500; line-height: 1.2; }
.mk-t thead th {
  padding-top: 0; padding-bottom: 8px; border-bottom-color: var(--line-strong);
  font: 500 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.mk-t tbody th { font-weight: 600; }
.mk-t__n { display: inline-flex; align-items: center; gap: 10px; }
.mk-t th:first-child { width: 38%; }
.mk-t th:nth-child(2) { width: 22%; }
.mk-t .mk-t__v { font: 600 13.5px/1.2 var(--mono); letter-spacing: .02em; }
.mk-t tr:last-child th, .mk-t tr:last-child td { border-bottom-color: var(--line-strong); }
.mk-t tbody tr { transition: background .2s; }
.mk-t tbody tr.is-hot { background: var(--red-soft); }
.mk-t tbody tr.is-hot th { box-shadow: inset 2px 0 0 var(--red); }
@media (max-width: 600px) {
  .mk-t { font-size: 14px; }
  .mk-t th, .mk-t td { padding-right: 6px; }
  .mk-ch__lab { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .mk-rng::-webkit-slider-thumb, .mk-btn, .mk-btn__ic i, .mk-dn__hl, .mk-fn__hl { transition: none; }
}
