/**
 * Ask The Expert - frontend styling for the real, wired panel.
 *
 * Deliberately layered ON TOP of the theme's own .da-expert-demo/
 * .da-expert-field/.da-expert-submit rules (main.css) rather than
 * duplicating them - this file only styles what did NOT already exist in
 * the theme (the disabled "coming soon" look, the response timeline, the
 * accordion, citation cards, rating buttons) and overrides the small
 * number of theme rules that were specifically styled for the old
 * disabled state (dashed borders, not-allowed cursor, muted submit
 * button). Enqueued with a dependency on the theme's own stylesheet so
 * these overrides always load after it - see class-frontend-renderer.php.
 * Uses ONLY the theme's own existing --da-* custom properties - no new
 * color/spacing tokens are introduced.
 *
 * @package Digi_Analogi_Ask_Expert
 */

/* ---- Live field state (overrides the old disabled/dashed look) ---- */

.da-expert-field input,
.da-expert-field textarea {
	cursor: text;
	border-style: solid;
	border-color: var(--da-border);
	color: var(--da-paper);
	transition: border-color var(--da-transition), background var(--da-transition);
}

.da-expert-field input::placeholder,
.da-expert-field textarea::placeholder {
	color: #959ba6;
	opacity: 1;
}

.da-expert-field input:hover,
.da-expert-field textarea:hover {
	border-color: var(--da-border-strong);
}

.da-expert-field input:focus-visible,
.da-expert-field textarea:focus-visible {
	background: rgba(255, 255, 255, 0.05);
	border-color: var(--da-accent-light);
	outline: 2px solid var(--da-accent-light);
	outline-offset: 2px;
}

.da-expert-field--primary textarea {
	min-height: 96px;
	font-size: 1rem;
}

.da-expert-submit {
	cursor: pointer;
	background: var(--da-accent);
	color: var(--da-ink);
	border-color: var(--da-accent);
	transition: background var(--da-transition), transform var(--da-transition);
}

.da-expert-submit:hover:not(:disabled) {
	background: var(--da-accent-light);
}

.da-expert-submit:focus-visible {
	outline: 2px solid var(--da-accent-light);
	outline-offset: 3px;
}

.da-expert-submit:disabled,
.da-expert-submit[aria-disabled='true'] {
	cursor: not-allowed;
	background: rgba(255, 255, 255, 0.06);
	color: var(--da-muted);
	border-color: var(--da-border-strong);
	transform: none;
}

.da-expert-submit--secondary {
	width: auto;
	min-height: 42px;
	padding: 0.6rem 1.2rem;
	font-size: 0.9rem;
	background: rgba(255, 255, 255, 0.06);
	color: var(--da-paper);
	border-color: var(--da-border-strong);
}

.da-expert-submit--secondary:hover:not(:disabled) {
	background: rgba(255, 255, 255, 0.1);
}

/* Quality-of-life: a submit in progress gets a subtle animated state,
   never a generic spinner icon - matches the section's own existing
   "sound wave" visual language instead of a borrowed chat-widget look. */
.da-expert-submit.is-loading {
	position: relative;
	color: transparent;
}

.da-expert-submit.is-loading::after {
	content: '';
	position: absolute;
	inset: 0;
	margin: auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid rgba(16, 17, 20, 0.35);
	border-top-color: var(--da-ink);
	animation: da-expert-spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
	.da-expert-submit.is-loading::after {
		animation: none;
	}
}

@keyframes da-expert-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---- Smart Context accordion ---- */

.da-expert-context {
	margin: 0.25rem 0 1.1rem;
}

.da-expert-context summary {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0;
	color: var(--da-accent-light);
	font-size: 0.88rem;
	font-weight: 700;
	cursor: pointer;
	list-style: none;
}

.da-expert-context summary::-webkit-details-marker {
	display: none;
}

.da-expert-context summary::before {
	content: '';
	flex-shrink: 0;
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform var(--da-transition);
}

.da-expert-context[open] summary::before {
	transform: rotate(-135deg);
}

.da-expert-context summary:focus-visible {
	outline: 2px solid var(--da-accent-light);
	outline-offset: 3px;
	border-radius: 4px;
}

.da-expert-context-fields {
	display: grid;
	gap: 0.9rem;
	padding-top: 0.75rem;
}

@media (min-width: 560px) {
	.da-expert-context-fields {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 1rem;
	}

	.da-expert-context-fields .da-expert-field:last-child {
		grid-column: 1 / -1;
	}
}

