/*
 * Shared directory components, loaded everywhere: star strips, chips, flags
 * (online), the "Featured" badge with its "how featured works" panel, rank
 * markers, initials avatars, rating rings and histograms, the SRA regulator
 * badge, sidebar widgets, mini lists, verified ticks, stat lines and the
 * Google rating badge. Built on the --sg-* tokens.
 */

/* ---------- Stars ---------- */
.pdir-stars {
	position: relative;
	display: inline-block;
	color: #d5dae3;
	font-size: 1em;
	line-height: 1;
	letter-spacing: 0.08em;
	white-space: nowrap;
}

.pdir-stars__fill {
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	white-space: nowrap;
	color: var(--sg-gold);
}

/* ---------- Chips ---------- */
.pdir-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pdir-chip {
	display: inline-flex;
	align-items: center;
	padding: 3px 11px;
	border: 1px solid var(--sg-line);
	border-radius: var(--sg-radius-pill);
	background: var(--sg-soft);
	color: var(--sg-text);
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1.45;
	text-decoration: none;
	white-space: nowrap;
}

a.pdir-chip:hover {
	border-color: var(--sg-line-strong);
	background: #fff;
	color: var(--sg-ink);
	text-decoration: none;
}

/* "Online consultancy" tag: a firm present here through national
   availability rather than a local office. Icon + text carry the meaning. */
.pdir-chip--online {
	gap: 5px;
	border-color: #d6e0fb;
	background: var(--sg-tint);
	color: #1e3a8a;
	font-weight: 600;
}

.pdir-chip--online .pdir-flag__icon {
	width: 13px;
	height: 13px;
	flex: none;
}

/* ---------- Flags (online) ---------- */
.pdir-flag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--sg-ink);
	font-family: var(--sg-font-head);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.pdir-flag__icon {
	width: 13px;
	height: 13px;
	flex: none;
}

.pdir-flag--pill {
	padding: 4px 10px;
	border: 1px solid var(--sg-line);
	border-radius: var(--sg-radius-pill);
	background: #fff;
}

.pdir-flag--online {
	color: #1e3a8a;
}

.pdir-flag--online.pdir-flag--pill {
	border-color: #d6e0fb;
	background: var(--sg-tint);
}

/* ---------- Featured badge (inc/featured.php) ----------
   The paid featured firm looks like every other firm; only this small badge
   next to its name marks it: the Solicitors Guide mark (drawn here, so PHP
   and JS print the same markup) and the word "Featured". No gold, no
   coloured edges. Three forms share the look: a button that opens a small
   "how featured works" panel (details/summary, so it works without
   JavaScript; site.js closes it on Escape, a click outside or focus moving
   away), a link to /how-we-rank/#featured in small places, and plain text
   inside a row that is already one link. The badge sits above a card's
   stretched name link (z-index 1) and the card's other controls (z-index 2). */
.sg-featbadge {
	position: relative;
	z-index: 3;
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 5px;
	width: fit-content;
	max-width: 100%;
	padding: 2px 8px 2px 3px;
	border: 1px solid var(--sg-line);
	border-radius: var(--sg-radius-pill);
	background: var(--sg-bg);
	color: var(--sg-ink);
	font-family: var(--sg-font-head);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.4;
	text-decoration: none;
	text-transform: none;
	white-space: nowrap;
	vertical-align: middle;
	list-style: none;
	transition: border-color var(--sg-dur-hover) var(--sg-ease);
}

/* The Solicitors Guide mark (the site icon). */
.sg-featbadge::before {
	content: "";
	flex: none;
	width: 16px;
	height: 16px;
	background: url("../img/sg-mark.svg") center / 16px 16px no-repeat;
}

/* A 44px tall hit area that does not make the row taller. */
.sg-featbadge--button::after,
.sg-featbadge--link::after {
	content: "";
	position: absolute;
	top: calc(50% - 22px);
	right: -4px;
	left: -4px;
	height: 44px;
}

.sg-featbadge--button {
	cursor: pointer;
}

.sg-featbadge--button::-webkit-details-marker {
	display: none;
}

.sg-featbadge--button:hover,
.sg-featinfo[open] > .sg-featbadge--button,
a.sg-featbadge:hover {
	border-color: var(--sg-line-strong);
	color: var(--sg-ink);
	text-decoration: none;
}

/* The link form keeps its look inside running text and tables, whose link
   rules (.sg-prose a and the like) would otherwise colour and underline it. */
a.sg-featbadge.sg-featbadge--link,
a.sg-featbadge.sg-featbadge--link:hover {
	color: var(--sg-ink);
	text-decoration: none;
}

