/* ==========================================================================
   QF Callout — attention beacon for calling out UI elements
   --------------------------------------------------------------------------
   Two ways to use it (see public/javascripts/qf-callout.js):

     1. Declarative: add the `pulse` class to any element. The script watches
        the DOM and attaches a beacon overlay; remove the class to dismiss.
        Optional attributes on the element:
          data-callout="Label text"   data-callout-place="top|bottom|left|right"
          data-callout-color="ice|cyan|gold|warn|danger|success|white|faction_1..3|R,G,B"

     2. Programmatic (tutorials): qfCallout.show(el, { label, place, color,
        shape: 'box'|'hex', spotlight, once, duration }) / qfCallout.hide(el)
        / qfCallout.clear() / qfCallout.has(el)
        or jQuery: $(sel).callout({...}) / $(sel).callout('off')

   The overlay is appended to <body>, tracks the target every frame, never
   intercepts pointer events, and works on anything with a bounding box
   (buttons with their own pseudo-elements, <img>, sprites, SVG, etc.).
   Map tiles (.tile) keep their own polygon pulse and are excluded.
   ========================================================================== */

.qf-callout {
	--c: var(--qf-ice);          /* accent, rgb triplet */
	--b: 2px;                    /* bracket thickness */
	--l: 18px;                   /* bracket length */
	--r: 6px;                    /* ring / glow radius */
	position: fixed;
	left: 0;
	top: 0;
	width: 0;
	height: 0;
	z-index: 100000;
	pointer-events: none;
	will-change: transform;
	font-family: 'Play', 'Segoe UI', sans-serif;
}
.qf-callout[hidden] { display: none; }
.qf-callout--under { z-index: 900; }    /* ambient beacons: above the map, beneath panels and nav */

/* ---- spotlight backdrop (opt-in): dims everything except the target ---- */
.qf-callout__dim {
	position: absolute;
	inset: -8px;
	border-radius: calc(var(--r) + 2px);
	box-shadow: 0 0 0 200vmax rgba(1, 6, 16, 0.62);
	animation: qf-co-fade 0.4s ease-out both;
}

/* ---- soft glow hugging the target ---- */
.qf-callout__glow {
	position: absolute;
	inset: -3px;
	border-radius: var(--r);
	box-shadow:
		-10px 0 18px -2px rgba(var(--c), 0.6),
		 10px 0 18px -2px rgba(var(--c), 0.6),
		 0 0 18px 4px rgba(var(--c), 0.5),
		inset 0 0 14px rgba(var(--c), 0.22);
	animation: qf-co-glow 1.8s ease-in-out infinite;
}

/* ---- scan sweep across the target ---- */
.qf-callout__scan {
	position: absolute;
	inset: 0;
	overflow: hidden;
	border-radius: var(--r);
	mix-blend-mode: screen;
}
.qf-callout__scan::before {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	top: -40%;
	height: 40%;
	background: linear-gradient(180deg,
		transparent 0%,
		rgba(var(--c), 0.18) 70%,
		rgba(255, 255, 255, 0.38) 97%,
		transparent 100%);
	animation: qf-co-scan 2.4s linear infinite;
}

/* ---- sonar rings radiating outward ---- */
.qf-callout__ring {
	position: absolute;
	inset: -3px;
	border: 3px solid rgba(var(--c), 0.95);
	border-radius: var(--r);
	box-shadow: 0 0 8px rgba(var(--c), 0.6), inset 0 0 8px rgba(var(--c), 0.4);
	opacity: 0;
	animation: qf-co-ring 2s cubic-bezier(0.1, 0.6, 0.3, 1) 0.45s infinite;
}
.qf-callout__ring.is-2 { animation-delay: 1.45s; }

/* ---- targeting brackets: fly in from oversized, lock on, then breathe ---- */
.qf-callout__frame {
	position: absolute;
	inset: -3px;
	--k: rgb(var(--c));
	background:
		linear-gradient(var(--k), var(--k)) top left     / var(--l) var(--b) no-repeat,
		linear-gradient(var(--k), var(--k)) top left     / var(--b) var(--l) no-repeat,
		linear-gradient(var(--k), var(--k)) top right    / var(--l) var(--b) no-repeat,
		linear-gradient(var(--k), var(--k)) top right    / var(--b) var(--l) no-repeat,
		linear-gradient(var(--k), var(--k)) bottom left  / var(--l) var(--b) no-repeat,
		linear-gradient(var(--k), var(--k)) bottom left  / var(--b) var(--l) no-repeat,
		linear-gradient(var(--k), var(--k)) bottom right / var(--l) var(--b) no-repeat,
		linear-gradient(var(--k), var(--k)) bottom right / var(--b) var(--l) no-repeat;
	filter: drop-shadow(0 0 4px rgba(var(--c), 0.9));
	animation:
		qf-co-lock 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25) both,
		qf-co-breathe 1.8s ease-in-out 0.55s infinite;
}