/* ---- Continuation prompt (shown once a conversation already has an answer) ---- */

.da-expert-continuation {
	margin: 0 0 0.75rem;
	color: var(--da-accent-light);
	font-size: 0.88rem;
	font-weight: 700;
}

/* ---- Quota / free-question usage (Stage 4B: real credit ledger) ---- */

.da-expert-quota-intro {
	margin: 0 0 0.75rem;
	color: var(--da-muted);
	font-size: 0.82rem;
	line-height: 1.6;
	white-space: pre-line;
}

.da-expert-quota {
	margin: 0 0 0.6rem;
	color: var(--da-muted);
	font-size: 0.78rem;
	text-align: center;
}

.da-expert-quota-extra {
	margin: 0 0 0.6rem;
	text-align: center;
}

.da-expert-disclaimer { margin: 1rem 0; color: var(--da-muted); font-size: 0.8rem; line-height: 1.65; }
.da-expert-disclaimer p { margin: 0 0 0.55rem; }
.da-expert-lead-title { margin: 0 0 0.45rem; color: var(--da-paper); font-size: 1rem; }
.da-expert-lead-copy { margin: 0 0 0.85rem; color: var(--da-muted); white-space: pre-line; line-height: 1.6; }
.da-expert-lead-form { display: grid; gap: 0.75rem; margin-top: 1rem; text-align: right; }
.da-expert-lead-field { display: grid; gap: 0.3rem; color: var(--da-muted); font-size: 0.85rem; }
.da-expert-lead-field input { width: 100%; box-sizing: border-box; }
.da-expert-lead-consent { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--da-muted); font-size: 0.78rem; line-height: 1.5; }
.da-expert-lead-consent input { margin-top: 0.25rem; }
.da-expert-lead-status { margin: 0; color: var(--da-muted); font-size: 0.8rem; white-space: pre-line; }
.da-expert-lead-success { margin: 0; color: var(--da-paper); white-space: pre-line; line-height: 1.6; }

/* ---- Response timeline ---- */

.da-expert-response {
	display: grid;
	gap: 1.1rem;
	margin-top: 1.5rem;
}

.da-expert-response:empty {
	margin-top: 0;
}

.da-expert-turn {
	padding-top: 1.25rem;
	border-top: 1px solid var(--da-border);
}

