/*
 * Accessibility bar (#a11y-bar) and the font-size function.
 * Spec: specs/run/A1-digitalna-pristupacnost/session-1-foundation-font-size.md, section 7.
 * Markup: yiisemis/protected/views/_common/_accessibilityBar.php, behaviour: js/accessibility.js.
 * High contrast lives in css/accessibility-contrast.css, the dyslexia font in css/accessibility-dyslexia.css.
 */

/* ---------- 1. Bar ---------- */

#a11y-bar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 34px;
	z-index: 1031;
	background: #111;
	color: #fff;
	font: 13px/34px "Open Sans", Calibri, Candara, Arial, sans-serif;
}

.a11y-bar__inner {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: nowrap;
	overflow: hidden;
	max-width: 1170px;
	margin: 0 auto;
	padding: 0 15px;
}

.a11y-bar__title {
	white-space: nowrap;
}

.a11y-bar__group {
	display: flex;
	align-items: center;
	gap: 4px;
}

.a11y-bar__value {
	min-width: 3.2em;
	text-align: center;
	white-space: nowrap;
}

.a11y-btn {
	margin: 0;
	padding: 2px 8px;
	border: 1px solid #888;
	border-radius: 3px;
	background: transparent;
	color: #fff;
	font: inherit;
	line-height: 20px;
	white-space: nowrap;
	cursor: pointer;
}

.a11y-btn:hover,
.a11y-btn[aria-pressed="true"] {
	background: #fff;
	color: #000;
}

/* font-down / font-up at the smallest / largest scale (js/accessibility.js sets disabled) */
.a11y-btn[disabled],
.a11y-btn[disabled]:hover {
	background: transparent;
	color: #fff;
	opacity: 0.45;
	cursor: default;
}

/* Visible focus in every state. This is an accessibility feature: never remove it. */
#a11y-bar .a11y-btn:focus,
#a11y-bar-expand:focus {
	outline: 2px solid #ff0;
	outline-offset: 1px;
}

.a11y-btn--link {
	border-color: transparent;
}

.a11y-bar__collapse {
	margin-left: auto;
}

.a11y-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

/* ---------- 2. Offsets ---------- */

/*
 * The navbar is fixed at top: 0 and the content clears it by #banner.page-header { margin-top: 60px }.
 * The bar is rendered directly before <div class="wrapper">, so these sibling selectors are the single
 * source of truth: no bar rendered, no offset. Screen only, so printouts keep their old top margin.
 */
@media screen {
	#a11y-bar + .wrapper .navbar-fixed-top {
		top: 34px;
	}

	#a11y-bar + .wrapper #banner.page-header {
		margin-top: 94px;
	}
}

/* ---------- 3. Collapsed state ---------- */

html.a11y-bar-collapsed #a11y-bar {
	display: none;
}

html.a11y-bar-collapsed #a11y-bar + .wrapper .navbar-fixed-top {
	top: 0;
}

html.a11y-bar-collapsed #a11y-bar + .wrapper #banner.page-header {
	margin-top: 60px;
}

#a11y-bar-expand {
	display: none;
	position: fixed;
	bottom: 16px;
	right: 16px;
	z-index: 1031;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 1px solid #888;
	border-radius: 50%;
	background: #111;
	color: #fff;
	font-size: 18px;
	line-height: 38px;
	text-align: center;
	cursor: pointer;
}

html.a11y-bar-collapsed #a11y-bar-expand {
	display: block;
}

/* ---------- 4. Static variant (eSavjetnik layout: no fixed navbar, no .wrapper) ---------- */

#a11y-bar.a11y-bar--static {
	position: static;
}

/* ---------- 5. Small screens: the bar moves to the bottom ---------- */

@media (max-width: 767px) {
	#a11y-bar {
		top: auto;
		bottom: 0;
		height: auto;
		min-height: 34px;
		padding: 2px 0;
		line-height: 30px;
	}

	.a11y-bar__inner {
		flex-wrap: wrap;
	}

	.a11y-btn {
		padding: 1px 6px;
	}

	#a11y-bar + .wrapper .navbar-fixed-top {
		top: 0;
	}

	#a11y-bar + .wrapper #banner.page-header {
		margin-top: 60px;
	}
}