.sg-featbadge:focus-visible {
	outline: 2px solid var(--sg-blue);
	outline-offset: 2px;
}

.sg-featbadge__info {
	flex: none;
	color: var(--sg-muted);
}

/* A firm's name and its badge side by side; the badge wraps under the name
   when there is no room. Deliberately not positioned (a card's stretched
   name link must keep the card as its box). */
.sg-featrow {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 8px;
	min-width: 0;
}

/* The details element stays unpositioned, so its panel hangs from the
   nearest positioned box (the card, panel or header the badge sits in). */
.sg-featinfo {
	min-width: 0;
}

/* Straight under the badge (top: auto keeps its place in the flow), across
   the box it hangs from (left and right are that box's edges), so never
   wider than that box and never wider than the screen. */
.sg-featinfo__panel {
	position: absolute;
	top: auto;
	right: 12px;
	left: 12px;
	z-index: 4;
	max-width: 22rem;
	margin-top: 8px;
	padding: 14px 16px;
	border: 1px solid var(--sg-line);
	border-radius: var(--sg-radius-card);
	background: var(--sg-bg);
	box-shadow: var(--sg-shadow-raised);
	color: var(--sg-text);
	font-family: var(--sg-font-body);
	font-size: 0.875rem;
	font-weight: 400;
	letter-spacing: normal;
	line-height: 1.5;
	text-align: left;
	text-transform: none;
	white-space: normal;
}

.sg-featinfo__panel p {
	margin: 0;
}

.sg-featinfo__panel p + p {
	margin-top: 8px;
}

/* A 44px tall hit area (::after) that does not make the panel taller; the
   focus ring stays round the link's own text. */
.sg-featinfo__panel a {
	position: relative;
	display: inline-block;
	color: var(--sg-blue);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.sg-featinfo__panel a::after {
	content: "";
	position: absolute;
	inset: -12px -4px;
}

.sg-featinfo__panel a:hover {
	color: var(--sg-ink);
}

@media (prefers-reduced-motion: no-preference) {
	.sg-featinfo[open] > .sg-featinfo__panel {
		animation: sg-featinfo-in var(--sg-dur-open) var(--sg-ease);
	}
}

@keyframes sg-featinfo-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

@media print {
	.sg-featinfo__panel {
		display: none !important;
	}
}

/* ---------- Rank marker ---------- */
.pdir-rank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 28px;
	height: 28px;
	border: 1px solid var(--sg-line-strong);
	border-radius: 50%;
	background: #fff;
	color: var(--sg-ink);
	font-family: var(--sg-font-head);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1;
}

.pdir-rank--top {
	border-color: var(--sg-ink);
	background: var(--sg-ink);
	color: #fff;
}

/* ---------- Initials avatar ---------- */
.pdir-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 48px;
	height: 48px;
	border: 1px solid var(--sg-line);
	border-radius: 12px;
	background: var(--sg-soft);
	color: var(--sg-ink);
	font-family: var(--sg-font-head);
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.pdir-avatar--round {
	border-radius: 50%;
}

.pdir-avatar--sm {
	width: 36px;
	height: 36px;
	font-size: 0.8125rem;
}

