/*
 * The Prayer App companion site: the page layout, the menus, and dark mode.
 *
 * Colours, fonts and sizes are named in theme.json; this file only uses them
 * (var(--wp--preset--color--accent) and so on). To change a colour, change it
 * in theme.json, and in the dark-mode block below if it differs there.
 *
 * Layout: a navy header band; under it the left-hand menu beside the page;
 * a footer pinned to the bottom of the screen. Below 782px wide (phones, and the in-app browser sheet) the menu
 * moves above the page and folds behind a "Menu" button.
 */

/* ---- Dark mode: follows the phone or computer setting, like the app ---- */

:root {
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root:root {
		--wp--preset--color--background: #030712;
		--wp--preset--color--surface: #101828;
		--wp--preset--color--text: #f3f4f6;
		--wp--preset--color--muted: #99a1af;
		--wp--preset--color--border: #1e2939;
		--wp--preset--color--accent: #dab2ff;
		--wp--preset--color--accent-soft: #2a1a40;
	}
}

body {
	margin: 0;
	-webkit-font-smoothing: antialiased;
}

/* The page is a column: header, the menu-and-page area, footer. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.wp-site-blocks > * {
	margin-block-start: 0;
}

/* ---- Header ---- */

.site-header {
	background: var(--wp--preset--color--navy);
	color: var(--wp--preset--color--on-navy);
	border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.site-header__inner {
	max-width: var(--wp--style--global--wide-size);
	margin: 0 auto;
	padding: 0.75rem 1.5rem;
	box-sizing: border-box;
}

.site-brand {
	display: inline-flex;
	align-items: center;
	gap: 0.75rem;
	color: inherit;
	text-decoration: none;
	font-size: 1.125rem;
	font-weight: 650;
	letter-spacing: -0.01em;
}

.site-brand:hover {
	color: inherit;
}

.site-brand img {
	width: 36px;
	height: 36px;
	border-radius: 8px;
	display: block;
}

/* ---- Menu beside the page ---- */

.site-shell {
	flex: 1 0 auto;
	width: 100%;
	max-width: var(--wp--style--global--wide-size);
	margin: 0 auto;
	padding: 0 1.5rem;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 15.5rem minmax(0, 1fr);
	column-gap: 3.5rem;
}

.site-shell > * {
	margin-block-start: 0;
}

.site-sidebar {
	position: sticky;
	top: 0;
	align-self: start;
	max-height: calc(100vh - var(--site-footer-height));
	max-height: calc(100dvh - var(--site-footer-height));
	overflow-y: auto;
	box-sizing: border-box;
	padding: 2.25rem 0;
}

.site-main {
	min-width: 0;
	max-width: var(--wp--style--global--content-size);
	padding: 2.25rem 0 4rem;
}

.site-main > .wp-block-post-title {
	margin-top: 0;
}

/* Boxed paragraphs (a background colour set in the editor). */
.site-main p.has-background {
	padding: 1rem 1.25rem;
	border-radius: 0.5rem;
}

/* Quotes, such as the hymn on the front page. */
.site-main .wp-block-quote {
	margin: 1.5rem 0;
	padding: 0.25rem 0 0.25rem 1.25rem;
	border-left: 3px solid var(--wp--preset--color--accent);
	font-style: italic;
}

.site-main .wp-block-quote cite {
	display: block;
	margin-top: 0.5rem;
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	color: var(--wp--preset--color--muted);
}

/* Section links land a little below the top edge, not flush against it. */
.site-main :is(h2, h3, h4)[id] {
	scroll-margin-top: 1.5rem;
}

/* ---- The left-hand menu ---- */

.site-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.site-nav--primary .site-nav__list {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
}

.site-nav--primary a {
	display: block;
	padding: 0.5rem 0.75rem;
	border-radius: 0.5rem;
	color: var(--wp--preset--color--muted);
	text-decoration: none;
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.35;
}

.site-nav--primary a:hover {
	color: var(--wp--preset--color--text);
	background: var(--wp--preset--color--surface);
}

.site-nav--primary .is-current > a,
.site-nav--primary .is-in-section > a {
	color: var(--wp--preset--color--text);
	font-weight: 650;
}

.site-nav--primary .is-current > a {
	color: var(--wp--preset--color--accent);
	background: var(--wp--preset--color--accent-soft);
}

.site-nav__sublist {
	margin: 0.125rem 0 0.25rem 0.75rem !important;
	padding-left: 0.5rem !important;
	border-left: 1px solid var(--wp--preset--color--border);
}

.site-nav--primary .site-nav__sublist a {
	font-size: 0.875rem;
	padding-block: 0.375rem;
}

.site-nav__toggle {
	display: none;
}

/* ---- Footer: pinned to the bottom of the screen, so it shows on every page ---- */

:root {
	/* How much room the pinned footer takes; the left menu stops above it. */
	--site-footer-height: 4.5rem;
}

.site-footer {
	position: sticky;
	bottom: 0;
	z-index: 10;
	border-top: 1px solid var(--wp--preset--color--border);
	background: var(--wp--preset--color--surface);
}

.site-footer__inner {
	max-width: var(--wp--style--global--wide-size);
	margin: 0 auto;
	padding: 1.5rem;
	box-sizing: border-box;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem 2rem;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.site-footer__inner > * {
	margin: 0;
}

.site-nav--footer .site-nav__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
}

.site-nav--footer a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
}

