/*
 * Warm, light styling: ivory and stone with a gold accent, echoing the
 * limestone and mudbrick palette of Diriyah rather than a generic chat widget.
 * Logical properties throughout (inline-start/end rather than left/right) so
 * the Arabic toggle flips the whole layout without a second stylesheet.
 * No web fonts: the stack resolves locally, so the UI renders offline.
 */

:root {
  --bg: #faf7f1;
  --bg-tint: #f3ebdf;
  --surface: #ffffff;
  --surface-2: #f6f1e8;
  --line: #e3dacb;
  --line-soft: #ece4d7;
  --ink: #241f18;
  --text: #322c23;
  --muted: #6b6354;
  --faint: #8d8475;
  --gold: #9a7536;
  --gold-deep: #7f6029;
  --gold-soft: #cdab72;
  --gold-wash: rgba(154, 117, 54, 0.08);
  --danger: #8f3b3b;
  --danger-bg: #fbf0ee;
  --danger-line: #eed6d2;

  --shadow-sm: 0 1px 2px rgba(70, 52, 22, 0.05);
  --shadow-md: 0 2px 6px rgba(70, 52, 22, 0.05), 0 12px 30px rgba(70, 52, 22, 0.07);
  --shadow-lg: 0 4px 10px rgba(70, 52, 22, 0.06), 0 20px 46px rgba(70, 52, 22, 0.09);

  --serif: Georgia, "Times New Roman", "Noto Naskh Arabic", serif;
  --sans: "Segoe UI", Tahoma, system-ui, -apple-system, "Noto Sans Arabic", sans-serif;

  --radius: 14px;
  --shell: 900px;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  background-image: radial-gradient(1000px 460px at 50% -6%, var(--bg-tint) 0%, transparent 72%);
  color: var(--text);
  font: 15.5px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--gold-wash);
  color: var(--ink);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  height: 100dvh;
  width: min(var(--shell), 100%);
  margin-inline: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  position: relative;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 24px;
  border-block-end: 1px solid var(--line-soft);
  background: linear-gradient(to bottom, rgba(250, 247, 241, 0.97), rgba(250, 247, 241, 0.86));
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

/* The logo is a full lockup (mark plus wordmark). Beside the title text only
   the architectural mark is wanted, so the artwork is zoomed and offset to
   crop the lettering out. */
.brand-logo {
  flex: none;
  width: 44px;
  height: 44px;
  background: url("/assets/logo.webp") no-repeat 50% 32% / 190% auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
  letter-spacing: 0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  cursor: default;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.is-ok {
  color: #3f6b4a;
  background: #eef5ef;
  border-color: #d7e7db;
}

/* A visitor ready to buy should never have to hunt for the phone number. */
.call-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--gold-deep);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: border-color 0.18s, box-shadow 0.18s, color 0.18s;
}

.call-btn svg {
  width: 14px;
  height: 14px;
  flex: none;
  stroke-width: 1.5;
}

.call-btn:hover {
  border-color: var(--gold-soft);
  box-shadow: var(--shadow-md);
  color: var(--gold);
}

.lang-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.lang-toggle button {
  background: transparent;
  border: 0;
  padding: 7px 13px;
  font-size: 12.5px;
  line-height: 1.2;
  color: var(--faint);
  letter-spacing: 0.04em;
  transition: color 0.15s, background 0.15s;
}

.lang-toggle button:hover {
  color: var(--ink);
}

.lang-toggle button.is-active {
  background: var(--gold-wash);
  color: var(--gold-deep);
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--faint);
  box-shadow: var(--shadow-sm);
  transition: color 0.15s, border-color 0.15s, box-shadow 0.18s;
}

.icon-btn:hover {
  color: var(--gold);
  border-color: var(--gold-soft);
  box-shadow: var(--shadow-md);
}

/* ------------------------------------------------------------------ thread */

.thread {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.thread::-webkit-scrollbar {
  width: 9px;
}

.thread::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid var(--bg);
}

/* ------------------------------------------------------------------- hero */

.hero {
  margin: auto;
  width: 100%;
  max-width: 680px;
  text-align: center;
  padding-block: 8px 4px;
  animation: rise 0.5s ease both;
}

/* The hero has room for the complete lockup, wordmark included. */
.hero-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  margin-block-end: 10px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 31px;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.hero-text {
  margin: 0 auto 30px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.7;
  max-width: 42ch;
  text-wrap: balance;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

/* Buttons centre their text by default, which made these read as form
   controls rather than cards. */
.prompt-grid button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  text-align: start;
  padding: 15px 15px 15px 17px;
  padding-inline: 17px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.prompt-grid button:hover {
  border-color: var(--gold-soft);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.prompt-kicker {
  grid-column: 1;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.prompt-text {
  grid-column: 1;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}

.prompt-arrow {
  grid-column: 2;
  grid-row: 1 / 3;
  width: 16px;
  height: 16px;
  color: var(--line);
  stroke-width: 1.6;
  transition: color 0.18s, transform 0.18s;
}

[dir="rtl"] .prompt-arrow {
  transform: scaleX(-1);
}

.prompt-grid button:hover .prompt-arrow {
  color: var(--gold-soft);
  transform: translateX(2px);
}

[dir="rtl"] .prompt-grid button:hover .prompt-arrow {
  transform: scaleX(-1) translateX(2px);
}

/* --------------------------------------------------------------- messages */

.row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: rise 0.28s ease both;
}

.row.user {
  justify-content: flex-end;
}

/* The brand mark identifies the assistant's turns. */
.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface) url("/assets/logo.webp") no-repeat 50% 30% / 180% auto;
  box-shadow: var(--shadow-sm);
  margin-block-start: 3px;
}

.bubble {
  max-width: min(78%, 60ch);
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
}

