/**
 * Question block: one question and its answer.
 *
 * Figma: PAC-Page-Designs, page "Home Page", inside "Show Hide"
 *   closed  60px tall at 1440: 12 above and below a 36px row
 *   open    plus 8px and the answer, and 20px below instead of 12
 *   nodes I2001:1726;6092:589 (open) and ...;6092:591 (closed)
 *
 * How the questions sit beside the heading is in blocks/accordion/style.css.
 */

.pchs-accordion__item {
	/*
	 * The line above each question.
	 *
	 * An inset shadow rather than border-top, because a border is a pixel of
	 * height and the frames do not have it: Figma draws a stroke on top of a
	 * shape without making it taller, so three bordered questions would push
	 * the section three pixels past its frame. A shadow paints the same line
	 * and changes no measurement.
	 */
	box-shadow: inset 0 1px 0 var(--wp--preset--color--blue-300);
	padding-block: var(--wp--preset--spacing--12); /* 12px */
}

/* On the gold tone the line is yellow-700, which is the only thing about a
   question that the tone changes. Written here rather than in the parent's
   stylesheet because it is this element's own rule - see the note above for
   why it is a shadow and not a border. */
.pchs-accordion--gold .pchs-accordion__item {
	box-shadow: inset 0 1px 0 var(--wp--preset--color--yellow-700);
}


/* ------------------------------------------------------------
   The question
   ------------------------------------------------------------ */

/* list-style and the WebKit rule remove the triangle the browser puts on a
   <summary>; the designs have their own icon on the other side. Both are
   needed - display: flex alone still leaves the marker in some browsers. */
.pchs-accordion__question {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--20); /* 20px */
	padding-left: var(--wp--preset--spacing--8); /* 8px */
	cursor: pointer;
	list-style: none;
}

.pchs-accordion__question::-webkit-details-marker {
	display: none;
}

/*
 * HOVERED, AND THIS WAS MISSING FROM EVERY FAQ ON THE SITE.
 *
 * The design system draws it: Show Hide item, State=Hover, node 6092:670
 * in Pacific College Library. The row takes a gray-300 ground and nothing
 * else changes - the rule above it stays blue-300, the question stays
 * blue-500, and nothing moves.
 *
 * On the item rather than on the <summary>, because the frame fills the
 * whole row and not just the line of words.
 */
.pchs-accordion__item {
	transition: background-color 0.2s ease;
}

.pchs-accordion__item:hover {
	background-color: var(--wp--preset--color--gray-300);
}

/*
 * EXCEPT ON THE GOLD TONE, WHICH HAS NO HOVER DRAWN FOR IT.
 *
 * gray-300 is a cool grey and the gold tone's panels are a warm pale
 * yellow, so the row came out as a grey-blue band across the yellow -
 * visibly wrong, and not something the design asked for. The Library's
 * item is drawn on the grey tone; the gold tone is a recolouring that the
 * item's own variants know nothing about, and the warm value a gold row
 * should take is not written anywhere.
 *
 * So the gold FAQ keeps what it has had all along, which is nothing. This
 * is a question for the design rather than a colour to pick here.
 */
.pchs-accordion--gold .pchs-accordion__item:hover {
	background-color: transparent;
}

@media (prefers-reduced-motion: reduce) {

	.pchs-accordion__item {
		transition: none;
	}
}

/* Only when reached by keyboard: a mouse user clicking a question should not
   be left with a ring around it. */
.pchs-accordion__question:focus-visible {
	outline: 2px solid var(--wp--preset--color--blue-300);
	outline-offset: 2px;
}

.pchs-accordion__text {
	min-width: 0;
	flex: 1 1 0;
	color: var(--wp--preset--color--blue-500);
	font-family: var(--wp--preset--font-family--navigation);
	font-size: var(--wp--preset--font-size--md); /* 16px */
	font-weight: 500;
	/* Whole pixels rather than the 1.24 Figma reports, because Figma lays
	   text out on whole pixels and the leftover fraction would leave every
	   question slightly taller than its frame. */
	line-height: 20px; /* 16 x 1.24 */
	text-align: left;
}