.site-nav--footer a:hover,
.site-nav--footer .is-current > a {
	color: var(--wp--preset--color--text);
	text-decoration: underline;
}

/* ---- Sections with sub-pages (Features) ---- */

/* A section's sub-pages show in the left menu only while you're in it. */
.site-nav--primary .site-nav__item:not(.is-current):not(.is-in-section) > .site-nav__sublist {
	display: none;
}

/* Above a sub-page's title: the way back to its section. */
.section-trail {
	margin-bottom: 0.5rem;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
}

.section-trail a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
}

.section-trail a::before {
	content: "‹ ";
}

.section-trail a:hover {
	color: var(--wp--preset--color--accent);
}

/* Below a sub-page: Previous and Next, in menu order. */
.section-pager {
	display: flex;
	gap: 0.75rem;
	margin-top: 3rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--wp--preset--color--border);
}

.section-pager a {
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	padding: 0.75rem 1rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 0.75rem;
	text-decoration: none;
	color: var(--wp--preset--color--text);
}

.section-pager a:hover {
	border-color: var(--wp--preset--color--accent);
}

.section-pager__next {
	margin-left: auto;
	text-align: right;
}

.section-pager__label {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.section-pager__title {
	font-weight: 650;
	color: var(--wp--preset--color--accent);
}

/* A list with the class "feature-index" (set in the editor) shows as cards:
   the first link in each item is its title, and the whole card is clickable. */
.feature-index.feature-index {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: 0.75rem;
	padding: 0;
	list-style: none;
}

.feature-index > li {
	position: relative;
	margin: 0;
	padding: 0.875rem 1rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 0.75rem;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--muted);
	font-size: 0.9375rem;
	line-height: 1.45;
}

.feature-index > li:hover {
	border-color: var(--wp--preset--color--accent);
}

.feature-index > li > a:first-child {
	display: block;
	margin-bottom: 0.25rem;
	color: var(--wp--preset--color--text);
	font-size: var(--wp--preset--font-size--base);
	font-weight: 650;
	text-decoration: none;
}

.feature-index > li > a:first-child::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

/* ---- Phones and the in-app browser sheet ---- */

@media (max-width: 781px) {
	.site-header__inner {
		padding: 0.625rem 1rem;
	}

	.site-shell {
		display: block;
		padding: 0 1rem;
	}

	.site-sidebar {
		position: static;
		max-height: none;
		overflow: visible;
		padding: 0.5rem 0;
		border-bottom: 1px solid var(--wp--preset--color--border);
	}

	.site-nav__toggle {
		display: inline-flex;
		align-items: center;
		gap: 0.375rem;
		margin: 0;
		padding: 0.5rem 0.75rem;
		border: 1px solid var(--wp--preset--color--border);
		border-radius: 0.5rem;
		background: var(--wp--preset--color--surface);
		color: var(--wp--preset--color--text);
		font: inherit;
		font-size: 0.9375rem;
		font-weight: 600;
		cursor: pointer;
	}

	.site-nav__toggle[hidden] {
		display: none;
	}

	.site-nav__toggle svg {
		transition: transform 0.15s ease;
	}

	.site-nav__toggle[aria-expanded="true"] svg {
		transform: rotate(180deg);
	}

	.site-nav--primary.is-collapsible:not(.is-open) .site-nav__list {
		display: none;
	}

	.site-nav--primary.is-open .site-nav__list {
		padding-top: 0.5rem;
	}

	.site-main {
		padding: 1.5rem 0 3rem;
	}

	/* On a phone the pinned footer keeps to its links, so it takes little of the screen. */
	.site-footer__inner {
		padding: 0.625rem 1rem calc(0.625rem + env(safe-area-inset-bottom));
		justify-content: center;
	}

	.site-footer__note {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.site-nav__toggle svg {
		transition: none;
	}
}
