/*
 * nmg-apply-autofill.css — W7.3 "Raider.IO Scan" control
 *
 * The applicant pastes a character link and the panel scans Raider.IO data:
 * on a match it re-skins to that character's CLASS colour (--af-accent, set by
 * the JS) and prints a combat-log readout. Idle accent is the brand epic-purple.
 *
 * Everything is scoped under .nmg-autofill so it cannot leak into the form or
 * the theme. Tokens fall back to literals so the control is self-contained even
 * if the theme's :root vars aren't present.
 */

.nmg-autofill {
	--af-bg:     var(--surface, #141a21);
	--af-bg-2:   var(--surface2, #1b232d);
	--af-line:   var(--border, #28323f);
	--af-txt:    var(--txt, #e7ebf0);
	--af-dim:    var(--muted, #9aa6b2);
	--af-accent: var(--epic-glow, #b15cf0); /* idle = brand epic (brightened for AA); JS swaps to class colour */
	--af-bad:    #ff7a7a;

	grid-column: 1 / -1; /* span the full apply grid; harmless if parent isn't a grid */
	margin-top: .9rem;
	border: 1px solid var(--af-line);
	border-left: 2px solid var(--af-accent);
	border-radius: var(--nmg-radius-sm, 8px);
	background:
		linear-gradient(180deg, var(--af-bg) 0%, var(--af-bg-2) 100%);
	padding: .95rem 1.05rem 1.05rem;
	position: relative;
	overflow: hidden;
	transition: border-color .25s ease;
}

/* one-shot scan sweep across the top edge while fetching */
.nmg-autofill::after {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 2px;
	background: linear-gradient(90deg, transparent, var(--af-accent), transparent);
	transform: translateX(-100%);
	opacity: 0;
	pointer-events: none;
}
.nmg-autofill[data-state="scanning"]::after {
	opacity: 1;
	animation: af-sweep 1.1s linear infinite;
}

/* ---- head: label + (on match) class name --------------------------------- */
.nmg-autofill__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: .7rem;
}
.nmg-autofill__label {
	font-family: var(--mono, 'JetBrains Mono', monospace);
	font-size: 10.5px;
	letter-spacing: .28em;
	text-transform: uppercase;
	color: var(--af-dim);
}
.nmg-autofill__who {
	font-family: var(--disp, 'Chakra Petch', system-ui, sans-serif);
	font-weight: 700;
	font-size: 14px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--af-accent);
	display: inline-flex;
	align-items: center;
	gap: .45em;
}
/* ---- guidance: what the scan does + which link to paste ------------------ */
.nmg-autofill__desc {
	margin: 0 0 .6rem;
	font-size: 13.5px;
	line-height: 1.55;
	color: var(--af-txt);
}
.nmg-autofill__hint {
	margin: 0 0 .85rem;
	font-size: 12px;
	line-height: 1.5;
	color: var(--af-dim);
}
.nmg-autofill__ex {
	font-family: var(--mono, 'JetBrains Mono', monospace);
	font-size: 11px;
	color: var(--af-txt);
	background: var(--af-bg-2);
	border: 1px solid var(--af-line);
	border-radius: 4px;
	padding: .05em .4em;
	white-space: nowrap;
}
/* ---- action row: trigger + state chip ------------------------------------ */
.nmg-autofill__action {
	display: flex;
	align-items: center;
	gap: .85rem;
	flex-wrap: wrap;
}
.nmg-autofill__btn {
	font-family: var(--disp, 'Chakra Petch', system-ui, sans-serif);
	font-weight: 600;
	font-size: 13px;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--af-accent);
	background: transparent;
	border: 1px solid var(--af-accent);
	border-radius: var(--nmg-radius-sm, 8px);
	padding: .52em 1.05em;
	cursor: pointer;
	transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.nmg-autofill__btn::before {
	content: "\25B8"; /* ▸ */
	margin-right: .55em;
	opacity: .85;
}
.nmg-autofill__btn:hover {
	background: color-mix(in srgb, var(--af-accent) 16%, transparent);
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--af-accent) 40%, transparent);
}
.nmg-autofill__btn:focus-visible {
	outline: 2px solid var(--af-accent);
	outline-offset: 2px;
}
.nmg-autofill__btn[disabled] {
	opacity: .55;
	cursor: progress;
}

.nmg-autofill__chip {
	display: inline-flex;
	align-items: center;
	gap: .5em;
	font-family: var(--mono, 'JetBrains Mono', monospace);
	font-size: 11px;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--af-dim);
}
.nmg-autofill__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	flex: none;
}
.nmg-autofill[data-state="scanning"] .nmg-autofill__chip { color: var(--af-accent); }
.nmg-autofill[data-state="scanning"] .nmg-autofill__dot { animation: af-pulse 1s ease-in-out infinite; }
.nmg-autofill[data-state="locked"]   .nmg-autofill__chip { color: var(--af-accent); }
.nmg-autofill[data-state="bad"]       .nmg-autofill__chip { color: var(--af-bad); }
.nmg-autofill[data-state="bad"]       { border-left-color: var(--af-bad); }

