/* =========================
   BASE LAYOUT
   ========================= */

html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background-color: var(--color-background);
}

main.demo-stage {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-20);
  padding: var(--space-18) var(--space-20) calc(var(--space-28) + env(safe-area-inset-bottom));
}


/* =========================
   NAVBAR FIX
   ========================= */

.navbar {
  position: relative;
  z-index: 10;
}


/* =========================
   INTRO
   ========================= */

.demo-intro {
  width: min(100%, 560px);
  margin: 0 auto;
  margin-top: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  animation: panelIn 0.55s ease both;
}

.demo-intro h1 {
  color: var(--color-text-strong);
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.demo-intro p {
  color: var(--color-text);
  font-size: var(--fs-lg);
  line-height: 1.25;
  max-width: 34ch;
}


/* =========================
   DEVICE SHELL
   ========================= */

.device-shell {
  width: min(100%, 680px);
  max-width: 92vw;
  margin: 0 auto;
  animation: panelIn 0.6s ease 0.05s both;
  /* ensure the device doesn't exceed available viewport height */
  max-height: calc(100vh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-frame {
  position: relative;
  padding: 14px;
  border-radius: 42px;
  background: linear-gradient(180deg, rgba(27, 37, 51, 0.96), rgba(18, 26, 38, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 26px 80px rgba(15, 23, 42, 0.18),
    0 8px 24px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* make frame and screen use available shell height */
.device-frame {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

.device-shell .device-frame > .device-screen {
  height: 100%;
}

.device-topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-16);
  min-height: 54px;
  padding-bottom: 0;
  position: relative;
}

.device-camera {
  display: none;
}

.device-activity {
  display: none;
}

.device-topbar::before {
  /* hidden per request */
  display: none;
}

.device-topbar::after {
  /* hidden per request */
  display: none;
}

.device-screen {
  background: var(--neutral-100);
  border-radius: 20px; /* rounded white area to fit within frame */
  padding: var(--space-20) var(--space-28);
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  width: 100%;
  /* prefer a portrait tablet ratio but keep a height fallback for smaller screens */
  aspect-ratio: 3 / 4;
  height: clamp(520px, 70svh, 760px);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.28) transparent;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

/* If viewport height is small, reduce the shell max-height so device scales to fit */
@media (max-height: 800px) {
  .device-shell { max-height: calc(100vh - 160px); }
  .device-screen { height: clamp(480px, 64svh, 640px); }
  main.demo-stage { padding-top: var(--space-12); padding-bottom: var(--space-12); }
}

@media (min-height: 1000px) {
  main.demo-stage { justify-content: center; }
  .device-shell { max-height: calc(100vh - 260px); }
}

/* Responsive tuning: smaller widths use a shorter height and fallback from aspect-ratio */
@media (max-width: 900px) {
  .device-shell {
    width: min(100%, 560px);
  }
  .device-screen {
    aspect-ratio: auto;
    height: clamp(520px, 68vh, 700px);
    padding: var(--space-16) var(--space-20);
  }
}

@media (max-width: 600px) {
  .device-shell {
    width: 100%;
    padding: 0 12px;
  }
  .device-frame {
    border-radius: 26px;
    padding: 10px;
  }
  .device-screen {
    border-radius: 14px;
    padding: 12px;
    height: clamp(480px, 60vh, 640px);
  }
  #chat-options button {
    font-size: 0.95rem;
    padding: 14px 16px;
  }
}

/* hide home indicator line */
.device-screen::after { display: none; }

/* end-mode: when end screen is shown, allow chat-window to expand */
#chat-window.end-mode {
  height: auto !important;
  max-height: none !important;
}

.device-screen::-webkit-scrollbar {
  width: 8px;
}

.device-screen::-webkit-scrollbar-track {
  background: transparent;
}

.device-screen::-webkit-scrollbar-thumb {
  background-color: rgba(15, 23, 42, 0.28);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

.device-screen::-webkit-scrollbar-thumb:hover {
  background-color: rgba(15, 23, 42, 0.4);
}

#scenario-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}


/* =========================
   INSTRUCTION
   ========================= */

#instruction {
  background: transparent;
  padding: var(--space-8) 0 0;
  border-radius: 0;
  font-weight: var(--fw-semibold);
  border-left: 0;
}

#instruction::before {
  content: attr(data-step-title);
  display: block;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-8);
  color: var(--neutral-500);
  text-align: center;
}


/* =========================
   CHAT WINDOW
   ========================= */

#chat-window {
  height: 196px;
  max-height: none;
  overflow-y: auto;
  padding: var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  overflow-y: auto;

  background: var(--neutral-200);
  border-radius: 14px;
}


/* =========================
   CHAT BUBBLES
   ========================= */

.chat-message {
  padding: 9px 20px;
  border-radius: 999px;
  max-width: 80%;
  font-size: var(--fs-base);
  line-height: 1.375;
  animation: messageIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  will-change: transform, opacity;
}

/* gebruiker */
.chat-user {
  background: var(--primary-purple-400, #c55cab);
  color: var(--neutral-100);
  align-self: flex-end;
}

/* andere */
.chat-other {
  background: var(--neutral-300);
  color: var(--color-text-strong);
  align-self: flex-start;
  border: 0;
}

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

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* =========================
   TYPING INDICATOR
   ========================= */

.typing {
  display: flex;
  gap: var(--space-4);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--neutral-500);
  border-radius: var(--radius-full);
  animation: blink 1s infinite ease-in-out, pulseDot 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

@keyframes pulseDot {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1px) scale(1.15); }
}


