/* Orb chat (contact page only). Loaded after site.css; only styles the chat box.
 * Orb image: /assets/world/orb-chat.webp (a 192px still cut from the home page orb poster). */
:root {
  --oc-navy: #0f1c3f;
  --oc-gold: #c9a24a;
  --oc-gold-ink: #8a6a1c;
  --oc-glow: rgba(47, 92, 255, 0.38);
}

/* ---------- Header ---------- */
.chatbox { position: relative; background: linear-gradient(180deg, #fbfbfd 0%, var(--mg-off) 100%); box-shadow: 0 18px 40px rgba(15, 28, 63, 0.06); }
.oc-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: rgba(255, 255, 255, 0.86); border-bottom: 1px solid var(--mg-line); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
.oc-head__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.oc-head__name { font-weight: 700; color: var(--oc-navy); letter-spacing: -0.01em; font-size: 0.98rem; }
.oc-head__status { display: inline-flex; align-items: center; gap: 6px; color: var(--mg-dim); font-family: var(--font-mg-mono); font-size: 0.74rem; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-head__status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--mg-accent); flex-shrink: 0; }
.chatbox[data-state="thinking"] .oc-head__status { color: var(--oc-gold-ink); }
.chatbox[data-state="thinking"] .oc-head__status::before { background: var(--oc-gold); animation: oc-blink 1s ease-in-out infinite; }
.oc-head__note { margin: 0 0 0 auto; font-size: 0.74rem; color: var(--mg-dim); text-align: right; max-width: 24ch; line-height: 1.35; }
@media (max-width: 480px) { .oc-head__note { display: none; } }

/* ---------- The orb ---------- */
.oc-orb { position: relative; display: inline-block; width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; }
.oc-orb--lg { width: 44px; height: 44px; }
.oc-orb img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; border-radius: 50%; filter: drop-shadow(0 3px 6px rgba(15, 28, 63, 0.18)); }
/* soft blue glow behind */
.oc-orb::before { content: ""; position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(circle, var(--oc-glow) 0%, rgba(47, 92, 255, 0) 68%); opacity: 0.35; transform: scale(0.85); transition: opacity 400ms ease, transform 400ms ease; }
/* thin gold ring that sweeps while thinking */
.oc-orb::after { content: ""; position: absolute; inset: -4px; z-index: 2; border-radius: 50%; opacity: 0; transition: opacity 300ms ease;
  background: conic-gradient(from 0deg, rgba(201, 162, 74, 0) 0deg, rgba(201, 162, 74, 0) 200deg, rgba(201, 162, 74, 0.95) 320deg, rgba(201, 162, 74, 0) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px)); }
.oc-orb.is-thinking::before { opacity: 1; animation: oc-pulse 1.5s ease-in-out infinite; }
.oc-orb.is-thinking::after { opacity: 1; animation: oc-spin 1.4s linear infinite; }
.oc-orb.is-thinking img { animation: oc-churn 3.2s linear infinite, oc-bright 1.5s ease-in-out infinite; }
.oc-orb.is-speaking::before { opacity: 0.7; transform: scale(1); animation: oc-pulse 2.6s ease-in-out infinite; }
.oc-orb.is-speaking img { animation: oc-churn 9s linear infinite; }
@keyframes oc-pulse { 0%, 100% { transform: scale(0.85); opacity: 0.55; } 50% { transform: scale(1.15); opacity: 1; } }
@keyframes oc-spin { to { transform: rotate(360deg); } }
@keyframes oc-churn { to { transform: rotate(360deg); } }
@keyframes oc-bright { 0%, 100% { filter: drop-shadow(0 3px 6px rgba(15, 28, 63, 0.18)) brightness(1); } 50% { filter: drop-shadow(0 0 8px rgba(47, 92, 255, 0.55)) brightness(1.12); } }
@keyframes oc-blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ---------- Log + rows ---------- */
.chat-log { scroll-behavior: smooth; overscroll-behavior: contain; min-height: 340px; }
.oc-row { display: flex; align-items: flex-end; gap: 10px; align-self: flex-start; max-width: 92%; min-width: 0; }
.oc-row .oc-orb { margin-bottom: 6px; }
.oc-row.is-cont .oc-orb:not(.is-thinking):not(.is-speaking) { visibility: hidden; }
.oc-row .msg.bot { max-width: 100%; min-width: 0; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(15, 28, 63, 0.04); }
.msg.user { overflow-wrap: anywhere; max-width: 85%; }
.oc-status { padding: 0.55rem 0.2rem; font-size: 0.88rem; color: var(--mg-dim); font-style: italic; }
.oc-status span { background: linear-gradient(90deg, var(--mg-dim) 0%, var(--mg-dim) 35%, var(--mg-accent) 50%, var(--mg-dim) 65%, var(--mg-dim) 100%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; animation: oc-shimmer 1.8s linear infinite; }
@keyframes oc-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.msg.is-typing .oc-typed::after, .oc-summary li.is-typing .oc-typed::after { content: ""; display: inline-block; width: 2px; height: 1.05em; margin-left: 2px; vertical-align: -0.18em; background: var(--mg-accent); animation: oc-blink 0.9s steps(2, start) infinite; }
.oc-fadein { animation: oc-in 260ms ease-out both; }
@keyframes oc-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Summary card ---------- */
.oc-summary { align-self: stretch; margin-left: 38px; padding: 16px 18px; background: #ffffff; border: 1px solid var(--mg-line); border-left: 3px solid var(--oc-gold); border-radius: 14px; box-shadow: 0 6px 20px rgba(15, 28, 63, 0.06); }
.oc-summary__eyebrow { margin: 0 0 10px; font-family: var(--font-mg-mono); font-size: 0.74rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--oc-gold-ink); }
.oc-summary ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: oc; }
.oc-summary li { position: relative; padding-left: 34px; font-size: 0.95rem; line-height: 1.5; color: var(--mg-ink); counter-increment: oc; min-height: 24px; }
.oc-summary li::before { content: counter(oc); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-mg-mono); font-size: 0.75rem; font-weight: 500; color: #ffffff; background: var(--oc-navy); box-shadow: inset 0 0 0 1.5px rgba(201, 162, 74, 0.85); }
.oc-summary li strong { color: var(--oc-navy); }

