/* Kontrollmärke widget. Scoped to .km.
   Same language as the arbetsmiljö widget (Empire: Lato body, Jost headings,
   the theme blue, 3 px corners): flat sections separated by rules, the mark
   preview and the buy button carry the page. */
.km {
  --km-accent: #007bff;
  --km-ink: #2e3238;
  --km-muted: #6c7178;
  --km-line: #e3e5e8;
  --km-line-strong: #c9cdd2;
  --km-soft: #f5f6f7;
  --km-pick: color-mix(in oklab, var(--km-accent) 6%, #fff);
  --km-warn: #a15c00;
  --km-error: #b3261e;
  --km-ok: #1e7b45;
  --km-radius: 3px;
  --km-head: Jost, inherit;
  color: var(--km-ink);
  font-size: 15px;
  line-height: 1.5;
  margin: 8px 0 28px;
  -webkit-font-smoothing: antialiased;
}
.km *, .km *::before, .km *::after { box-sizing: border-box; }
.km :where(button, input) { font: inherit; color: inherit; }
.km-muted { color: var(--km-muted); font-weight: 400; }
.km-note { margin: 0 0 10px; font-size: 13px; color: var(--km-muted); }

/* preview */
.km-preview { margin: 0 0 16px; }
.km-stage-wrap { background: var(--km-soft); padding: clamp(20px, 6%, 48px); }
.km-stage { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; max-height: 440px; margin: 0 auto; }
.km-stage > svg { width: min(100%, 360px); height: auto; filter: drop-shadow(0 1px 2px rgb(30 35 45 / .2)) drop-shadow(0 10px 22px rgb(30 35 45 / .14)); }
.km-stage-sheet { aspect-ratio: auto; max-height: none; }
.km-stage-sheet > svg { width: auto; max-width: 100%; max-height: min(70vh, 640px); filter: drop-shadow(0 1px 3px rgb(30 35 45 / .2)); }
.km-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 0; }
.km-chip { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--km-muted); font-variant-numeric: tabular-nums; }
.km-chip strong { color: var(--km-ink); font-weight: 600; }
.km-chip-mark { display: inline-flex; width: 34px; height: 34px; flex: none; }
.km-chip-mark svg { width: 100%; height: 100%; }
.km-preview-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 10px; font-size: 13px; color: var(--km-muted); }
.km-preview-bar .km-note { flex-basis: 100%; margin: 0; }
.km-spec strong { color: var(--km-ink); font-weight: 600; }
.km-preview-host > [data-km-hidden] { display: none !important; }

@media (min-width: 1000px) {
  .km-page.product--outer { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); column-gap: clamp(32px, 4vw, 64px); align-items: start; }
  .km-page > .product-form--alt { display: none !important; }
  .km-page > .product-gallery, .km-page > .product-main { width: auto !important; max-width: none !important; margin-left: 0 !important; margin-right: 0 !important; padding-left: 0; padding-right: 0; }
  .km-page > .product-gallery { position: sticky; top: 16px; }
}

/* fields */
.km-field { padding: 16px 0 14px; border-top: 1px solid var(--km-line); }
.km-field:first-child { border-top: 0; padding-top: 4px; }
.km-field-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.km-label { font-family: var(--km-head); font-size: 17px; font-weight: 600; }
.km-inline { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; }

.km-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.km-swatch {
  position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border-radius: 50%; border: 1px solid rgb(0 0 0 / .14); background: var(--sw, #fff); cursor: pointer;
  transition: transform .15s cubic-bezier(.22, 1, .36, 1);
}
.km-swatch:hover { transform: scale(1.06); }
.km-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--km-accent); }
.km-swatch:focus-visible, .km-swatch:focus-within { outline: 2px solid var(--km-accent); outline-offset: 3px; }
.km-swatch-custom { background: conic-gradient(from 90deg, #e53935, #fdd835, #43a047, #00acc1, #3949ab, #8e24aa, #e53935); overflow: hidden; }
.km-swatch-custom[aria-pressed="true"] { background: var(--sw); }
.km-swatch-custom::after { content: '+'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / .5); pointer-events: none; }
.km-swatch-custom[aria-pressed="true"]::after { content: '✎'; font-size: 15px; }
.km-swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

.km-seg { display: inline-flex; border: 1px solid var(--km-line-strong); border-radius: var(--km-radius); background: #fff; overflow: hidden; }
.km-seg button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; border-left: 1px solid var(--km-line); background: none; cursor: pointer; font-size: 13px; color: var(--km-muted); }
.km-seg button:first-child { border-left: 0; }
.km-seg button[aria-pressed="true"] { color: var(--km-ink); font-weight: 600; background: var(--km-pick); box-shadow: inset 0 -2px 0 var(--km-accent); }
.km-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--sw); border: 1px solid rgb(0 0 0 / .25); }

