/* /test: kompetenceafklaring. Owned by slice 2. Tokens and components from app.css (contract: DESIGN.md).
   1 overview  2 form frame  3 questions (+ accounting schedules)  4 matrix  5 send  6 motion */

/* ================= 1 overview ================= */
.ov { padding-bottom: var(--s-6); }
.ov .h1 { margin-top: var(--s-4); }
.ov .lead { max-width: 48ch; }

/* sent state: green bar + "Sendt" tag (word), then the next part */
.sent { margin-top: var(--s-5); max-width: 72rem; padding-top: var(--s-3); border-top: var(--bar) solid var(--result); display: grid; justify-items: start; gap: var(--s-3); }
.sent .h2 { max-width: 28ch; }

/* the three parts: whole row is the link; tag and button keep their own width */
.parts { container: parts / inline-size; margin-top: var(--s-4); max-width: 72rem; border-top: var(--rule) solid var(--text); }
.partrow {
  display: grid; grid-template-columns: 2rem minmax(0, 1fr); grid-template-areas: "nr main" "nr end";
  column-gap: var(--s-2); row-gap: var(--s-3); padding-block: var(--s-4);
  border-bottom: var(--rule) solid var(--line); text-decoration: none;
}
.partrow .nr { grid-area: nr; font-family: var(--font-display); font-size: var(--t-h2); line-height: 1; color: var(--text-muted); padding-top: 0.15em; }
.partrow .pm { grid-area: main; display: grid; justify-items: start; gap: var(--s-1); min-width: 0; }
.partrow .pk { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-small); font-weight: 600; }
.partrow .pt { font-family: var(--font-display); font-weight: 500; font-size: var(--t-h2); line-height: 1.08; letter-spacing: -0.01em; transition: transform var(--dur-3) var(--ease-out); }
.partrow .pd { font-size: var(--t-small); color: var(--text-muted); }
.partrow .meter { width: min(100%, 14rem); margin-top: var(--s-1); }
.partrow .pe { grid-area: end; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); }
.partrow .go { min-width: 7.5rem; }
.partrow:active .go { transform: translateY(1px) scale(0.98); }

@container parts (min-width: 40rem) {
  .partrow { grid-template-columns: 3rem minmax(0, 1fr) auto; grid-template-areas: "nr main end"; column-gap: var(--s-4); align-items: center; }
  .partrow .nr { align-self: start; padding-top: 1.1em; }
  .partrow .pe { justify-content: flex-end; }
  .partrow { padding-block: var(--s-3); }
}
@container parts (min-width: 60rem) {
  .partrow .nr { font-size: var(--t-h1); padding-top: 0.2em; }
  .partrow { grid-template-columns: 5rem minmax(0, 1fr) auto; }
}
@media (hover: hover) {
  .partrow:hover .pt { transform: translateX(0.12em); }
  .partrow:hover .go { --btn-bg: var(--text); --btn-fg: var(--bg); --btn-bd: var(--text); }
}

/* ================= 2 form frame ================= */
/* sticky header: back | subject bar + title | count. Phones show the short title and "5 af 31". */
.tbar .appbar-in { column-gap: var(--s-3); }
.tbar .appbar-title { display: flex; align-items: center; gap: var(--s-2); }
.tbar .appbar-title > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; position: relative; top: 0.16em; } /* optical: serif sits high next to sans */
.tbar .bar6 { flex: none; }
.tbar .tl-s { display: none; }
.tbar .pg { font-size: var(--t-small); color: var(--text-muted); }
.tbar .pg b { color: var(--text); font-weight: 600; }
@media (max-width: 599px) {
  .tbar .appbar-title { font-size: var(--t-body); }
  .tbar .tl-f { display: none; }
  .tbar .tl-s { display: inline; }
  .tbar .pgw { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

.tform { padding-bottom: var(--s-6); }
.tmain { container: form / inline-size; min-width: 0; max-width: 72rem; }
.tindex { display: none; }
@media (min-width: 1024px) {
  .tgrid { display: grid; grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr); column-gap: var(--s-4); align-items: start; }
  .tindex {
    display: block; position: sticky; top: calc(var(--bar-h, 3.75rem) + var(--s-3)); margin-top: var(--s-5);
    max-height: calc(100dvh - var(--bar-h, 3.75rem) - var(--s-4)); overflow-y: auto;
  }
}
.ixh { font-size: var(--t-small); font-weight: 600; color: var(--text-muted); padding-bottom: var(--s-1); }
.tindex ol { list-style: none; padding: 0; border-top: var(--rule) solid var(--text); }
.ix {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-2);
  width: 100%; min-height: var(--tap); padding: var(--s-1) 0; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left; font-size: var(--t-small); line-height: 1.25; cursor: pointer;
}
.ix .sk { color: var(--text-muted); }
.ix .n { color: var(--text-muted); padding: 0.125rem 0.375rem; border-radius: var(--radius); }
.ix.done .n { background: var(--text); color: var(--bg); font-weight: 600; }
.ix[aria-current] { font-weight: 600; padding-left: var(--s-2); border-left: var(--bar) solid var(--text); }
@media (min-width: 1600px) { .tgrid { grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr); column-gap: var(--s-5); } }
@media (hover: hover) { .ix:hover .l { text-decoration: underline; text-underline-offset: 3px; } }

