/* ============== */
/* === DYNBOT === */
/* ============== */

/* === Base === */
:root {
  /* Bubble / action styling (match your manual-decision-button look) */
  --action-bg: #f5f7ff;
  --action-text: #1c2a4b;
  --action-border: #cfd7ff;
  --action-radius: 14px;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.08);
  /* --chat-font-size: 1.25rem; */
  --chat-font-size: 1.4rem;

  /* layout helpers (JS updates --input-bar-h dynamically) */
  --input-bar-h: 72px;    /* fallback */
  --scroll-btn-gap: 8px; /* was 12px gap above input for the floating button */
}

#chat-container,
#chat-container .message,
#chat-container button,
#chat-container .user-question-bubble,
#chat-container .rag-box,
#chat-container .choices-buttons button,
#chat-container .topic-buttons button {
  font-size: var(--chat-font-size);
}

* { box-sizing: border-box; }

body {
  background: #fff;
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  height: 100vh;
  display: flex;
  letter-spacing: 0.02em;
  flex-direction: column;
}

/* === App Layout === */
#chat-container {
  position: relative;  /* anchor for the floating button */
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;    /* prevent overscroll glow */
}

/* wrapper for scroller (messages) */
#chat-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;       /* critical so the child scroller can shrink */
}

/* === Scrollable chat area === */
#chat-output {
  position: relative;
  overflow-y: auto;
  /* start collapsed; fade/expand when .expanded is added */
  max-height: 0;
  opacity: 0;
  transition: max-height 0.6s ease, opacity 0.6s ease;
  padding: 0 1rem;
  /* keep last lines visible above input bar */
  /* padding-bottom: calc(var(--input-bar-h) + 24px); */
  padding-bottom: 40px;
  overflow-anchor: none; 
  overscroll-behavior: auto;
}

#chat-output.expanded {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  opacity: 1;
  padding-top: 1rem;
}

.reply-spacer { 
  display:block; 
}

/* invisible tail spacer; just reserves height, never blocks clicks */
.reserve-tail {
  opacity: 0;
  pointer-events: none;
  display: block;
}

/* Messages */
.message {
  margin: 1rem 0;
  white-space: pre-wrap;
  padding-top: 30px;
  padding-bottom:20px;
  line-height: 1.5;
  border: 1px solid #777;
  border-radius: 50px;
  border-color: #031953;
  color: #222;
}

/* compact, centered loading bubble */
.message.is-loading{
  /* your tweaks */
  padding: 4px 10px;
  min-height: 90px;
  border-radius: 50px;
  font-size: 1.4em;
  white-space: normal;
  line-height: 1;

  /* make it a horizontal row */
  display: flex;
  flex-direction: row;       /* ⬅ force row, overrides any column rule */
  align-items: center;
  justify-content: flex-start;  /* 'left' is invalid; use flex-start */
  gap: 8px;
  flex-wrap: nowrap;         /* prevent wrapping */
}

/* prevent children from expanding to full width */
.message.is-loading > *{
  flex: 0 0 auto;           /* ⬅ don’t grow, don’t shrink into zero */
}

/* make sure the spinner isn’t a row hog */
.message.is-loading .spinner{
  display: inline-block;     /* ⬅ be a compact inline box */
  width: 14px;
  height: 14px;
  border-width: 2px;
}



.user { text-align: right; font-weight: bold; }

.assistant { 
  text-align: left;
  padding-left: 10px;
  font-size: 1.2rem;
}

.assistant p {
  font-size: 1.2rem;
}

/* Info text (optional hint above input) */
.info-text {
  background: #fff;
  color: #000;
  text-align: center;
  margin: 1vh 0 1.5vh;
  border-radius: 0;
  font-size: 2.0rem;
  font-weight: 500;
  padding-top: 10px;
  padding-bottom: 16px;
}

/* === Input Bar === */
#input-area {
  background: #fff;
  box-shadow: 0 -1px 5px rgba(0,0,0,0.05);
  z-index: 1;
  padding: 0.75rem 1rem;
}

#input-box {
  display: flex;
  align-items: flex-end;          /* align input & button baseline */
  /* background: rgb(248,248,248); */
  border: 3px solid #ccc;
  border-radius: 2rem;  /* was 1rem, then 0.00001*/
  border-color: #031953;
  padding: 0.5rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

#messageInput {
  flex: 1 1 auto;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Segoe UI', sans-serif;
  letter-spacing: 1px;
  font-weight: 500;
  min-height: 100px;
  font-size: 1.8rem;
  background: transparent;
  padding: 0.5rem;
  color: black;
  /* color: rgb(48,48,48) !important; */
  -webkit-text-fill-color: rgb(48,48,48) !important;
}

