/* MAQASA — editorial, private-banking palette. Warm ink, ivory, copper hairlines, linen. */
:root {
  --ink: #1B1A17;
  --ink-2: #22201C;
  --ink-3: #3A362F;
  --ivory: #F4EFE6;
  --ivory-78: rgba(244, 239, 230, 0.78);
  --ivory-55: rgba(244, 239, 230, 0.55);
  --ivory-30: rgba(244, 239, 230, 0.30);
  --copper: #B08D3C;
  --bronze: #8A6A2F;
  --linen: #E9E1D3;
  --linen-2: #DED4C2;
  --rule-dark: rgba(34, 32, 28, 0.16);
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --arabic: "Noto Kufi Arabic", "Tajawal", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
html[lang="ar"] body { font-family: var(--arabic); }
button { font: inherit; color: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 1px solid var(--copper); outline-offset: 4px; }

/* Small-caps label style used across the page */
.caps, .status, .laila-role, .mode-btn, .btn, .lang-toggle {
  font-family: var(--sans);
  font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.24em; text-transform: uppercase;
}
html[lang="ar"] .status, html[lang="ar"] .laila-role, html[lang="ar"] .mode-btn, html[lang="ar"] .btn {
  font-family: var(--arabic); letter-spacing: 0; text-transform: none; font-size: 14px;
}

/* ── Background ─────────────────────────────────────────── */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--ink); }
.bg-poster, .bg-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(0.55) sepia(0.18) brightness(0.92) contrast(1.02);
}
.bg-video { opacity: 0; transition: opacity 3.2s ease-in-out; }
.bg-video.is-on { opacity: 1; }
.bg-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(27, 26, 23, 0.72) 0%, rgba(27, 26, 23, 0.56) 32%, rgba(27, 26, 23, 0.60) 68%, rgba(27, 26, 23, 0.90) 100%),
    radial-gradient(120% 100% at 50% 50%, rgba(27, 26, 23, 0) 40%, rgba(27, 26, 23, 0.45) 100%);
}
.reduced .bg-video { display: none; }

/* ── Top bar ────────────────────────────────────────────── */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(26px, env(safe-area-inset-top)) clamp(16px, 5vw, 64px) 0;
}
.status { display: inline-flex; align-items: center; gap: 14px; color: var(--ivory-78); }
.status::before { content: ""; width: 28px; height: 1px; background: var(--copper); }

.lang-toggle {
  display: inline-flex; align-items: center; gap: 12px;
  background: none; border: 0; padding: 6px 0; color: var(--ivory-55);
}
.lang-toggle span { padding-bottom: 3px; border-bottom: 1px solid transparent; transition: color .3s, border-color .3s; }
.lang-toggle .lt-ar { font-family: var(--arabic); letter-spacing: 0; text-transform: none; font-size: 13.5px; }
html[lang="en"] .lt-en, html[lang="ar"] .lt-ar { color: var(--ivory); border-bottom-color: var(--copper); }
.lang-toggle:hover span { color: var(--ivory); }
.lt-sep { width: 1px; height: 12px; background: var(--ivory-30); padding: 0 !important; border: 0 !important; }

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative; z-index: 1; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 32px 16px 28px;
}
.logo {
  width: min(500px, 80vw); height: auto;
  opacity: 0; animation: fade 2.2s var(--ease) .1s forwards;
}
.rule { display: flex; align-items: center; gap: 12px; margin: clamp(26px, 4.5vh, 44px) 0 clamp(22px, 3.5vh, 34px); }
.rule::before, .rule::after { content: ""; width: clamp(48px, 9vw, 110px); height: 1px; background: var(--copper); opacity: .8; }
.rule span { width: 5px; height: 5px; background: var(--copper); transform: rotate(45deg); }