/* ---- edge rails: complete the silhouette between the brackets ---- */
.qf-callout__rails {
	position: absolute;
	inset: -3px;
	--k: rgb(var(--c));
	--rl: 0px;                   /* vertical rail length (left/right), set by JS */
	--rt: 0px;                   /* horizontal rail length (top/bottom), set by JS */
	background:
		linear-gradient(180deg, transparent, var(--k) 20%, var(--k) 80%, transparent) left   center / var(--b) var(--rl) no-repeat,
		linear-gradient(180deg, transparent, var(--k) 20%, var(--k) 80%, transparent) right  center / var(--b) var(--rl) no-repeat,
		linear-gradient(90deg,  transparent, rgba(var(--c), 0.7) 20%, rgba(var(--c), 0.7) 80%, transparent) center top    / var(--rt) var(--b) no-repeat,
		linear-gradient(90deg,  transparent, rgba(var(--c), 0.7) 20%, rgba(var(--c), 0.7) 80%, transparent) center bottom / var(--rt) var(--b) no-repeat;
	filter: drop-shadow(0 0 6px rgba(var(--c), 0.95));
	animation:
		qf-co-lock 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25) both,
		qf-co-breathe 1.8s ease-in-out 0.55s infinite;
}

/* ---- hex shape (map tiles): the SVG reticle replaces the box parts ---- */
.qf-callout--hex .qf-callout__scan {
	clip-path: polygon(0 50%, 25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%);
}
.qf-callout svg.qf-callout__svg {    /* specificity beats Bootstrap's svg:not(:root){overflow:hidden} */
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
}
.qf-callout__svg .hx-glow {
	fill: rgba(var(--c), 0.12);
	stroke: rgba(var(--c), 0.9);
	stroke-width: 3px;
	vector-effect: non-scaling-stroke;
	filter: drop-shadow(0 0 8px rgba(var(--c), 0.95));
	animation: qf-co-glow 1.8s ease-in-out infinite;
}
.qf-callout__svg .hx-ring {
	fill: none;
	stroke: rgb(var(--c));
	stroke-width: 3px;
	vector-effect: non-scaling-stroke;
	transform-box: fill-box;
	transform-origin: center;
	opacity: 0;
	animation: qf-co-hexring 2s cubic-bezier(0.1, 0.6, 0.3, 1) 0.45s infinite;
}
.qf-callout__svg .hx-ring.is-2 { animation-delay: 1.45s; }
.qf-callout__svg .hx-frame {
	fill: none;
	stroke: rgb(var(--c));
	stroke-width: 3px;
	stroke-linecap: square;
	vector-effect: non-scaling-stroke;
	transform-box: fill-box;
	transform-origin: center;
	filter: drop-shadow(0 0 5px rgba(var(--c), 0.95));
	animation:
		qf-co-hexlock 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25) both,
		qf-co-hexbreathe 1.8s ease-in-out 0.55s infinite;
}

/* ---- label tag with leader line (also the pointer button) ---- */
.qf-callout__label,
.qf-pointer__label {
	position: absolute;
	left: 50%;
	top: 100%;
	transform: translate(-50%, 16px);
	white-space: nowrap;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: #eaf7ff;
	text-shadow: 0 0 6px rgba(var(--c), 0.6);
	padding: 8px 12px 7px 14px;
	background: linear-gradient(180deg, rgba(8, 36, 70, 0.94), rgba(2, 12, 30, 0.96));
	border: 1px solid rgba(var(--c), 0.8);
	box-shadow:
		inset 3px 0 0 rgb(var(--c)),
		0 0 14px rgba(var(--c), 0.35);
	animation: qf-co-label 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.35s both;
}
.qf-pointer__label {
	left: 0;
	top: 0;
	transform: none;
	pointer-events: auto;
	animation-delay: 0s;
	transition: filter 0.2s, color 0.2s;
	padding: 8px 12px 7px;                     /* no accent bar, so even padding */
	box-shadow: 0 0 14px rgba(var(--c), 0.35); /* thin even 1px border only, no left accent bar */
}
.qf-pointer__label.is-clickable { cursor: pointer; }
.qf-pointer__label.is-clickable:hover {
	color: #ffffff;
	filter: brightness(1.35) drop-shadow(0 0 8px rgba(var(--c), 0.9));
}
.qf-callout__label::before {              /* leader line to the frame */
	content: '';
	position: absolute;
	left: 50%;
	bottom: 100%;
	width: 1px;
	height: 14px;
	background: rgba(var(--c), 0.9);
}
.qf-callout[data-place="top"] .qf-callout__label {
	top: auto;
	bottom: 100%;
	transform: translate(-50%, -16px);
}
.qf-callout[data-place="top"] .qf-callout__label::before { bottom: auto; top: 100%; }
.qf-callout[data-place="left"] .qf-callout__label {
	top: 50%;
	left: auto;
	right: 100%;
	transform: translate(-16px, -50%);
}
.qf-callout[data-place="left"] .qf-callout__label::before {
	left: 100%;
	top: 50%;
	bottom: auto;
	width: 14px;
	height: 1px;
}
.qf-callout[data-place="right"] .qf-callout__label {
	top: 50%;
	left: 100%;
	transform: translate(16px, -50%);
}
.qf-callout[data-place="right"] .qf-callout__label::before {
	left: auto;
	right: 100%;
	top: 50%;
	bottom: auto;
	width: 14px;
	height: 1px;
}