/* ---------- 6. Print ---------- */

@media print {
	#a11y-bar,
	#a11y-bar-expand {
		display: none !important;
	}
}

/* ---------- 7. Font size ---------- */

/*
 * Every size in this UI is in px (Bootstrap 3), so html { font-size } changes nothing. zoom scales text,
 * controls and layout together. The bar and the fixed navbar are inside body, so they scale with the
 * content and the 34px / 94px offsets stay consistent. Screen only: printouts keep their normal size.
 */
@media screen {
	html.a11y-font-85 body { zoom: 0.85; }
	html.a11y-font-115 body { zoom: 1.15; }
	html.a11y-font-130 body { zoom: 1.30; }
	html.a11y-font-150 body { zoom: 1.50; }

	/* Best-effort fallback for browsers without zoom (Firefox before 126): it scales text only, not controls or layout. */
	@supports not (zoom: 1) {
		html.a11y-font-85 body, html.a11y-font-85 .form-control, html.a11y-font-85 .btn, html.a11y-font-85 .dropdown-menu, html.a11y-font-85 .table, html.a11y-font-85 .navbar-nav > li > a { font-size: 12.75px; }
		html.a11y-font-115 body, html.a11y-font-115 .form-control, html.a11y-font-115 .btn, html.a11y-font-115 .dropdown-menu, html.a11y-font-115 .table, html.a11y-font-115 .navbar-nav > li > a { font-size: 17px; }
		html.a11y-font-130 body, html.a11y-font-130 .form-control, html.a11y-font-130 .btn, html.a11y-font-130 .dropdown-menu, html.a11y-font-130 .table, html.a11y-font-130 .navbar-nav > li > a { font-size: 19.5px; }
		html.a11y-font-150 body, html.a11y-font-150 .form-control, html.a11y-font-150 .btn, html.a11y-font-150 .dropdown-menu, html.a11y-font-150 .table, html.a11y-font-150 .navbar-nav > li > a { font-size: 22.5px; }
	}
}

/* ---------- 8. Boxes of fixed height in the application (added in session 4) ---------- */

/*
 * Found on the running instance: with enlarged text or the dyslexia font, text wraps onto more lines than two boxes of
 * the application allow. Only in those states; the default look does not change.
 * - Home page tiles (tpl/home.php): every column has an inline height of 200px, and captions of three or more lines
 *   ran under the next row of tiles. The column grows with its caption, and every row of six starts on a new line.
 * - Calendars (tpl/daily-activity-list.php, views/karticaTecaja/courseCalendarView.php): a weekday title that wraps
 *   ("Ponedjeljak") is taller than the others, and the floated day cells then started beside it, one column too far
 *   right. The row of titles now encloses its floats.
 */
@media screen {
	html.a11y-font-115 body.home section > .row > .col-sm-2,
	html.a11y-font-130 body.home section > .row > .col-sm-2,
	html.a11y-font-150 body.home section > .row > .col-sm-2,
	html.a11y-dyslexia body.home section > .row > .col-sm-2 {
		height: auto !important;
		min-height: 200px;
	}

	html.a11y-font-115 body.home section > .row > .col-sm-2:nth-child(6n+1),
	html.a11y-font-130 body.home section > .row > .col-sm-2:nth-child(6n+1),
	html.a11y-font-150 body.home section > .row > .col-sm-2:nth-child(6n+1),
	html.a11y-dyslexia body.home section > .row > .col-sm-2:nth-child(6n+1) {
		clear: left;
	}

	html.a11y-font-115 .weekday-titles:after,
	html.a11y-font-130 .weekday-titles:after,
	html.a11y-font-150 .weekday-titles:after,
	html.a11y-dyslexia .weekday-titles:after {
		content: "";
		display: table;
		clear: both;
	}
}