.headline {
  margin: 0; max-width: 26ch;
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(36px, 5.4vw, 74px); line-height: 1.06; letter-spacing: -0.005em;
  color: var(--ivory);
  opacity: 0; animation: fade 2.2s var(--ease) .4s forwards;
}
html[lang="ar"] .headline { font-family: var(--arabic); font-weight: 500; font-size: clamp(28px, 4.2vw, 54px); line-height: 1.55; max-width: 20ch; }
.subline {
  margin: clamp(16px, 2.4vh, 24px) 0 0; max-width: 54ch;
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: clamp(19px, 1.7vw, 23px); line-height: 1.45; color: var(--ivory-78);
  opacity: 0; animation: fade 2.2s var(--ease) .7s forwards;
}
html[lang="ar"] .subline { font-family: var(--arabic); font-style: normal; font-weight: 400; font-size: clamp(15px, 1.35vw, 18px); line-height: 1.9; }
.cta {
  display: flex; gap: clamp(22px, 3vw, 40px); flex-wrap: wrap; align-items: center; justify-content: center;
  margin-top: clamp(30px, 5vh, 52px);
  opacity: 0; animation: fade 2.2s var(--ease) 1s forwards;
}
@keyframes fade { to { opacity: 1; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 52px; padding: 0 30px; border-radius: 0;
  background: none; color: var(--ivory);
  transition: background .4s var(--ease), color .4s var(--ease), border-color .4s var(--ease);
}
.btn-primary { border: 1px solid var(--copper); }
.btn-primary:hover { background: rgba(176, 141, 60, 0.14); }
.btn-primary .arrow { color: var(--copper); letter-spacing: 0; transition: transform .4s var(--ease); }
.btn-primary:hover .arrow { transform: translateX(4px); }
html[dir="rtl"] .btn-primary .arrow { transform: scaleX(-1); }
html[dir="rtl"] .btn-primary:hover .arrow { transform: scaleX(-1) translateX(4px); }
.cta-talk { display: inline-flex; align-items: center; gap: 16px; }
.cta-avatar {
  position: relative; flex: none; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%;
  background: var(--ink-2);
}
.cta-avatar video {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; border-radius: 50%; display: block;
  filter: saturate(0.8) sepia(0.14) brightness(0.95);
}
.cta-avatar::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid var(--copper);
  animation: ringBreathe 4.5s ease-in-out infinite;
}
@keyframes ringBreathe { 0%, 100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.07); opacity: .45; } }
.cta-avatar:hover::after { opacity: 1; }
.btn-link {
  min-height: 44px; padding: 0 2px; border: 0;
  color: var(--ivory-78);
  background-image: linear-gradient(var(--copper), var(--copper));
  background-size: 100% 1px; background-position: 0 calc(100% - 10px); background-repeat: no-repeat;
}
.btn-link:hover { color: var(--ivory); }

.foot {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px;
  padding: 20px 16px max(24px, env(safe-area-inset-bottom));
  font-size: 12.5px; color: var(--ivory-55); letter-spacing: .03em; text-align: center;
}
.foot-sep { width: 1px; height: 12px; background: var(--ivory-30); }

/* ── LAiLA takeover ─────────────────────────────────────── */
.laila {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(27, 26, 23, 0.52);
  backdrop-filter: blur(8px) saturate(0.8); -webkit-backdrop-filter: blur(8px) saturate(0.8);
  opacity: 0; transition: opacity .6s var(--ease);
}
.laila[hidden] { display: none; }
.laila.is-open { opacity: 1; }
.laila-inner {
  position: relative; height: 100%; max-width: 1160px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(250px, 340px) 1fr; gap: clamp(24px, 4vw, 64px);
  padding: clamp(64px, 9vh, 88px) clamp(16px, 4vw, 48px) clamp(24px, 5vh, 56px);
  transform: translateY(10px); transition: transform .7s var(--ease);
}
.laila.is-open .laila-inner { transform: none; }
.laila-close {
  position: absolute; top: clamp(12px, 2.5vh, 24px); right: clamp(12px, 3vw, 30px); z-index: 3;
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; color: var(--ivory-78);
  transition: color .3s;
}
html[dir="rtl"] .laila-close { right: auto; left: clamp(12px, 3vw, 30px); }
.laila-close:hover { color: var(--copper); }

