/* /vis/mm: the form of the Mesternes mester page (design handoff v2).
 * Colours come from /vis/vis.css; this file names none. Mobile first: one
 * column at every width, designed at 390 px, never wider than 720 px. */

.mm-k-ball { --k: var(--k-ball); }
.mm-k-vatn { --k: var(--k-vatn); }
.mm-k-nordisk { --k: var(--k-nordisk); }
.mm-k-alpint { --k: var(--k-alpint); }
.mm-k-uthald { --k: var(--k-uthald); }
.mm-k-friidrett { --k: var(--k-friidrett); }
.mm-k-kamp { --k: var(--k-kamp); }
.mm-k-styrke { --k: var(--k-styrke); }
.mm-k-dans { --k: var(--k-dans); }
.mm-k-motor { --k: var(--k-motor); }
.mm-k-eventyr { --k: var(--k-eventyr); }
.mm-k-presisjon { --k: var(--k-presisjon); }
.mm-k-anna { --k: var(--k-anna); }

/* ── page ──────────────────────────────────────────────────────────────── */
.mm-side { max-width: 720px; margin: 0 auto; padding: 16px 20px 64px; }
.mm-side h1 {
  font-family: var(--font-disp); font-weight: 600; letter-spacing: -0.02em;
  font-size: clamp(2rem, 8vw, 3rem); line-height: 1.05; margin: 0; text-wrap: balance;
}
.mm-side h2 {
  font-family: var(--font-disp); font-weight: 600; font-size: 1.5rem; line-height: 1.2;
  margin: 0; text-wrap: pretty;
}
.mm-side p { margin: 0; }

