/**
 * GGF Community Core: design tokens, scoped reset and shared controls.
 *
 * Loaded before ggfc.css (article widgets, dialog, member area) and
 * ggfc-account.css (account links, Save and Follow buttons).
 *
 * How the plugin keeps the theme out
 * ----------------------------------
 * Every element the plugin prints sits inside an element with the class
 * "ggfc" (the root). Themes style bare elements (button, input, h3, p, ul)
 * and content areas (".post-content h3"); some use long selectors such as
 * "button:not(:hover):not(:active):not(.has-background)" (Twenty Twenty-One)
 * or ".s-dark button:hover" (SmartMag). See docs/THEME_COMPATIBILITY.md.
 *
 * 1. Every rule of the plugin starts with  .ggfc:not(#ggfc-i)  . The
 *    ":not(#ggfc-i)" matches every element (no element has that id) and
 *    gives each rule the weight of one id, which is more than any selector
 *    built from classes, attributes and elements. No !important is needed
 *    to win, and the plugin's own rules keep their normal order among
 *    themselves. Themes that want to adjust the plugin use the custom
 *    properties below.
 * 2. The reset sets "all: revert" on the elements inside a root, which throws away
 *    every theme rule that reached them (margins, uppercase buttons, fixed
 *    heights, red backgrounds, underlines, transitions) and starts from the
 *    browser's defaults. The plugin's own rules then style each element.
 * 3. Colours come from tokens. A light and a dark set exist; which one a
 *    root uses is decided by the background it actually sits on (see
 *    ggfc-scheme in Frontend.php), not by the operating system setting.
 *
 * !important appears only where nothing may override the result: [hidden],
 * screen-reader text and the reader's "reduce motion" setting.
 */

/* ------------------------------------------------------------------ *
 * Tokens
 * ------------------------------------------------------------------ */
.ggfc {
	/* Brand. Settings, Appearance writes these four; themes may set them too. */
	--ggfc-accent: #4f46e5;
	--ggfc-accent-fg: #fff;
	--ggfc-accent-ink-light: #4338ca;
	--ggfc-accent-ink-dark: #a5b4fc;
	/* 8px matches GGF Game Hubs 1.1; a stored Appearance value (12 on sites installed before 1.2.0-rc.2) still wins. */
	--ggfc-radius: 8px;

	/* Type. SmartMag exposes its interface font as --ui-font; other themes fall back to the system font. */
	--ggfc-font: var(--ui-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
	--ggfc-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	--ggfc-size: 16px;
	--ggfc-size-sm: 14px;
	--ggfc-size-xs: 13px;

	/* Shape and space. */
	--ggfc-radius-ctl: calc(var(--ggfc-radius) * 0.75);
	--ggfc-radius-lg: calc(var(--ggfc-radius) * 1.33);
	--ggfc-ctl-h: 40px;
	--ggfc-gap: 12px;
	--ggfc-pad: 20px;
	--ggfc-ease: 150ms ease;

	/* Light scheme. */
	--ggfc-text: #18181b;
	--ggfc-text-2: #52525b;
	--ggfc-surface: #fff;
	--ggfc-card: #fafafa;
	--ggfc-field: #fff;
	--ggfc-field-solid: #fff;
	--ggfc-btn-bg: #fff;
	--ggfc-on-bad: #fff;
	--ggfc-border: #e4e4e7;
	--ggfc-border-strong: #8b8b94;
	--ggfc-hover: rgba(24, 24, 27, 0.05);
	--ggfc-press: rgba(24, 24, 27, 0.09);
	--ggfc-ink: var(--ggfc-accent-ink-light);
	--ggfc-tint: color-mix(in srgb, var(--ggfc-accent) 7%, transparent);
	--ggfc-good: #15803d;
	--ggfc-good-bg: #f0fdf4;
	--ggfc-bad: #b91c1c;
	--ggfc-bad-bg: #fef2f2;
	--ggfc-warn: #a16207;
	--ggfc-warn-bg: #fefce8;
	--ggfc-info-bg: #eef2ff;
	--ggfc-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
	--ggfc-shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.25);
	--ggfc-backdrop: rgba(9, 9, 11, 0.55);
	--ggfc-scheme: light;
}

