/* UTKAST-ONLY: remove before go-live. "Snakk med Nettside" chat on the draft preview. */

.ch-panel[hidden], .ch-panel [hidden], .ch-badge[hidden] { display: none !important; }
.ch-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Same row as the navy "Tilbakemelding" button, to its left (chat.js sets "right" from its width).
   If the row is too narrow, .ch-stack puts it right above instead. */
.ch-fab {
  position: fixed;
  right: calc(max(1rem, env(safe-area-inset-right)) + 10.5rem);
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--navy, #071e33);
  border-radius: 999px;
  background: #fff;
  color: var(--navy, #071e33);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(4, 20, 33, 0.25);
}
.ch-fab:hover, .ch-fab:focus-visible { background: var(--navy, #071e33); color: #fff; border-color: #fff; }
.ch-fab:focus-visible { outline: 2px solid var(--navy, #071e33); outline-offset: 2px; }
.ch-icon { width: 18px; height: 18px; flex: none; }
.ch-badge {
  position: absolute; top: -3px; right: -3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #c8102e; border: 2px solid #fff;
}

.ch-fab.ch-stack { right: max(1rem, env(safe-area-inset-right)); bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 44px + 0.6rem); }
/* Two rows of fixed buttons: keep the footer text clear of them. */
.ch-stacked .site-footer { padding-bottom: 8.5rem; }

.ch-panel {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(25rem, calc(100vw - 2rem));
  height: min(40rem, calc(100vh - 2rem));
  height: min(40rem, calc(100dvh - 2rem));
  background: #fff;
  color: var(--navy, #071e33);
  border: 1px solid var(--navy, #071e33);
  box-shadow: 0 18px 50px rgba(4, 20, 33, 0.35);
  font-family: inherit;
}
.ch-is-open .ch-fab, .ch-is-open .fb-fab { visibility: hidden; }

.ch-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding: 0.9rem 1rem 0.85rem;
  background: var(--navy, #071e33);
  color: #fff;
}
.ch-title { margin: 0; font-size: 1.1rem; line-height: 1.25; font-weight: 600; color: #fff; }
.ch-note { margin: 0.3rem 0 0; font-size: 0.8rem; line-height: 1.4; color: rgba(255, 255, 255, 0.85); }
.ch-x {
  flex: none; width: 36px; height: 36px; margin: -0.35rem -0.4rem 0 0;
  border: 0; border-radius: 50%; background: transparent; color: #fff;
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.ch-x:hover, .ch-x:focus-visible { background: rgba(255, 255, 255, 0.15); }
.ch-x:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.ch-code { padding: 1.25rem 1rem; overflow: auto; }
.ch-label { display: block; margin-bottom: 0.35rem; font-weight: 600; }
.ch-code-input, .ch-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(7, 30, 51, 0.45);
  border-radius: 6px;
  background: #fff;
  color: var(--navy, #071e33);
  font: inherit;
  font-size: 1rem; /* 16px: no zoom on iOS */
}
.ch-code-input:focus, .ch-input:focus { outline: 2px solid var(--navy, #071e33); outline-offset: 1px; border-color: var(--navy, #071e33); }
.ch-help { margin: 0.45rem 0 1rem; font-size: 0.85rem; color: var(--muted, #3c5164); }

.ch-btn {
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--navy, #071e33);
  border-radius: 6px;
  background: var(--navy, #071e33);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.ch-btn:hover:not(:disabled), .ch-btn:focus-visible { background: #fff; color: var(--navy, #071e33); }
.ch-btn:focus-visible { outline: 2px solid var(--navy, #071e33); outline-offset: 2px; }
.ch-btn:disabled { opacity: 0.6; cursor: wait; }

.ch-status { margin: 0.5rem 0 0; font-size: 0.85rem; min-height: 1.2em; }
.ch-status:empty { min-height: 0; margin: 0; }
.ch-error { color: #a4262c; font-weight: 600; }

.ch-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ch-list {
  flex: 1; min-height: 0; overflow-y: auto;
  margin: 0; padding: 1rem 1rem 0.5rem; list-style: none;
  background: #f4f7fa;
  overscroll-behavior: contain;
}
.ch-msg { max-width: 85%; margin: 0 0 0.75rem; }
.ch-user { margin-left: auto; }
.ch-meta { display: flex; gap: 0.4rem; align-items: baseline; margin: 0 0 0.2rem; font-size: 0.72rem; color: var(--muted, #3c5164); }
.ch-user .ch-meta { justify-content: flex-end; }
.ch-who { font-weight: 600; }
.ch-text {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  line-height: 1.45;
}
.ch-bot .ch-text { background: #fff; border: 1px solid rgba(7, 30, 51, 0.15); border-top-left-radius: 2px; }
.ch-user .ch-text { background: var(--navy, #071e33); color: #fff; border-top-right-radius: 2px; }
.ch-user .ch-text a { color: #fff; }
.ch-text a { color: inherit; text-decoration: underline; }
.ch-intro .ch-text { background: #e6edf3; border-color: transparent; }

.ch-typing { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.75rem; padding: 0; font-size: 0.85rem; font-style: italic; color: var(--muted, #3c5164); }
.ch-typing .ch-dots { padding: 0.55rem 0.75rem; background: #fff; border: 1px solid rgba(7, 30, 51, 0.15); border-radius: 10px; border-top-left-radius: 2px; }
.ch-dots { display: inline-flex; gap: 3px; }
.ch-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: ch-blink 1.2s infinite ease-in-out; }
.ch-dots i:nth-child(2) { animation-delay: 0.2s; }
.ch-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes ch-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.ch-form { padding: 0.7rem 1rem 0.6rem; border-top: 1px solid rgba(7, 30, 51, 0.15); background: #fff; }
.ch-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.ch-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.ch-input { resize: none; min-height: 44px; max-height: 160px; line-height: 1.4; }
.ch-send { flex: none; }
.ch-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem 0.75rem; margin-top: 0.35rem; }
.ch-foot .ch-status { flex: 1 1 100%; }
.ch-count { margin: 0; font-size: 0.78rem; color: var(--muted, #3c5164); }
.ch-count.ch-over { color: #a4262c; font-weight: 600; }
.ch-link {
  margin-left: auto; padding: 0.25rem 0; border: 0; background: none;
  color: var(--muted, #3c5164); font: inherit; font-size: 0.8rem; text-decoration: underline; cursor: pointer;
}
.ch-link:hover, .ch-link:focus-visible { color: var(--navy, #071e33); }

@media (max-width: 600px) {
  .ch-fab { padding: 0.5rem 0.9rem; font-size: 0.85rem; }
  .ch-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    box-shadow: none;
  }
  .ch-is-open, .ch-is-open body { overflow: hidden; }
  .ch-head { padding-top: max(0.9rem, env(safe-area-inset-top)); }
  .ch-form { padding-bottom: max(0.6rem, env(safe-area-inset-bottom)); }
  .ch-msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .ch-dots i { animation: none; opacity: 0.6; }
}