#send-button-wrapper,
.send-button-wrapper {
  display: flex;
  align-items: flex-end;
  padding-left: 0.5rem;
  padding-bottom: 0.25rem;
}

#sendButton {
  background-color: #031953;
  border: none;
  border-radius: 50%;
  width: 2.5rem; height: 2.5rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 0;
  position: relative;
}
#sendButton:hover { background-color: rgb(163,163,163); }

.send-icon svg {
  width: 22px; height: 22px;
  /* stroke: #fff; fill: none; */
  stroke: #fff; fill: none;  /* was #EEBE43  */
  display: block;
  margin-top: 2px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  /* border-top-color: #fff; */
  border-top-color:#EEBE43;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Topic & Choices Buttons === */
.topic-buttons {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin: 4vh 4vw 1rem;
  align-items: center; justify-content: center;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}
@media (max-width: 600px) {
  .topic-buttons { justify-content: flex-start; }
}

#topic-buttons.collapsed { max-height: 0; opacity: 0; overflow: hidden; }

.topic-buttons button,
.choices-buttons button {
  /* background: #020C20; */
  background: #031953;
  color: white;
  border: none;
  padding-top: 15px;
  padding-bottom: 15px;
  padding-left: 20px;
  padding-right: 20px;
  /* padding: 15px 15px; */
  border-radius: 30px; /* was 12px then 0 */
  cursor: pointer;
  font-size: 15px;
  letter-spacing: 1px;
  font-size: 15px;
}

.topic-buttons button:hover,
.choices-buttons button:hover { background: #cfcfcf; }

.choices-buttons {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin: 5vh 1rem 1rem;
  justify-content: center;
}
.choices-buttons button.selected {
  background-color: #8d8d8d !important;
  border: 1px solid #cfcfcf;
}

/* === RAG explanation box (optional) === */
.rag-box {
  /* background-color: #e6f0ff; */
  /* background-color: #020C20; */
  /* background-color: #031953; */
  background-color: #02113b;
  color: #fff;   /* was   EEBE43  */
  padding: 12px;
  padding-top: 30px;
  padding-bottom: 30px;
  border-radius: 50px;  /* was 6px then 0 */
  margin-top: 30px;
  line-height: 1.4;
}

/* === User Question Bubble (right-aligned) === */
.user-question-bubble {
  /* background: var(--action-bg); */
  background: #031953;
  color: white;
  /* color: var(--action-text); */
  border: 1px solid var(--action-border);
  border-radius: 30px;    /* was 18px then 3 */
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  max-width: min(75%, 680px);
  margin: 40px 8px 16px auto;  /* right aligned */
  line-height: 1.35;
  word-wrap: break-word;
}

.user-question-meta {
  font-size: 12px;
  color: #6b7280;
  text-align: right;
  margin: -10px 8px 12px auto;
  max-width: min(75%, 680px);
}

/* === “Scroll to end” floating button (circular, centered) ===
   Lives inside #chat-container (NOT inside the scroller) */
.scroll-to-end {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  /* bottom: calc(var(--input-bar-h) + var(--scroll-btn-gap)); */
  width: 44px; height: 44px;
  border-radius: 50%;
  display: none; /* toggled by JS */
  align-items: center; justify-content: center;
  /* background: #fff; */
  background-color: rgba(255, 255, 255, 0.5);
  /* backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); 
  /* border-color: rgba(0, 0, 0, 0.08); */
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 22px rgba(0,0,0,0.14);
  cursor: pointer;
      position: absolute;
    left: 50%;
    transform: translateX(-50%);
    /* bottom: calc(var(--input-bar-h) + var(--scroll-btn-gap)); */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    /* background: #fff; */
    background-color: rgba(255, 255, 255, 0.5);
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
    cursor: pointer;
    margin-bottom: 85px;
  /* z-index: 5; /* above input bar */
  bottom: calc(var(--input-bar-h) + var(--scroll-btn-gap)) !important;
  z-index: 2; /* above messages, below anything super-high */
}

.scroll-to-end svg { 
  width: 22px; 
  height: 22px;
  margin-top: 4px;
  /* transform: translateY(2px); */
}
.scroll-to-end:hover { filter: brightness(0.98); }
.scroll-to-end:focus { outline: 2px solid #c7d2fe; outline-offset: 2px; }

/* === Intro / Restart === */
#intro-wrapper {
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}
#intro-wrapper.collapsed { max-height: 0; opacity: 0; }

#restart-area {
  text-align: center;
  padding: 1rem 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#restart-area.visible { opacity: 1; }

#restartButton {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
  background-color: #e1e1e1;
  color: #fff;
  border: none;
  border-radius: 1.5rem;    /*  was 1.5rem then 0.00001  */
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.1);
  transition: background-color 0.2s ease;
}
#restartButton:hover { background-color: #adadad; }