.da-expert-turn-question-label,
.da-expert-turn-answer-label {
	margin: 0 0 0.35rem;
	color: var(--da-muted);
	font-size: 0.72rem;
	font-weight: 750;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.da-expert-turn-question {
	margin: 0 0 1rem;
	color: var(--da-silver);
	font-size: 0.92rem;
	line-height: 1.6;
}

.da-expert-card {
	padding: clamp(1.1rem, 2.5vw, 1.5rem);
	background: var(--da-surface);
	border: 1px solid var(--da-border);
	border-radius: var(--da-radius-medium);
}

.da-expert-card-summary {
	margin: 0 0 0.85rem;
	color: var(--da-paper);
	font-size: 1.02rem;
	font-weight: 700;
	line-height: 1.55;
}

.da-expert-card-answer {
	margin: 0;
	color: var(--da-silver);
	font-size: 0.94rem;
	line-height: 1.75;
	white-space: pre-wrap;
}

.da-expert-card-sections {
	display: grid;
	gap: 0.9rem;
	margin-top: 1.1rem;
}

.da-expert-card-section {
	padding-inline-start: 0.9rem;
	border-inline-start: 2px solid var(--da-border-strong);
}

.da-expert-card-section-heading {
	margin: 0 0 0.3rem;
	color: var(--da-paper);
	font-size: 0.9rem;
	font-weight: 700;
}

.da-expert-card-section-body {
	margin: 0;
	color: var(--da-silver);
	font-size: 0.88rem;
	line-height: 1.65;
	white-space: pre-wrap;
}

/* ---- Related internal content ---- */

.da-expert-related {
	margin-top: 1.25rem;
}

.da-expert-related-title {
	margin: 0 0 0.6rem;
	color: var(--da-muted);
	font-size: 0.78rem;
	font-weight: 750;
}

.da-expert-related-list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.da-expert-related-link {
	display: block;
	padding: 0.65rem 0.9rem;
	background: rgba(255, 255, 255, 0.03);
	border: 1px solid var(--da-border);
	border-radius: var(--da-radius-small);
	color: var(--da-accent-light);
	font-size: 0.86rem;
	font-weight: 650;
	text-decoration: none;
	transition: border-color var(--da-transition), background var(--da-transition);
}

.da-expert-related-link:hover,
.da-expert-related-link:focus-visible {
	background: rgba(255, 255, 255, 0.06);
	border-color: var(--da-border-strong);
}

.da-expert-related-link:focus-visible {
	outline: 2px solid var(--da-accent-light);
	outline-offset: 2px;
}

/* ---- Stage 4A: external research sources - deliberately visually
   distinct from .da-expert-related above (signal-green accent instead of
   gold) so a visitor can tell at a glance "this site's own content" apart
   from "an external source a live web search found", matching section
   11's own explicit requirement to never blend the two. ---- */

.da-expert-sources {
	margin-top: 1.25rem;
}

.da-expert-sources-title {
	margin: 0 0 0.6rem;
	color: var(--da-muted);
	font-size: 0.78rem;
	font-weight: 750;
}

.da-expert-sources-list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.da-expert-source-link {
	display: block;
	padding: 0.65rem 0.9rem;
	background: rgba(112, 196, 154, 0.06);
	border: 1px solid rgba(112, 196, 154, 0.25);
	border-radius: var(--da-radius-small);
	color: var(--da-signal);
	font-size: 0.86rem;
	font-weight: 650;
	text-decoration: none;
	transition: border-color var(--da-transition), background var(--da-transition);
}

.da-expert-source-link:hover,
.da-expert-source-link:focus-visible {
	background: rgba(112, 196, 154, 0.12);
	border-color: rgba(112, 196, 154, 0.45);
}

.da-expert-source-link:focus-visible {
	outline: 2px solid var(--da-signal);
	outline-offset: 2px;
}

.da-expert-source-domain {
	color: var(--da-muted);
	font-weight: 500;
}

/* ---- Rating ---- */

.da-expert-rating {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-top: 1.25rem;
	padding-top: 1rem;
	border-top: 1px solid var(--da-border);
}

.da-expert-rating-label {
	margin: 0;
	color: var(--da-muted);
	font-size: 0.82rem;
}

.da-expert-rating-buttons {
	display: flex;
	gap: 0.5rem;
}

.da-expert-rating-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid var(--da-border);
	border-radius: 50%;
	color: var(--da-silver);
	font-size: 1rem;
	cursor: pointer;
	transition: border-color var(--da-transition), background var(--da-transition), transform var(--da-transition);
}

.da-expert-rating-button:hover:not(:disabled) {
	border-color: var(--da-border-strong);
	transform: translateY(-1px);
}

.da-expert-rating-button:focus-visible {
	outline: 2px solid var(--da-accent-light);
	outline-offset: 2px;
}

.da-expert-rating-button:disabled {
	cursor: not-allowed;
	opacity: 0.55;
}

.da-expert-rating-button.is-selected {
	background: rgba(215, 154, 92, 0.16);
	border-color: var(--da-accent-light);
}

.da-expert-rating-note {
	margin: 0.5rem 0 0;
	color: var(--da-muted);
	font-size: 0.78rem;
}

/* ---- Notices (clarification / research_required / error / rate-limit) ---- */

.da-expert-notice {
	padding: clamp(1rem, 2.5vw, 1.35rem);
	border-radius: var(--da-radius-medium);
	font-size: 0.92rem;
	line-height: 1.65;
}

.da-expert-notice-title {
	margin: 0 0 0.4rem;
	font-size: 0.95rem;
	font-weight: 750;
}

.da-expert-notice-body {
	margin: 0;
}

.da-expert-notice--clarification {
	background: rgba(215, 154, 92, 0.1);
	border: 1px solid rgba(215, 154, 92, 0.35);
	color: var(--da-paper);
}

.da-expert-notice--clarification .da-expert-notice-title {
	color: var(--da-accent-light);
}

.da-expert-notice--info {
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid var(--da-border);
	color: var(--da-silver);
}

.da-expert-notice--error {
	background: rgba(203, 92, 92, 0.1);
	border: 1px solid rgba(203, 92, 92, 0.35);
	color: var(--da-paper);
}

.da-expert-notice--error .da-expert-notice-title {
	color: #e39a9a;
}

/* ---- Mobile ---- */

@media (max-width: 480px) {
	.da-expert-submit {
		width: 100%;
	}

	.da-expert-submit--secondary {
		width: 100%;
	}

	.da-expert-rating {
		flex-wrap: wrap;
	}
}