/* Dark scheme: chosen by ggfc-scheme from the real background, or before that runs by a known dark-theme class. */
.ggfc[data-ggfc-scheme="dark"],
:where(.s-dark, .site-s-dark, .is-dark-theme, .dark-mode, .theme-dark, [data-theme="dark"]) .ggfc:not([data-ggfc-scheme="light"]) {
	--ggfc-text: #f4f4f5;
	--ggfc-text-2: #a1a1aa;
	--ggfc-surface: #1c1c1f;
	--ggfc-card: rgba(255, 255, 255, 0.04);
	--ggfc-field: rgba(255, 255, 255, 0.06);
	--ggfc-field-solid: #26262a;
	--ggfc-btn-bg: rgba(255, 255, 255, 0.06);
	--ggfc-on-bad: #18181b;
	--ggfc-border: rgba(255, 255, 255, 0.12);
	--ggfc-border-strong: rgba(255, 255, 255, 0.46);
	--ggfc-hover: rgba(255, 255, 255, 0.07);
	--ggfc-press: rgba(255, 255, 255, 0.12);
	--ggfc-ink: var(--ggfc-accent-ink-dark);
	--ggfc-tint: color-mix(in srgb, var(--ggfc-accent) 12%, transparent);
	--ggfc-good: #4ade80;
	--ggfc-good-bg: rgba(74, 222, 128, 0.1);
	--ggfc-bad: #f87171;
	--ggfc-bad-bg: rgba(248, 113, 113, 0.1);
	--ggfc-warn: #facc15;
	--ggfc-warn-bg: rgba(250, 204, 21, 0.1);
	--ggfc-info-bg: rgba(165, 180, 252, 0.1);
	--ggfc-shadow: none;
	--ggfc-shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
	--ggfc-backdrop: rgba(0, 0, 0, 0.7);
	--ggfc-scheme: dark;
}

/* ------------------------------------------------------------------ *
 * Scoped reset
 * ------------------------------------------------------------------ */
