/* ============================================================
   FIKRA — live chat page
   Reuses the variables and components from ../style.css
   ============================================================ */

.chat-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(36px, 4.4vw, 56px) 0 clamp(32px, 3.6vw, 44px);
  background: var(--blue);
  color: var(--paper);
}

.chat-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(244, 241, 234, 0.4) 1.3px, transparent 1.4px);
  background-size: 16px 16px;
  opacity: 0.22;
  -webkit-mask-image: radial-gradient(circle at 82% 30%, #000 0%, transparent 64%);
  mask-image: radial-gradient(circle at 82% 30%, #000 0%, transparent 64%);
}

.chat-hero .wrap {
  position: relative;
  z-index: 1;
}

.chat-hero h1 {
  margin: 18px 0 18px;
  font-size: clamp(52px, 8vw, 112px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.chat-hero .lead {
  max-width: 64ch;
  color: rgba(244, 241, 234, 0.88);
}

.chat-hero .lead strong { color: var(--paper); font-weight: 600; }

.chat-hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 26px;
  color: rgba(244, 241, 234, 0.82);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-hero-facts span::before {
  content: "◆";
  margin-right: 8px;
  color: var(--pink);
}

/* ---------- chat panel ---------- */

.chat-section {
  padding: clamp(48px, 6vw, 80px) 0;
  background: var(--ink);
}

.chat-shell {
  max-width: 940px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line-light);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}

.chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-dark);
  background: #e9e5d9;
}

.chat-id {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #0e8a45;
  box-shadow: 0 0 8px rgba(14, 138, 69, 0.65);
}

.chat-tag {
  padding: 3px 7px;
  border: 1px solid rgba(5, 5, 7, 0.32);
  font-family: var(--pixel);
  font-size: 7.5px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.chat-clear {
  padding: 4px 0;
  border: 0;
  background: none;
  color: rgba(5, 5, 7, 0.66);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.chat-clear:hover { color: var(--ink); }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 260px;
  max-height: 58vh;
  overflow-y: auto;
  padding: clamp(18px, 3vw, 28px);
  scroll-behavior: smooth;
}

.chat-log:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 100%;
}

.msg-user { align-items: flex-end; }
.msg-bot { align-items: flex-start; }