/* === Optional: unify manual decision button look with bubbles === */
/*
.manual-decision-button {
  background: var(--action-bg);
  color: var(--action-text);
  border: 1px solid var(--action-border);
  border-radius: var(--action-radius);
}  */

/* Instructions copy tidy */
#instructions {
  font-size: 2.0rem;
  color: #000;
  font-weight: 500;
  margin-top: 20px;
  margin-bottom: 50px;
  margin-left: 0;
  margin-right: 0;
  padding: 0 10px;
  text-align: center;
  transition: opacity 1s ease;
}
#instructions.fade { opacity: 0; }

/* Start state: input directly below intro-wrapper */
#chat-container.start-mode #input-area {
  position: static;   /* flow directly after intro-wrapper */
  box-shadow: none;   /* optional: remove bottom bar look */
  margin: 1rem 0;     /* small spacing below topic buttons */
}

/* After first send (normal mode) */
#chat-container:not(.start-mode) #input-area {
  position: sticky;
  bottom: 0;
  width: 100%;
}

#chat-container:not(.start-mode) #chat-output{
  padding-bottom: 70px; /* calc(var(--input-bar-h) + 16px) !important; /* was 40px */
}

/* Start state: show input directly below intro; hide scroller */
#chat-container.start-mode #chat-wrapper {
  display: none;          /* prevents the middle flex child from taking space */
}

#chat-container.start-mode #input-area {
  position: static;       /* flow under intro-wrapper */
  box-shadow: none;       /* optional: less "bar" look at start */
  margin: 0.75rem 1rem 0; /* small spacing under the topic buttons */
}

.footer-wrap {
  margin-top: 24px;   /* ~2 line breaks above */
}

.quote-box {
  margin-bottom: 24px;  /* space below quote */
  padding: 10px 12px;
  border-left: 3px solid #ccd;
  font-style: italic;
  opacity: .9;
}

.rag-box .rag-quote {
  border-left: none !important;
  padding-left: 0;
  margin-left: 0;
  font-style: italic;         /* optional polish */
  opacity: .95;               /* optional polish */
}

.cta-box {
  margin-top: 24px;    /* extra space before CTA */
  line-height: 1.4;
  border-left: 3px solid #02113b;
  padding-left: 12px;
}

.cta-box a {
  font-weight: bold;
  text-decoration: none;
  color: #031953;
}

.cta-box a:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.02em; /* or try 0.5px */
  text-underline-offset: 5px;        /* moves the line a bit down = lighter feel */
  text-decoration-color: currentColor;
  text-decoration-skip-ink: auto;
}

/* === House of PM Referenzstory (box-in-the-box) === */
.rag-box .ref-empf { 
  text-align: left; 
  margin-top: 10px;
  font-size: 1.4em;
  font-weight: 600;
  margin-bottom: 0px;
}

/* FINAL override for the Referenzstory headline inside the rag box */
.rag-box p.ref-empf,
.rag-box p.ref-empf * {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important; /* handles WebKit gradient/clip cases */
}

