/*
 * Screen styles for a rendered resume.
 *
 * Sizing follows the anchor established in the typography research: the scale
 * is pinned at 12pt = 1rem = 16px, so one set of ratios drives both this file
 * and print.css, and every stop lands on a whole number in both unit systems.
 *
 * Deliberately restrained. This is a document, not a site page, and by default
 * the theme's styles are not loaded around it (includes/design.php removes
 * them). A resume with "Use theme styles" on gets them back, and the theme
 * then decides the fonts and the body size.
 */

:root {
	--ppres-ink: #1a1a1a;
	--ppres-muted: #4a4a4a;

	/*
	 * #767676 is the lightest grey that still clears 4.5:1 on white. It is
	 * also about where a laser printer stops rendering a rule reliably and
	 * starts dithering it, so the accessibility floor and the print floor
	 * happen to be the same value. Do not go lighter for either reason.
	 */
	--ppres-rule: #767676;

	--ppres-link: #16437e;
	--ppres-bg: #fff;

	--ppres-measure: 34rem;
	--ppres-gap: 1.5rem;
}

* {
	box-sizing: border-box;
}

body.ppres-resume-view {
	/*
	 * The resume's design, as set in the editor's "Resume design" panel
	 * (includes/design.php). These are the defaults; a styled resume gets an
	 * inline `body.ppres-resume-view` rule after this sheet that overrides
	 * only what the author changed.
	 *
	 * Declared on body, not :root, deliberately. A custom property that refers
	 * to another is resolved on the element that declares it — so if
	 * --ppres-heading-font lived on :root, it would capture :root's body font
	 * and never see the override on body.
	 *
	 * --ppres-text-scale is the chosen print body size over 10.5pt. Every
	 * font size in this sheet and in print.css is multiplied by it, so the
	 * screen and print scales stay one scale. --ppres-heading-scale then
	 * multiplies the headings alone.
	 */
	--ppres-body-font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
	--ppres-heading-font: var(--ppres-body-font);
	--ppres-text-scale: 1;
	--ppres-heading-scale: 1;
	--ppres-body-size: calc(1rem * var(--ppres-text-scale));
	--ppres-heading-factor: calc(var(--ppres-text-scale) * var(--ppres-heading-scale));

	/* Print only; see print.css. Declared here because this sheet loads for every medium. */
	--ppres-link-pdf: #16437e;
	--ppres-link-print: #000;

	margin: 0;
	padding: 2rem 1rem 4rem;
	font-family: var(--ppres-body-font);

	/*
	 * 1rem, never px. A user who has raised their browser's default font size
	 * has asked every site to respect it; px would silently ignore that while
	 * still passing a zoom test.
	 */
	font-size: var(--ppres-body-size);
	line-height: 1.5;
}

/*
 * Page colors. A standalone resume paints its own; with theme styles on
 * (`ppres-theme-styles`), the theme's rules for `body` give the page the
 * site's background and text colors, as on any other page of the site.
 * The PDF is always standalone, so it stays black on white.
 */
body.ppres-resume-view:not(.ppres-theme-styles) {
	background: var(--ppres-bg);
	color: var(--ppres-ink);
}

/*
 * The optional site header (includes/design.php, "Use the site header").
 * Negative margins cancel the body padding above, so the header runs to the
 * page edges as it does on the rest of the site. Keep in step with that
 * padding.
 */
.ppres-site-header {
	margin: -2rem -1rem 2rem;
}

/*
 * `width: 100%` here and on .ppres-actions: some themes make `body` a flex
 * column, where an auto-margined child shrinks to its content and centers.
 */
.ppres-shell {
	width: 100%;
	max-width: 46rem;
	margin: 0 auto;
}

/*
 * Body text is held to a comfortable measure independently of the page
 * margins. Resume convention wants tight margins for density; comfortable
 * reading wants roughly 60-75 characters. Constraining the text block rather
 * than the page satisfies both instead of trading one off against the other.
 */
.ppres-shell p,
.ppres-shell li {
	max-width: var(--ppres-measure);
}

/*
 * With theme styles on, the theme's larger screen type already keeps a line
 * near the comfortable range at the full resume width, and a narrower text
 * block left a visible gap under the full-width section rules. The PDF never
 * has this class, and print.css resets the measure for paper.
 */
body.ppres-theme-styles {
	--ppres-measure: none;
}

/*
 * Line breaking. This sheet loads for every medium, so these rules also reach
 * print and the exported PDF.
 *
 * `pretty` on body text stops a paragraph or bullet ending on a lone word: the
 * browser re-breaks the last few lines instead. Chromium 117+ (the exporter
 * runs a current Chromium); elsewhere it falls back to normal wrapping.
 *
 * `balance` on headings evens out a heading that wraps to two lines. It is
 * deliberately NOT used on body text: it shortens every line of a paragraph,
 * which costs space on a document that is fighting for its page count.
 */