.formhead { padding-top: var(--s-5); }
.formhead .subj { display: inline-block; min-width: 9rem; font-size: var(--t-small); }
.formhead .h1 { margin-top: var(--s-2); }
.intro { display: grid; gap: var(--s-2); margin-top: var(--s-3); max-width: var(--measure); }
.intro p:first-child { font-size: var(--t-lead); line-height: 1.4; color: var(--text-muted); }
.intro b { font-weight: 600; }
.was { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-2); margin-top: var(--s-3); max-width: var(--measure); font-size: var(--t-small); }

.sec { margin-top: var(--s-6); padding-top: var(--s-3); border-top: var(--rule) solid var(--text); scroll-margin-top: calc(var(--bar-h, 3.75rem) + var(--s-2)); }
.sec:focus { outline: none; } /* jump target only; the index shows where you are */
.sec.open-sec { border-top-color: var(--line); }
.sec .h2 { max-width: 32ch; }
.sk { color: var(--text-muted); }
.sintro { max-width: var(--measure); margin-top: var(--s-2); }

/* given figures: a small ledger, amounts right-aligned */
.given { margin-top: var(--s-3); max-width: 30rem; padding-block: var(--s-2); border-block: var(--rule) solid var(--line); }
.given .gl { font-size: var(--t-small); font-weight: 600; color: var(--text-muted); }
.given ul { list-style: none; padding: 0; margin-top: var(--s-1); }
.given li { display: flex; justify-content: space-between; gap: var(--s-3); padding-block: 0.3rem; font-variant-numeric: tabular-nums lining-nums; }
.given li + li { border-top: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.given .v { white-space: nowrap; text-align: right; }

/* ================= 3 questions ================= */
.q { margin-top: var(--s-5); min-width: 0; padding: 0; border: 0; }
.qt { padding: 0; max-width: var(--measure); font-size: var(--t-lead); font-weight: 600; line-height: 1.35; }
.qn { color: var(--text-muted); font-weight: 500; margin-right: 0.35em; font-variant-numeric: tabular-nums lining-nums; }
.opts { margin-top: var(--s-2); }

/* the mark: radio = circle, filled ink with a paper dot when chosen; checkbox = square, filled ink with a paper tick */
.mark {
  appearance: none; -webkit-appearance: none; flex: none; display: grid; place-items: center;
  width: 1.375rem; height: 1.375rem; margin: 0; border: var(--rule) solid var(--text); border-radius: 50%;
  background: var(--surface); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out);
}
.mark:focus-visible { outline: none; }
.mark:checked { background: var(--text); }
.mark::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--surface); transform: scale(0); transition: transform var(--dur-1) var(--ease-in); }
.mark:checked::before { transform: scale(1); transition: transform var(--dur-2) var(--ease-spring); }
.mark[type=checkbox] { border-radius: 3px; }
.mark[type=checkbox]::before { width: 0.375rem; height: 0.6875rem; border-radius: 0; background: none; border: solid var(--surface); border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg) scale(0); }
.mark[type=checkbox]:checked::before { transform: translateY(-1px) rotate(45deg) scale(1); }

