/* Shared page typography. Layered important declarations supersede the legacy
   module rules, including their important colours, without changing backgrounds. */
@layer tke-page-typography {
  :is(.tke-app, .tke-login-page, .tke-public-agreement, .tke-lmra-page,
      .tke-modal, .tke-lmra-modal, .tke-service-handover-modal),
  :is(.tke-app, .tke-login-page, .tke-public-agreement, .tke-lmra-page,
      .tke-modal, .tke-lmra-modal, .tke-service-handover-modal) * {
    color: var(--tke-site-text, #172033) !important;
  }

  :is(.tke-app, .tke-login-page, .tke-public-agreement, .tke-lmra-page,
      .tke-modal, .tke-lmra-modal, .tke-service-handover-modal)
  :is(h1, h2, h3, h4, h5, h6, [role="heading"], th, .tke-side-title,
      .tke-menu-folder-title, .tke-diagram-title,
      .tke-lmra-brand > span, .tke-lmra-view-brand strong),
  :is(.tke-app, .tke-login-page, .tke-public-agreement, .tke-lmra-page,
      .tke-modal, .tke-lmra-modal, .tke-service-handover-modal)
  :is(h1, h2, h3, h4, h5, h6, [role="heading"], th, .tke-side-title,
      .tke-menu-folder-title, .tke-diagram-title,
      .tke-lmra-brand > span, .tke-lmra-view-brand strong) * {
    color: var(--tke-site-heading, #172033) !important;
  }

  :is(.tke-app, .tke-login-page, .tke-public-agreement, .tke-lmra-page,
      .tke-modal, .tke-lmra-modal, .tke-service-handover-modal)
  :is(input, textarea)::placeholder {
    color: var(--tke-site-text, #172033) !important;
    opacity: 1 !important;
  }

  .tke-check-row label, .tke-lmra-question > label {
    opacity: 1 !important;
  }

  /* Keep fields legible even when the active theme or an older module stylesheet
     applies dark form controls. Deliberately excludes buttons, choices and files. */
  .tke-lmra-page #tke-lmra-form .tke-lmra-grid
      input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  .tke-lmra-page #tke-lmra-form .tke-lmra-grid select,
  .tke-lmra-page #tke-lmra-form .tke-lmra-block textarea,
  .tke-app .tke-page textarea.tke-comments,
  .tke-app.tke-shell-contract .tke-contract-question-form textarea[name="message"] {
    background-color: #fff !important;
    background-image: none !important;
    color: #111 !important;
    -webkit-text-fill-color: #111 !important;
    caret-color: #111 !important;
    border: 1px solid #111 !important;
    color-scheme: light !important;
  }

  .tke-lmra-page #tke-lmra-form .tke-lmra-grid
      input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"])::placeholder,
  .tke-lmra-page #tke-lmra-form .tke-lmra-block textarea::placeholder,
  .tke-app .tke-page textarea.tke-comments::placeholder,
  .tke-app.tke-shell-contract .tke-contract-question-form textarea[name="message"]::placeholder {
    color: #555 !important;
    -webkit-text-fill-color: #555 !important;
    opacity: 1 !important;
  }

  .tke-lmra-page #tke-lmra-form .tke-lmra-grid
      input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):-webkit-autofill,
  .tke-lmra-page #tke-lmra-form .tke-lmra-grid select:-webkit-autofill,
  .tke-lmra-page #tke-lmra-form .tke-lmra-block textarea:-webkit-autofill,
  .tke-app .tke-page textarea.tke-comments:-webkit-autofill,
  .tke-app.tke-shell-contract .tke-contract-question-form textarea[name="message"]:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    box-shadow: 0 0 0 1000px #fff inset !important;
    -webkit-text-fill-color: #111 !important;
    caret-color: #111 !important;
  }

  .tke-lmra-page #tke-lmra-form .tke-lmra-block canvas {
    background: #fff !important;
    border: 1px solid #111 !important;
    color-scheme: light !important;
  }

  /* The dark navigation has its own contrast-safe colour. Page text remains
     controlled by "Tekst på sider". */
  .tke-app .tke-sidebar,
  .tke-app .tke-sidebar * {
    color: var(--tke-sidebar-text-color, #fff) !important;
  }

  /* Mobile chrome shares the app's dark canvas. Keep its contrast exception
     in this layer: layered important page text wins over unlayered nav CSS. */
  .tke-app :is(.tke-v391-bottom-nav, .tke-v391-mobile-header),
  .tke-app :is(.tke-v391-bottom-nav, .tke-v391-mobile-header) * {
    color: #fff !important;
  }

  /* Section headings must keep the text colour paired with their LMRA block. */
  .tke-lmra-page .tke-lmra-section-title,
  .tke-lmra-page .tke-lmra-section-title *,
  .tke-lmra-view-section-title,
  .tke-lmra-view-section-title * {
    color: var(--tke-lmra-section-text, #fff) !important;
  }
}

/* Keep the LMRA heading pair together even when this file is combined with
   older unlayered heading rules by a cache/minification plugin. */
.tke-lmra-page .tke-lmra-section-title,
.tke-lmra-page .tke-lmra-section-title * {
  color: var(--tke-lmra-section-text, #fff) !important;
}
