/* ============================================
   ePortal håndbok — brand-profil
   Matcher ui/ePortal.ui/src/styles/_action-buttons.scss
   og _kai.scss for visuell konsistens med selve portalen.
   ============================================ */

:root {
  /* Brand-farger — eksakte hex fra _action-buttons.scss */
  --eportal-dark: #0C0C0C;
  --eportal-dark-soft: #2a2a2a;
  --eportal-gold: #C7AA80;
  --eportal-gold-light: #e0c9a8;
  --eportal-gold-dark: #b39568;
  --eportal-kai-purple: #7c3aed;
  --eportal-kai-purple-light: #a855f7;

  /* Material primær overstyrt til ePortal-mørk */
  --md-primary-fg-color: var(--eportal-dark);
  --md-primary-fg-color--light: var(--eportal-dark-soft);
  --md-primary-fg-color--dark: #000000;

  /* Material aksent overstyrt til ePortal-gull */
  --md-accent-fg-color: var(--eportal-gold-dark);
  --md-accent-fg-color--transparent: rgba(199, 170, 128, 0.15);
}

/* Mørk modus får lysere gull for kontrast */
[data-md-color-scheme="slate"] {
  --md-accent-fg-color: var(--eportal-gold-light);
  --md-accent-fg-color--transparent: rgba(224, 201, 168, 0.15);
}

/* ============================================
   Header med ePortal sin svarte gradient
   (matcher .btn-action-dark)
   ============================================ */