/* if the label is a link or contains a link, force link states too */
.rag-box p.ref-empf a:link,
.rag-box p.ref-empf a:visited,
.rag-box p.ref-empf a:hover,
.rag-box p.ref-empf a:active {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

/* === House of PM Referenzstory (box-in-the-box) === */
.rag-box .ref-intro { 
  text-align: left; 
  margin-top: 20px;
  font-size: 1.4em;
  font-weight: 600;
  /* margin: 8px 2vw 0; */
}

.rag-box .ref-intro a {
  color: #EEBE43;  /* was   EEBE43  */
  text-decoration: underline;
  text-decoration-thickness: 0.02em; /* or try 0.5px */
  text-underline-offset: 5px;        /* moves the line a bit down = lighter feel */
  text-decoration-color: currentColor;
  text-decoration-skip-ink: auto;
  cursor: pointer;
}

/* FINAL override for the Referenzstory headline inside the rag box */
.rag-box p.ref-intro,
.rag-box p.ref-intro * {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important; /* handles WebKit gradient/clip cases */
}

/* if the label is a link or contains a link, force link states too */
.rag-box p.ref-intro a:link,
.rag-box p.ref-intro a:visited,
.rag-box p.ref-intro a:hover,
.rag-box p.ref-intro a:active {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

.rag-box .ref-box {
  margin-left: 1vw;
  margin-right: 1vw;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .35s ease, opacity .35s ease;
  overflow-anchor: none;
}
.rag-box .ref-box.open {
  max-height: none; /*200vh;  /* plenty for smooth expand */
  opacity: 1;
}

.ref-story { 
  line-height: 1.5; 
}

/*
.rag-box .ref-story-frame {
  border: 0px solid #EEBE43;  
  border: 16px solid #fff;
}
*/

/* existing globals — keep */
.ref-section {
  padding: 5px 0;
  border-top: 1px solid rgba(255,255,255,.15);
}
.ref-section:first-child {
  border-top: none;
}

/* scoped tweak for the framed story only */
.ref-story-frame > .ref-section:first-child {
  padding-top: 0;   /* removes the 5px gap at the very top */
  /* border-top already none via the global :first-child rule */
}

/* (optional) if the first child element has default top margin */
.ref-story-frame > .ref-section:first-child > :first-child {
  margin-top: 0;
}

/* optional label line inside a section */
.ref-section .ref-tag {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
  opacity: .9;
}

/* Tag-specific hooks (example; style freely per tag) */
.ref-titel   {
  display: block;
  background-color: white;
  font-size: 1.4em;
  color: black;
  padding-left: 10px;
  padding-top: 20px !important;
}

.ref-beschreibung-titel{
  background-color: white;
  color: black;
  padding-left: 10px;
}

.ref-beschreibung{
  background-color: #031953;
  color: white;
  padding-left: 10px;
}

.ref-beschreibung-highlight{
  background-color: white;
  color: black;
  padding-left: 10px;
}

.ref-beschreibung-finish{
  background-color: #031953;
  color: white;
  padding-left: 10px;
}

.ref-beitrag{
  background-color: white;
  color: black;
  padding-left: 10px;
}

.ref-zitat{
  background-color: #031953;
  color: white;
  padding-left: 10px;
}

.ref-subtitel{
  background-color: white;
  color: black;
  padding-left: 10px;
}
.ref-problem {
  background-color: white;
  color: black;
  padding-left: 10px;
}
.ref-loesung {
  background-color: white;
  color: black;
  padding-left: 10px;
}
.ref-ergebnis{
  background-color: white;
  color: black;
  padding-left: 10px;
}

/* Hide Einordnung block in the RAG box if it ever appears */
.rag-box .ref-section.ref-einordnung { display: none !important; }

/* Make the video responsive and give it breathing room */
.rag-box .ref-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  margin: 0 0 12px;               /* space below the video */
  border-radius: 12px;
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(0,0,0,.08));
  background: #000;               /* nice while loading */
}

/* Since a video now precedes the first section, use :first-of-type */
.rag-box .ref-story > .ref-section:first-of-type {
  padding-top: 0;
  border-top: none;
}

/* layout + spacing */
.ref-intro{
  display:flex;
  align-items:baseline;
  gap:.5ch;                 /* base spacing between items */
}

/* visual order: mark, intro text, chevron, link */
.ref-mark{ order:0; }
.ref-intro-text{ order:1; }
.ref-caret{ order:2; margin-left:.5ch; }  /* ← space on the LEFT of chevron */
.ref-open{ order:3; }

/* chevron content + flip based on the LINK state */
.ref-open[aria-expanded="false"] ~ .ref-caret::before { content:"»"; font-weight:600; }
.ref-open[aria-expanded="true"]  ~ .ref-caret::before { content:"«"; font-weight:600; }

/* optional: keep link tidy */
.ref-open{ white-space:nowrap; }


/* === Width control for Referenzstory inside the RAG box === */
.rag-box{
  /* one knob to rule width; tweak to taste */
  --ref-max: clamp(52ch, 58vw, 76ch);
}

/* keep the collapsible wrapper flush; the frame will add its own padding */
.rag-box .ref-box{
  margin-left: 0;     /* was 1vw – reset to avoid double inset */
  margin-right: 0;
}

/* the actual content column for the Referenzstory */
.rag-box .ref-box .ref-story-frame{
  /* max-width: var(--ref-max); */
  margin-inline: auto;                     /* center the column */
  /* padding-inline: min(2vw, 24px);       inner side breathing room */
  box-sizing: border-box;
}