/* The client's own words anchor the thread in ink. */
.row.user .bubble {
  background: var(--ink);
  border-color: var(--ink);
  color: #f6f1e6;
  box-shadow: var(--shadow-md);
  border-start-end-radius: 4px;
}

.row.assistant .bubble {
  border-start-start-radius: 4px;
}

/* Arabic text reads right-to-left inside its own bubble. */
.bubble[dir="rtl"] {
  text-align: right;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble > :last-child {
  margin-block-end: 0;
}

.bubble ul,
.bubble ol {
  margin: 0 0 10px;
  padding-inline-start: 20px;
}

.bubble li {
  margin-block-end: 6px;
}

.bubble li::marker {
  color: var(--gold-soft);
}

.bubble strong {
  color: var(--ink);
  font-weight: 600;
}

.row.user .bubble strong {
  color: #fffdf8;
}

.bubble code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

.bubble a {
  color: var(--gold-deep);
  text-underline-offset: 3px;
}

/* ------------------------------------------------------------ agent trace */

.trace {
  align-self: flex-start;
  max-width: min(78%, 60ch);
  margin-inline-start: 44px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 10px 14px;
  animation: rise 0.28s ease both;
}

.trace summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.trace summary::-webkit-details-marker {
  display: none;
}

.trace summary::after {
  content: "";
  margin-inline-start: auto;
  width: 6px;
  height: 6px;
  border-inline-end: 1.4px solid var(--faint);
  border-block-end: 1.4px solid var(--faint);
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.trace[open] summary::after {
  transform: rotate(-135deg);
}

.trace-steps {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-block-start: 10px;
  padding-block-start: 10px;
  border-block-start: 1px solid var(--line);
}

.trace-steps span {
  display: block;
  padding-inline-start: 15px;
  position: relative;
}

.trace-steps span::before {
  content: "";
  position: absolute;
  inset-inline-start: 2px;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-soft);
}

.trace-steps .result {
  color: #574f42;
}

.spark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
  animation: pulse 1.2s ease-in-out infinite;
}

.trace.is-done .spark {
  animation: none;
  background: var(--gold-soft);
}

/* ---------------------------------------------------------------- typing */

.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 2px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-soft);
  animation: bounce 1.1s ease-in-out infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

/* ----------------------------------------------------------------- error */

.notice {
  align-self: flex-start;
  max-width: min(78%, 60ch);
  margin-inline-start: 44px;
  font-size: 13.5px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 11px;
  padding: 12px 15px;
  animation: rise 0.28s ease both;
}

/* A neutral note, such as a team member being about to reply. */
.notice.info {
  color: var(--gold-deep);
  background: var(--gold-wash);
  border-color: var(--line);
}

/* The team member's name on a reply they sent from the inbox. */
.staff-label {
  display: block;
  margin-block-end: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-deep);
}

/* ----------------------------------------------------------- scroll button */

.scroll-end {
  position: absolute;
  inset-block-end: 112px;
  inset-inline-end: 28px;
  width: 36px;
  height: 36px;
  padding: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: var(--shadow-lg);
  transition: color 0.15s, border-color 0.15s;
}

.scroll-end:hover {
  color: var(--gold);
  border-color: var(--gold-soft);
}

/* -------------------------------------------------------------- composer */

.composer-wrap {
  padding: 14px 24px 18px;
  background: linear-gradient(to top, var(--bg) 58%, rgba(250, 247, 241, 0));
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-inline: 18px 9px;
  padding-block: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.composer:focus-within {
  border-color: var(--gold-soft);
  box-shadow: var(--shadow-lg);
}

.composer textarea {
  flex: 1;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  resize: none;
  /* The script sizes the field; a native scrollbar here showed up as stray
     arrows beside the send button. */
  overflow-y: hidden;
  max-height: 168px;
  padding-block: 10px;
  line-height: 1.5;
  scrollbar-width: thin;
}

.composer textarea.is-scrolling {
  overflow-y: auto;
}

.composer textarea::placeholder {
  color: #9d9484;
}

.composer textarea:focus {
  outline: none;
}

.composer button {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 11px;
  border-radius: 50%;
  background: var(--gold);
  border: 0;
  color: #fffdf7;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
}

.composer button:hover:not(:disabled) {
  background: var(--gold-deep);
  transform: translateY(-1px);
}

.composer button:disabled {
  opacity: 0.38;
  cursor: default;
}

/* The arrow points the way the language reads. */
[dir="rtl"] .composer button svg {
  transform: scaleX(-1);
}

.disclaimer {
  margin: 11px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------- motion */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------- narrow */

@media (max-width: 760px) {
  .call-btn span {
    display: none;
  }

  .call-btn {
    padding: 8px;
  }

  .call-btn svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 620px) {
  .topbar,
  .thread,
  .composer-wrap {
    padding-inline: 15px;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .bubble,
  .trace,
  .notice {
    max-width: 88%;
  }

  .trace,
  .notice {
    margin-inline-start: 0;
  }

  .hero h1 {
    font-size: 25px;
  }

  .hero-logo {
    width: 115px;
    height: 115px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }
}

/* Short windows: tighten the hero so the starter cards stay in view. */
@media (max-height: 620px) {
  .hero-logo {
    display: none;
  }

  .hero h1 {
    font-size: 24px;
  }

  .hero-text {
    margin-block-end: 20px;
  }
}

/* Photos, videos and brochures the bot sends in the web chat. */
.bubble.chat-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  max-width: min(420px, 100%);
}

.chat-files img,
.chat-files video {
  display: block;
  width: 100%;
  border-radius: 8px;
}

.chat-files img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.chat-files video,
.chat-files .chat-file {
  grid-column: 1 / -1;
}