.msg-meta {
  color: rgba(5, 5, 7, 0.6);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bubble {
  max-width: min(78%, 620px);
  padding: 13px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.62;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg-user .bubble {
  border-bottom-right-radius: 4px;
  background: var(--blue);
  color: var(--paper);
}

.msg-bot .bubble {
  border-bottom-left-radius: 4px;
  background: #e9e5d9;
  color: var(--ink);
}

.msg-bot .bubble.error {
  border: 1px solid rgba(5, 5, 7, 0.28);
  background: #ffe3dd;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(5, 5, 7, 0.55);
  animation: fikra-blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes fikra-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- suggestions ---------- */

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 clamp(18px, 3vw, 28px) 16px;
}

.chat-suggestions button {
  padding: 8px 12px;
  border: 1px solid rgba(5, 5, 7, 0.26);
  border-radius: 999px;
  background: transparent;
  color: rgba(5, 5, 7, 0.8);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.chat-suggestions button:hover {
  border-color: var(--ink);
  background: rgba(5, 5, 7, 0.05);
  color: var(--ink);
}

/* ---------- composer ---------- */

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px clamp(18px, 3vw, 28px);
  border-top: 1px solid var(--line-dark);
  background: #e9e5d9;
}

.chat-composer textarea {
  flex: 1;
  min-height: 46px;
  max-height: 140px;
  padding: 12px 14px;
  border: 1px solid rgba(5, 5, 7, 0.28);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
}

.chat-composer textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.chat-composer .btn {
  padding: 12px 20px;
}

.chat-composer .btn:disabled {
  opacity: 0.55;
  transform: none;
  cursor: wait;
}

.chat-status {
  margin: 0;
  padding: 10px clamp(18px, 3vw, 28px) 14px;
  border-top: 1px solid rgba(5, 5, 7, 0.1);
  background: #e9e5d9;
  color: rgba(5, 5, 7, 0.68);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.chat-status[data-state="busy"] { color: var(--blue); }
.chat-status[data-state="error"] { color: var(--red-deep); }

.chat-noscript {
  margin: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--line-dark);
  background: var(--pink);
  color: var(--ink);
  font-size: 13px;
}

/* ---------- hidden state ---------- */

.chat-composer[hidden],
.chat-suggestions[hidden],
.chat-clear[hidden] { display: none; }

/* ---------- how it works ---------- */

.chat-how {
  padding: clamp(56px, 7vw, 96px) 0;
  background: var(--paper);
  color: var(--ink);
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 28px;
  border: 1px solid var(--line-dark);
  background: var(--line-dark);
}

.how-grid article {
  padding: 24px;
  background: var(--paper);
}

.how-grid .n {
  display: block;
  margin-bottom: 18px;
  color: var(--blue);
  font-family: var(--pixel);
  font-size: 10px;
  font-weight: 400;
}

.how-grid h3 {
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.how-grid p {
  margin: 0;
  color: rgba(5, 5, 7, 0.74);
  font-size: 13.5px;
  line-height: 1.6;
}

.chat-how .fine { margin-top: 22px; }

/* ---------- notice + fallback ---------- */

.chat-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  max-width: 940px;
  margin: 0 auto 16px;
  padding: 16px 18px;
  border: 1px solid rgba(5, 5, 7, 0.25);
  border-left: 4px solid var(--blue);
  background: #e9e5d9;
  color: var(--ink);
}

.chat-notice strong {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-family: var(--pixel);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-notice p {
  max-width: 72ch;
  margin: 0;
  color: rgba(5, 5, 7, 0.84);
  font-size: 12.5px;
  line-height: 1.6;
}

.chat-notice > a {
  flex: none;
  padding-top: 2px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-fallback {
  margin: 0 clamp(18px, 3vw, 28px) 14px;
  padding: 14px 16px;
  border: 1px solid rgba(5, 5, 7, 0.25);
  background: #ffe3dd;
  color: var(--ink);
}

.chat-fallback p {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

.chat-fallback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-fallback .btn {
  padding: 9px 14px;
  font-size: 9.5px;
}

/* ---------- limits ---------- */

.chat-top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-limits-link {
  color: rgba(5, 5, 7, 0.72);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-limits-link:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-limits {
  padding: clamp(56px, 7vw, 96px) 0;
  background: var(--pink);
  color: var(--ink);
}

.chat-limits .eyebrow { color: var(--ink); }
.chat-limits h2 { max-width: 16ch; }
.chat-limits .lead { color: rgba(5, 5, 7, 0.8); }

.limits-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 32px;
  border: 1px solid rgba(5, 5, 7, 0.28);
  background: rgba(5, 5, 7, 0.28);
}

.limit-card {
  padding: 22px;
  background: var(--pink);
}

.limit-card .n {
  display: block;
  margin-bottom: 16px;
  font-family: var(--pixel);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.limit-card h3 {
  margin-bottom: 8px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.limit-card p {
  margin: 0;
  color: rgba(5, 5, 7, 0.8);
  font-size: 13.5px;
  line-height: 1.6;
}

.limits-cta {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: center;
  gap: 28px;
  margin-top: 32px;
  padding: clamp(22px, 3vw, 32px);
  background: var(--ink);
  color: var(--paper);
}

.limits-cta .limits-cta-kicker {
  margin: 0 0 8px;
  color: var(--pink);
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.limits-cta h3 {
  margin: 0 0 8px;
  color: var(--paper);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}

.limits-cta p {
  margin: 0;
  color: rgba(244, 241, 234, 0.78);
  font-size: 13.5px;
  line-height: 1.6;
}

.limits-cta .cta-row {
  justify-content: flex-end;
  margin-top: 0;
}

.chat-limits .fine {
  color: rgba(5, 5, 7, 0.92);
  opacity: 1;
}

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .how-grid { grid-template-columns: 1fr; }
  .limits-grid { grid-template-columns: 1fr 1fr; }
  .limits-cta { grid-template-columns: 1fr; }
  .limits-cta .cta-row { justify-content: flex-start; }
}

@media (max-width: 680px) {
  .chat-hero h1 { font-size: clamp(44px, 14vw, 72px); }
  .chat-log { min-height: 240px; max-height: 46vh; padding: 18px; }
  .bubble { max-width: 88%; font-size: 14px; }
  .chat-shell { border-radius: 16px; }
  .chat-top { padding: 12px 16px; }
  .chat-id { font-size: 8.5px; }
  .chat-tag { display: none; }
  .chat-top-actions { gap: 10px; }
  .limits-grid { grid-template-columns: 1fr; }
  .chat-suggestions { padding: 0 16px 14px; }
  .chat-composer { padding: 12px 16px; }
  .chat-composer textarea { font-size: 16px; }
  .chat-status { padding: 10px 16px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; opacity: 0.6; }
  .chat-log { scroll-behavior: auto; }
}

/* ---------- contrast fixes for the red / paper palette ---------- */

.chat-hero { color: #fff; }
.chat-hero .lead { color: rgba(255, 255, 255, 0.94); }
.chat-hero-facts { color: rgba(255, 255, 255, 0.92); }
.chat-hero .btn-outline-light { color: #fff; border-color: rgba(255, 255, 255, 0.7); }
.chat-hero .btn-outline-light:hover { border-color: #fff; background: rgba(255, 255, 255, 0.12); }

.chat-notice strong { color: var(--red-deep); }
.how-grid .n { color: var(--red-deep); }
.msg-user .bubble { background: var(--red-deep); color: var(--paper); }
.chat-status[data-state="busy"] { color: var(--red-deep); }