.mm-sti {
  font-size: 0.875rem; color: var(--muted); min-height: 44px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.mm-sti a { color: var(--muted); padding: 10px 0; }
.mm-sti a:hover { color: var(--lenke); }

.mm-hovud { margin: 20px 0 0; display: flex; flex-direction: column; gap: 12px; }
.mm-auge { font-size: 13px; color: var(--muted); }
.mm-ingress { color: var(--muted); font-size: 1.0625rem; text-wrap: pretty; }
.mm-tal {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin: 8px 0 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.mm-tal div { display: flex; flex-direction: column-reverse; }
.mm-tal dt { font-size: 13px; color: var(--muted); }
.mm-tal dd { margin: 0; font-family: var(--font-disp); font-weight: 600; font-size: 1.75rem; line-height: 1.1; }

/* ── the code badge: a category's colour with its two letters on it ──────── */
.mm-kode {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 18px; padding: 0 3px; border-radius: 4px;
  font: 600 10px/1 var(--font-ui); letter-spacing: 0.02em;
  color: var(--on); background: var(--k);
}

/* ── error ─────────────────────────────────────────────────────────────── */
.mm-feil {
  margin: 24px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.mm-feil[hidden] { display: none; }
.mm-feil-tittel { font-weight: 600; }
.mm-feil-tekst { color: var(--muted); font-size: 14px; }
.mm-knapp-sterk {
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font: 600 14px var(--font-ui); cursor: pointer;
}

/* ── the sticky bar: search, the chosen person, the category chips ──────── */
.mm-sticky {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  margin: 16px -20px 0; padding: 12px 20px; border-bottom: 1px solid var(--rutenett);
  display: flex; flex-direction: column; gap: 10px;
}
.mm-sok { position: relative; }
.mm-sok input {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); font: 16px var(--font-ui);
}
.mm-forslag, .mm-ingen {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}
.mm-forslag { list-style: none; margin: 0; padding: 4px; }
.mm-forslag[hidden], .mm-ingen[hidden] { display: none; }
.mm-forslag li {
  min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: 15px;
}
.mm-forslag li:hover, .mm-forslag li[aria-selected="true"] { background: var(--hover); }
.mm-ingen { padding: 12px; font-size: 14px; color: var(--muted); }
.mm-to-linjer { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mm-to-linjer b { font-weight: 500; }
.mm-to-linjer small { font-size: 12px; color: var(--muted); }

.mm-person {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.mm-person[hidden] { display: none; }
.mm-person .mm-to-linjer { flex: 1; line-height: 1.3; }
.mm-person .mm-to-linjer b { font-weight: 600; }
.mm-person .mm-to-linjer small { font-size: 13px; }

.mm-pille, .mm-maal button {
  flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  font: 500 14px var(--font-ui); background: var(--panel); color: var(--ink); border: 1px solid var(--line);
}
.mm-pille[aria-pressed="true"], .mm-maal button[aria-pressed="true"] {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.mm-pille .mm-kode { border-radius: 999px; }
.mm-pille:has(.mm-kode) { padding-left: 5px; }
.mm-chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -20px; padding: 0 20px;
}
.mm-chips::-webkit-scrollbar { display: none; }

/* ── sections ──────────────────────────────────────────────────────────── */
.mm-seksjon {
  margin: 48px 0 0; padding: 32px 0 0; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.mm-seksjon.mm-fyrste { margin-top: 40px; padding-top: 0; border-top: 0; }
.mm-nr { font-family: var(--font-disp); font-weight: 600; font-size: 1rem; color: var(--graa); }
.mm-intro { color: var(--muted); text-wrap: pretty; }
.mm-forklaring {
  font-size: 13px; color: var(--muted); padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--rutenett); border-radius: 8px;
}
.mm-merknad { font-size: 13px; color: var(--muted); }
.mm-maal { display: flex; gap: 6px; }
.mm-graf { position: relative; margin: 4px 0 0; }

/* Dimming: whatever is not chosen fades to 0.15 in every chart and table. */
[data-mark], .mm-dimbar { transition: opacity 0.2s; }
.mm-dim { opacity: 0.15; }

/* ── 01 bars ───────────────────────────────────────────────────────────── */
.mm-bar { display: flex; flex-direction: column; gap: 2px; }
.mm-barrad {
  display: grid; grid-template-columns: 26px minmax(72px, 112px) minmax(0, 1fr) 34px; gap: 8px;
  align-items: center; min-height: 36px; padding: 2px 4px; border-radius: 6px; cursor: default;
}
.mm-barrad:hover { background: var(--hover); }
.mm-barnamn { font-size: 14px; line-height: 1.2; }
.mm-spor { height: 14px; background: var(--rutenett); border-radius: 999px; overflow: hidden; display: flex; }
.mm-spor span { background: var(--k); border-radius: 999px; }
.mm-verdi { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }

/* ── 02 dots, 05 bubbles: SVG ──────────────────────────────────────────── */
.mm-graf svg { width: 100%; height: auto; display: block; overflow: visible; }
.mm-graf svg text { font: 12px var(--font-ui); fill: var(--ink); }
.mm-graf svg text.mm-akse { font-size: 11px; fill: var(--muted); }
.mm-graf svg .mm-linje { stroke: var(--rutenett); stroke-width: 1; }
.mm-graf svg .mm-strek { stroke: var(--rutenett); stroke-width: 1; stroke-dasharray: 2 3; }
.mm-prikk { fill: var(--k); stroke: var(--bg); stroke-width: 0.8; outline: none; }
.mm-prikk:focus-visible { stroke: var(--fokus); stroke-width: 2; }
.mm-flate { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.mm-ring { fill: none; stroke-width: 2; pointer-events: none; }
.mm-ring-aktiv { stroke: var(--lenke); }
.mm-ring-person { stroke: var(--ink); }
.mm-boble { fill: var(--k); fill-opacity: 0.85; stroke: var(--bg); stroke-width: 1.5; outline: none; }
.mm-boble:focus-visible { stroke: var(--fokus); stroke-width: 2.5; }
.mm-treff { fill: transparent; }
.mm-graf svg text.mm-bobletekst { font-size: 11px; pointer-events: none; }

/* ── 03 winner tiles ───────────────────────────────────────────────────── */
.mm-flisar { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; }
.mm-flis {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  min-height: 72px; display: flex; flex-direction: column; cursor: default;
}
.mm-flis:hover { border-color: var(--graa); }
.mm-flis-band {
  height: 18px; padding: 0 6px; display: flex; align-items: center;
  font: 600 10px var(--font-ui); letter-spacing: 0.04em; color: var(--on); background: var(--k);
}
.mm-flis-nr { padding: 6px 8px 0; font-size: 11px; color: var(--muted); }
.mm-flis-namn {
  padding: 0 8px 8px; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mm-flis.mm-pagar { border-style: dashed; }
.mm-flis.mm-pagar .mm-flis-band { background: var(--rutenett); color: var(--muted); }

/* ── 04 season stacks ──────────────────────────────────────────────────── */
.mm-stablar { display: flex; flex-direction: column; gap: 4px; }
.mm-stabel { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: center; min-height: 26px; }
.mm-stabel-nr { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.mm-stabel-bar { display: flex; gap: 2px; height: 22px; }
.mm-seg {
  min-width: 0; overflow: hidden; display: flex; align-items: center; justify-content: center;
  font: 600 10px var(--font-ui); color: var(--on); background: var(--k); border-radius: 3px; cursor: default;
}
.mm-seg.mm-valt { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ── the one tooltip ───────────────────────────────────────────────────── */
.mm-tip {
  position: absolute; z-index: 30; pointer-events: none; width: max-content; max-width: 240px;
  background: var(--tip-bg); color: var(--tip-fg); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, calc(-100% - 10px));
}
.mm-tip.mm-under { transform: translate(-50%, 10px); }
.mm-tip[hidden] { display: none; }
.mm-tip b { display: block; font-weight: 600; margin: 0 0 2px; }
.mm-tip span { display: block; color: var(--tip-sub); }

[data-mark]:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; }
/* An SVG mark shows focus with its own stroke; a box around a circle reads as a bug. */
svg [data-mark]:focus-visible { outline: none; }

/* ── tables ────────────────────────────────────────────────────────────── */
details.mm-tekst { margin: 4px 0 0; }
details.mm-tekst > summary {
  cursor: pointer; color: var(--lenke); font-size: 0.9375rem; min-height: 44px;
  display: flex; align-items: center;
}
details.mm-tekst > summary::before { content: '▸'; margin-right: 6px; }
details.mm-tekst[open] > summary::before { content: '▾'; }
details.mm-tekst > summary::-webkit-details-marker { display: none; }
details.mm-tekst > summary { list-style: none; }

.mm-rull { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.mm-tabell { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.mm-tabell th, .mm-tabell td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--rutenett); vertical-align: middle; }
.mm-tabell th:first-child, .mm-tabell td:first-child { padding-left: 0; }
.mm-tabell th:last-child, .mm-tabell td:last-child { padding-right: 0; }
.mm-tabell thead th {
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap;
  border-bottom-color: var(--ink);
}
.mm-tabell tbody th { font-weight: 400; }
.mm-tabell tbody th .mm-kode, .mm-tabell td .mm-kode { margin-right: 8px; vertical-align: 1px; }
.mm-tabell .mm-tal-k { text-align: right; }
.mm-tabell td.mm-null { color: var(--muted); }
.mm-tabell abbr { text-decoration: none; }
.mm-smal th, .mm-smal td { padding: 8px 5px; }
.mm-fotnote { margin-left: 2px; text-decoration: none; font-weight: 600; }

.mm-metode { margin: 40px 0 0; font-size: 0.875rem; color: var(--muted); text-wrap: pretty; }
.mm-metode p { margin: 0 0 8px; }
.mm-metode ol { margin: 8px 0 0; padding-left: 1.2em; }

@media (prefers-reduced-motion: reduce) {
  [data-mark], .mm-dimbar { transition: none; }
}