/* 36px of box around a 20px drawing, which is what the designs draw and what
   gives the question its 60px closed height. */
.pchs-accordion__icon {
	display: flex;
	width: 36px;
	height: 36px;
	flex: 0 0 36px;
	align-items: center;
	justify-content: center;
	border-radius: var(--wp--custom--radius--full);
	color: var(--wp--preset--color--blue-500);
	transition: transform 0.2s ease;
}

/* The cross on an open question is the plus turned through 45 degrees - the
   same drawing, so the two states cannot drift apart. */
.pchs-accordion__item[open] .pchs-accordion__icon {
	transform: rotate(45deg);
}


/* ------------------------------------------------------------
   The answer

   Ordinary paragraphs and lists, written in the editor like any
   other content, so the rules here set the type and the rhythm
   rather than naming particular elements.
   ------------------------------------------------------------ */

/*
 * The space above and below the answer is margin on the answer rather than
 * padding on the question, and the open and closed states differ in nothing
 * else. That is what lets view.js animate the answer alone: height, both
 * margins and opacity are all on this one box, so there is nothing left to
 * jump while it slides.
 *
 * It measures the same either way. Closed: 12 + 36 + 12 = 60. Open:
 * 12 + 36 + 8 + the answer + 8 + 12, which is the 235 the frame draws.
 */
.pchs-accordion__answer {
	margin-top: var(--wp--preset--spacing--8); /* 8px */
	margin-bottom: var(--wp--preset--spacing--8); /* 8px */
	padding-left: var(--wp--preset--spacing--8); /* 8px */
	color: var(--wp--preset--color--neutral-800);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--sm); /* 14px */
	font-weight: 400;
	line-height: 21px; /* 14 x 1.5 */
}

.pchs-accordion__answer > * {
	margin: 0;
}

/*
 * A link in an answer is set in the heavier weight and underlined, which
 * the frames draw and the theme's ordinary link style does not give: the
 * expanded FAQ on the Grants page (node 2555:18515) sets every one of
 * them in Work Sans SemiBold at blue-500.
 *
 * The external-link glyph beside outbound ones comes from
 * .pchs-external-links on the container - see render.php.
 */
.pchs-accordion__answer a {
	color: var(--wp--preset--color--blue-500);
	font-weight: 600;
	text-decoration: underline;
	text-underline-position: from-font;
}

/*
 * 12 between the blocks of an answer.
 *
 * Measured, and worth the note because the frames disagree with each other.
 * Holistic Nursing's open answer (node 3034:11594) steps 33 from the last
 * line of its first paragraph to the first line of its second - 21 for the
 * line box and 12 for the gap. BS in Nursing's (node I2460:8936;6092:589)
 * steps 42, because whoever wrote it typed a blank line instead of starting
 * a second paragraph. 12 is the component's own spacing and is what every
 * page here uses, so an open BSN answer with two paragraphs comes out nine
 * pixels short of that one frame. DESIGN-QUESTIONS.md asks which is meant.
 */
.pchs-accordion__answer > * + * {
	margin-top: var(--wp--preset--spacing--12); /* 12px */
}

/* The bullets appear only in the frame that shows every question open
   (node 2001:2045), which is not one of the four the harness measures - so
   unlike everything else here these two numbers are chosen rather than
   taken from a frame. */
.pchs-accordion__answer ul {
	padding-left: var(--wp--preset--spacing--20);
	list-style: disc;
}

/* A numbered answer: the BSN Application To-Do List on BS in Nursing, node
   I2460:8936;6092:591, which hangs its numbers outside the text the same way
   the bulleted ones do. */
.pchs-accordion__answer ol {
	padding-left: var(--wp--preset--spacing--20);
	list-style: decimal;
}

.pchs-accordion__answer li + li {
	margin-top: var(--wp--preset--spacing--4);
}