.ppres-shell p,
.ppres-shell li {
	text-wrap: pretty;
}

.ppres-name,
.ppres-shell h2,
.ppres-shell h3,
.ppres-shell h4 {
	text-wrap: balance;
}

/*
 * Heading sizes are max()-floored at the body size, so a heading scale below
 * 100% can shrink a heading to the body size but never under it — an entry
 * heading smaller than the text beneath it reads as a typo.
 */
.ppres-name,
.ppres-shell h2,
.ppres-shell h3,
.ppres-shell h4 {
	font-family: var(--ppres-heading-font);
}

.ppres-name {
	font-size: max(var(--ppres-body-size), calc(2rem * var(--ppres-heading-factor)));
	line-height: 1.2;
	margin: 0 0 0.25em;
}

.ppres-shell h2 {
	font-size: max(var(--ppres-body-size), calc(1.25rem * var(--ppres-heading-factor)));
	line-height: 1.3;
	margin: var(--ppres-gap) 0 0.5rem;
	padding-bottom: 0.2em;
	border-bottom: 1px solid var(--ppres-rule);
}

.ppres-shell h3 {
	font-size: max(var(--ppres-body-size), calc(1.0625rem * var(--ppres-heading-factor)));
	margin: 1.25rem 0 0.15rem;
}

.ppres-shell h4 {
	font-size: max(var(--ppres-body-size), calc(1rem * var(--ppres-heading-factor)));
	margin: 1rem 0 0.15rem;
}

.ppres-dates {
	margin: 0 0 0.5rem;
	color: var(--ppres-muted);
	font-size: calc(0.9375rem * var(--ppres-text-scale));
}

/*
 * An entry's heading and dates on one line (ppres_wrap_entry_head()).
 *
 * One wrapping row: the heading takes what it needs, the dates sit at the
 * right end. When the two do not fit, the dates wrap below the heading — never
 * over it. Source order is untouched, so assistive technology still reads the
 * heading first.
 *
 * The wrapper takes over the margins the heading and dates had: the heading's
 * top margin (1.25rem for an employer's h3, 1rem for a project's h4) and the
 * dates' bottom margin. A block-level flex container's own margins collapse
 * with its neighbors, so the spacing around the entry is exactly what it was.
 * Inside it, margins would not collapse, so the children's are zeroed and the
 * old 0.15rem heading-to-dates gap becomes the row gap.
 *
 * `.ppres-shell` in the child selector is for specificity: it has to beat
 * `.ppres-shell h3`.
 */
.ppres-entry-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 1em;
	row-gap: 0.15rem;
	margin: 1.25rem 0 0.5rem;
}

.ppres-entry-head:has(> h4) {
	margin-top: 1rem;
}

.ppres-shell .ppres-entry-head > * {
	margin: 0;
}

.ppres-entry-head > :first-child {
	flex: 1 1 auto;
}

.ppres-entry-head > .ppres-dates {
	flex: 0 1 auto;
	margin-left: auto;
	text-align: right;
}

/*
 * "Dates under titles" (includes/design.php): the dates leave the heading's
 * line and sit below it, left-aligned. Same row, stacked, so the margins
 * above still apply unchanged.
 */
.ppres-dates-below .ppres-entry-head {
	flex-direction: column;
	align-items: flex-start;
}

.ppres-dates-below .ppres-entry-head > .ppres-dates {
	margin-left: 0;
	text-align: left;
}

.ppres-employer,
.ppres-project {
	margin-bottom: 1rem;
}

.ppres-shell ul {
	margin: 0.35rem 0 0.75rem;
	padding-left: 1.25em;
}

.ppres-shell li {
	margin-bottom: 0.3rem;
}

/* Not the theme-styled Download button, which keeps the theme's button colors. */
.ppres-shell a:not(.wp-element-button) {
	color: var(--ppres-link);
}

/* Visible focus everywhere, never removed. */
.ppres-resume-view :focus-visible {
	outline: 3px solid var(--ppres-link);
	outline-offset: 2px;
}

.ppres-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: var(--ppres-bg);
	color: var(--ppres-link);
	padding: 0.75rem 1rem;
	z-index: 10;
}

.ppres-skip-link:focus {
	left: 0;
}

/* Under the name (templates/single-resume.php). */
.ppres-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	width: 100%;
	max-width: 46rem;
	margin: 0 auto 1.5rem;
}

.ppres-button {
	display: inline-block;
	font: inherit;
	padding: 0.6rem 1rem;
	border: 1px solid var(--ppres-link);
	border-radius: 3px;
	background: var(--ppres-bg);
	color: var(--ppres-link);
	cursor: pointer;
	text-decoration: none;
}

.ppres-button:hover {
	background: var(--ppres-link);
	color: var(--ppres-bg);
}

.ppres-notice {
	padding: 1rem;
	border-left: 4px solid var(--ppres-rule);
	background: #f4f4f4;
}