/* sections live inside the frame: never spill wider than the column */
.rag-box .ref-section{
  max-width: 100%;
  margin-inline: auto;
}

/* safety: media should never overflow the column */
.rag-box .ref-section img,
.rag-box .ref-section video{
  max-width: 100%;
  height: auto;
  display: block;
}

.app-title{
  text-align:center;
  font-weight: 500;
  /* word-spacing: 10px; */
  letter-spacing: 3px;
  font-family: Nunito;
  font-size:4.3rem;           /* your existing size */
  line-height:1.1;         /* tweak if needed */
  margin-bottom: 0px;
}

/* tiny “TM-like” icon */
.tm-icon{
  width:0.9em;             /* scales with text size */
  height:auto;
  margin-left:0.25em;      /* gap from the text */
  vertical-align:middle;   /* baseline alignment first… */
  transform:translateY(-0.15em); /* …then lift it slightly */
  /* fine-tune: try -0.1em to -0.25em depending on look */
}

.rag-video-box{
  margin-top: 2rem;
  /* padding: 1rem; */
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  border-radius: var(--action-radius);
}
.rag-video-title{
  margin: 0 0 .5rem;
  font-size: 1rem;
  color: var(--action-text);
}
.rag-video{
  width: 100%;
  height: auto;
  /* max-height: 60vh; */
  display: block;
}

.choices-question{
  /* margin: .5rem 0 .25rem; */
  margin-top: 28px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 1.6rem;       
  /* color: var(--action-text, #1c2a4b); */
  letter-spacing: .1px;
}

/* tighten spacing to the buttons that follow */
.choices-question + .choices-buttons{
  margin-top: .25rem;
}

/* Badge under the input box */
#input-area .powered-by {
  display: block;           /* forces a new line under the input row */
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.2;
  color: black;
  letter-spacing: 0.02em;   /* matches your global preference */
  /* opacity: .6;              /* subtle in both light/dark */
  user-select: none;
  align-self: flex-start;   /* works if #input-area is flex */
  flex: 0 0 100%;           /* if #input-area is flex, span full width */
  order: 99;                /* ensure it sits last in a flex container */
  margin-left: 26px;
}

#input-area .powered-by a {
  color: inherit;
  text-decoration: none;
  color: black;
  font-weight: 600;
  /* border-bottom: 1px dotted currentColor; /* tiny hint without loud underline */
}
#input-area .powered-by a:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.02em; /* or try 0.5px */
  text-underline-offset: 5px;        /* moves the line a bit down = lighter feel */
  text-decoration-color: currentColor;
  text-decoration-skip-ink: auto;
}

/* 1) Theme tokens */
:root{
  --sb-track:  #f2f4f7;   /* track/background */
  --sb-thumb:  #bcc4d0;   /* thumb */
  --sb-hover:  #9aa6b2;   /* thumb on hover */
  --sb-size:   100px;      /* thickness */
}

/* 2) Attach to your scrollable container */
.scrollable{
  overflow: auto;

  /* Firefox */
  scrollbar-width: thin;                          /* auto | thin | none */
  scrollbar-color: var(--sb-thumb) var(--sb-track);

  /* Optional: avoid layout shift when the bar appears */
  scrollbar-gutter: stable both-edges;
}

/* 3) WebKit browsers (Chrome/Edge/Safari) */
.scrollable::-webkit-scrollbar{
  width: var(--sb-size);
  height: var(--sb-size);                         /* horizontal bars */
}
.scrollable::-webkit-scrollbar-track{
  background: var(--sb-track);
  border-radius: 999px;
}
.scrollable::-webkit-scrollbar-thumb{
  background: var(--sb-thumb);
  border-radius: 999px;
  border: 2px solid var(--sb-track);              /* creates a nice inset look */
}
.scrollable::-webkit-scrollbar-thumb:hover{
  background: var(--sb-hover);
}
.scrollable::-webkit-scrollbar-corner{
  background: transparent;                        /* removes corner square on two-axis scroll */
}

/* 4) Dark mode tweak (optional) */
@media (prefers-color-scheme: dark){
  :root{
    --sb-track:#0f1115;
    --sb-thumb:#3b4350;
    --sb-hover:#566075;
  }
}

/* 5) If you ever want to hide the bar but keep scrolling */
.no-scrollbar{
  scrollbar-width: none;                  /* Firefox */
}
.no-scrollbar::-webkit-scrollbar{
  display: none;                          /* WebKit */
}