/* Six calm tones picked by data-tone, all AA for their text colour. */
.pdir-avatar[data-tone="0"] { background: #eef3ff; border-color: #dbe4fb; color: #1e3a8a; }
.pdir-avatar[data-tone="1"] { background: #e8f3f2; border-color: #cfe5e3; color: #0f4f4f; }
.pdir-avatar[data-tone="2"] { background: #fff6da; border-color: #f3dfa2; color: #7a5300; }
.pdir-avatar[data-tone="3"] { background: #f1effa; border-color: #dcd7f0; color: #4b3f8f; }
.pdir-avatar[data-tone="4"] { background: #fdeeee; border-color: #f4d3d3; color: #8a2f2f; }
.pdir-avatar[data-tone="5"] { background: #eaf7ef; border-color: #c8e8d3; color: #14532d; }

/* ---------- Ring stat (set --pdir-ring-value: 0-100) ---------- */
.pdir-ring {
	--pdir-ring-value: 0;
	position: relative;
	flex: none;
	width: 54px;
	height: 54px;
	border-radius: 50%;
	background: conic-gradient(var(--sg-green) calc(var(--pdir-ring-value) * 1%), var(--sg-line) 0);
}

.pdir-ring::after {
	content: "";
	position: absolute;
	inset: 5px;
	border-radius: 50%;
	background: #fff;
}

.pdir-ring__label {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--sg-ink);
	font-family: var(--sg-font-head);
	font-size: 0.75rem;
	font-weight: 600;
}

/* ---------- Histogram (set --pdir-bar-value per bar) ---------- */
.pdir-histogram {
	display: grid;
	gap: 7px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pdir-histogram__row {
	display: grid;
	grid-template-columns: 2.4rem 1fr 3rem;
	align-items: center;
	gap: 10px;
	color: var(--sg-text);
	font-size: 0.8125rem;
}

.pdir-histogram__bar {
	--pdir-bar-value: 0;
	position: relative;
	height: 8px;
	overflow: hidden;
	border-radius: var(--sg-radius-pill);
	background: var(--sg-line);
}

.pdir-histogram__bar::after {
	content: "";
	position: absolute;
	inset: 0;
	width: calc(var(--pdir-bar-value) * 1%);
	border-radius: inherit;
	background: var(--sg-gold);
}

.pdir-histogram__row--low .pdir-histogram__bar::after {
	background: #d97762;
}

.pdir-histogram__count {
	color: var(--sg-muted);
	font-variant-numeric: tabular-nums;
	text-align: right;
}

/* ---------- SRA regulator badge ---------- */
.pdir-regulator {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border: 1px solid #c8e8d3;
	border-radius: var(--sg-radius-input);
	background: var(--sg-green-bg);
	color: var(--sg-green);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.35;
}

.pdir-regulator__icon {
	flex: none;
	width: 16px;
	height: 16px;
}

/* ---------- Sidebar widget ---------- */
.pdir-widget {
	padding: 20px;
	border: 1px solid var(--sg-line);
	border-radius: var(--sg-radius-card);
	background: #fff;
	box-shadow: var(--sg-shadow-card);
}

.pdir-widget + .pdir-widget {
	margin-top: 16px;
}

.pdir-widget__title {
	margin: 0 0 12px;
	color: var(--sg-ink);
	font-family: var(--sg-font-head);
	font-size: 1.0625rem;
	font-weight: 600;
	line-height: 1.3;
}

.pdir-widget--tint {
	border-color: #dfe7fb;
	background: linear-gradient(180deg, var(--sg-tint) 0%, var(--sg-tint-2) 100%);
}

/* ---------- Mini list (sidebar rankings) ---------- */
.pdir-minilist {
	display: grid;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pdir-minilist__item {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 -8px;
	padding: 8px;
	border: 1px solid transparent;
	border-radius: var(--sg-radius-input);
}

.pdir-minilist__item:hover {
	background: var(--sg-soft);
}

.pdir-minilist__body {
	min-width: 0;
}

.pdir-minilist__name {
	display: block;
	overflow: hidden;
	color: var(--sg-ink);
	font-size: 0.875rem;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pdir-minilist__meta {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--sg-muted);
	font-size: 0.75rem;
}

/* ---------- Verified tick ---------- */
.pdir-verified {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	color: var(--sg-green);
	font-size: 0.75rem;
	font-weight: 600;
}

.pdir-verified__icon {
	flex: none;
	width: 14px;
	height: 14px;
}

/* ---------- Stat line ---------- */
.pdir-statline {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 22px;
	color: var(--sg-text);
	font-size: 0.875rem;
}

.pdir-statline strong {
	color: var(--sg-ink);
	font-variant-numeric: tabular-nums;
}

/* ---------- Google rating badge (real Google data only) ---------- */
.pdir-gbadge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	color: var(--sg-ink);
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	vertical-align: middle;
}

.pdir-gbadge__mark {
	flex: none;
	width: 13px;
	height: 13px;
}

.pdir-gbadge__value {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.pdir-gbadge__star {
	color: var(--sg-gold);
	font-size: 0.9em;
}

.pdir-gbadge__count {
	color: var(--sg-muted);
	font-variant-numeric: tabular-nums;
}

.pdir-gbadge--chip {
	padding: 5px 10px;
	border: 1px solid var(--sg-line);
	border-radius: var(--sg-radius-pill);
	background: #fff;
}

a.pdir-gbadge--chip:hover {
	border-color: var(--sg-line-strong);
	background: var(--sg-soft);
	color: var(--sg-ink);
	text-decoration: none;
}

.pdir-gbadge--row {
	gap: 7px;
	font-size: 0.875rem;
}

.pdir-gbadge--row .pdir-gbadge__mark {
	width: 15px;
	height: 15px;
}

.pdir-gbadge__label {
	color: var(--sg-text);
	font-weight: 600;
}

a.pdir-gbadge--row:hover .pdir-gbadge__value {
	text-decoration: underline;
}

@media (max-width: 480px) {
	.pdir-gbadge--row {
		font-size: 0.8125rem;
	}
}
