/* Lumen 0.3.5 — immersive UI: streaming reveal, orb states, bulb meter, claim vs record,
 * lesson cards, share-as-image sheet, Corporal+ settings, interactive charts.
 * Every animation here is switched off under prefers-reduced-motion (see the foot of the file
 * and the global rule in climate-ai.css). */

/* ---------- streaming reveal ---------- */
html body .tai .tai-rv-live { white-space: pre-wrap; }
html body .tai .tai-rv-w { opacity: 0; animation: tai-rv-in 260ms var(--tai-ease, ease-out) forwards; }
@keyframes tai-rv-in { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }

/* ---------- orb states: thinking (existing breathe) → answering (steady glow) → done (settle) ---------- */
html body .tai.tai-answering .tai-orb,
html body .tai .tai-answering .tai-orb {
	animation: tai-orb-answer 1.6s ease-in-out infinite;
	filter: drop-shadow(0 0 10px rgba(142,67,240,.75)) drop-shadow(0 0 22px rgba(94,200,255,.35));
}
@keyframes tai-orb-answer { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
html body .tai.tai-done .tai-orb,
html body .tai .tai-done .tai-orb { animation: tai-orb-done 900ms var(--tai-ease, ease-out) 1; }
@keyframes tai-orb-done {
	0% { filter: drop-shadow(0 0 16px rgba(255,214,120,.9)); transform: scale(1.06); }
	100% { filter: none; transform: scale(1); }
}

/* ---------- bulb meter (visitors) and slim bar (members) ---------- */
html body .tai .tai-bulbs { display: flex; gap: 8px; align-items: center; margin: 2px 0 6px; }
html body .tai .tai-bulb {
	position: relative; display: block; width: 14px; height: 20px;
	border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
	background: rgba(255,255,255,.12);
	transition: background var(--tai-t-slow, 320ms), box-shadow var(--tai-t-slow, 320ms);
}
html body .tai .tai-bulb::after {
	content: ""; position: absolute; left: 4px; right: 4px; bottom: -4px; height: 4px;
	border-radius: 0 0 3px 3px; background: rgba(255,255,255,.28);
}
html body .tai .tai-bulb.is-lit {
	background: radial-gradient(circle at 45% 38%, #fff6d6 0 18%, #ffd36b 45%, #f0a73a 100%);
	box-shadow: 0 0 10px rgba(255,205,100,.55);
	animation: tai-bulb-on 420ms ease-out both; animation-delay: calc(var(--i, 0) * 60ms);
}
html body .tai .tai-bulb.is-dimming { animation: tai-bulb-dim 900ms ease-out both; }
@keyframes tai-bulb-on { from { opacity: .3; } to { opacity: 1; } }
@keyframes tai-bulb-dim {
	0% { background: #ffd36b; box-shadow: 0 0 14px rgba(255,205,100,.8); }
	40% { background: #ffe39b; box-shadow: 0 0 6px rgba(255,205,100,.4); }
	100% { background: rgba(255,255,255,.12); box-shadow: none; }
}
html body .tai .tai-bulbs-note { margin: 0 0 8px; font-size: 11px; color: var(--tai-muted); }
html body .tai[data-theme="light"] .tai-bulb { background: rgba(21,14,31,.12); }
html body .tai[data-theme="light"] .tai-bulb::after { background: rgba(21,14,31,.25); }
html body .tai[data-theme="light"] .tai-bulb.is-lit { box-shadow: 0 0 8px rgba(230,160,40,.5); }
html body .tai .tai-usage-slim { height: 3px; }
html body .tai .tai-usage-slim i { transition: width var(--tai-t-slow, 320ms) var(--tai-ease, ease-out); }

/* ---------- claim vs record ---------- */
html body .tai .tai-claim-slot { margin: 10px 0 4px; }
html body .tai .tai-claim-btn {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 6px 12px; border-radius: 99px; cursor: pointer;
	font: 600 12px/1.2 var(--tai-font); color: var(--tai-ink);
	background: transparent; border: 1px solid var(--tai-line);
	transition: border-color var(--tai-t), background var(--tai-t);
}
html body .tai .tai-claim-btn:hover, html body .tai .tai-claim-btn:focus-visible { border-color: var(--tai-accent); background: rgba(142,67,240,.12); }
html body .tai .tai-claim {
	border: 1px solid var(--tai-line); border-radius: 14px; overflow: hidden;
	background: rgba(0,0,0,.18); animation: tai-rv-in 260ms ease-out both;
}
html body .tai[data-theme="light"] .tai-claim { background: rgba(255,255,255,.6); }
html body .tai .tai-claim-cols { display: grid; grid-template-columns: 1fr 1fr; }
html body .tai .tai-claim-c { padding: 12px 14px; }
html body .tai .tai-claim-myth { border-right: 1px solid var(--tai-line); }
html body .tai .tai-claim-h { margin: 0 0 4px; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--tai-muted); }
html body .tai .tai-claim-fact .tai-claim-h { color: var(--tai-good); }
html body .tai[data-theme="light"] .tai-claim-fact .tai-claim-h { color: #1c7a4f; }
html body .tai .tai-claim-t { margin: 0; font-size: 13.5px; line-height: 1.5; }
html body .tai .tai-claim-myth .tai-claim-t { color: var(--tai-muted); }
html body .tai .tai-claim-myth s { text-decoration-color: rgba(255,110,110,.7); text-decoration-thickness: 1.5px; }
html body .tai .tai-claim-foot {
	margin: 0; padding: 8px 14px; border-top: 1px solid var(--tai-line);
	font-size: 11.5px; color: var(--tai-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
html body .tai .tai-claim button.tai-claim-hide {
	box-shadow: none; min-height: 0; border-radius: 4px;
	margin-left: auto; background: none; border: 0; padding: 2px 4px; cursor: pointer;
	font: 600 11.5px var(--tai-font); color: var(--tai-muted); text-decoration: underline; text-underline-offset: 2px;
}
@media (max-width: 560px) {
	html body .tai .tai-claim-cols { grid-template-columns: 1fr; }
	html body .tai .tai-claim-myth { border-right: 0; border-bottom: 1px solid var(--tai-line); }
}

/* ---------- Learning Centre lesson cards ---------- */
html body .tai .tai-lessons { display: grid; gap: 8px; margin: 10px 0 4px; }
html body .tai a.tai-lesson {
	display: grid; grid-template-columns: 128px 1fr auto; gap: 12px; align-items: center;
	padding: 8px; border-radius: 14px; text-decoration: none; color: var(--tai-ink);
	border: 1px solid var(--tai-line); background: rgba(142,67,240,.08);
	transition: border-color var(--tai-t), transform var(--tai-t);
}
html body .tai a.tai-lesson:hover, html body .tai a.tai-lesson:focus-visible { border-color: var(--tai-accent); transform: translateY(-1px); }
html body .tai .tai-lesson-th {
	position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden;
	background: linear-gradient(135deg, #2a1746, #0f2a3d);
}
html body .tai .tai-lesson-th img { display: block; width: 100%; height: 100%; object-fit: cover; }
html body .tai .tai-lesson-play {
	position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
	border-radius: 50%; background: rgba(11,8,20,.72); color: #fff; font-size: 11px;
	display: flex; align-items: center; justify-content: center; padding-left: 2px; box-sizing: border-box;
}
html body .tai .tai-lesson-len {
	position: absolute; right: 5px; bottom: 5px; padding: 1px 5px; border-radius: 4px;
	background: rgba(0,0,0,.75); color: #fff; font-size: 10.5px; font-weight: 600;
}
html body .tai .tai-lesson-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
html body .tai .tai-lesson-kicker { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--tai-cyan); }
html body .tai .tai-lesson-members { color: #ffcf6b; }
html body .tai[data-theme="light"] .tai-lesson-members { color: #a5600a; }
html body .tai .tai-lesson-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
html body .tai .tai-lesson-meta { font-size: 11.5px; color: var(--tai-muted); }
html body .tai .tai-lesson-cta {
	padding: 7px 12px; border-radius: 99px; white-space: nowrap;
	font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(90deg, #8e43f0, #5b6cf0);
}
@media (max-width: 560px) {
	html body .tai a.tai-lesson { grid-template-columns: 104px 1fr; }
	html body .tai .tai-lesson-cta { grid-column: 1 / -1; text-align: center; }
}

/* ---------- share-as-image glyph on the action row ---------- */
html body .tai .tai-act.tai-act-ico { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; min-width: 32px; }
html body .tai .tai-act.tai-act-ico svg { display: block; }

/* ---------- share sheet ---------- */
html body .tai .tai-share {
	position: fixed; inset: 0; z-index: 2147483000; display: flex; align-items: center; justify-content: center;
	padding: 16px; background: rgba(6,4,12,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
	animation: tai-rv-in 200ms ease-out both;
}
html body .tai .tai-share-box {
	width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box;
	padding: 16px; border-radius: 18px; background: var(--tai-panel); color: var(--tai-ink);
	border: 1px solid var(--tai-line); box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
html body .tai .tai-share-top { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
html body .tai .tai-share-h { margin: 0; font-size: 16px; font-weight: 700; }
html body .tai .tai-share-x { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--tai-line); background: transparent; color: var(--tai-ink); font-size: 20px; line-height: 1; cursor: pointer; }
html body .tai .tai-share-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 12px; }
html body .tai .tai-share-seg button {
	display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; cursor: pointer;
	border-radius: 10px; border: 1px solid var(--tai-line); background: transparent; color: var(--tai-ink);
	font: 600 12.5px var(--tai-font);
}
html body .tai .tai-share-seg button small { font-size: 10.5px; font-weight: 500; color: var(--tai-muted); }
html body .tai .tai-share-seg button.is-on { border-color: var(--tai-accent); background: rgba(142,67,240,.16); }
html body .tai .tai-share-prev {
	display: flex; align-items: center; justify-content: center; min-height: 220px; max-height: 52vh;
	border-radius: 12px; background: rgba(0,0,0,.25); overflow: hidden;
}
html body .tai .tai-share-prev img { display: block; max-width: 100%; max-height: 52vh; width: auto; height: auto; border-radius: 8px; }
html body .tai .tai-share-wait { margin: 0; font-size: 13px; color: var(--tai-muted); }
html body .tai .tai-share-note { margin: 10px 0 12px; font-size: 11.5px; color: var(--tai-muted); text-align: center; }
html body .tai .tai-share-btns { display: flex; gap: 8px; }
html body .tai .tai-share-btns button { flex: 1; padding: 11px 14px; border-radius: 99px; cursor: pointer; font: 700 13.5px var(--tai-font); }
html body .tai .tai-share-dl { border: 1px solid var(--tai-line); background: transparent; color: var(--tai-ink); }
html body .tai .tai-share-btns .tai-cta { border: 0; color: #fff; background: linear-gradient(90deg, #8e43f0, #5b6cf0); }

/* ---------- Corporal+ settings in the menu ---------- */
/* the menu grows with Settings at its foot: keep it on screen and let it scroll on short / mobile screens */
html body .tai .tai-menu { max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
html body .tai .tai-prefs { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--tai-line); }
html body .tai .tai-prefs-open { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
html body .tai .tai-prefs-open::after { content: "›"; margin-left: auto; transition: transform var(--tai-t); }
html body .tai .tai-prefs-open[aria-expanded="true"]::after { transform: rotate(90deg); }
html body .tai .tai-prefs-panel { padding: 8px 2px 2px; }
html body .tai .tai-pref-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
html body .tai .tai-pref-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
html body .tai .tai-switch-ui {
	position: relative; flex: 0 0 auto; width: 34px; height: 20px; border-radius: 99px;
	background: rgba(255,255,255,.18); transition: background var(--tai-t);
}
html body .tai[data-theme="light"] .tai-switch-ui { background: rgba(21,14,31,.18); }
html body .tai .tai-switch-ui::after {
	content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
	background: #fff; transition: transform var(--tai-t);
}
html body .tai .tai-pref-row input:checked + .tai-switch-ui { background: var(--tai-accent); }
html body .tai .tai-pref-row input:checked + .tai-switch-ui::after { transform: translateX(14px); }
html body .tai .tai-pref-row input:focus-visible + .tai-switch-ui { outline: 2px solid var(--tai-cyan); outline-offset: 2px; }
html body .tai .tai-prefs-note { margin: 6px 0 0 44px; font-size: 11.5px; color: var(--tai-muted); line-height: 1.45; }

/* ---------- interactive charts ---------- */
html body .tai .tai-chart-head { display: flex; align-items: flex-start; gap: 8px; }
html body .tai .tai-chart-head .tai-chart-title { flex: 1; }
html body .tai .tai-chart-expand {
	flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center;
	border: 1px solid var(--tai-line); background: transparent; color: var(--tai-muted);
}
html body .tai .tai-chart-expand:hover, html body .tai .tai-chart-expand:focus-visible { color: var(--tai-ink); border-color: var(--tai-accent); }
html body .tai .tai-chart-plot { position: relative; outline: none; border-radius: 8px; touch-action: pan-y; }
html body .tai .tai-chart-plot:focus-visible { box-shadow: 0 0 0 2px var(--tai-cyan); }
html body .tai .tai-chart-tip {
	position: absolute; z-index: 3; top: 0; left: 0; pointer-events: none; min-width: 90px; max-width: 220px;
	padding: 7px 9px; border-radius: 9px; font-size: 12px; line-height: 1.35;
	background: rgba(11,8,20,.94); color: #f4ecff; border: 1px solid rgba(255,255,255,.12);
	box-shadow: 0 8px 22px rgba(0,0,0,.35);
}
html body .tai .tai-chart-tip[hidden] { display: none; }
html body .tai .tai-chart-tip-label { display: block; font-weight: 700; margin: 0 0 2px; }
html body .tai .tai-chart-tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
html body .tai .tai-chart-tip-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
html body .tai .tai-chart-live { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html body .tai .tai-chart-guide { stroke: currentColor; stroke-width: 1; stroke-dasharray: 3 3; opacity: .45; }
html body .tai .tai-chart-band { fill: rgba(142,67,240,.12); }
html body .tai .tai-chart-mark { stroke: var(--tai-panel, #150e1f); stroke-width: 2; }
html body .tai .tai-chart-data { margin: 8px 0 0; font-size: 12px; }
html body .tai .tai-chart-data summary { cursor: pointer; color: var(--tai-muted); font-weight: 600; }
html body .tai .tai-chart-table-wrap { overflow-x: auto; margin: 6px 0 0; -webkit-overflow-scrolling: touch; }
html body .tai .tai-chart-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
html body .tai .tai-chart-table th, html body .tai .tai-chart-table td { padding: 4px 8px; border-bottom: 1px solid var(--tai-line); text-align: right; white-space: nowrap; }
html body .tai .tai-chart-table th:first-child, html body .tai .tai-chart-table td:first-child { text-align: left; }
/* draw-in */
html body .tai .tai-chart-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: tai-chart-draw 900ms var(--tai-ease, ease-out) 120ms forwards; }
@keyframes tai-chart-draw { to { stroke-dashoffset: 0; } }
html body .tai .tai-chart-bar { transform-box: fill-box; transform-origin: 0 100%; animation: tai-chart-grow 600ms var(--tai-ease, ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
html body .tai .tai-chart-hbar-bar { transform-origin: 0 50%; animation-name: tai-chart-grow-x; }
@keyframes tai-chart-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes tai-chart-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
/* full-screen view */
html.tai-chart-modal-open, html.tai-chart-modal-open body { overflow: hidden; }
html body .tai .tai-chart-modal {
	position: fixed; inset: 0; z-index: 2147483000; display: flex; align-items: center; justify-content: center;
	padding: 16px; background: rgba(6,4,12,.8); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
html body .tai .tai-chart-modal-box {
	position: relative; width: min(1100px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box;
	padding: 18px; border-radius: 18px; background: var(--tai-panel); color: var(--tai-ink); border: 1px solid var(--tai-line);
}
html body .tai .tai-chart-modal .tai-chart { margin: 0; border: 0; background: transparent; }
html body .tai .tai-chart-modal .tai-chart-svg { max-height: 62vh; }
html body .tai .tai-chart-close {
	position: absolute; top: 10px; right: 10px; z-index: 4; width: 36px; height: 36px; border-radius: 50%;
	border: 1px solid var(--tai-line); background: var(--tai-panel); color: var(--tai-ink); font-size: 20px; cursor: pointer;
}

/* ---------- sidebar chats: latest only, dropdown arrow for the full list ---------- */
html body .tai .tai-chats-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
html body .tai .tai-chats-head .tai-side-label { flex: 1; }
html body .tai .tai-chats-toggle {
	display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; min-width: 32px; height: 26px; padding: 0 6px 0 8px;
	border-radius: 99px; border: 1px solid var(--tai-line); background: transparent; color: var(--tai-muted);
	font: 600 11px var(--tai-font); cursor: pointer; transition: color var(--tai-t), border-color var(--tai-t);
}
html body .tai .tai-chats-toggle[hidden] { display: none; }
html body .tai .tai-chats-toggle:hover, html body .tai .tai-chats-toggle:focus-visible { color: var(--tai-ink); border-color: var(--tai-accent); }
html body .tai .tai-chats-toggle svg { transition: transform var(--tai-t) var(--tai-ease, ease-out); }
html body .tai .tai-chats-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
html body .tai .tai-chats li[hidden] { display: none; }
html body .tai .tai-chats.is-collapsed { flex: 0 0 auto; }

/* ---------- reduced motion: show everything at once ---------- */
@media (prefers-reduced-motion: reduce) {
	html body .tai .tai-rv-w, html body .tai .tai-claim, html body .tai .tai-share { animation: none !important; opacity: 1 !important; filter: none !important; }
	html body .tai .tai-chart-line { stroke-dasharray: none; stroke-dashoffset: 0; animation: none !important; }
	html body .tai .tai-chart-bar { animation: none !important; transform: none !important; }
	html body .tai .tai-bulb, html body .tai .tai-orb { animation: none !important; transition: none !important; }
}

/* ---------- visitor sign-up card: lessons are a membership benefit ---------- */
html body .tai .tai-limit-members-note { margin: 10px 0 0; font-size: 12px; line-height: 1.45; color: var(--tai-muted); }

/* 0.3.6: tappable glossary explainers on jargon (first use in an answer). */
html body .tai .tai-gloss { position: relative; display: inline; cursor: help; border-bottom: 1px dotted currentColor; text-decoration: none; outline: none; }
html body .tai .tai-gloss:focus-visible { outline: 2px solid var(--tai-accent, #f5c542); outline-offset: 2px; border-radius: 2px; }
html body .tai .tai-gloss-tip { display: none !important; }
html body .tai .tai-gloss.is-open { background: rgba(245,197,66,.14); border-radius: 2px; }
.tai-gloss-pop { position: fixed; z-index: 100000; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; background: #111; color: #f4f4f4; border: 1px solid rgba(255,255,255,.14); font: 400 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-align: left; box-shadow: 0 8px 24px rgba(0,0,0,.4); pointer-events: none; }
.tai-gloss-pop[hidden] { display: none; }
