/*
Theme Name:   Divi 5 Child
Theme URI:    https://davidfarr.com/
Description:  Child theme for Divi 5. Adds a per-category summary block above the post list on category archives.
Author:       David Farr
Author URI:   https://davidfarr.com/
Template:     Divi
Version:      1.0.2
Requires at least: 6.0
Requires PHP: 7.4
License:      GNU General Public License v2
License URI:  http://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  divi5-child
*/

/* -------------------------------------------------------------------------
 * Category summary block
 *
 * Printed on `et_before_main_content`, so it sits inside #et-main-area and
 * directly above #main-content. The inner .container reuses Divi's own
 * content width so the summary lines up with the posts beneath it.
 * ---------------------------------------------------------------------- */

:root {
	/* Text colours for the classic (non-builder) archive templates.
	 * Change these two values to restyle the whole archive. */
	--divi5-child-archive-text: #666;
	--divi5-child-archive-meta: #777;
}

.divi5-child-term-summary {
	padding-top: 58px;
}

.divi5-child-term-summary__title {
	margin-bottom: 15px;
	padding-bottom: 0;
	font-size: 32px;
	line-height: 1.3em;
}

.divi5-child-term-summary__text {
	max-width: 46em;
	color: var(--divi5-child-archive-text);
}

.divi5-child-term-summary__text > *:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
}

/* Divi gives #main-content .container a 58px top padding. With the summary
 * above it that reads as a double gap, so tighten it up on these pages. */
.divi5-child-has-term-summary #main-content .container {
	padding-top: 24px;
}

/* -------------------------------------------------------------------------
 * Readable body text on classic archives
 *
 * Divi's own #666 rules for archive text are scoped to
 * `.et_pb_bg_layout_light .et_pb_post p` -- a class that only exists on
 * builder-rendered pages. Category, tag, author and date archives render
 * through the parent theme's index.php, which has no such wrapper, so the
 * excerpt and meta text inherits the global body colour instead, which Divi 5
 * emits on :root as the global colour token --gcid-body-color.
 *
 * On this site that token is #f2f2f2 -- a near-white picked to sit on dark
 * builder sections -- so the archive's excerpts render as near-invisible text
 * on a white background. Builder and Theme Builder layouts never show it
 * because their modules set their own per-module text colours.
 *
 * These rules restate a readable colour for the classic templates only.
 * ---------------------------------------------------------------------- */

/* The colour goes on .et_pb_post itself, not on a `p` inside it.
 * truncate_post() prints the excerpt as a BARE TEXT NODE sitting directly
 * in the <article>, with no <p> or .post-content wrapper:
 *
 *     <article class="et_pb_post">
 *       <h2 class="entry-title">...</h2>
 *       <p class="post-meta">...</p>
 *       Transform your next company gathering with...   <-- no element
 *     </article>
 *
 * so it can only be reached by inheritance. The entry title keeps its own
 * #333 from Divi's heading rules, and .post-meta is set separately below,
 * so colouring the article only affects the excerpt. */
body.archive #left-area .et_pb_post,
body.search #left-area .et_pb_post {
	color: var(--divi5-child-archive-text);
}

/* With Divi's "Blog Style" option on, the loop calls the_content() instead
 * and the text does arrive in real paragraphs. */
body.archive #left-area .et_pb_post p,
body.archive #left-area .et_pb_post .post-content,
body.archive #left-area .et_pb_post .post-content p,
body.search #left-area .et_pb_post p,
body.search #left-area .et_pb_post .post-content p {
	color: var(--divi5-child-archive-text);
}

body.archive #left-area .et_pb_post .post-meta,
body.archive #left-area .et_pb_post .post-meta a,
body.search #left-area .et_pb_post .post-meta,
body.search #left-area .et_pb_post .post-meta a {
	color: var(--divi5-child-archive-meta);
}

@media all and (max-width: 980px) {
	.divi5-child-term-summary {
		padding-top: 40px;
	}

	.divi5-child-term-summary__title {
		font-size: 26px;
	}
}
