/* Karmelindo portal — shared responsive base for this app's `www/` pages.
 *
 * Loaded on every website page of the site via `web_include_css` (hooks.py),
 * so EVERY rule here is scoped under `.kp-portal`. Nothing outside a
 * Karmelindo portal page can be affected by this file - the site is shared
 * with ERPNext's own web pages and other apps' pages.
 *
 * A portal page opts in with ONE class on its outermost element:
 *     <div class="kp-portal"> ... </div>
 *
 * What is deliberately NOT here:
 *  - no viewport meta: Frappe's own base.html already emits
 *    `width=device-width, initial-scale=1` for every www page (guarded by a
 *    test in tests/test_portal_mobile.py, so an override would be caught).
 *  - no media-query breakpoint system and no grid: Bootstrap 4.6 ships with
 *    the website bundle and its `row`/`col-md-*` already stack on phones.
 *    This file only fixes what Bootstrap does not give us.
 *  - no JS: no resize listeners, no layout measurement (performance gate).
 */

.kp-portal {
	/* Long titles, author names and ISBNs must wrap rather than widen the
	   page - unintended horizontal scrolling is the failure mode this whole
	   file exists to prevent. */
	overflow-wrap: break-word;
	word-wrap: break-word;
}

.kp-portal img,
.kp-portal table,
.kp-portal pre {
	max-width: 100%;
}

.kp-portal table {
	display: block;
	overflow-x: auto; /* a wide table scrolls itself, never the page */
}

/* iOS Safari zooms the whole page in when a focused input's font is under
   16px. That zoom is what makes a form feel broken on a phone. */
.kp-portal .form-control,
.kp-portal .custom-select,
.kp-portal select,
.kp-portal input,
.kp-portal textarea {
	font-size: 16px;
	max-width: 100%;
}

/* 44px is the smallest comfortable touch target; Bootstrap 4's default
   button is ~38px. Applies to the pagination links too, which are plain
   anchors. */
.kp-portal .btn,
.kp-portal .kp-pagination a {
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

/* Bootstrap 4.6 has no `gap` utility (that is Bootstrap 5), so action rows
   space themselves. */
.kp-portal .kp-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
}

.kp-portal .kp-actions > * + * {
	margin-left: 0.5rem;
}

.kp-portal .kp-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	margin-top: 1rem;
}

.kp-portal .kp-pagination > * {
	padding: 0 0.75rem;
}

/* Phone widths (the todo's targets are 320 / 375 / 480px): the action row
   stacks and its buttons go full width, so nothing is squeezed under the
   thumb and nothing overflows at 320px. */
@media (max-width: 575.98px) {
	.kp-portal .kp-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.kp-portal .kp-actions > * + * {
		margin-left: 0;
		margin-top: 0.5rem;
	}

	.kp-portal .kp-pagination {
		justify-content: space-between;
	}

	.kp-portal .kp-pagination > * {
		padding: 0;
	}
}