.ggfc:not(#ggfc-i) :where(div, span, section, article, aside, header, footer, nav, main, form, fieldset, legend, label, p, h1, h2, h3, h4, h5, h6, ul, ol, li, dl, dt, dd, a, button, input, select, textarea, table, caption, thead, tbody, tfoot, tr, th, td, code, strong, b, em, i, small, img, figure, figcaption, details, summary, dialog, time, mark, hr, blockquote, output, progress),
.ggfc:not(#ggfc-i) :where(div, span, p, h1, h2, h3, h4, li, a, button, label, summary)::before,
.ggfc:not(#ggfc-i) :where(div, span, p, h1, h2, h3, h4, li, a, button, label, summary)::after {
	all: revert;
}
.ggfc:not(#ggfc-i) :where(div, span, section, article, aside, header, footer, nav, main, form, fieldset, legend, label, p, h1, h2, h3, h4, h5, h6, ul, ol, li, dl, dt, dd, a, button, select, textarea, table, caption, th, td, code, strong, b, em, small, img, figure, figcaption, details, summary, time, mark, blockquote, output),
/*
 * Inside :where() so this reset weighs no more than the element reset above
 * (one id, one class). Written plainly it outweighed the field rules below,
 * and text inputs lost their border and background (0.11.0 to 0.13.0).
 */
.ggfc:not(#ggfc-i) :where(input:not([type="radio"], [type="checkbox"])) {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0 solid;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	line-height: inherit;
	text-align: inherit;
	text-transform: inherit;
	text-decoration: none;
	text-shadow: none;
	box-shadow: none;
	float: none;
}
.ggfc:not(#ggfc-i) :where(strong, b) { font-weight: 650; }
.ggfc:not(#ggfc-i) :where(ul, ol) { list-style: none; }
.ggfc:not(#ggfc-i) :where(img) { max-width: 100%; height: auto; }
.ggfc:not(#ggfc-i) :where(input[type="radio"], input[type="checkbox"]) {
	box-sizing: border-box;
	width: 20px;
	height: 20px;
	margin: 0;
	flex: 0 0 auto;
	accent-color: var(--ggfc-accent);
	cursor: pointer;
}
.ggfc:not(#ggfc-i) :where(code) { font-family: var(--ggfc-mono); font-size: 0.92em; }

/*
 * The root: the plugin's own type, independent of the content area around it.
 * The root itself is not reset, so the layout the theme gives to blocks in
 * its content column (width, centring in block themes) still applies; the
 * properties a theme sets on bare elements are overridden one by one below.
 */
.ggfc:not(#ggfc-i) {
	box-sizing: border-box;
	color-scheme: var(--ggfc-scheme);
	color: var(--ggfc-text);
	font-family: var(--ggfc-font);
	font-size: var(--ggfc-size);
	font-weight: 400;
	font-style: normal;
	line-height: 1.5;
	letter-spacing: normal;
	word-spacing: normal;
	text-align: start;
	text-transform: none;
	text-decoration: none;
	text-indent: 0;
	white-space: normal;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Links inside plugin text. */
.ggfc:not(#ggfc-i) a {
	color: var(--ggfc-ink);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
	cursor: pointer;
}
.ggfc:not(#ggfc-i) a:hover { text-decoration-thickness: 2px; }

/* One focus mark for everything the plugin draws. */
.ggfc:not(#ggfc-i) :focus { outline: none; }
.ggfc:not(#ggfc-i) :focus-visible {
	outline: 2px solid var(--ggfc-ink);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */
.ggfc:not(#ggfc-i) .ggfc-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: var(--ggfc-ctl-h);
	padding: 8px 16px;
	border: 1px solid var(--ggfc-border);
	border-radius: var(--ggfc-radius-ctl);
	background: var(--ggfc-btn-bg);
	color: var(--ggfc-text);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	white-space: normal;
	cursor: pointer;
	user-select: none;
	box-shadow: var(--ggfc-shadow);
	transition: background-color var(--ggfc-ease), border-color var(--ggfc-ease), color var(--ggfc-ease), box-shadow var(--ggfc-ease);
}
.ggfc:not(#ggfc-i) .ggfc-btn:hover { border-color: var(--ggfc-border-strong); background: var(--ggfc-hover); color: var(--ggfc-text); }
.ggfc:not(#ggfc-i) .ggfc-btn:active { background: var(--ggfc-press); }
.ggfc:not(#ggfc-i) .ggfc-btn--primary {
	border-color: var(--ggfc-accent);
	background: var(--ggfc-accent);
	color: var(--ggfc-accent-fg);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.ggfc:not(#ggfc-i) .ggfc-btn--primary:hover {
	border-color: color-mix(in srgb, var(--ggfc-accent) 85%, #000);
	background: color-mix(in srgb, var(--ggfc-accent) 85%, #000);
	color: var(--ggfc-accent-fg);
}
.ggfc:not(#ggfc-i) .ggfc-btn--primary:active { background: color-mix(in srgb, var(--ggfc-accent) 75%, #000); }
.ggfc:not(#ggfc-i) .ggfc-btn--danger,
.ggfc:not(#ggfc-i) .ggfc-member__form--danger .ggfc-btn--primary { border-color: var(--ggfc-bad); background: var(--ggfc-bad); color: var(--ggfc-on-bad); }
.ggfc:not(#ggfc-i) .ggfc-btn--danger:hover,
.ggfc:not(#ggfc-i) .ggfc-member__form--danger .ggfc-btn--primary:hover { background: color-mix(in srgb, var(--ggfc-bad) 85%, #000); border-color: color-mix(in srgb, var(--ggfc-bad) 85%, #000); }
.ggfc:not(#ggfc-i) .ggfc-btn--ghost { border-color: transparent; background: transparent; box-shadow: none; }
.ggfc:not(#ggfc-i) .ggfc-btn[disabled],
.ggfc:not(#ggfc-i) .ggfc-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.ggfc:not(#ggfc-i) .ggfc-btn[disabled]:hover { background: var(--ggfc-btn-bg); border-color: var(--ggfc-border); }
.ggfc:not(#ggfc-i) .ggfc-btn--primary[disabled]:hover { background: var(--ggfc-accent); border-color: var(--ggfc-accent); }

/* Busy: a small spinner; the button keeps its size so nothing moves. */
.ggfc:not(#ggfc-i) [aria-busy="true"] .ggfc-btn[type="submit"][disabled]::after,
.ggfc:not(#ggfc-i) .ggfc-btn.is-busy::after {
	content: "";
	width: 14px;
	height: 14px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: ggfc-spin 0.7s linear infinite;
}
@keyframes ggfc-spin { to { transform: rotate(360deg); } }

.ggfc:not(#ggfc-i) .ggfc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }

/* ------------------------------------------------------------------ *
 * Form fields
 * ------------------------------------------------------------------ */
.ggfc:not(#ggfc-i) .ggfc-field { margin: 0 0 16px; }
.ggfc:not(#ggfc-i) .ggfc-label { display: block; margin: 0 0 6px; color: var(--ggfc-text); font-size: var(--ggfc-size-sm); font-weight: 600; line-height: 1.4; }
.ggfc:not(#ggfc-i) .ggfc-optional { color: var(--ggfc-text-2); font-weight: 400; }
.ggfc:not(#ggfc-i) .ggfc-field :where(input:not([type="radio"], [type="checkbox"]), select, textarea),
.ggfc:not(#ggfc-i) .ggfc-member__input,
.ggfc:not(#ggfc-i) .ggfc-input {
	display: block;
	width: 100%;
	min-height: 44px;
	padding: 10px 12px;
	border: 1px solid var(--ggfc-border-strong);
	border-radius: var(--ggfc-radius-ctl);
	background-color: var(--ggfc-field);
	color: var(--ggfc-text);
	font-size: 16px; /* 16px keeps iOS from zooming into the field */
	line-height: 1.4;
	transition: border-color var(--ggfc-ease), box-shadow var(--ggfc-ease);
}
.ggfc:not(#ggfc-i) .ggfc-field textarea,
.ggfc:not(#ggfc-i) textarea.ggfc-member__input { min-height: 112px; resize: vertical; }
.ggfc:not(#ggfc-i) .ggfc-field select,
.ggfc:not(#ggfc-i) select.ggfc-member__input {
	appearance: none;
	padding-right: 40px;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	cursor: pointer;
}
.ggfc:not(#ggfc-i) select.ggfc-member__select { width: auto; max-width: 100%; display: inline-block; }
/*
 * Native option lists. Browsers draw the open list with the select's own
 * background and text colour (Chrome and Edge on Windows, Firefox) or with
 * the page's colour scheme (Android, macOS, iOS). A see-through background on
 * a dark page gave light text on the default white list in 0.12.0. So: an
 * opaque background on the select, explicit colours on every option, and
 * color-scheme for the browsers that follow it.
 */
.ggfc:not(#ggfc-i) select,
.ggfc:not(#ggfc-i) .ggfc-field select,
.ggfc:not(#ggfc-i) select.ggfc-member__input { background-color: var(--ggfc-field-solid); color-scheme: var(--ggfc-scheme); }
.ggfc:not(#ggfc-i) select option,
.ggfc:not(#ggfc-i) select optgroup { background-color: var(--ggfc-field-solid); color: var(--ggfc-text); font-weight: 400; }
.ggfc:not(#ggfc-i) select option:checked { background-color: color-mix(in srgb, var(--ggfc-accent) 22%, var(--ggfc-field-solid)); }
.ggfc:not(#ggfc-i) select option:disabled { color: var(--ggfc-text-2); }
.ggfc:not(#ggfc-i) :is(input, select, textarea)::placeholder { color: var(--ggfc-text-2); opacity: 1; }
.ggfc:not(#ggfc-i) .ggfc-field :is(input, select, textarea):hover,
.ggfc:not(#ggfc-i) .ggfc-member__input:hover { border-color: var(--ggfc-text-2); }
.ggfc:not(#ggfc-i) .ggfc-field :where(input:not([type="radio"], [type="checkbox"]), select, textarea):focus-visible,
.ggfc:not(#ggfc-i) .ggfc-member__input:focus-visible,
.ggfc:not(#ggfc-i) .ggfc-input:focus-visible {
	outline: 2px solid var(--ggfc-ink);
	outline-offset: 0;
	border-color: var(--ggfc-ink);
}
.ggfc:not(#ggfc-i) [aria-invalid="true"],
.ggfc:not(#ggfc-i) .ggfc-field :where(input:not([type="radio"], [type="checkbox"]), select, textarea)[aria-invalid="true"] { border-color: var(--ggfc-bad); box-shadow: inset 0 0 0 1px var(--ggfc-bad); }
.ggfc:not(#ggfc-i) .ggfc-help,
.ggfc:not(#ggfc-i) .ggfc-note { display: block; margin: 6px 0 0; color: var(--ggfc-text-2); font-size: var(--ggfc-size-xs); line-height: 1.45; }
.ggfc:not(#ggfc-i) .ggfc-error { display: flex; gap: 6px; margin: 6px 0 0; color: var(--ggfc-bad); font-size: var(--ggfc-size-xs); font-weight: 600; line-height: 1.45; }
.ggfc:not(#ggfc-i) .ggfc-error::before { content: "\26A0\FE0E"; flex: 0 0 auto; }
.ggfc:not(#ggfc-i) .ggfc-check { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px; font-size: var(--ggfc-size-sm); cursor: pointer; }
.ggfc:not(#ggfc-i) .ggfc-check input { margin-top: 2px; }
.ggfc:not(#ggfc-i) .ggfc-check label { cursor: pointer; }

/* ------------------------------------------------------------------ *
 * Messages
 * ------------------------------------------------------------------ */
.ggfc:not(#ggfc-i) .ggfc-alert {
	display: block;
	margin: 0 0 16px;
	padding: 12px 14px;
	border: 1px solid color-mix(in srgb, var(--ggfc-bad) 35%, transparent);
	border-radius: var(--ggfc-radius-ctl);
	background: var(--ggfc-bad-bg);
	color: var(--ggfc-text);
	font-size: var(--ggfc-size-sm);
	line-height: 1.5;
}
.ggfc:not(#ggfc-i) .ggfc-alert::before { content: "\26A0\FE0E  "; color: var(--ggfc-bad); font-weight: 700; }
.ggfc:not(#ggfc-i) .ggfc-alert--ok,
.ggfc:not(#ggfc-i) .ggfc-member__alert--ok { border-color: color-mix(in srgb, var(--ggfc-good) 35%, transparent); background: var(--ggfc-good-bg); }
.ggfc:not(#ggfc-i) .ggfc-alert--ok::before,
.ggfc:not(#ggfc-i) .ggfc-member__alert--ok::before { content: "\2713\FE0E  "; color: var(--ggfc-good); }
.ggfc:not(#ggfc-i) .ggfc-alert--info { border-color: color-mix(in srgb, var(--ggfc-ink) 30%, transparent); background: var(--ggfc-info-bg); }
.ggfc:not(#ggfc-i) .ggfc-alert--info::before { content: "\2139\FE0E  "; color: var(--ggfc-ink); }

/* ------------------------------------------------------------------ *
 * Helpers
 * ------------------------------------------------------------------ */
.ggfc:not(#ggfc-i) .ggfc-sr,
.ggfc .ggfc-sr {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	border: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
}
.ggfc:not(#ggfc-i) .ggfc-trap,
.ggfc:not(#ggfc-i) .ggfc-member__trap { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

@media (pointer: coarse) {
	.ggfc { --ggfc-ctl-h: 44px; }
}

@media (prefers-reduced-motion: reduce) {
	.ggfc:not(#ggfc-i),
	.ggfc:not(#ggfc-i) *,
	.ggfc:not(#ggfc-i) *::before,
	.ggfc:not(#ggfc-i) *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
	.ggfc:not(#ggfc-i) .ggfc-btn.is-busy::after,
	.ggfc:not(#ggfc-i) [aria-busy="true"] .ggfc-btn[type="submit"][disabled]::after { animation: none; border-right-color: currentColor; opacity: 0.6; }
}

@media (forced-colors: active) {
	.ggfc:not(#ggfc-i) .ggfc-btn,
	.ggfc:not(#ggfc-i) .ggfc-field :is(input, select, textarea),
	.ggfc:not(#ggfc-i) .ggfc-member__input { border: 1px solid ButtonText; }
	.ggfc:not(#ggfc-i) :focus-visible { outline-color: Highlight; }
}

/* Last, so no component rule can show what is meant to be hidden. */
.ggfc[hidden],
.ggfc:not(#ggfc-i) [hidden] { display: none !important; }
