/* ==========================================================================
   Teletekst RTVFBiH - moderni front
   Radi nad postojecim FAB exportom (NNN/NNN_SSSS.htm + .png). Ne mijenja ih.
   ========================================================================== */

/* --------------------------------------------------------------- svjetla tema */

:root {
	--bg:          #ffffff;
	--bg-2:        #f4f7fb;
	--surface:     #ffffff;
	--surface-2:   #eef2f8;
	--surface-3:   #e3eaf3;
	--border:      #dde5ef;
	--border-soft: #e9eef5;

	--text:        #13294b;
	--text-2:      #40506b;
	--muted:       #6b7b95;
	--faint:       #93a1b5;

	--gold:        #d99a1f;
	--accent:      #13294b;
	--accent-soft: rgba(19, 41, 75, .07);
	--live:        #e0342f;

	--frame:       #e8eef6;
	--frame-edge:  #d5dfeb;
	--shadow:      0 18px 40px -18px rgba(19, 41, 75, .35);

	--radius:      12px;
	--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--mono: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

	color-scheme: light;
}

/* ----------------------------------------------------------------- tamna tema */

:root[data-theme="dark"] {
	--bg:          #0b0e14;
	--bg-2:        #10151e;
	--surface:     #141a25;
	--surface-2:   #1b2230;
	--surface-3:   #232c3c;
	--border:      #273042;
	--border-soft: #1d2533;

	--text:        #e8eef7;
	--text-2:      #b2bdcd;
	--muted:       #8695aa;
	--faint:       #616f85;

	--gold:        #e8b54a;
	--accent:      #e8eef7;
	--accent-soft: rgba(232, 181, 74, .12);
	--live:        #ff5a56;

	--frame:       #171d28;
	--frame-edge:  #2a3446;
	--shadow:      0 24px 60px -22px rgba(0, 0, 0, .85);

	color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg:          #0b0e14;
		--bg-2:        #10151e;
		--surface:     #141a25;
		--surface-2:   #1b2230;
		--surface-3:   #232c3c;
		--border:      #273042;
		--border-soft: #1d2533;

		--text:        #e8eef7;
		--text-2:      #b2bdcd;
		--muted:       #8695aa;
		--faint:       #616f85;

		--gold:        #e8b54a;
		--accent:      #e8eef7;
		--accent-soft: rgba(232, 181, 74, .12);
		--live:        #ff5a56;

		--frame:       #171d28;
		--frame-edge:  #2a3446;
		--shadow:      0 24px 60px -22px rgba(0, 0, 0, .85);

		color-scheme: dark;
	}
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	font-family: var(--font);
	font-size: 14px;
	color: var(--text);
	background: var(--bg);
	transition: background .2s, color .2s;
}

a { color: inherit; text-decoration: none; }

[hidden] { display: none !important; }

/* ====================================================== traka 1: meni RTVFBiH */

/* meni je centriran; logo i prekidac teme su "zakaceni" za rubove */
.sitebar {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 26px;
	min-height: 62px;
	background: var(--bg);
	border-bottom: 1px solid var(--border);
}

.sitebar__logo {
	position: absolute;
	left: 26px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	gap: 10px;
}

.sitebar__logo img { width: 34px; height: auto; display: block; }

:root[data-theme="dark"] .sitebar__logo img,
.sitebar__logo img { background: #fff; border-radius: 7px; padding: 3px; }

/* glavni meni */

/* bez overflow-a: padajuci izbornici se ne smiju odsjeci, pa se meni lomi u vise redova */
.sitenav {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0 4px;
	max-width: 100%;
}

.sitenav__group { position: relative; flex: none; }

.sitenav__link {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 20px 13px;
	font-size: 14px;
	font-weight: 500;
	color: var(--text);
	white-space: nowrap;
	background: none;
	border: 0;
	border-bottom: 3px solid transparent;
	font-family: inherit;
	cursor: pointer;
	transition: color .15s, border-color .15s;
}

.sitenav__link:hover { color: var(--gold); }

.sitenav__group.is-active > .sitenav__link {
	font-weight: 650;
	border-bottom-color: var(--gold);
}

.sitenav__caret {
	width: 9px;
	height: 9px;
	flex: none;
	transition: transform .18s;
}

.sitenav__group.is-open .sitenav__caret { transform: rotate(180deg); }

/* padajuci izbornik */

.sitenav__menu {
	position: absolute;
	top: 100%;
	left: 4px;
	z-index: 50;
	min-width: 220px;
	padding: 6px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: var(--shadow);
}

.sitenav__item {
	display: block;
	padding: 9px 11px;
	font-size: 13.5px;
	color: var(--text-2);
	border-radius: 7px;
	white-space: nowrap;
	cursor: pointer;
	transition: background .13s, color .13s;
}

.sitenav__item:hover { background: var(--surface-2); color: var(--text); }

/* prekidac teme */

.themetoggle {
	position: absolute;
	right: 26px;
	top: 50%;
	transform: translateY(-50%);
	width: 38px;
	height: 38px;
	display: grid;
	place-items: center;
	color: var(--text-2);
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 9px;
	cursor: pointer;
	transition: background .15s, color .15s;
}

.themetoggle:hover { background: var(--surface-3); color: var(--text); }

.themetoggle svg { width: 17px; height: 17px; }

/* ===================================================== traka 2: meni teleteksta */

.ttbar {
	position: sticky;
	top: 0;
	z-index: 30;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px 26px;
	background: var(--bg-2);
	border-bottom: 1px solid var(--border);
}

/*
 * Namjerno drugaciji jezik od glavnog menija: glavni je obican tekst sa
 * zlatnom linijom, ovaj je segmentirana grupa pilula sa brojem stranice.
 */
.nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 2px;
	padding: 4px;
	max-width: 100%;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
}