/* ---------- Inputs ---------- */
.chat-input-row { scroll-margin-bottom: calc(var(--mg-cookie-h, 0px) + 16px); }
.chat-input-row:empty { display: none; }
.oc-compose { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-row .oc-compose textarea { flex: 1; min-width: 0; min-height: 52px; max-height: 160px; resize: none; line-height: 1.45; }
.oc-compose .mg-cta-chat { min-height: 52px; min-width: 52px; flex-shrink: 0; }
.oc-hint { margin: 8px 2px 0; font-size: 0.78rem; color: var(--mg-dim); }
.choice-btns { padding-left: 38px; }
.choice-btn { text-align: left; }
.chat-input-row .mg-cta-chat { min-height: 48px; }
/* 16px stops iOS from zooming into fields */
.chat-input-row input[type="text"], .chat-input-row input[type="email"], .chat-input-row textarea { font-size: 16px; min-height: 48px; }
.consent { min-height: 44px; align-items: center; margin-bottom: 4px; }
.consent input[type="checkbox"] { width: 22px; height: 22px; margin: 0; }
.consent label { display: flex; align-items: center; min-height: 44px; padding: 6px 0; }
.oc-close { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--mg-line); font-size: 0.9rem; color: var(--oc-navy); font-weight: 500; display: flex; gap: 10px; align-items: center; line-height: 1.4; }
.oc-close .oc-orb { width: 22px; height: 22px; }

/* Keep the chat clear of the cookie banner while it is open. */
html.mg-cookie-open .mg-contact-grid { padding-bottom: var(--mg-cookie-h, 0px); }

/* ---------- Phones ---------- */
@media (max-width: 767px) {
  .chatbox { min-height: 0; }
  .oc-head { padding: 12px 16px; }
  .chat-log { min-height: 300px; max-height: min(520px, 62vh); max-height: min(520px, 62svh); padding: 16px 14px; }
  .oc-row { max-width: 100%; gap: 8px; }
  .oc-summary { margin-left: 0; padding: 14px; }
  .choice-btns { padding-left: 0; }
  .choice-btn { flex: 1 1 auto; }
  .chat-input-row { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-log { scroll-behavior: auto; }
  .oc-orb::before, .oc-orb::after, .oc-orb img, .oc-status span, .msg.is-typing .oc-typed::after, .oc-summary li.is-typing .oc-typed::after, .oc-fadein, .chatbox[data-state="thinking"] .oc-head__status::before { animation: none !important; }
  .oc-orb.is-thinking::before { opacity: 0.8; transform: scale(1); }
  .oc-orb.is-thinking::after { opacity: 0.6; }
  .oc-status span { color: var(--mg-dim); -webkit-text-fill-color: currentColor; background: none; }
}

/* ---------- v2: email gate + inline errors ---------- */
.oc-gate { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-family: var(--font-mg-mono); font-size: 0.76rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--oc-gold-ink); scroll-margin-top: 90px; }
.oc-gate__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--oc-gold); box-shadow: 0 0 0 4px rgba(201, 162, 74, 0.18); }
.oc-error { margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px; background: #fff8ec; border: 1px solid rgba(201, 162, 74, 0.55); color: var(--oc-navy); font-size: 0.92rem; line-height: 1.45; overflow-wrap: anywhere; scroll-margin-bottom: calc(var(--mg-cookie-h, 0px) + 16px); }
.oc-error a { color: var(--oc-navy); font-weight: 600; }
.oc-error[hidden] { display: none; }
.chat-final-actions { scroll-margin-bottom: calc(var(--mg-cookie-h, 0px) + 16px); }
