/*
 * Frequently asked questions.
 *
 * Twenty-eight questions with every answer open: 13,459px on a desktop and
 * 22,168 on a phone. The answers run from 147 characters to 3,124, so the long
 * ones buried the short ones and there was no way to see what was asked without
 * reading what was answered.
 *
 * Every custom property carries a fallback. The plugin owns this markup
 * (ADR-001) and has to keep looking like itself under a theme that has never
 * heard of these tokens.
 */

.jmns-faq {
	margin-block-start: var(--wp--preset--spacing--40, 1.5rem);
}

.jmns-faq__count {
	margin-block: 0 var(--wp--preset--spacing--30, 1rem);
	color: var(--wp--preset--color--text-secondary, #5E6D63);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

.jmns-faq__item {
	border-block-end: 1px solid var(--wp--preset--color--border, #DCE4DF);
}

.jmns-faq__item:first-of-type {
	border-block-start: 1px solid var(--wp--preset--color--border, #DCE4DF);
}

/*
 * The summary is the control, so it carries a control's target — the whole row,
 * not the words — and 44px of height at the shortest question.
 */
.jmns-faq__summary {
	display: flex;
	align-items: baseline;
	gap: var(--wp--preset--spacing--30, 1rem);
	min-block-size: 44px;
	padding-block: var(--wp--preset--spacing--30, 1rem);
	cursor: pointer;
	list-style: none;
}

/* Safari draws its own triangle through this pseudo-element. */
.jmns-faq__summary::-webkit-details-marker {
	display: none;
}

/*
 * A chevron that turns rather than two glyphs that swap: one element, one
 * state, nothing to keep in step. `flex: none` so a two-line question does not
 * squeeze it.
 */
.jmns-faq__summary::before {
	content: "";
	flex: none;
	align-self: center;
	inline-size: 0.5rem;
	block-size: 0.5rem;
	border-inline-end: 2px solid var(--wp--preset--color--interactive, #245746);
	border-block-end: 2px solid var(--wp--preset--color--interactive, #245746);
	transform: rotate(-45deg);
	transition: transform var(--t-fast, 150ms) var(--ease, ease);
}

.jmns-faq__item[open] > .jmns-faq__summary::before {
	transform: rotate(45deg);
}

/*
 * The question is a heading inside the summary, which the content model allows
 * so a disclosure can still be navigable by heading. It is set at body weight
 * and size: twenty-eight headings at heading size is a wall of its own.
 */
.jmns-faq__question {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading, inherit);
	font-size: var(--wp--preset--font-size--medium, 1rem);
	font-weight: 600;
	line-height: 1.45;
	text-wrap: pretty;
}

.jmns-faq__summary:hover .jmns-faq__question {
	color: var(--wp--preset--color--interactive-hover, #173D32);
}

.jmns-faq__summary:focus-visible {
	outline: 3px solid var(--wp--preset--color--interactive, #245746);
	outline-offset: 2px;
	border-radius: var(--r-input, 12px);
}

/*
 * The answer is indented to the question's text, not the chevron, so an open
 * answer reads as belonging to the line above it.
 */
.jmns-faq__answer {
	max-inline-size: 62ch;
	margin-inline-start: calc(0.5rem + var(--wp--preset--spacing--30, 1rem));
	padding-block-end: var(--wp--preset--spacing--40, 1.25rem);
	line-height: 1.7;
}

.jmns-faq__answer > :first-child {
	margin-block-start: 0;
}

.jmns-faq__answer > :last-child {
	margin-block-end: 0;
}

/*
 * Two answers are tables of prayer-time zones and calendar types, and a table
 * cannot reflow. It scrolls inside its own box so the page never does — a
 * horizontally scrolling document is the failure this avoids.
 */
.jmns-faq__answer table {
	display: block;
	max-inline-size: 100%;
	overflow-x: auto;
	border-collapse: collapse;
}

.jmns-faq__answer th,
.jmns-faq__answer td {
	padding: var(--wp--preset--spacing--20, 0.5rem);
	border: 1px solid var(--wp--preset--color--border, #DCE4DF);
	text-align: start;
	vertical-align: top;
}

.jmns-faq__answer th {
	background-color: var(--wp--preset--color--surface-tint, #EAF1EC);
	font-weight: 700;
}

@media (max-width: 30rem) {
	.jmns-faq__answer {
		/* The indent costs a fifth of a 342px screen; the border and the
		   chevron already say what belongs to what. */
		margin-inline-start: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jmns-faq__summary::before {
		transition: none;
	}
}

/* --------------------------------------------------------------- groups -- */

/*
 * Two subjects, fourteen questions each: the department's own divisions, Fatwa
 * and Falak. The page carried no marker for the boundary — twenty-eight
 * questions ran together — so it is read from what each question is about.
 */
.jmns-faq__group + .jmns-faq__group {
	margin-block-start: var(--wp--preset--spacing--60, 2.5rem);
}

.jmns-faq__group-title {
	display: flex;
	align-items: baseline;
	gap: var(--wp--preset--spacing--20, 0.5rem);
	margin-block: 0 var(--wp--preset--spacing--20, 0.5rem);
	font-family: var(--wp--preset--font-family--heading, inherit);
	font-size: var(--wp--preset--font-size--title-sm, 1.25rem);
	font-weight: 700;
	line-height: 1.3;
}

/*
 * The count sits in the heading because it is what tells you how much is behind
 * it before you open anything — the reason the boundary is worth drawing.
 */
.jmns-faq__group-count {
	padding-inline: var(--wp--preset--spacing--20, 0.5rem);
	border-radius: var(--r-pill, 999px);
	background-color: var(--wp--preset--color--surface-tint, #EAF1EC);
	color: var(--wp--preset--color--interactive, #245746);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-variant-numeric: tabular-nums;
	font-weight: 700;
}
