/* The Sacred Files: country and language preferences. Uses the theme's design tokens. */

.tsfp-bar,
.tsfp-panel {
	--tsfp-bg: var(--tsf-abyss, #120d12);
	--tsfp-fg: var(--tsf-ivory, #f4ecdf);
	--tsfp-gold: var(--tsf-gold, #b99867);
	--tsfp-gold-light: var(--tsf-gold-light, #d9c19a);
	--tsfp-line: rgba(185, 152, 103, 0.4);
	font-family: var(--tsf-sans, system-ui, sans-serif);
	color: var(--tsfp-fg);
}

.tsfp-bar[hidden],
.tsfp-panel[hidden] { display: none !important; }

/* First-visit suggestion: a slim bar at the bottom that never covers the text for long. */
.tsfp-bar {
	position: fixed;
	z-index: 9990;
	inset: auto 0 0 0;
	padding: 0.75rem var(--tsf-gutter, 1rem) calc(0.75rem + env(safe-area-inset-bottom, 0px));
	background: linear-gradient(180deg, rgba(18, 13, 18, 0.96), var(--tsfp-bg));
	border-top: 1px solid var(--tsfp-line);
	box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
}
.tsfp-bar__inner {
	max-width: 72rem;
	margin: 0 auto;
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 0.25rem 1.25rem;
	align-items: center;
}
.tsfp-bar__title {
	grid-column: 1;
	margin: 0;
	font: 600 0.72rem/1.3 var(--tsf-sans, system-ui, sans-serif);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--tsfp-gold-light);
}
.tsfp-bar__text { grid-column: 1; margin: 0; font-size: 0.95rem; line-height: 1.45; }
.tsfp-bar__actions {
	grid-column: 2;
	grid-row: 1 / span 2;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.tsfp-bar__close,
.tsfp-notice__close {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}
.tsfp-bar__close:hover { background: rgba(217, 193, 154, 0.1); }

@media (max-width: 640px) {
	.tsfp-bar__inner { grid-template-columns: 1fr; }
	.tsfp-bar__actions { grid-column: 1; grid-row: auto; flex-wrap: wrap; }
	.tsfp-bar__close { position: absolute; top: 0.25rem; right: 0.25rem; }
	.tsfp-bar__title { padding-right: 2.5rem; }
}

/* Buttons */
.tsfp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 1.1rem;
	border-radius: 999px;
	font: 600 0.88rem/1 var(--tsf-sans, system-ui, sans-serif);
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.tsfp-btn--gold { border: 1px solid var(--tsfp-gold); background: var(--tsfp-gold); color: var(--tsf-abyss, #120d12); }
.tsfp-btn--gold:hover { background: var(--tsfp-gold-light); border-color: var(--tsfp-gold-light); }
.tsfp-btn--ghost { border: 1px solid var(--tsfp-line); background: transparent; color: var(--tsfp-fg); }
.tsfp-btn--ghost:hover { border-color: var(--tsfp-gold-light); background: rgba(217, 193, 154, 0.08); }
.tsfp-btn:focus-visible,
.tsfp-bar__close:focus-visible,
.tsfp-notice__close:focus-visible,
.tsfp-country-btn:focus-visible,
.tsfp-footer__button:focus-visible,
.tsfp-panel select:focus-visible {
	outline: 2px solid var(--tsfp-gold-light, #d9c19a);
	outline-offset: 3px;
}

/* Panel: a small, non-modal dialog anchored to the top right on large screens. */
.tsfp-panel {
	position: fixed;
	z-index: 9995;
	top: 5.25rem;
	right: max(1rem, calc((100vw - 80rem) / 2));
	width: min(24rem, calc(100vw - 2rem));
	background: var(--tsfp-bg);
	border: 1px solid var(--tsfp-line);
	border-radius: var(--tsf-radius, 12px);
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.tsfp-panel__inner { padding: 1.25rem 1.25rem 1rem; }
.tsfp-panel__title {
	margin: 0 0 0.75rem;
	font: 500 1.35rem/1.2 var(--tsf-serif, Georgia, serif);
	color: var(--tsfp-fg);
}
.tsfp-panel__field { margin: 0 0 0.85rem; }
.tsfp-panel__field label {
	display: block;
	margin-bottom: 0.3rem;
	font: 600 0.72rem/1.3 var(--tsf-sans, system-ui, sans-serif);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--tsfp-gold-light);
}
.tsfp-panel select {
	width: 100%;
	min-height: 44px;
	padding: 0 0.75rem;
	border: 1px solid var(--tsfp-line);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.04);
	color: var(--tsfp-fg);
	font: 500 1rem/1.2 var(--tsf-sans, system-ui, sans-serif);
}
.tsfp-panel select option { color: #111; background: #fff; }
.tsfp-panel__note { margin: 0 0 0.6rem; font-size: 0.88rem; line-height: 1.45; color: rgba(244, 236, 223, 0.85); }
.tsfp-panel__note--small { font-size: 0.8rem; color: rgba(244, 236, 223, 0.65); }
.tsfp-panel__actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; }

@media (max-width: 640px) {
	.tsfp-panel {
		top: auto;
		bottom: 0;
		right: 0;
		left: 0;
		width: auto;
		border-radius: var(--tsf-radius, 12px) var(--tsf-radius, 12px) 0 0;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}
}

/* Header control, next to the language switcher. */
.tsfp-country-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 44px;
	padding: 0 0.7rem;
	border: 1px solid rgba(185, 152, 103, 0.45);
	border-radius: 999px;
	background: transparent;
	color: var(--tsf-ivory, #f4ecdf);
	font: 600 0.78rem/1 var(--tsf-sans, system-ui, sans-serif);
	letter-spacing: 0.1em;
	cursor: pointer;
}
.tsfp-country-btn:hover,
.tsfp-country-btn[aria-expanded="true"] { border-color: var(--tsf-gold-light, #d9c19a); background: rgba(217, 193, 154, 0.08); }
.tsfp-country-btn .tsfp-icon { width: 1rem; height: 1rem; }
.tsfp-country-btn__name { display: none; letter-spacing: 0; font-weight: 500; font-size: 0.95rem; }
.tsfp-country-btn__label { display: none; color: var(--tsf-gold-light, #d9c19a); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; margin-right: 0.4rem; }

/* In the mobile menu the control becomes a full row, like the theme's language row. */
@media (max-width: 1023px) {
	.site-nav .tsfp-country-btn { width: 100%; justify-content: flex-start; border-radius: 10px; }
	.site-nav .tsfp-country-btn__code { display: none; }
	.site-nav .tsfp-country-btn__name,
	.site-nav .tsfp-country-btn__label { display: inline; }
}

/* Footer */
.tsfp-footer__button {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	text-decoration: underline;
	text-underline-offset: 0.2em;
	text-decoration-color: rgba(185, 152, 103, 0.6);
	cursor: pointer;
	min-height: 44px;
}
.tsfp-footer__button:hover { color: var(--tsf-gold-light, #d9c19a); }

/* Language notice on articles */
.tsfp-notice {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	max-width: 72rem;
	margin: 1rem auto 0;
	padding: 0.6rem 0.6rem 0.6rem 1rem;
	border: 1px solid rgba(185, 152, 103, 0.45);
	border-left: 3px solid var(--tsf-gold, #b99867);
	border-radius: 8px;
	background: var(--tsf-parchment, #f7f1e6);
	color: var(--tsf-abyss, #1b1418);
	font: 400 0.95rem/1.5 var(--tsf-sans, system-ui, sans-serif);
	width: calc(100% - 2 * var(--tsf-gutter, 1rem));
	box-sizing: border-box;
}
.tsfp-notice__text { margin: 0; flex: 1; }
.tsfp-notice__link { color: var(--tsf-burgundy, #6b1f2a); font-weight: 600; text-underline-offset: 0.2em; }
.tsfp-notice__close { color: var(--tsf-abyss, #1b1418); flex: none; }

.tsfp-preview-flag {
	position: fixed;
	z-index: 9980;
	left: 0.75rem;
	bottom: 0.75rem;
	max-width: 22rem;
	margin: 0;
	padding: 0.45rem 0.75rem;
	border-radius: 8px;
	background: #2b2440;
	color: #fff;
	font: 500 0.75rem/1.35 system-ui, sans-serif;
	opacity: 0.9;
	pointer-events: none;
}
.tsfp-has-bar .tsfp-preview-flag { bottom: 7rem; }
@media (max-width: 640px) { .tsfp-has-bar .tsfp-preview-flag { display: none; } }

@media (prefers-reduced-motion: reduce) {
	.tsfp-btn { transition: none; }
}