/* ---- readout ------------------------------------------------------------- */
.nmg-autofill__log {
	margin-top: .8rem;
	padding-top: .75rem;
	border-top: 1px solid var(--af-line);
	font-family: var(--mono, 'JetBrains Mono', monospace);
	font-size: 12.5px;
	line-height: 1.75;
	color: var(--af-txt);
	min-height: 1.75em;
}
.nmg-autofill__log:empty { border-top: 0; padding-top: 0; margin-top: 0; }

.nmg-autofill__line {
	display: block;
	white-space: pre-wrap;
	word-break: break-word;
}
.nmg-autofill__line::before {
	content: "> ";
	color: var(--af-accent);
}
.nmg-autofill__line--idle { color: var(--af-dim); }
.nmg-autofill__line--idle::before { color: var(--af-dim); }
.nmg-autofill__line--meta { color: var(--af-dim); } /* trailing ilvl / M+ line */
.nmg-autofill__line--bad::before { color: var(--af-bad); }

/* staggered "printing" reveal */
.nmg-autofill__line {
	animation: af-line-in .28s ease both;
}
.nmg-autofill__line:nth-child(2) { animation-delay: .07s; }
.nmg-autofill__line:nth-child(3) { animation-delay: .14s; }
.nmg-autofill__line:nth-child(4) { animation-delay: .21s; }
.nmg-autofill__line:nth-child(5) { animation-delay: .28s; }

/* visually-hidden live region (screen-reader summary) */
.nmg-autofill__sr {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0; border: 0;
	overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
	white-space: nowrap;
}

@keyframes af-sweep   { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes af-pulse   { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes af-line-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
	.nmg-autofill[data-state="scanning"]::after { animation: none; }
	.nmg-autofill[data-state="scanning"] .nmg-autofill__dot { animation: none; opacity: .6; }
	.nmg-autofill__line { animation: none; }
}

/* Role picker chips (main_role / additional_roles) */
.nmg-roleset { display: flex; flex-wrap: wrap; gap: .5rem; }
.nmg-rolechip {
  position: relative; /* anchor the absolutely-positioned radio inside the chip */
  display: inline-flex; align-items: center; gap: .5em;
  padding: .5em .85em; cursor: pointer;
  border: 1px solid rgba(255,255,255,.16); border-radius: 8px;
  background: rgba(8,10,16,.45); color: rgba(255,255,255,.78);
  font-size: 14px; line-height: 1; user-select: none;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.nmg-rolechip input { position: absolute; left: 0; top: 0; opacity: 0; width: 0; height: 0; }
.nmg-roleicon { width: 1.15em; height: 1.15em; fill: currentColor; flex: 0 0 auto; }
.nmg-rolechip:hover { border-color: rgba(255,255,255,.32); color: #fff; }
.nmg-rolechip:has(input:focus-visible) { outline: 2px solid var(--af-accent, #a371f7); outline-offset: 2px; }
.nmg-rolechip:has(input:checked) {
  border-color: var(--af-accent, #a371f7);
  color: #fff; background: rgba(163,113,247,.16);
}
