/*
 * Qazaqstan mektebi — journal homepage layout (templates/frontend/pages/indexJournal.tpl override).
 * Scope: .qm-home-page (journal index only). Colour tokens come from the journal stylesheet
 * (:root --qm-*); fallbacks keep the page readable if that stylesheet is missing.
 * Selectors are deliberately ≥ the specificity of the older homepage rules in the journal
 * stylesheet (.pkp_structure_main a.qm-btn, ul.qm-facts …), which loads later.
 */

.qm-home-page {
	--qmh-ink: var(--qm-ink, #1c1838);
	--qmh-muted: var(--qm-muted, #5d5a78);
	--qmh-primary: var(--qm-primary, #5734ff);
	--qmh-indigo: var(--qm-indigo, #2a1f8f);
	--qmh-border: var(--qm-border, #e4e1f5);
	--qmh-divider: var(--qm-divider, #ece9f7);
	--qmh-tint: var(--qm-tint, #eeebff);
	--qmh-gradient: var(--qm-gradient, linear-gradient(90deg, #5734ff 0%, #0072e5 100%));
	--qmh-radius: 14px;
}

/* vertical rhythm between the homepage sections */
.qm-home-page > section + section,
.qm-home-page > .qm-hero + .cmp_announcements {
	margin-top: 2.75rem;
}

/* ---------- 1. hero ---------- */
.pkp_structure_main .qm-hero {
	position: relative;
	margin: 0;
	padding: 2rem 2rem 1.75rem;
	border: 1px solid var(--qmh-border);
	border-radius: var(--qmh-radius);
	background:
		radial-gradient(520px 220px at 100% 0%, rgb(0 150 255 / 0.10), transparent 70%),
		radial-gradient(420px 220px at 0% 100%, rgb(87 52 255 / 0.08), transparent 70%),
		linear-gradient(180deg, #fbfaff 0%, #f4f2ff 100%);
	overflow: hidden;
}

.pkp_structure_main .qm-hero--media {
	display: grid;
	grid-template-columns: minmax(0, 168px) minmax(0, 1fr);
	gap: 1.75rem;
	align-items: start;
}

.qm-hero__media img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 10px;
	box-shadow: 0 14px 30px -18px rgb(28 24 56 / 0.55);
}

.pkp_structure_main .qm-hero__title {
	margin: 0 0 0.6rem;
	font-size: 2rem;
	font-size: clamp(1.55rem, 1.2rem + 1.2vw, 2.15rem);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--qmh-ink);
}

.qm-hero__ids {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin: 0 0 1.1rem;
}

.qm-chip {
	display: inline-flex;
	align-items: center;
	padding: 0.2rem 0.7rem;
	border: 1px solid var(--qmh-border);
	border-radius: 999px;
	background: #fff;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--qmh-indigo);
	font-variant-numeric: tabular-nums;
}

/* Additional Content inside the hero (admin-authored HTML) */
.pkp_structure_main .qm-hero .additional_content {
	margin: 0;
	padding: 0;
	border: 0;
}

.qm-hero .qm-home {
	display: flex;
	flex-direction: column;
}

.qm-hero .qm-home > * {
	margin: 0 0 0.8rem;
}

.qm-hero .qm-home p {
	max-width: 68ch;
	font-size: 1rem;
	line-height: 1.7;
	color: var(--qmh-ink);
}

.qm-hero .qm-home .qm-home__lead {
	font-size: 1.08rem;
	line-height: 1.65;
}

/* CTA row: the paragraph that holds the buttons comes before the facts */
.qm-hero .qm-home > p:has(.qm-btn) {
	order: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	margin-top: 0.4rem;
}

/* buttons placed directly in .qm-home (not wrapped in a paragraph) */
.qm-hero .qm-home > a.qm-btn {
	order: 2;
	align-self: flex-start;
}

.pkp_structure_main .qm-hero a.qm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin: 0;
	padding: 0.65rem 1.3rem;
	border-radius: 10px;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.2;
	box-shadow: 0 10px 22px -14px rgb(87 52 255 / 0.85);
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.pkp_structure_main .qm-hero a.qm-btn:hover,
.pkp_structure_main .qm-hero a.qm-btn:focus-visible {
	transform: translateY(-1px);
	opacity: 1;
	box-shadow: 0 14px 26px -14px rgb(87 52 255 / 0.95);
}

.pkp_structure_main .qm-hero a.qm-btn--ghost {
	box-shadow: inset 0 0 0 1px rgb(87 52 255 / 0.45);
}

.pkp_structure_main .qm-hero a.qm-btn:focus-visible {
	outline: 3px solid rgb(87 52 255 / 0.35);
	outline-offset: 2px;
}

/* ---------- 2. facts as cards ---------- */
.pkp_structure_main .qm-hero ul.qm-facts {
	order: 3;
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.75rem;
	margin: 1.25rem 0 0;
	padding: 1.25rem 0 0;
	border: 0;
	border-top: 1px solid var(--qmh-border);
	border-radius: 0;
	background: transparent;
	list-style: none;
}

.pkp_structure_main .qm-hero ul.qm-facts li {
	margin: 0;
	padding: 0.9rem 1rem;
	border: 1px solid var(--qmh-border);
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 1px 2px rgb(42 31 143 / 0.05);
	font-size: 0.82rem;
	line-height: 1.45;
	color: var(--qmh-muted);
}

.pkp_structure_main .qm-hero ul.qm-facts strong {
	display: block;
	margin-bottom: 0.2rem;
	font-size: 1.35rem;
	font-weight: 700;
	line-height: 1.2;
	color: var(--qmh-primary);
	font-variant-numeric: tabular-nums;
}

/* ---------- section headings ---------- */
.qm-section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.25rem 1rem;
	margin-bottom: 0.35rem;
}

.pkp_page_index .pkp_structure_main .qm-section-head h2,
.pkp_page_index .pkp_structure_main .qm-home-page .cmp_announcements > h2 {
	position: relative;
	margin: 0;
	padding-left: 0.85rem;
	font-size: 1.4rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--qmh-ink);
}

.pkp_structure_main .qm-section-head h2::before,
.pkp_structure_main .qm-home-page .cmp_announcements > h2::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.2em;
	bottom: 0.2em;
	width: 4px;
	border-radius: 4px;
	background: var(--qmh-gradient);
}

.pkp_structure_main a.qm-section-head__link {
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: none;
}

.pkp_structure_main a.qm-section-head__link::after {
	content: " \2192";
}

/* ---------- 3. current issue ---------- */
.qm-issue__card {
	display: grid;
	grid-template-columns: 132px minmax(0, 1fr);
	gap: 1.5rem;
	align-items: center;
	margin-top: 1rem;
	padding: 1.25rem;
	border: 1px solid var(--qmh-border);
	border-radius: var(--qmh-radius);
	background: #fff;
	box-shadow: 0 1px 2px rgb(42 31 143 / 0.05);
}

.qm-issue__cover img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 14px 30px -18px rgb(28 24 56 / 0.55);
}

/* stand-in "cover" when the issue has no cover image */
.qm-issue__tile {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	aspect-ratio: 3 / 4;
	padding: 0.8rem 0.7rem;
	border-radius: 8px;
	background:
		radial-gradient(120px 90px at 100% 0%, rgb(0 215 255 / 0.35), transparent 70%),
		linear-gradient(160deg, #2a1f8f 0%, #4b33e6 60%, #1f8bff 100%);
	color: #fff;
	box-shadow: 0 14px 30px -18px rgb(28 24 56 / 0.55);
}

.qm-issue__tile-name {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1.25;
	text-transform: uppercase;
	opacity: 0.9;
}

.qm-issue__tile-id {
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.2;
}

.pkp_page_index .qm-issue .qm-issue__title {
	margin: 0 0 0.9rem;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--qmh-ink);
}

.qm-issue__galleys {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* cover is shown in the card; hide the TOC copy and collapse an empty heading */
.qm-issue .obj_issue_toc .heading .cover {
	display: none;
}

.qm-issue .obj_issue_toc .heading:not(:has(> :not(.cover))) {
	display: none;
}

.pkp_structure_main a.qm-galley {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	min-height: 44px;
	padding: 0.55rem 0.95rem;
	border-radius: 10px;
	background: var(--qmh-gradient);
	color: #fff;
	font-weight: 600;
	font-size: 0.92rem;
	text-decoration: none;
	box-shadow: 0 10px 22px -14px rgb(87 52 255 / 0.85);
}

.pkp_structure_main a.qm-galley:hover,
.pkp_structure_main a.qm-galley:focus-visible {
	color: #fff;
	opacity: 0.92;
}

.pkp_structure_main a.qm-galley:focus-visible {
	outline: 3px solid rgb(87 52 255 / 0.35);
	outline-offset: 2px;
}

.qm-galley.pdf::before {
	content: "";
	width: 1.05rem;
	height: 1.05rem;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M12 18v-6M9 15l3 3 3-3'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M12 18v-6M9 15l3 3 3-3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.qm-galley__lang {
	padding: 0.05rem 0.45rem;
	border-radius: 999px;
	background: rgb(255 255 255 / 0.22);
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.06em;
}

.qm-galley.restricted::after {
	content: "\1F512";
	font-size: 0.8rem;
}

/* issue_toc.tpl inside the section */
.qm-issue .obj_issue_toc .heading {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
	align-items: flex-start;
	margin: 0 0 0.5rem;
}

.qm-issue .obj_issue_toc .heading .description,
.qm-issue .obj_issue_toc .heading .published,
.qm-issue .obj_issue_toc .heading .pub_id {
	flex: 1 1 260px;
	margin: 0;
	color: var(--qmh-muted);
	font-size: 0.9rem;
}

.qm-issue .obj_issue_toc .sections .section > h3 {
	margin: 1.5rem 0 0.25rem;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--qmh-muted);
}

.qm-issue .cmp_article_list > li {
	margin: 0;
	padding: 0.9rem 0;
	border-bottom: 1px solid var(--qmh-divider);
}

.qm-issue .cmp_article_list > li:last-child {
	border-bottom: 0;
}

.qm-issue .obj_article_summary > .title {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.45;
}

.qm-issue .obj_article_summary .authors {
	color: var(--qmh-muted);
	font-size: 0.875rem;
}

/* ---------- 4. announcements ---------- */
.qm-home-page .cmp_announcements {
	border-top: 0;
}

.qm-home-page .cmp_announcements > .obj_announcement_summary,
.qm-home-page .cmp_announcements .more {
	padding-left: 0.85rem;
}

/* sidebar: hide the duplicate "Make a submission" block on the homepage, but only
   when the hero really contains a CTA button (otherwise the block stays visible) */
body.pkp_page_index:has(.qm-hero a.qm-btn) .pkp_structure_sidebar .block_make_submission {
	display: none;
}

/* ---------- responsive ---------- */
@media (max-width: 767px) {
	.pkp_structure_main .qm-hero {
		padding: 1.35rem 1.1rem 1.2rem;
		border-radius: 12px;
	}

	.pkp_structure_main .qm-hero--media {
		grid-template-columns: minmax(0, 1fr);
		gap: 1rem;
	}

	.qm-hero__media img {
		max-width: 140px;
	}

	.pkp_structure_main .qm-hero ul.qm-facts {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.5rem;
	}

	.pkp_structure_main .qm-hero ul.qm-facts li {
		padding: 0.75rem 0.8rem;
	}

	.pkp_structure_main .qm-hero ul.qm-facts strong {
		font-size: 1.15rem;
	}

	.qm-hero .qm-home > p:has(.qm-btn) > a.qm-btn {
		flex: 1 1 100%;
	}

	.qm-issue__card {
		grid-template-columns: 96px minmax(0, 1fr);
		gap: 1rem;
		padding: 1rem;
	}

	.qm-issue__tile-id {
		font-size: 0.85rem;
	}

	.pkp_page_index .qm-issue .qm-issue__title {
		font-size: 1.1rem;
	}

	.pkp_page_index .pkp_structure_main .qm-section-head h2,
	.pkp_page_index .pkp_structure_main .qm-home-page .cmp_announcements > h2 {
		font-size: 1.25rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pkp_structure_main .qm-hero a.qm-btn {
		transition: none;
	}

	.pkp_structure_main .qm-hero a.qm-btn:hover,
	.pkp_structure_main .qm-hero a.qm-btn:focus-visible {
		transform: none;
	}
}
