/**
 * Coresight Advance AI Search — front-end overlay styles.
 *
 * A full-screen light takeover that mirrors the site's existing AI search UI:
 * logo + breadcrumb + Close top bar, a large search field, an "AI Overview"
 * card, and a "Top reports matching" list of horizontal cards. Scoped under
 * .caais- / #caais-overlay-root so nothing bleeds into the theme. The accent is
 * the site red and is overridable via --caais-accent. Light only — it matches
 * the current search exactly and never flips to a dark theme.
 */

#caais-overlay-root {
	--caais-accent: #e4002b;
	--caais-bg: #f4f5f7;
	--caais-surface: #ffffff;
	--caais-fg: #16181d;
	--caais-muted: #6b7280;
	--caais-line: #e6e8ec;
	--caais-line-strong: #d8dbe0;
	--caais-mark: #ffe1e6;
	--caais-pill: #fde8ea;
	--caais-radius: 12px;
	display: none;
}
#caais-overlay-root.caais-visible { display: block; }

#caais-overlay-root *, #caais-overlay-root *::before, #caais-overlay-root *::after { box-sizing: border-box; }

.caais-shell {
	position: fixed; inset: 0; z-index: 2147480001;
	display: flex; flex-direction: column;
	background: var(--caais-bg); color: var(--caais-fg);
	font-family: inherit; line-height: 1.5;
	animation: caais-in .16s ease-out;
}
@keyframes caais-in { from { opacity: 0; } to { opacity: 1; } }

/* -------------------------------------------------------------------- */
/* Top bar: brand + breadcrumb (left), Close (right).                   */
/* -------------------------------------------------------------------- */
.caais-topbar {
	flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
	gap: 16px; height: 64px; padding: 0 clamp(16px, 4vw, 40px);
	background: var(--caais-surface); border-bottom: 1px solid var(--caais-line);
}
.caais-topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.caais-brand { display: inline-flex; align-items: center; text-decoration: none; }
.caais-logo { height: 30px; width: auto; display: block; }
.caais-brand-text { font-weight: 800; font-size: 16px; color: var(--caais-fg); letter-spacing: .01em; }
.caais-brand-sep { width: 1px; height: 28px; background: var(--caais-line-strong); display: inline-block; }
.caais-crumb { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; min-width: 0; }
.caais-crumb a { color: var(--caais-fg); text-decoration: none; }
.caais-crumb a:hover { color: var(--caais-accent); }
.caais-crumb-sep { color: #b9bdc6; display: inline-flex; }
.caais-crumb-cur { color: var(--caais-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.caais-close {
	flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
	font: inherit; font-size: 14px; font-weight: 600; color: var(--caais-fg);
	background: var(--caais-surface); border: 1px solid var(--caais-line-strong);
	padding: 8px 14px; border-radius: 8px; line-height: 1;
}
.caais-close:hover { background: var(--caais-bg); }

/* -------------------------------------------------------------------- */
/* Search band.                                                         */
/* -------------------------------------------------------------------- */
.caais-searchband { flex: 0 0 auto; background: var(--caais-bg); padding: clamp(14px, 3vw, 22px) clamp(16px, 4vw, 40px); position: relative; }
.caais-field {
	display: flex; align-items: center; height: 56px; padding: 0 12px 0 16px;
	background: var(--caais-surface); border: 1px solid var(--caais-line-strong); border-radius: var(--caais-radius);
}
.caais-field:focus-within { border-color: var(--caais-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--caais-accent) 16%, transparent); }
.caais-field-ico { color: var(--caais-muted); display: inline-flex; margin-right: 10px; flex: 0 0 auto; }
.caais-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; border: 0; outline: 0; background: transparent; color: var(--caais-fg); }
.caais-clear { flex: 0 0 auto; display: none; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: #eef0f3; color: var(--caais-muted); cursor: pointer; }
.caais-clear:hover { background: #e2e5ea; color: var(--caais-fg); }

.caais-suggest { position: absolute; left: clamp(16px, 4vw, 40px); right: clamp(16px, 4vw, 40px); margin-top: 8px; z-index: 5; background: var(--caais-surface); border: 1px solid var(--caais-line); border-radius: 10px; overflow: hidden; box-shadow: 0 12px 28px rgba(18,20,26,.12); }
.caais-suggest-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 14px; padding: 10px 16px; border: 0; background: transparent; color: var(--caais-fg); cursor: pointer; }
.caais-suggest-item svg { color: var(--caais-muted); flex: 0 0 auto; }
.caais-suggest-item:hover { background: var(--caais-bg); }
.caais-suggest-item mark, .caais-card-title mark { background: var(--caais-mark); color: var(--caais-accent); padding: 0 2px; border-radius: 3px; }

/* -------------------------------------------------------------------- */
/* Content.                                                             */
/* -------------------------------------------------------------------- */
.caais-content { flex: 1 1 auto; overflow-y: auto; padding: 4px clamp(16px, 4vw, 40px) 48px; }

.caais-card { background: var(--caais-surface); border: 1px solid var(--caais-line); border-radius: var(--caais-radius); }
.caais-overview-wrap { padding: 18px 22px; margin-bottom: 16px; }

.caais-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.caais-section-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; margin: 0; color: var(--caais-fg); }
.caais-reports-title { font-size: 20px; }
.caais-q { font-weight: 700; color: var(--caais-fg); }
.caais-spark { color: var(--caais-accent); display: inline-flex; }
.caais-count { color: var(--caais-muted); font-size: 14px; white-space: nowrap; }

.caais-copy { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; cursor: pointer; border: 0; background: transparent; color: var(--caais-muted); padding: 2px 4px; }
.caais-copy:hover { color: var(--caais-fg); }

.caais-overview { font-size: 16px; line-height: 1.7; color: var(--caais-fg); }
.caais-overview p { margin: 0 0 13px; }
.caais-overview p:last-child { margin-bottom: 0; }
.caais-overview a { color: var(--caais-accent); font-weight: 700; text-decoration: underline; }
.caais-overview .caais-cite { color: var(--caais-accent); font-size: .72em; font-weight: 700; vertical-align: super; margin-left: 1px; }
.caais-overview .caais-cite-link { cursor: pointer; text-decoration: none; }
.caais-overview .caais-cite-link:hover, .caais-overview .caais-cite-link:focus { text-decoration: underline; outline: none; }

/* Show more / less. */
.caais-overview-clamp { position: relative; }
.caais-clamped .caais-overview-clamp { max-height: 5.1em; overflow: hidden; }
.caais-clamped .caais-overview-clamp::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2em; background: linear-gradient(to bottom, rgba(255,255,255,0), var(--caais-surface)); pointer-events: none; }
.caais-expanded .caais-overview-clamp { max-height: none; overflow: visible; }
.caais-expanded .caais-overview-clamp::after { display: none; }
.caais-toggle-wrap { position: relative; display: flex; align-items: center; justify-content: center; margin-top: 12px; }
.caais-toggle-wrap::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--caais-line); }
.caais-toggle { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--caais-accent); background: var(--caais-surface); border: 1px solid var(--caais-line); border-radius: 20px; padding: 6px 14px; }
.caais-toggle:hover { background: var(--caais-bg); }