.nav__item {
	display: flex;
	align-items: baseline;
	gap: 6px;
	padding: 7px 13px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-2);
	white-space: nowrap;
	cursor: pointer;
	transition: background .14s, color .14s;
}

.nav__item:hover { background: var(--surface-2); color: var(--text); }

.nav__num {
	font-family: var(--mono);
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: .03em;
	color: var(--faint);
	transition: color .14s;
}

.nav__item:hover .nav__num { color: var(--muted); }

.nav__item.is-active {
	background: var(--text);
	color: var(--bg);
	font-weight: 600;
}

.nav__item.is-active .nav__num { color: var(--gold); }

/* unos broja stranice - zakacen za desni rub trake */

.goto {
	position: absolute;
	right: 26px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	gap: 6px;
}

.goto__input {
	width: 62px;
	padding: 7px 10px;
	font-family: var(--mono);
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: .05em;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	outline: none;
	transition: border-color .15s;
}

.goto__input:focus { border-color: var(--gold); }
.goto__input::placeholder { color: var(--faint); font-weight: 500; }

.goto__btn {
	padding: 8px 14px;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	color: var(--bg);
	background: var(--text);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	transition: opacity .15s;
}

.goto__btn:hover { opacity: .85; }

/* ================================================================ ekran */

.stage {
	flex: 1 0 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 30px 20px 38px;
	background: var(--bg-2);
}

.meta {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 12px;
	color: var(--muted);
}

.meta__page {
	font-family: var(--mono);
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: .05em;
	color: var(--text);
	padding: 4px 10px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 6px;
}

.meta__live { display: flex; align-items: center; gap: 6px; }

.meta__live::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--live);
	animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
	0%   { box-shadow: 0 0 0 0 rgba(224, 52, 47, .45); }
	70%  { box-shadow: 0 0 0 7px rgba(224, 52, 47, 0); }
	100% { box-shadow: 0 0 0 0 rgba(224, 52, 47, 0); }
}

.screen {
	position: relative;
	/* 1.4286 = 480/336 - ekran se suzi da pager i traka ostanu u vidnom polju */
	width: min(960px, 100%, calc((100vh - 320px) * 1.4286));
	aspect-ratio: 480 / 336;
	padding: 12px;
	background: var(--frame);
	border: 1px solid var(--frame-edge);
	border-radius: 16px;
	box-shadow: var(--shadow);
}

.screen__inner {
	position: relative;
	width: 100%;
	height: 100%;
	background: #000;
	border-radius: 6px;
	overflow: hidden;
	transition: opacity .12s;
}

.screen.is-loading .screen__inner { opacity: .45; }

.screen__img {
	display: block;
	width: 100%;
	height: 100%;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
}

.hotspot {
	position: absolute;
	border-radius: 3px;
	cursor: pointer;
	transition: background .12s, box-shadow .12s;
}

.hotspot:hover {
	background: rgba(232, 181, 74, .25);
	box-shadow: 0 0 0 1px rgba(232, 181, 74, .8) inset;
}

.empty {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	text-align: center;
	padding: 24px;
}

.empty__code {
	font-family: var(--mono);
	font-size: clamp(38px, 7vw, 64px);
	font-weight: 700;
	letter-spacing: .04em;
	color: #2b3446;
}