.laila-side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.portrait { position: relative; width: clamp(190px, 22vw, 280px); aspect-ratio: 1; }
.portrait::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 1px solid rgba(176, 141, 60, 0.55);
}
.portrait-video {
  position: relative; width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  filter: saturate(0.8) sepia(0.14) brightness(0.93);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 60%, rgba(0,0,0,.7) 66%, transparent 71%);
          mask-image: radial-gradient(circle at 50% 50%, #000 60%, rgba(0,0,0,.7) 66%, transparent 71%);
}
.laila-id { text-align: center; }
.laila-name { font-family: var(--serif); font-size: 36px; font-weight: 500; letter-spacing: .04em; line-height: 1.1; color: var(--ivory); }
.ar-name { font-family: var(--arabic); font-size: 21px; color: var(--copper); font-weight: 400; margin-inline-start: 8px; letter-spacing: 0; }
.laila-role { color: var(--ivory-55); margin-top: 10px; }

.mode-switch { display: flex; gap: 26px; border: 0; }
.mode-btn { border: 0; background: none; padding: 8px 0 7px; color: var(--ivory-55); border-bottom: 1px solid transparent; transition: color .3s, border-color .3s; }
.mode-btn:hover { color: var(--ivory); }
.mode-btn.is-active { color: var(--ivory); border-bottom-color: var(--copper); }
.progress { width: min(220px, 70%); height: 1px; background: var(--ivory-30); overflow: hidden; }
.progress[hidden] { display: none; }
.progress-bar { height: 100%; width: 0; background: var(--copper); transition: width .6s var(--ease); }

/* Frosted linen panel */
.laila-chat {
  min-height: 0; display: flex; flex-direction: column;
  background: rgba(233, 225, 211, 0.93);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: var(--ink-2);
  border-top: 2px solid var(--copper);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 30px clamp(18px, 3vw, 36px) 12px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }
.thread::-webkit-scrollbar { width: 6px; } .thread::-webkit-scrollbar-thumb { background: rgba(34,32,28,.18); }
.msg { max-width: 84%; font-size: 15.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; animation: msgIn .5s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.bot { align-self: flex-start; color: var(--ink-2); padding-inline-start: 16px; border-inline-start: 1px solid var(--copper); }
html[lang="ar"] .msg { font-size: 15px; line-height: 1.9; }
.msg.me { align-self: flex-end; background: var(--ink-2); color: var(--ivory); padding: 10px 16px; }
.msg.err { border-inline-start-color: #9A3B2E; color: #6E2A20; }
.typing { display: inline-flex; gap: 6px; align-items: center; height: 20px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--bronze); animation: blink 1.3s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.review { align-self: stretch; max-width: 100%; border: 1px solid var(--rule-dark); border-top: 1px solid var(--copper); background: rgba(244, 239, 230, 0.6); padding: 20px 20px 8px; animation: msgIn .5s var(--ease); }
.review h3 { margin: 0 0 12px; font-family: var(--serif); font-weight: 500; font-size: 24px; color: var(--ink); }
html[lang="ar"] .review h3 { font-family: var(--arabic); font-size: 17px; }
.review dl { margin: 0; display: grid; grid-template-columns: max-content 1fr auto; gap: 0 18px; font-size: 14px; }
.review dt, .review dd, .review .edit { padding: 9px 0; border-top: 1px solid var(--rule-dark); }
.review dt { color: rgba(34,32,28,.6); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; align-self: stretch; display: flex; align-items: center; }
html[lang="ar"] .review dt { letter-spacing: 0; font-size: 13px; }
.review dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); }
.review .edit { background: none; border: 0; border-top: 1px solid var(--rule-dark); color: var(--bronze); font-size: 13px; padding-inline: 0; text-align: end; text-decoration: underline; text-decoration-color: rgba(138,106,47,.45); text-underline-offset: 4px; }
.review .edit:hover { color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px clamp(18px, 3vw, 36px) 14px; }
.chips:empty { display: none; }
.chip {
  border: 1px solid rgba(34,32,28,.28); background: transparent; border-radius: 0;
  padding: 8px 14px; font-size: 13.5px; color: var(--ink-2);
  transition: border-color .3s, background .3s, color .3s;
}
.chip:hover { border-color: var(--bronze); background: rgba(176,141,60,.10); }
.chip.primary { background: var(--ink-2); border-color: var(--ink-2); color: var(--ivory); }
.chip.primary:hover { background: var(--ink); }
.chip.quiet { border-color: transparent; color: var(--bronze); text-decoration: underline; text-decoration-color: rgba(138,106,47,.45); text-underline-offset: 4px; padding-inline: 6px; }
.chip.quiet:hover { background: none; color: var(--ink); }