.caais-sources { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--caais-line); }
.caais-sources-label, .caais-follow-label { font-size: 12px; font-weight: 700; color: var(--caais-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.caais-sources-list { display: grid; gap: 6px; }
.caais-source { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--caais-accent); text-decoration: none; padding: 2px 4px; margin: 0 -4px; border-radius: 6px; transition: background .5s ease; }
.caais-source:hover { text-decoration: underline; }
.caais-source-n { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 5px; background: var(--caais-mark); color: var(--caais-accent); font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.caais-source-locked { color: var(--caais-muted); }
.caais-source-locked .caais-source-n { background: var(--caais-bg); color: var(--caais-muted); }
.caais-source-flash { background: var(--caais-mark); transition: background .15s ease; }

.caais-followups { margin-top: 16px; }
.caais-chip { font: inherit; font-size: 13px; cursor: pointer; border: 1px solid var(--caais-line); background: var(--caais-surface); color: var(--caais-fg); padding: 6px 12px; border-radius: 20px; margin: 0 6px 6px 0; }
.caais-chip:hover { border-color: var(--caais-accent); color: var(--caais-accent); }

/* Report cards. */
.caais-reports { display: grid; gap: 12px; }
.caais-report { display: flex; gap: 16px; padding: 16px; text-decoration: none; color: var(--caais-fg); transition: border-color .12s, box-shadow .12s; }
.caais-report:hover { border-color: var(--caais-line-strong); box-shadow: 0 6px 18px rgba(18,20,26,.07); }
.caais-thumb { flex: 0 0 auto; width: 150px; height: 112px; border-radius: 8px; overflow: hidden; background: #eef0f3; }
.caais-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.caais-thumb-empty { display: flex; align-items: center; justify-content: center; color: #b9bdc6; }
.caais-card-body { flex: 1 1 auto; min-width: 0; }
.caais-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.caais-date { color: var(--caais-muted); font-size: 13px; font-weight: 600; }
.caais-date:not(:last-child)::after { content: "|"; margin-left: 10px; color: var(--caais-line-strong); font-weight: 400; }
.caais-access, .caais-type { font-size: 12px; font-weight: 700; color: var(--caais-accent); background: var(--caais-pill); padding: 3px 9px; border-radius: 6px; }
.caais-card-title { font-size: 17px; font-weight: 700; line-height: 1.35; margin-bottom: 6px; color: var(--caais-fg); }
.caais-card-excerpt { color: var(--caais-muted); font-size: 15px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.caais-unlock { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--caais-accent); }

/* Events section (shown above the reports when the query is event-relevant). */
.caais-events-wrap { background: var(--caais-surface); border: 1px solid var(--caais-line); border-radius: var(--caais-radius); padding: 15px 18px 16px; margin-bottom: 16px; }
.caais-events-title { font-size: 17px; }
.caais-events-all { font-size: 13.5px; font-weight: 600; color: var(--caais-accent); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.caais-events-all:hover { text-decoration: underline; }
.caais-events { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(196px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.caais-event { display: flex; flex-direction: column; text-decoration: none; color: var(--caais-fg); min-width: 0; }
.caais-event-media { position: relative; height: 104px; border-radius: 8px; overflow: hidden; background: #eef0f3; }
.caais-event-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.caais-event-date { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; align-items: center; line-height: 1; background: var(--caais-surface); border-radius: 7px; padding: 5px 8px; box-shadow: 0 2px 8px rgba(18,20,26,.18); }
.caais-event-mon { font-size: 10px; font-weight: 800; letter-spacing: .04em; color: var(--caais-accent); text-transform: uppercase; }
.caais-event-day { font-size: 15px; font-weight: 800; color: var(--caais-fg); margin-top: 1px; }
.caais-event-cat { font-size: 11.5px; font-weight: 700; color: var(--caais-accent); margin: 9px 0 3px; line-height: 1.3; }
.caais-event-title { font-size: 14.5px; font-weight: 700; line-height: 1.3; color: var(--caais-fg); margin-bottom: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.caais-event-meta { font-size: 12.5px; color: var(--caais-muted); line-height: 1.4; }
.caais-event .caais-dot { color: var(--caais-line-strong); }
.caais-event-tags { display: flex; flex-direction: column; gap: 4px; margin-top: 5px; }
.caais-event-tag { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--caais-muted); line-height: 1.3; }
.caais-event-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: #eef0f3; }
.caais-event-tag-ico { display: inline-flex; align-items: center; justify-content: center; color: var(--caais-accent); flex: 0 0 auto; }
.caais-event-tag-attending .caais-event-tag-label { font-weight: 700; color: var(--caais-fg); }
.caais-event-more { margin-top: 10px; padding-top: 9px; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--caais-accent); border-top: 1px solid var(--caais-line); }
.caais-event:hover .caais-event-more { text-decoration: underline; }

/* Loading + spinner. */
.caais-loading, .caais-empty { font-size: 14px; color: var(--caais-muted); padding: 12px 2px; }
.caais-loading { display: flex; align-items: center; gap: 8px; }
.caais-thinking { display: flex; align-items: center; gap: 10px; color: var(--caais-muted); font-size: 14px; padding: 4px 0; }
.caais-spinner { display: inline-block; width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%; border: 2px solid var(--caais-line); border-top-color: var(--caais-accent); animation: caais-spin .7s linear infinite; }
.caais-spinner-sm { width: 14px; height: 14px; }
@keyframes caais-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .caais-spinner { animation-duration: 1.6s; } }

body.caais-noscroll { overflow: hidden; }

/* -------------------------------------------------------------------- */
/* Responsive.                                                          */
/* -------------------------------------------------------------------- */
@media (max-width: 719px) {
	.caais-topbar { height: 56px; }
	.caais-logo { height: 24px; }
	.caais-brand-sep, .caais-crumb { display: none; }
	.caais-close span { display: none; }
	.caais-close { padding: 8px 10px; }
	.caais-field { height: 50px; }
	.caais-overview-wrap { padding: 16px; }
	.caais-report { gap: 12px; padding: 12px; }
	.caais-thumb { width: 104px; height: 80px; }
	.caais-card-title { font-size: 16.5px; }
	.caais-card-excerpt { font-size: 14px; }
	.caais-overview { font-size: 15.5px; }
	.caais-reports-title { font-size: 17px; }
}