.md-header {
  background: linear-gradient(135deg, var(--eportal-dark-soft) 0%, var(--eportal-dark) 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.md-header__title {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Tabs i header */
.md-tabs {
  background: linear-gradient(135deg, var(--eportal-dark-soft) 0%, var(--eportal-dark) 100%);
}

.md-tabs__link {
  opacity: 0.85;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.md-tabs__link:hover,
.md-tabs__link--active {
  opacity: 1;
  color: var(--eportal-gold) !important;
}

/* Gull-underline på aktiv tab */
.md-tabs__item--active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--eportal-gold);
}

/* ============================================
   Typografi — overskrifter får mer karakter
   ============================================ */
.md-typeset h1 {
  color: var(--eportal-dark);
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--eportal-gold);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

[data-md-color-scheme="slate"] .md-typeset h1 {
  color: #f5f5f5;
}

.md-typeset h2 {
  font-weight: 600;
  margin-top: 2rem;
  color: var(--eportal-dark);
}

[data-md-color-scheme="slate"] .md-typeset h2 {
  color: #e0e0e0;
}

.md-typeset h3 {
  font-weight: 600;
  color: var(--eportal-dark-soft);
}

[data-md-color-scheme="slate"] .md-typeset h3 {
  color: #d0d0d0;
}

/* ============================================
   md-button — match btn-action-dark + btn-action-gold
   ============================================ */
.md-typeset .md-button {
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.md-typeset .md-button--primary {
  background: linear-gradient(135deg, var(--eportal-dark-soft) 0%, var(--eportal-dark) 100%) !important;
  border-color: var(--eportal-dark) !important;
  color: white !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.md-typeset .md-button--primary:hover {
  background: linear-gradient(135deg, var(--eportal-dark) 0%, #000000 100%) !important;
  border-color: #000000 !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.md-typeset .md-button:not(.md-button--primary) {
  border-color: var(--eportal-gold-dark);
  color: var(--eportal-dark);
}

[data-md-color-scheme="slate"] .md-typeset .md-button:not(.md-button--primary) {
  color: var(--eportal-gold-light);
}

.md-typeset .md-button:not(.md-button--primary):hover {
  background: var(--eportal-gold) !important;
  border-color: var(--eportal-gold-dark) !important;
  color: var(--eportal-dark) !important;
  transform: translateY(-1px);
}

/* ============================================
   Tabeller — mer profesjonell finish
   ============================================ */
.md-typeset table:not([class]) {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.md-typeset table:not([class]) th {
  background: linear-gradient(135deg, var(--eportal-dark-soft) 0%, var(--eportal-dark) 100%);
  color: white;
  font-weight: 600;
  letter-spacing: 0.02em;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) {
  border-color: #444;
}

/* ============================================
   Kode-blokker
   ============================================ */
.md-typeset code {
  background-color: rgba(199, 170, 128, 0.12);
  color: var(--eportal-dark);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

[data-md-color-scheme="slate"] .md-typeset code {
  background-color: rgba(224, 201, 168, 0.15);
  color: var(--eportal-gold-light);
}

/* ============================================
   Lenker — gull-aksent på hover
   ============================================ */
.md-typeset a {
  color: var(--eportal-gold-dark);
  font-weight: 500;
  border-bottom: 1px dotted transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.md-typeset a:hover {
  color: var(--eportal-dark);
  border-bottom-color: var(--eportal-gold);
}

[data-md-color-scheme="slate"] .md-typeset a {
  color: var(--eportal-gold-light);
}

[data-md-color-scheme="slate"] .md-typeset a:hover {
  color: var(--eportal-gold);
  border-bottom-color: var(--eportal-gold-light);
}

/* ============================================
   Søke-input fokus
   ============================================ */
.md-search__input {
  background: rgba(255, 255, 255, 0.1);
}

.md-search__input:hover,
.md-search__input:focus {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   Sidebar nav — aktiv side får gull-aksent
   ============================================ */
.md-nav__link--active {
  color: var(--eportal-gold-dark) !important;
  font-weight: 600;
}

[data-md-color-scheme="slate"] .md-nav__link--active {
  color: var(--eportal-gold-light) !important;
}

/* ============================================
   Footer
   ============================================ */
.md-footer {
  background: var(--eportal-dark);
}

.md-footer-meta {
  background: #000000;
}

/* ============================================
   Admonitions (notater, advarsler)
   ============================================ */
.md-typeset .admonition,
.md-typeset details {
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.md-typeset .admonition.note {
  border-color: var(--eportal-gold);
}

.md-typeset .admonition.note > .admonition-title {
  background-color: rgba(199, 170, 128, 0.15);
}

.md-typeset .admonition.note > .admonition-title::before {
  background-color: var(--eportal-gold-dark);
}

/* --------------------------------------------
   .endring — én release-oppføring inne i et modulpanel.

   Release-sidene nøster to nivåer: modulen ("CRM / Salg (25 endringer)") er en
   `note` i gull, og hver oppføring inni er en `endring`. Uten et eget uttrykk ser
   de to nivåene identiske ut og hierarkiet forsvinner — leseren ser bare en vegg
   av like paneler.

   Derfor: dusere farger som trekker seg tilbake, og et chevron-ikon som sier
   "åpne meg" i stedet for blyanten. Rammen og hodet er de samme tokenene som
   `sec-panel` bruker i selve appen, så håndboken og produktet ser like ut.
   -------------------------------------------- */
:root {
  --md-admonition-icon--endring: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59 16.58 13.17 12 8.59 7.41 10 6l6 6-6 6z"/></svg>');
}

.md-typeset .admonition.endring,
.md-typeset details.endring {
  border-color: #e6e1d8;
  box-shadow: none;
}

.md-typeset .endring > .admonition-title,
.md-typeset .endring > summary {
  background-color: #fdfcf9;
  font-weight: 600;
}

.md-typeset .endring > .admonition-title::before,
.md-typeset .endring > summary::before {
  background-color: #8a8580;
  -webkit-mask-image: var(--md-admonition-icon--endring);
  mask-image: var(--md-admonition-icon--endring);
}

[data-md-color-scheme="slate"] .md-typeset .admonition.endring,
[data-md-color-scheme="slate"] .md-typeset details.endring {
  border-color: rgba(255, 255, 255, 0.12);
}

[data-md-color-scheme="slate"] .md-typeset .endring > .admonition-title,
[data-md-color-scheme="slate"] .md-typeset .endring > summary {
  background-color: rgba(255, 255, 255, 0.04);
}

/* ============================================
   role-grid — match forsidens 5 rolle-kort
   (brukt i docs/manual/index.md)
   ============================================ */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.role-grid h3 {
  margin-top: 0;
  border-bottom: 2px solid var(--eportal-gold);
  padding-bottom: 0.5rem;
}

/* ============================================
   Skroll-til-toppen-knapp
   ============================================ */
.md-top {
  background-color: var(--eportal-dark);
  color: var(--eportal-gold);
}

.md-top:hover {
  background-color: var(--eportal-dark-soft);
  color: var(--eportal-gold-light);
}

/* ============================================
   Logo-størrelse — K-logoen er kvadratisk
   ============================================ */
.md-header__button.md-logo {
  padding: 0.4rem 0.6rem;
}

.md-header__button.md-logo img,
.md-header__button.md-logo svg {
  height: 1.8rem;
  width: 1.8rem;
  border-radius: 4px;
}

/* Release notes — expand/collapse all toolbar */
.release-expand-toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem 0;
  flex-wrap: wrap;
}
.release-expand-toolbar .md-button {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ============================================
   Tekniske kode-henvisninger — toggle av/på
   ============================================ */

/* Default: skjul tekniske refs for vanlige lesere */
body:not(.show-tech-refs) .tech-ref-link,
body:not(.show-tech-refs) .tech-ref-paren,
body:not(.show-tech-refs) .tech-ref-block {
  display: none !important;
}

/* Visuell antydning på inline-link når synlig */
body.show-tech-refs .tech-ref-link {
  font-size: 0.85em;
  opacity: 0.85;
  text-decoration: underline dotted;
}
body.show-tech-refs .tech-ref-paren {
  font-size: 0.85em;
  opacity: 0.85;
}
body.show-tech-refs .tech-ref-block {
  border-left: 3px solid rgba(125, 125, 125, 0.3);
  padding-left: 0.75rem;
  font-size: 0.85em;
  color: var(--md-default-fg-color--light);
}

/* Toggle-knapp i topp-header */
.md-header-tech-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--md-primary-bg-color, currentColor);
  cursor: pointer;
  padding: 0.4rem;
  margin: 0;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
.md-header-tech-toggle:hover,
.md-header-tech-toggle:focus-visible {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.1);
}
.md-header-tech-toggle.active {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.18);
}
.md-header-tech-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
}

/* ============================================
   Author-marked technical content - same toggle
   ============================================ */

/* Hiding is gated on html.tech-toggle-ready, which docs/overrides/main.html sets
   in <head> and withdraws again if no toggle button appears. Unlike the
   .tech-ref-* classes above - which JavaScript adds, so without JavaScript they
   never exist and nothing is hidden - these classes are rendered by mkdocs and
   are present with or without JavaScript. Without the gate, a page whose toggle
   script failed to load would hide the content permanently. */
html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset details.technical,
html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset p.technical,
html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset li.technical,
html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset span.technical {
  display: none !important;
}

body.show-tech-refs .md-typeset details.technical {
  border-color: rgba(125, 125, 125, 0.3);
}
body.show-tech-refs .md-typeset details.technical > summary {
  background-color: rgba(125, 125, 125, 0.08);
}
body.show-tech-refs .md-typeset p.technical,
body.show-tech-refs .md-typeset li.technical {
  border-left: 3px solid rgba(125, 125, 125, 0.3);
  padding-left: 0.75rem;
  font-size: 0.85em;
  color: var(--md-default-fg-color--light);
}
body.show-tech-refs .md-typeset span.technical {
  font-size: 0.9em;
  opacity: 0.85;
}

/* Curly-brace admonition icon, same visual language as the header button. */
:root {
  --md-admonition-icon--technical: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 3c-1.1 0-2 .9-2 2v4c0 1.1-.9 2-2 2H3v2h1c1.1 0 2 .9 2 2v4c0 1.1.9 2 2 2h2v-2H8v-5c0-1.1-.9-2-2-2 1.1 0 2-.9 2-2V5h2V3H8m8 0c1.1 0 2 .9 2 2v4c0 1.1.9 2 2 2h1v2h-1c-1.1 0-2 .9-2 2v4c0 1.1-.9 2-2 2h-2v-2h2v-5c0-1.1.9-2 2-2-1.1 0-2-.9-2-2V5h-2V3h2Z"/></svg>');
}
.md-typeset details.technical > summary::before {
  -webkit-mask-image: var(--md-admonition-icon--technical);
          mask-image: var(--md-admonition-icon--technical);
}

@media print {
  /* Printed output is a technical artifact: show everything, expanded,
     regardless of the on-screen toggle state or whether JavaScript ever ran.
     `revert` and not `display: block` - .tech-ref-link/.tech-ref-paren are
     inline, and the auto-detector puts .tech-ref-block on p, li OR td, so a
     blanket block would break lines around links and strip list and table
     semantics out of the printed page. `revert` drops the author-level
     display:none and restores each element's own native display. */
  .md-typeset .tech-ref-link,
  .md-typeset .tech-ref-paren,
  .md-typeset .tech-ref-block,
  .md-typeset details.technical,
  .md-typeset p.technical,
  .md-typeset li.technical,
  .md-typeset span.technical,
  /* The on-screen hide rules above are `display: none !important` on MORE specific
     selectors - (0,2,1) for the auto-detected links, (0,4,3) for the author-marked
     content - so the bare selectors above lose to them and the print override never
     applied while the toggle was off. `@media` adds no specificity, so the only fix
     is to repeat the hiding selectors here: equal specificity, later in the file.
     Measured 2026-08-15 in Chromium 151 before this line existed: print-preview with
     the toggle off dropped every marked span, block, list item and source link, even
     though beforeprint had correctly opened the collapsed panels.
     Guarded by tools/docs-validate/__tests__/technical-print-visibility.spec.ts. */
  body:not(.show-tech-refs) .tech-ref-link,
  body:not(.show-tech-refs) .tech-ref-paren,
  body:not(.show-tech-refs) .tech-ref-block,
  html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset details.technical,
  html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset p.technical,
  html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset li.technical,
  html.tech-toggle-ready body:not(.show-tech-refs) .md-typeset span.technical {
    display: revert !important;
  }
  /* Force a collapsed <details> open without JavaScript. This one cannot use
     `revert`: the user-agent sheet is itself what hides a closed details' body,
     so reverting would restore the hiding. Tables are excluded because block
     would destroy them; every other admonition child is natively block anyway.
     Engine support varies, which is why tech-refs-toggle.js also sets `open` on
     beforeprint - that path is the guarantee, this one is the fallback. */
  .md-typeset details.technical > *:not(summary):not(table) {
    display: block !important;
  }
  .md-typeset details.technical > table {
    display: table !important;
  }
  .md-typeset details.technical::details-content {
    content-visibility: visible !important;
  }
}

/* ============================================
   Mermaid full-screen viewer
   ============================================ */

.mermaid-zoomable {
  position: relative;
  border-radius: 4px;
  transition: box-shadow 0.15s ease;
  cursor: zoom-in;
  outline: none;
}
.mermaid-zoomable > .mermaid {
  cursor: zoom-in;
}
.mermaid-zoomable:hover {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
}
.mermaid-zoomable .mermaid-zoom-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #1f2937;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.mermaid-zoomable:hover .mermaid-zoom-btn,
.mermaid-zoom-btn:focus-visible {
  opacity: 1;
}
.mermaid-zoom-btn:hover {
  background: #ffffff;
  color: #2563eb;
}

body.mermaid-zoom-open {
  overflow: hidden;
}
.mermaid-zoom-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  z-index: 9999;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  animation: mermaidZoomFadeIn 0.15s ease;
}
@keyframes mermaidZoomFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.mermaid-zoom-modal-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.mermaid-zoom-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: #ffffff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background-color 0.15s ease;
}
.mermaid-zoom-close:hover,
.mermaid-zoom-close:focus-visible {
  background: rgba(255, 255, 255, 0.3);
}
.mermaid-zoom-toolbar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  z-index: 3;
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.5rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.mermaid-zoom-toolbar button {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.65rem;
  color: #ffffff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  border-radius: 0.35rem;
  cursor: pointer;
}
.mermaid-zoom-toolbar button:hover,
.mermaid-zoom-toolbar button:focus-visible {
  background: rgba(255, 255, 255, 0.25);
}
.mermaid-zoom-hint {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  z-index: 3;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
}
.mermaid-zoom-stage {
  flex: 1;
  overflow: hidden;
  cursor: grab;
  position: relative;
  user-select: none;
  touch-action: none;
}
.mermaid-zoom-stage.is-dragging {
  cursor: grabbing;
}
.mermaid-zoom-stage svg {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.mermaid-zoom-loading,
.mermaid-zoom-error {
  position: absolute;
  top: 50%;
  left: 50%;
  color: rgba(255, 255, 255, 0.82);
  transform: translate(-50%, -50%);
}
.mermaid-zoom-error {
  color: #fecaca;
}

@media (max-width: 600px) {
  .mermaid-zoom-hint {
    top: auto;
    bottom: 4.75rem;
    width: max-content;
    max-width: calc(100vw - 2rem);
    white-space: normal;
    text-align: center;
  }
}

/* ── Release-notes «per modul» version badges ─────────────────────────────
   Rendered by tools/release-notes-publish/lib/module-history.js on
   docs/manual/hva-er-nytt/per-modul.md. Newest release gets a green (success)
   badge; older versions get a neutral badge that adapts to light/dark. */
.md-typeset .rn-badge {
  display: inline-block;
  padding: 0.05em 0.5em;
  margin: 0 0.1em 0 0.15em;
  border-radius: 0.6em;
  font-size: 0.72em;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.01em;
  vertical-align: middle;
  white-space: nowrap;
  background-color: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color--light);
}
.md-typeset .rn-badge--new {
  background-color: #2e7d32; /* success green — readable in light and dark */
  color: #fff;
}
.md-typeset .rn-date {
  font-size: 0.72em;
  color: var(--md-default-fg-color--light);
  white-space: nowrap;
}

/* Compact base typography (owner request 2026-07-22): smaller body + nav text. */
.md-typeset {
  -webkit-print-color-adjust: exact;
  color-adjust: exact;
  font-size: 0.6rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}
.md-nav {
  font-size: 0.6rem;
}
