/*!
 * @sann-systems/designsystem — temabryteren (skisse 7, sann.auth#122).
 * Bare tokens fra tokens.css. Forutsetter at tokens.css er importert.
 */

.sann-tema {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.sann-tema-tittel {
  padding: 0;
  margin: 0 0 8px;
}

/* I menyen er tittelen en gruppeoverskrift, som i skissen. */
.sann-tema-meny .sann-tema-tittel {
  padding: 0 4px 6px;
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

/* S7-1: én bryter, tre like brede valg. */
.sann-temabryter {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--field-border);
  border-radius: 0.375rem;
  background: var(--surface);
  min-width: 0;
}

.sann-temabryter-valg {
  flex: 1 1 0;
  display: flex;
  position: relative;
  min-width: 0;
}

/* Radioknappen er usynlig, men står i flyten for tastatur og skjermleser. */
.sann-temabryter-valg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

/* H2: trykkflaten er minst 44 px høy. */
.sann-temabryter-flate {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: calc(0.375rem - 2px);
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
}

.sann-temabryter-flate:hover {
  background: var(--surface-hover);
}

/* S7-2: valgt er flate, halvfet tekst og hake. Fargen står aldri alene. */
.sann-temabryter :is([aria-checked='true'], input:checked + .sann-temabryter-flate) {
  background: var(--surface-active);
  color: var(--text-primary);
  font-weight: 600;
}

.sann-temabryter-hake {
  display: none;
}

.sann-temabryter :is([aria-checked='true'], input:checked + .sann-temabryter-flate) .sann-temabryter-hake {
  display: inline;
}

.sann-temabryter :is([aria-checked='true'], input:checked + .sann-temabryter-flate) .sann-temabryter-ikon {
  display: none;
}

/* H3 og UU-regel 3: 2 px fokusring i interactive, 2 px avstand. */
.sann-temabryter :is(button.sann-temabryter-flate:focus-visible, input:focus-visible + .sann-temabryter-flate) {
  outline: 2px solid var(--interactive);
  outline-offset: 2px;
  position: relative;
  z-index: 1;
}

.sann-temabryter-hint {
  margin: 6px 4px 0;
  color: var(--text-muted);
  font-size: 13px; /* text-sm i skala.json */
  line-height: 1.5;
}

.sann-temabryter-hint:empty {
  display: none;
}

.sann-temabryter-hintlinje {
  display: block;
}

.sann-temabryter-hint-varsel {
  color: var(--text-secondary);
}

/* Windows høykontrast: valgt får egen kant, fordi bakgrunnen forsvinner. */
@media (forced-colors: active) {
  .sann-temabryter :is([aria-checked='true'], input:checked + .sann-temabryter-flate) {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }

  /* Fokus må stå sist, ellers skjuler valgt-kanten fokusringen på valgt valg. */
  .sann-temabryter :is(button.sann-temabryter-flate:focus-visible, input:focus-visible + .sann-temabryter-flate) {
    outline: 2px solid CanvasText;
    outline-offset: 2px;
  }
}