/* list rows: thin dividers, whole row tappable, chosen = filled mark + bold text + light ink tint */
.opts.list { max-width: 40rem; border-top: 1px solid var(--line); }
.opts.list .opt {
  display: flex; align-items: center; gap: var(--s-2); min-height: 3rem; padding: 0.625rem var(--s-1);
  border-bottom: 1px solid var(--line); line-height: 1.3; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color var(--dur-1) var(--ease-out);
}
.opt .let { flex: none; min-width: 1.1em; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.opt .ot { min-width: 0; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
.opts.list .opt .let + .ot { margin-left: calc(var(--s-1) - var(--s-2)); }
.opts.list .opt:has(:checked) { background: color-mix(in srgb, var(--text) 7%, transparent); }
.opts.list .opt:has(:checked) :is(.ot, .let) { font-weight: 600; color: var(--text); }
.opts.list .opt:has(:focus-visible) { outline: 3px solid var(--text); outline-offset: -3px; }
@media (hover: hover) { .opts.list .opt:hover { background: color-mix(in srgb, var(--text) 4%, transparent); } .opts.list .opt:has(:checked):hover { background: color-mix(in srgb, var(--text) 9%, transparent); } }

/* segmented control: joined equal steps, chosen = ink block with paper text. Used by short single choices
   and by every matrix row when the table does not fit. */
:is(.opts.seg, .mxw:not(.tbl) .mx tr) { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); max-width: 36rem; }
fieldset.q .opts.seg { max-width: min(100%, calc(var(--n) * 9rem)); }
:is(.opts.seg, .mxw:not(.tbl) td.c) .opt {
  position: relative; display: flex; align-items: center; justify-content: center; height: 100%;
  min-height: 3rem; padding: 0.25rem; margin-left: calc(-1 * var(--rule));
  border: var(--rule) solid var(--line); background: var(--surface);
  font-weight: 600; line-height: 1.15; text-align: center; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
:is(.opts.seg, .mxw:not(.tbl) td.c) .mark { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
:is(.opts.seg, .mxw:not(.tbl) td.c) .opt .let { min-width: 0; color: var(--text); }
.opts.seg .opt .let, .mxw.words:not(.tbl) .opt .let, .mxw.letters:not(.tbl) .opt .ot { display: none; }
fieldset .opts.seg .opt:first-child, .mxw:not(.tbl) td.qc + td.c .opt { margin-left: 0; border-radius: var(--radius) 0 0 var(--radius); }
fieldset .opts.seg .opt:last-child, .mxw:not(.tbl) td.c:has(+ :not(.c)) .opt, .mxw:not(.tbl) td.c:last-child .opt { border-radius: 0 var(--radius) var(--radius) 0; }
:is(.opts.seg, .mxw:not(.tbl) td.c) .opt:has(:checked) { z-index: 1; background: var(--text); border-color: var(--text); color: var(--bg); }
:is(.opts.seg, .mxw:not(.tbl) td.c) .opt:has(:checked) .let { color: var(--bg); }
:is(.opts.seg, .mxw:not(.tbl) td.c) .opt:has(:focus-visible) { z-index: 2; outline: 3px solid var(--text); outline-offset: 2px; }
.mxw.scale:not(.tbl) td.c:has(~ td.c :checked) .opt { background: color-mix(in srgb, var(--text) 12%, var(--surface)); }
@media (hover: hover) { :is(.opts.seg, .mxw:not(.tbl) td.c) .opt:not(:has(:checked)):hover { z-index: 1; border-color: var(--text); } }
.live :is(.opts.seg, .mxw:not(.tbl) td.c) .opt:has(:checked) { animation: settle var(--dur-3) var(--ease-out); }

/* short answers: label above, input below; a ledger row when there is room */
.fields { margin-top: var(--s-3); max-width: 46rem; }
.fr { display: grid; gap: var(--s-1); padding-block: var(--s-2); }
.fr label { font-weight: 600; }
.fr .inp { max-width: 16rem; text-align: right; }
@container form (min-width: 34rem) {
  .fields { border-top: 1px solid var(--line); }
  .fr { grid-template-columns: minmax(0, 1fr) minmax(9rem, 14rem); align-items: center; column-gap: var(--s-4); border-bottom: 1px solid var(--line); }
  .fr .inp { max-width: none; }
}

/* long answer: one textarea that grows with the text */
.q textarea.inp { display: block; margin-top: var(--s-2); max-width: 46rem; min-height: 7.5rem; field-sizing: content; max-height: 70vh; resize: none; }

/* ---------- accounting schedules (VØ B4, B6, B8) ---------- */
.sched { margin-top: var(--s-3); font-variant-numeric: tabular-nums lining-nums; }
.sched .am { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.sched .inp.am { min-height: 2.75rem; padding-block: 0.375rem; }
.sched .qn { font-size: var(--t-small); }

/* calc: operator | label | amount; rule above subtotals, double rule under the total */
.calc { max-width: 40rem; }
.calc .sl { display: grid; grid-template-columns: 1rem minmax(0, 1fr) 6.75rem; align-items: center; column-gap: var(--s-2); min-height: 2.75rem; padding-block: 0.25rem; }
.calc .hd { min-height: 0; padding-bottom: var(--s-1); border-bottom: 1px solid var(--line); font-size: var(--t-small); font-weight: 600; color: var(--text-muted); }
.calc .op { font-weight: 600; text-align: center; }
.calc .lb { min-width: 0; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
@container form (min-width: 34rem) { .calc .sl { grid-template-columns: 1.5rem minmax(0, 1fr) 11rem; } }
.calc .gv .am { padding-right: calc(0.875rem + var(--rule)); } /* lines up with the digits typed in the inputs */
.calc .in .lb { font-weight: 600; }
.calc .sub, .calc .total { margin-top: 0.25rem; padding-top: 0.5rem; border-top: var(--rule) solid var(--text); }
.calc .total { padding-bottom: 0.5rem; border-bottom: 6px double var(--text); }
.calc .sub + .gv { margin-top: 0.25rem; }

/* bal: kontoform. Two opposing sides with a centre rule, totals on the same row; label above input when narrow */
.bal { container: bal / inline-size; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 56rem; border-top: var(--rule) solid var(--text); }
.bal .l { padding-right: var(--s-2); border-right: var(--rule) solid var(--text); }
.bal .r { padding-left: var(--s-2); }
.bal .bh { display: flex; justify-content: space-between; align-items: baseline; padding-block: var(--s-1); border-bottom: var(--rule) solid var(--text); font-size: var(--t-small); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.bal .bh .u { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
.bal .bc { display: grid; align-content: end; gap: 0.25rem; padding-block: var(--s-2) 0; min-width: 0; }
.bal .bc:has(+ .tot) { padding-bottom: var(--s-2); } /* last row before the totals */
.bal .bc label { font-size: var(--t-small); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
.bal .bc.tot { padding-block: var(--s-1); border-top: var(--rule) solid var(--text); border-bottom: 6px double var(--text); }
.bal .bc.tot label { font-weight: 700; }
@container bal (min-width: 40rem) {
  .bal .bc { grid-template-columns: minmax(0, 1fr) minmax(7rem, 10rem); align-items: center; column-gap: var(--s-2); }
  .bal .bc label { font-size: var(--t-body); }
}

/* B8 "Poster": neutral two-column list above the balance (not pre-sorted: sorting is the task) */
.given.cols { max-width: 46rem; }
.given.cols ul { columns: 2 15rem; column-gap: var(--s-4); }
.given.cols li { break-inside: avoid; }
.given.cols li + li { border-top: 0; }

/* ================= 4 matrix ================= */
/* Default (no room for the table): per row the question, then a segmented control (see 3), then
   the chosen option's text (letters) or the scale's end labels (until something is chosen). */
.mxw { margin-top: var(--s-3); }
.mx, .mx tbody, .mx td { display: block; }
.mx thead { display: none; }
.mx tr { padding-block: var(--s-2) var(--s-3); border-top: 1px solid var(--line); }
.mx tr:first-child { border-top: 0; padding-top: var(--s-1); }
.mx td.qc { grid-column: 1 / -1; padding-bottom: var(--s-2); font-weight: 600; line-height: 1.35; max-width: var(--measure); }
.mx td.c { min-width: 0; }
.mx :is(td.ends, td.sel) { grid-column: 1 / -1; margin-top: var(--s-1); font-size: var(--t-small); line-height: 1.3; }
.mx td.ends { display: flex; justify-content: space-between; gap: var(--s-2); color: var(--text-muted); }
.mx td.ends span { flex: 0 1 auto; }
.mx td.ends span:last-child { text-align: right; }
.mx td.sel { display: none; }
.mx td.sel b { margin-right: 0.4em; }
.mx tr:has(:checked) td.sel { display: block; }
.mx tr:has(:checked) td.ends { display: none; }

/* key for letter matrices (phone): what A-G mean, once above the rows */
.key { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 0.125rem var(--s-3); max-width: 46rem; padding-block: var(--s-2); margin-bottom: var(--s-2); border-block: 1px solid var(--line); font-size: var(--t-small); line-height: 1.3; }
.mxw.short .key { grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); }
.key div { display: flex; gap: 0.5em; }
.key dt { flex: none; min-width: 1.1em; font-weight: 600; }
.key dd { margin: 0; color: var(--text-muted); }
.mxw.tbl .key { display: none; }

/* table: options are columns, header sticks under the app bar; chosen cell = ink block */
.mxw.tbl .mx { display: table; width: 100%; max-width: var(--maxw); table-layout: fixed; border-collapse: collapse; }
.mxw.tbl .mx thead { display: table-header-group; }
.mxw.tbl .mx tbody { display: table-row-group; }
.mxw.tbl .mx tr { display: table-row; padding: 0; border: 0; }
.mxw.tbl .mx th, .mxw.tbl .mx td { display: table-cell; }
.mxw.tbl .mx td:is(.ends, .sel) { display: none; }
.mxw.tbl .mx th {
  position: sticky; top: var(--bar-h, 3.75rem); z-index: 3; background: var(--bg);
  width: var(--cw); padding: var(--s-1) 0.375rem var(--s-2); border-bottom: var(--rule) solid var(--text);
  font-size: var(--t-small); font-weight: 600; line-height: 1.2; text-align: center; vertical-align: bottom;
  hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word;
}
.mxw.tbl .mx th.qh { width: auto; padding-left: 0; text-align: left; }
.mxw.tbl .mx th .let { display: block; color: var(--text-muted); }
.mxw.tbl .mx td { border-bottom: 1px solid var(--line); }
.mxw.tbl .mx td.qc { padding: var(--s-2) var(--s-3) var(--s-2) 0; font-weight: 500; vertical-align: middle; }
.mxw.tbl .mx td.c { height: 1px; padding: 0; }
.mxw.tbl .mx td.c .opt { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 3.25rem; cursor: pointer; transition: background-color var(--dur-1) var(--ease-out); }
.mxw.tbl .mx td.c .opt :is(.let, .ot) { display: none; }
.mxw.tbl .mx td.c .opt:has(:checked) { background: var(--text); }
.mxw.tbl .mx td.c .opt:has(:checked) .mark { border-color: var(--bg); }
.mxw.scale.tbl .mx td.c:has(~ td.c :checked) .opt { background: color-mix(in srgb, var(--text) 10%, transparent); }
.mxw.tbl .mx td.c .opt:has(:focus-visible) { position: relative; z-index: 2; outline: 3px solid var(--text); outline-offset: -3px; }
.mxw.tbl .mx td.c .opt:has(:checked:focus-visible) { outline-color: var(--bg); outline-offset: -6px; }
.mxw.tbl .mx tr:has(:checked) .qn { color: var(--text); }
@media (hover: hover) {
  .mxw.tbl .mx tbody tr:hover td.qc { background: color-mix(in srgb, var(--text) 4%, transparent); }
  .mxw.tbl .mx td.c .opt:not(:has(:checked)):hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
}

/* ================= 5 send ================= */
.sendbar { display: grid; justify-items: start; gap: var(--s-3); margin-top: var(--s-6); padding-top: var(--s-4); border-top: var(--rule) solid var(--text); }
.sendbar .sp { font-size: var(--t-small); color: var(--text-muted); }
.sendbar .btn { max-width: 100%; }
.msg { max-width: 60ch; }
.msg:empty { display: none; }
.msg.err { padding: var(--s-2) var(--s-3); background: var(--surface-2); border-left: var(--bar) solid var(--text); }

/* ================= 6 motion ================= */
/* the part title travels between its overview row and the form heading */
::view-transition-group(part-title) { animation-duration: var(--dur-4); animation-timing-function: var(--ease-move); }
::view-transition-old(part-title), ::view-transition-new(part-title) { height: 100%; object-fit: contain; object-position: left center; }