.km-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.km-option { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 10px 12px; border: 1px solid var(--km-line-strong); border-radius: var(--km-radius); background: #fff; cursor: pointer; text-align: left; }
.km-option:hover { border-color: var(--km-ink); }
.km-option[aria-pressed="true"] { border-color: var(--km-accent); box-shadow: inset 0 0 0 1px var(--km-accent); background: var(--km-pick); }
.km-option strong { font-weight: 600; }

/* years */
.km-yrows { display: grid; gap: 8px; }
.km-yrow { display: grid; grid-template-columns: minmax(0, 11em) auto minmax(0, 1fr) 28px; align-items: start; gap: 10px; }
.km-yrow > .km-fill { justify-self: start; }
.km-year { display: block; resize: none; overflow: hidden; line-height: 1.3; font-family: inherit; width: 100%; max-width: 11em; padding: 8px 10px; border: 1px solid var(--km-line-strong); border-radius: var(--km-radius); font-size: 16px; font-weight: 600; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.km-year:focus, .km-count:focus, .km-qty input:focus { outline: 2px solid var(--km-accent); outline-offset: -1px; border-color: transparent; }
.km-year[aria-invalid="true"] { border-color: var(--km-error); }
.km-blank { display: flex; flex-direction: column; font-weight: 600; line-height: 1.2; }
.km-blank small { font-weight: 400; color: var(--km-muted); font-size: 12px; }
.km-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--km-line-strong); border-radius: var(--km-radius); background: #fff; }
.km-stepper button { width: 34px; border: 0; background: none; cursor: pointer; font-size: 17px; color: var(--km-muted); }
.km-stepper button:hover { color: var(--km-ink); background: var(--km-soft); }
.km-stepper input { width: 3em; text-align: center; border: 0; border-left: 1px solid var(--km-line); border-right: 1px solid var(--km-line); padding: 7px 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.km-x { width: 28px; height: 28px; border: 0; background: none; cursor: pointer; color: var(--km-muted); font-size: 20px; line-height: 1; border-radius: 50%; }
.km-x:hover { color: var(--km-error); background: var(--km-soft); }
.km-adds { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 12px 0 4px; }
.km-link { padding: 0; border: 0; background: none; color: var(--km-accent); cursor: pointer; font-size: 14px; text-underline-offset: 3px; }
.km-link:hover { text-decoration: underline; }
.km-fill { font-size: 13px; white-space: nowrap; }
.km-status { margin: 10px 0 0; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.km-ok { color: var(--km-ok); }
.km-warn { color: var(--km-warn); }

/* buy */
.km-buybar { position: sticky; bottom: 0; z-index: 5; padding: 14px 0 12px; background: #fff; border-top: 1px solid var(--km-line); }
.km-buyrow { display: flex; gap: 10px; }
.km-qty input { width: 2.6em; }
.km-add { flex: 1; padding: 12px 16px; border: 0; border-radius: var(--km-radius); background: var(--km-accent); color: #fff !important; font-weight: 600; font-size: 16px; cursor: pointer; }
.km-add:hover:not(:disabled) { filter: brightness(.94); }
.km-add:disabled { opacity: .45; cursor: not-allowed; }
.km-buybar .km-note { margin: 8px 0 0; }
.km-msg { margin: 8px 0 0; font-size: 14px; }
.km-msg.km-error { color: var(--km-error); }
.km-msg.km-ok { color: var(--km-ok); }

@media (max-width: 480px) {
  .km-yrow { grid-template-columns: minmax(0, 1fr) auto 28px; }
  .km-fill { grid-column: 1 / -1; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { .km-swatch { transition: none; } }
.km-yrow > .km-x, .km-yrow > .km-fill { margin-top: 7px; }