.empty__text { font-size: 13.5px; color: #8695aa; max-width: 34ch; line-height: 1.5; }

/* ------------------------------------------------------------------ pager */

.pager {
	display: flex;
	align-items: center;
	gap: 9px;
	flex-wrap: wrap;
	justify-content: center;
}

.pager__btn {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 8px 14px;
	font: inherit;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-2);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 9px;
	cursor: pointer;
	transition: background .15s, color .15s, border-color .15s;
}

.pager__btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.pager__btn:disabled { opacity: .4; cursor: default; }

.pager__num { font-family: var(--mono); font-size: 12.5px; font-weight: 700; }

.subs {
	display: flex;
	align-items: center;
	gap: 3px;
	padding: 4px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 9px;
}

.subs__item {
	min-width: 30px;
	height: 28px;
	padding: 0 8px;
	display: grid;
	place-items: center;
	font-family: var(--mono);
	font-size: 12.5px;
	font-weight: 600;
	color: var(--muted);
	background: transparent;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	transition: background .14s, color .14s;
}

.subs__item:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.subs__item.is-active { background: var(--gold); color: #241a00; }
.subs__item:disabled { opacity: .3; cursor: default; }

.subs__select {
	height: 28px;
	padding: 0 6px;
	font-family: var(--mono);
	font-size: 12.5px;
	font-weight: 600;
	color: var(--text);
	background: var(--surface-2);
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	outline: none;
}

.hint {
	margin: 0;
	font-size: 11.5px;
	color: var(--faint);
	display: flex;
	align-items: center;
	gap: 7px;
	flex-wrap: wrap;
	justify-content: center;
}

kbd {
	font-family: var(--mono);
	font-size: 10.5px;
	padding: 2px 6px;
	color: var(--text-2);
	background: var(--surface);
	border: 1px solid var(--border);
	border-bottom-width: 2px;
	border-radius: 5px;
}

.keybuf {
	position: fixed;
	left: 50%;
	bottom: 40px;
	transform: translateX(-50%) translateY(10px);
	padding: 13px 25px;
	font-family: var(--mono);
	font-size: 29px;
	font-weight: 700;
	letter-spacing: .18em;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	box-shadow: var(--shadow);
	opacity: 0;
	pointer-events: none;
	transition: opacity .14s, transform .14s;
	z-index: 60;
}

.keybuf.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============================================================== podnozje */

.foot {
	flex: none;
	padding: 18px 26px;
	background: var(--bg);
	border-top: 1px solid var(--border);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 20px;
	font-size: 12.5px;
	color: var(--muted);
}

.foot__links { display: flex; flex-wrap: wrap; gap: 4px 16px; }

.foot__links a { color: var(--text-2); transition: color .14s; }
.foot__links a:hover { color: var(--gold); }

/* ------------------------------------------------------------- responsive */

/* polje za unos bi naletjelo na centrirane pilule - spusti ga u vlastiti red */
@media (max-width: 1150px) {
	.ttbar { flex-wrap: wrap; gap: 10px; }
	.nav   { order: 1; flex-basis: 100%; border-radius: 14px; }
	.goto {
		position: static;
		transform: none;
		right: auto;
		order: 2;
		flex-basis: 100%;
		justify-content: center;
	}
}

/* isto za glavni meni: logo i prekidac bi naletjeli na centrirane stavke */
@media (max-width: 1040px) {
	.sitebar {
		flex-wrap: wrap;
		align-items: center;
		padding: 10px 16px 0;
		min-height: 0;
	}
	.sitebar__logo,
	.themetoggle {
		position: static;
		transform: none;
		left: auto;
		right: auto;
	}
	.sitebar__logo { order: 1; }
	.themetoggle  { order: 2; margin-left: auto; }
	.sitenav      { order: 3; flex-basis: 100%; margin-top: 6px; }
	.sitenav__link { padding: 10px; font-size: 13.5px; border-bottom-width: 2px; }
}

@media (max-width: 900px) {
	.ttbar { padding: 10px 16px; }
	.stage { padding: 20px 16px 28px; justify-content: flex-start; }
	.screen { padding: 8px; border-radius: 12px; }
	.foot { padding: 16px; justify-content: center; text-align: center; }
}

@media (max-width: 560px) {
	.hint { display: none; }
	.pager__btn span:not(.pager__num) { display: none; }
	.pager__btn { padding: 8px 11px; }
	.goto { flex: 1 1 auto; }
	.goto__input { flex: 1 1 auto; width: auto; }
}