.composer { display: flex; gap: 12px; align-items: center; margin: 0 clamp(18px, 3vw, 36px); padding: 10px 0; border-top: 1px solid rgba(34,32,28,.22); position: relative; }
.composer-input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--ink); font: inherit; font-size: 16px; padding: 10px 0;
}
.composer-input::placeholder { color: rgba(34,32,28,.45); }
.composer-send {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--copper); background: transparent; color: var(--bronze);
  transition: background .3s, color .3s;
}
html[dir="rtl"] .composer-send svg { transform: scaleX(-1); }
.composer-send:hover { background: var(--ink-2); color: var(--ivory); border-color: var(--ink-2); }
.composer-send:disabled { opacity: .4; cursor: default; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.fine { margin: 0; padding: 4px clamp(18px, 3vw, 36px) 14px; font-size: 11.5px; color: rgba(34,32,28,.5); }

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 820px) {
  .laila-inner { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 14px; padding: max(16px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .laila-side { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 10px 16px; padding-inline-end: 52px; }
  .portrait { width: 72px; }
  .portrait::after { inset: -5px; }
  .laila-id { text-align: start; }
  .laila-name { font-size: 28px; }
  .ar-name { font-size: 17px; }
  .laila-role { margin-top: 2px; font-size: 10px; }
  .mode-switch { width: 100%; gap: 22px; }
  .mode-btn { white-space: nowrap; letter-spacing: .16em; font-size: 11px; }
  .progress { width: 100%; }
  .laila-close { top: max(16px, env(safe-area-inset-top)); }
  .thread { padding: 20px 16px 8px; }
  .msg { max-width: 92%; font-size: 15px; }
  .chips { padding: 6px 16px 10px; max-height: 136px; overflow-y: auto; }
  .composer { margin: 0 16px; }
  .fine { padding: 2px 16px 12px; }
  .review { padding: 16px 16px 6px; }
  .review dl { grid-template-columns: 1fr auto; }
  .review dt { grid-column: 1 / -1; padding-bottom: 0; }
  .review dd { border-top: 0; padding-top: 2px; }
  .review .edit { border-top: 0; padding-top: 2px; }
}
@media (max-width: 480px) {
  .top { padding-top: max(20px, env(safe-area-inset-top)); }
  .status::before { width: 18px; }
  .cta { flex-direction: column; gap: 14px; width: 100%; max-width: 320px; }
  .cta-talk { width: 100%; }
  .cta-avatar { width: 48px; height: 48px; }
  .btn-primary { flex: 1; }
  .foot { flex-direction: column; gap: 4px; }
  .foot-sep { display: none; }
}
@media (max-height: 560px) and (min-width: 821px) {
  .portrait { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .logo, .headline, .subline, .cta { opacity: 1; }
  .bg-video { display: none; }
}