/* =========================
   INTERACTION
   ========================= */

#interaction-section {
  width: 100%;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  gap: var(--space-12);

  margin-top: var(--space-16); 
}

#chat-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-8); 
}


/* opties → gebruik secondary stijl */
#chat-options button {
  width: 100%;
}


/* stop/restart → primary stijl */
#chat-stop,
#chat-restart {
  width: 100%;
}

#chat-options button,
#chat-stop,
#chat-restart {
  height: 50px;
  border-radius: 12px;
  font-size: 18px;
  letter-spacing: 0.2px;
  box-shadow: none;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    filter 0.18s ease;
}

#chat-options button {
  background: var(--secondary-whale, #1f4b63);
  color: var(--neutral-100);
  border: none;
}

#chat-stop {
  background: var(--secondary-blue-100, #d2e7f0);
  color: var(--secondary-blue-600, #064660);
  border: none;
}

#chat-restart {
  background: var(--secondary-blue-100, #d2e7f0);
  color: var(--secondary-blue-600, #064660);
  border: none;
}

@media (hover: hover) and (pointer: fine) {

  #chat-options button:hover {
    transform: translateY(-3px) scale(1.01);
    filter: brightness(1.04);
  }

  #chat-stop:hover,
  #chat-restart:hover {
    transform: translateY(-3px) scale(1.01);
    filter: brightness(1.03);
  }

  #chat-options button:active,
  #chat-stop:active,
  #chat-restart:active {
    transform: translateY(0);
    filter: brightness(0.98);
  }
}


/* =========================
   EINDSCHERM
   ========================= */

.end-screen {
  background: var(--neutral-100);
  border-radius: var(--radius-lg);
  padding: var(--space-24);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  box-shadow: 0 8px 20px rgba(6, 70, 96, 0.08);
}

.end-screen h2 {
  color: var(--color-text-strong);
}

.end-screen p {
  color: var(--color-text);
}


/* =========================
   CTA SECTIE
   ========================= */

.demo-cta {
  max-width: 560px;
  margin: var(--space-24) auto var(--space-48);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  animation: panelIn 0.6s ease 0.1s both;
}

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

.demo-cta h2 {
  color: var(--color-text-strong);
}

.demo-cta p {
  color: var(--color-text);
  max-width: 60ch;
  margin: 0 auto;
}

.cta-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  margin-top: var(--space-16);
}


/* =========================
   RESPONSIVE
   ========================= */

@media (min-width: 768px) {

  .cta-buttons {
    flex-direction: row;
    justify-content: center;
  }
}

@media (max-width: 767px) {

  main.demo-stage {
    justify-content: flex-start;
    padding-top: var(--space-24);
    gap: var(--space-16);
  }

  .demo-intro {
    margin-top: 0;
    padding-inline: var(--space-8);
  }

  .device-shell {
    width: min(100%, 560px);
  }

  .device-frame {
    padding: 10px;
    border-radius: 32px;
  }

  .device-screen {
    height: clamp(620px, 76svh, 700px);
    padding: var(--space-12) var(--space-20);
    border-radius: 12px; /* keep rounded corners on small screens */
  }

  #interaction-section {
    margin-top: var(--space-8);
    padding-bottom: var(--space-8);
  }

  .demo-cta {
    margin-top: var(--space-32);
  }
}

@media (max-width: 480px) {

  .device-screen {
    height: clamp(580px, 74svh, 660px);
  }

  .device-frame {
    padding: 8px;
    border-radius: 28px;
  }

  .device-topbar {
    min-height: 48px;
  }
}

/* Wider screen padding for device interior */
@media (min-width: 1100px) {
  .device-screen { padding: var(--space-20) var(--space-28); }
}
@media (min-width: 1400px) {
  .device-screen { padding: var(--space-24) var(--space-36); }
}

@media (prefers-reduced-motion: reduce) {

  .demo-intro,
  .device-shell,
  .demo-cta,
  .chat-message,
  .typing-dot,
  #chat-options button,
  #chat-stop,
  #chat-restart {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Additional demo fixes: clipping, wide padding, and button interactions --- */

/* Clip inner screen so content cannot escape rounded frame */
.device-frame { overflow: hidden; }

/* Restore larger horizontal padding on wide viewports so demo doesn't touch edges */
@media (min-width: 1100px) {
  main.demo-stage { padding-left: 48px; padding-right: 48px; }
}
@media (min-width: 1400px) {
  main.demo-stage { padding-left: 80px; padding-right: 80px; }
}

/* Hover and focus styles for demo buttons (clear visible effect) */
#chat-options button:hover,
#chat-stop:hover,
#chat-restart:hover,
#chat-options button:focus-visible,
#chat-stop:focus-visible,
#chat-restart:focus-visible {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 6px 18px rgba(8, 40, 56, 0.08);
  filter: brightness(1.03);
  outline: none;
}

/* Slightly stronger active feedback */
#chat-options button:active,
#chat-stop:active,
#chat-restart:active {
  transform: translateY(0) scale(0.995);
  box-shadow: none;
}

/* Ensure device-screen never visually overflows its rounded container */
.device-screen { box-sizing: border-box; }



