/* ===== Wetwijs =============================================================
   Kleurstelling: stempelinkt (aubergine) en meekrap-rood op koel steenpapier,
   ontleend aan het exploot: papier, stempel, zegel, paragraaf- en voetnoottekens.
   Type: Spectral voor de tekst van de wet, Archivo voor de interface.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Papier en inkt */
  --paper:       #F1EFF2;  /* pagina */
  --sheet:       #FFFFFF;  /* bubbels, kaartjes, paneel */
  --ink:         #241C2B;  /* lopende tekst */
  --ink-soft:    #6B6274;  /* bijschrift */
  --rule:        #DCD8E0;  /* haarlijnen */

  /* Accenten */
  --aubergine:      #4A3159;  /* wet, gebruiker, primaire actie */
  --aubergine-deep: #33203E;
  --aubergine-tint: rgba(74, 49, 89, .09);
  --madder:         #8C2230;  /* uitspraak */
  --madder-tint:    rgba(140, 34, 48, .09);

  /* Melding */
  --notice-bg:   #FBF3E4;
  --notice-ink:  #6E4906;
  --notice-rule: #A8730F;

  --header-h:  68px;
  --r-sheet:   2px;   /* kaartjes: strak, als een fiche */
  --r-bubble: 14px;   /* gebruikersbubbel: spraak */
  --r-control: 4px;   /* knoppen en invoer */

  --sans:  'Archivo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --serif: 'Spectral', Georgia, 'Times New Roman', serif;
}

html, body {
  height: 100%;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--aubergine); color: var(--sheet); }

:focus-visible {
  outline: 2px solid var(--aubergine);
  outline-offset: 2px;
}

/* ===== Briefhoofd ===== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}

/* Dubbele lijn onder het briefhoofd: dik, wit tussenwit, haarlijn. */
.header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 3px;
  height: 2px;
  background: var(--ink);
}

.header__inner {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: .8rem;
}

.header__brand {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--ink);
}

.header__subtitle {
  font-size: .82rem;
  font-weight: 400;
  color: var(--ink-soft);
}

.header__info-btn {
  margin-left: auto;
  align-self: center;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  color: var(--ink);
  padding: .32rem .75rem;
  font-family: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.header__info-btn:hover {
  border-color: var(--aubergine);
  background: var(--aubergine-tint);
  color: var(--aubergine);
}

/* ===== Bronnen-paneel ===== */
.info-panel {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  right: 1rem;
  width: min(380px, calc(100vw - 2rem));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--aubergine);
  border-radius: var(--r-sheet);
  box-shadow: 0 12px 32px rgba(36, 28, 43, .18);
  padding: 1rem 1.1rem 1.1rem;
  z-index: 200;
  font-size: .85rem;
}

.info-panel[hidden] { display: none; }

.info-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: .5rem;
  margin-bottom: .6rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font-weight: 600;
}

.info-panel__close {
  background: none;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0 .15rem;
}

.info-panel__close:hover { color: var(--ink); }

.info-panel__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: .9rem;
  color: var(--ink);
  font-size: .82rem;
}

.info-panel__list li {
  padding-left: 1.1rem;
  text-indent: -1.1rem;
}

.info-panel__list li::before {
  content: "\A7";                 /* § — dit is een wettekst */
  color: var(--aubergine);
  font-family: var(--serif);
  margin-right: .5rem;
}

.info-panel__note {
  color: var(--ink-soft);
  font-size: .78rem;
  line-height: 1.6;
}

.info-panel__note a {
  color: var(--aubergine);
  text-underline-offset: 2px;
}

/* ===== Gesprek ===== */
.chat {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--header-h);
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: thin;
  scrollbar-color: #c3bcca transparent;
}

/* ===== Berichten =====
   De vraag is spraak: een afgeronde, gevulde bubbel.
   Het antwoord is een document: een recht vel met een kantlijn. */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: fadeIn .25s ease;
}

.msg--user { align-self: flex-end; }
.msg--bot  { align-self: flex-start; }

.msg__bubble {
  padding: .8rem 1.05rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg--user .msg__bubble {
  background: var(--aubergine);
  color: var(--sheet);
  border-radius: var(--r-bubble);
  border-bottom-right-radius: 4px;
  font-size: .95rem;
  line-height: 1.6;
}

.msg--bot .msg__bubble {
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--aubergine);
  border-radius: var(--r-sheet);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 68ch;
  padding: .9rem 1.15rem;
}

/* ===== Verwijzingen in de tekst ===== */
sup { line-height: 0; }