/* ---- the target itself lights up too (shape-following glow) ---- */
.pulse:not(.tile) {
	animation: qf-pulse-glow 1.8s ease-in-out infinite;
}

/* ==========================================================================
   QF Pointer (qf-pointer.js): edge-anchored button + orthogonal line to a
   target that may be off screen. Layer is beneath panels and nav (z 900).
   ========================================================================== */
.qf-pointer-layer {
	position: fixed;
	inset: 0;
	z-index: 900;
	pointer-events: none;
	font-family: 'Play', 'Segoe UI', sans-serif;
}
.qf-pointer-lines {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
.qf-pointer { --c: var(--qf-ice); }
.qf-pointer__halo {
	fill: none;
	stroke: rgba(var(--c), 0.22);
	stroke-width: 8;
	stroke-linejoin: round;
	stroke-linecap: round;
}
.qf-pointer__line {
	fill: none;
	stroke: rgba(var(--c), 0.9);
	stroke-width: 2;
	stroke-linejoin: round;
	stroke-linecap: round;
}
.qf-pointer__tip {                         /* target on screen: ring where the line meets it */
	fill: rgba(var(--c), 0.25);
	stroke: rgb(var(--c));
	stroke-width: 2;
	animation: qf-co-glow 1.8s ease-in-out infinite;
}
.qf-pointer__arrow {                       /* target off screen: arrow at the viewport edge */
	fill: rgb(var(--c));
	filter: drop-shadow(0 0 4px rgba(var(--c), 0.95));
}

/* ---- keyframes ---- */

@keyframes qf-co-lock {
	0%   { inset: -40px; opacity: 0; }
	65%  { inset: -1px;  opacity: 1; }
	100% { inset: -3px;  opacity: 1; }
}
@keyframes qf-co-breathe {
	0%, 100% { inset: -3px; }
	50%      { inset: -6px; }
}
@keyframes qf-co-ring {
	0%   { inset: -3px;  opacity: 1;   border-width: 3px; }
	45%  { opacity: 0.85; }
	100% { inset: -32px; opacity: 0;   border-width: 1px; }
}
@keyframes qf-co-hexlock {
	0%   { transform: scale(1.5);  opacity: 0; }
	65%  { transform: scale(0.98); opacity: 1; }
	100% { transform: scale(1.03); opacity: 1; }
}
@keyframes qf-co-hexbreathe {
	0%, 100% { transform: scale(1.03); }
	50%      { transform: scale(1.08); }
}
@keyframes qf-co-hexring {
	0%   { transform: scale(1);    opacity: 1; }
	45%  { opacity: 0.85; }
	100% { transform: scale(1.35); opacity: 0; }
}
@keyframes qf-co-glow {
	0%, 100% { opacity: 0.55; }
	50%      { opacity: 1; }
}
@keyframes qf-co-scan {
	to { transform: translateY(350%); }
}
@keyframes qf-co-label {
	from { opacity: 0; filter: blur(4px); }
	to   { opacity: 1; filter: blur(0); }
}
@keyframes qf-co-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}
@keyframes qf-pulse-glow {
	0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 6px rgba(var(--qf-ice), 0.6)); }
	50%      { filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 14px rgba(var(--qf-ice), 0.95)); }
}

/* ---- reduced motion: static brackets + glow, no rings / sweep ---- */
@media (prefers-reduced-motion: reduce) {
	.qf-callout__ring,
	.qf-callout__svg .hx-ring,
	.qf-callout__scan { display: none; }
	.qf-callout__frame,
	.qf-callout__rails,
	.qf-callout__svg .hx-frame,
	.qf-callout__svg .hx-glow,
	.qf-callout__glow,
	.qf-callout__label,
	.qf-pointer__label,
	.qf-pointer__tip,
	.qf-callout__dim { animation: none; }
	.pulse:not(.tile) {
		animation: none;
		filter: drop-shadow(0 0 8px rgba(var(--qf-ice), 0.9));
	}
}