.marker {
  font-family: var(--sans);
  font-size: .74em;
  font-weight: 600;
  color: var(--aubergine);
  background: var(--aubergine-tint);
  border: 1px solid rgba(74, 49, 89, .3);
  border-radius: 2px;
  padding: .1em .3em;
  margin: 0 .08em;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}

.marker:hover,
.marker:focus-visible {
  background: var(--aubergine);
  border-color: var(--aubergine);
  color: var(--sheet);
}

.marker--uitspraak {
  color: var(--madder);
  background: var(--madder-tint);
  border-color: rgba(140, 34, 48, .3);
}

.marker--uitspraak:hover,
.marker--uitspraak:focus-visible {
  background: var(--madder);
  border-color: var(--madder);
  color: var(--sheet);
}

/* ===== Bronkaartjes ===== */
.sources {
  margin-top: .8rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.sources__head {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: .85rem;
  color: var(--ink-soft);
}

.sources__head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.source-card {
  display: flex;
  align-items: center;
  gap: .7rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--aubergine);
  border-radius: var(--r-sheet);
  padding: .55rem .8rem;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}

.source-card:hover,
.source-card:focus-visible {
  background: var(--aubergine-tint);
  border-color: var(--aubergine);
}

.source-card--uitspraak { border-left-color: var(--madder); }

.source-card--uitspraak:hover,
.source-card--uitspraak:focus-visible {
  background: var(--madder-tint);
  border-color: var(--madder);
}

/* Het emoji-teken uit de opmaak wordt vervangen door een zetteken:
   § voor een wetsartikel, ‡ voor een uitspraak. */
.source-card__icon {
  font-size: 0;
  flex-shrink: 0;
  width: 1rem;
  text-align: center;
}

.source-card__icon::before {
  content: "\A7";
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1;
  color: var(--aubergine);
}

.source-card--uitspraak .source-card__icon::before {
  content: "\2021";               /* ‡ */
  color: var(--madder);
}

.source-card__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.source-card__title {
  font-size: .86rem;
  font-weight: 500;
  color: var(--ink);
}

.source-card__detail {
  font-size: .78rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Suggesties: tabbladen, geen pillen ===== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-self: flex-start;
  max-width: 100%;
}

.chip {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-bottom: 2px solid var(--aubergine);
  border-radius: 3px;
  color: var(--ink);
  padding: .45rem .8rem;
  font-family: inherit;
  font-size: .86rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.chip:hover,
.chip:focus-visible {
  background: var(--aubergine-tint);
  border-color: var(--aubergine);
}

/* ===== Wachtstand ===== */
.msg--loading .msg__bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1rem 1.2rem;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aubergine);
  animation: bounce .6s infinite alternate;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  to { opacity: .3; transform: translateY(-4px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Invoer ===== */
.chat__form {
  padding: .85rem 1rem 1rem;
  background: var(--paper);
  border-top: 1px solid var(--rule);
}

.chat__input-row {
  display: flex;
  gap: .5rem;
}

.chat__input {
  flex: 1;
  min-width: 0;
  padding: .72rem 1rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  color: var(--ink);
  font-family: inherit;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.chat__input::placeholder { color: var(--ink-soft); }

.chat__input:focus {
  border-color: var(--aubergine);
  box-shadow: 0 0 0 3px var(--aubergine-tint);
}

.chat__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: var(--r-control);
  background: var(--aubergine);
  color: var(--sheet);
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}

.chat__send:hover { background: var(--aubergine-deep); }

.chat__send:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.chat__disclaimer {
  margin-top: .6rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: .8rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ===== Melding ===== */
.msg--error { align-self: flex-start; }

.msg--error .msg__bubble {
  background: var(--notice-bg);
  color: var(--notice-ink);
  border: 1px solid #ecdcbb;
  border-left: 3px solid var(--notice-rule);
  border-radius: var(--r-sheet);
  font-family: var(--serif);
  max-width: 68ch;
}

/* ===== Schuifbalk ===== */
.chat__messages::-webkit-scrollbar { width: 8px; }
.chat__messages::-webkit-scrollbar-thumb {
  background: #c3bcca;
  border-radius: 4px;
}
.chat__messages::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); }

/* ===== Klein scherm ===== */
@media (max-width: 600px) {
  :root { --header-h: 60px; }
  .msg { max-width: 94%; }
  .header { padding: 0 1rem; }
  .header__brand { font-size: 1.15rem; }
  .header__subtitle { display: none; }
  .chat__messages { padding: 1.25rem .75rem .75rem; }
  .msg--bot .msg__bubble { font-size: .98rem; }
  .chip { font-size: .84rem; }
}

/* ===== Beweging beperken ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .msg { animation: none; }
}
