/*
Theme Name: Outage Kits
Theme URI: http://outage-kits.local
Author: Digital Blocks
Author URI: https://digitalblocks.ca
Description: Block theme for Outage Kits, built on the Digital Blocks starter. theme.json is the design system; the kit builder lives in the outage-kits-core plugin.
Version: 0.1.0
Requires at least: 7.1
Tested up to: 7.1
Requires PHP: 8.2
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: outage-kits
*/

/*
 * Justified overrides only. Each block says why theme.json couldn't do it.
 */

/* Tabular numbers for prices and counts: no theme.json typography key for font-variant-numeric. */
.ok-num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
 * Header: a dark teal bar with an amber "active" underline on the current nav
 * link. The underline needs ::after on the current item (no theme.json state for
 * current-menu-item), and the logo swap on scroll needs two stacked images.
 * ------------------------------------------------------------------------- */
.ok-header {
	position: relative;
	z-index: 20;
}
.ok-header .ok-header__bar { min-height: 72px; }
.ok-header .ok-logo { margin: 0; line-height: 0; flex: none; }
.ok-header .ok-logo img { height: 30px; width: auto; display: block; }
.ok-header .ok-nav { align-self: stretch; }
.ok-header .ok-nav .wp-block-navigation__container { gap: 30px; height: 100%; }
.ok-header .ok-nav .wp-block-navigation-item { height: 100%; }
.ok-header .ok-nav .wp-block-navigation-item__content {
	display: flex;
	align-items: center;
	height: 100%;
	position: relative;
	text-decoration: none;
	color: var(--wp--preset--color--on-teal);
}
.ok-header .ok-nav .wp-block-navigation-item__content:hover { color: var(--wp--preset--color--white); }
.ok-header .ok-nav .current-menu-item > .wp-block-navigation-item__content,
.ok-header .ok-nav .wp-block-navigation-item__content[aria-current="page"] {
	color: var(--wp--preset--color--white);
	font-weight: 700;
}
.ok-header .ok-nav .current-menu-item > .wp-block-navigation-item__content::after,
.ok-header .ok-nav .wp-block-navigation-item__content[aria-current="page"]::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 3px;
	background: var(--wp--preset--color--amber-500);
}
.ok-header .wp-block-button__link { white-space: nowrap; }

/* Zero-JS mobile menu (starter upstream): native details under 782px. */
.ok-nav-mobile { display: none; }
@media (max-width: 781px) {
	.ok-header .ok-header__bar { min-height: 64px; }
	.ok-header .ok-logo img { height: 26px; }
	.ok-header .ok-nav { display: none; }
	/* The bar keeps the amber button; the country switch moves into the menu. */
	.ok-header .ok-header__bar > .wp-block-group > .ok-market { display: none; }
	.ok-header .ok-kit-btn__link { height: 40px; padding: 0 12px; font-size: 14px; }
	.ok-nav-mobile { display: block; }
	.ok-nav-mobile > summary {
		list-style: none;
		width: 44px;
		height: 44px;
		border-radius: 8px;
		border: 1px solid rgba(255, 255, 255, .35);
		cursor: pointer;
		color: transparent;
		overflow: hidden;
		position: relative;
		font-size: 0;
	}
	.ok-nav-mobile > summary::-webkit-details-marker { display: none; }
	.ok-nav-mobile > summary::before {
		content: "";
		position: absolute;
		inset: 0;
		margin: auto;
		width: 20px;
		height: 14px;
		background:
			linear-gradient(#fff, #fff) 0 0 / 100% 2px no-repeat,
			linear-gradient(#fff, #fff) 0 50% / 100% 2px no-repeat,
			linear-gradient(#fff, #fff) 0 100% / 100% 2px no-repeat;
	}
	.ok-nav-mobile[open] > summary::before {
		height: 20px;
		background:
			linear-gradient(45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%),
			linear-gradient(-45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%);
	}
	.ok-nav-mobile[open] .ok-nav-mobile__panel {
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		background: var(--wp--preset--color--teal-800);
		padding: 8px 20px 20px;
		border-top: 1px solid rgba(255, 255, 255, .12);
		box-shadow: 0 18px 30px -18px rgba(30, 43, 42, .6);
	}
	.ok-nav-mobile__panel .wp-block-navigation,
	.ok-nav-mobile__panel .wp-block-navigation__container,
	.ok-nav-mobile__panel .wp-block-navigation-item { width: 100%; }
	.ok-nav-mobile__panel .wp-block-navigation__container { flex-direction: column; align-items: stretch; gap: 0; }
	.ok-nav-mobile__panel .wp-block-navigation-item__content {
		display: block;
		flex: 1 1 auto;
		width: 100%;
		padding: 15px 0;
		color: var(--wp--preset--color--white);
		text-decoration: none;
		font-size: 1.25rem;
		font-weight: 600;
		border-bottom: 1px solid rgba(255, 255, 255, .14);
	}
	.ok-nav-mobile__panel .ok-nav-mobile__country { align-items: center; margin-top: 18px; gap: 12px; }
	.ok-nav-mobile__panel .ok-nav-mobile__country p { margin: 0; font-size: .9375rem; color: var(--wp--preset--color--on-teal); }
	.ok-nav-mobile__panel .ok-market { display: inline-flex; }
	.ok-nav-mobile__panel .ok-market__opt { min-width: 52px; height: 40px; font-size: 15px; }
}
@media (max-width: 380px) {
	/* "My kit · 15 items" would crowd the bar on the narrowest phones. */
	.ok-header .ok-kit-btn__count { display: none; }
}

/* ---------------------------------------------------------------------------
 * Marker highlight: a low amber band behind one or two words. A gradient
 * background on inline text has no theme.json equivalent.
 * ------------------------------------------------------------------------- */
.ok-marker,
mark.ok-marker {
	background: linear-gradient(transparent 60%, var(--wp--preset--color--amber-500) 60% 88%, transparent 88%);
	color: inherit;
	padding: 0 .06em;
}

/* Inline "OK" mark inside the hero headline. */
.ok-hero__title img {
	height: .8em;
	width: auto;
	vertical-align: -0.04em;
	margin-left: .04em;
}

/* ---------------------------------------------------------------------------
 * Hero media: a round photo inside the power O (ring.svg: the logo's O a little
 * lighter, centred in a 109-unit box with the ring's inner edge at 37 units).
 * The photo stops 8px short of the ring. The O turns half a circle as the page
 * scrolls, where the browser supports scroll-driven animations.
 * ------------------------------------------------------------------------- */
.ok-hero__media {
	--dial: min(100%, 300px);
	position: relative;
	width: var(--dial);
	aspect-ratio: 1;
	margin-inline: auto;
	display: grid;
	place-items: center;
	overflow: clip; /* the turning square would widen the page */
}
@media (min-width: 782px) {
	/* Wider than its column: it reaches 50px into the column gap and hangs below
	   the text, while its layout height stays the column's width (vertical %
	   margins resolve against the column's width). */
	.ok-hero .wp-block-column > .ok-hero__media {
		--dial: min(calc(100% + 50px), 610px);
		margin: 40px 0 calc(100% - var(--dial) - 40px) calc(100% - var(--dial));
	}
}
.ok-hero__media .ok-hero__photo { margin: 0; width: calc(67.89% - 16px); position: relative; z-index: 1; }
.ok-hero__media .ok-hero__photo img {
	width: 100%;
	height: auto;
	aspect-ratio: 1;
	border-radius: 50%;
	object-fit: cover;
	filter: sepia(.15) saturate(.92);
	display: block;
}
.ok-hero__media::before {
	content: "";
	position: absolute;
	inset: 0;
	background: url("assets/logo/ring.svg") center / contain no-repeat;
	z-index: 2;
	pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: scroll()) {
		.ok-hero__media::before {
			animation: ok-dial linear both;
			animation-timeline: scroll(root);
			animation-range: 0 80vh;
		}
	}
}
@keyframes ok-dial {
	to { transform: rotate(180deg); }
}
@media (max-width: 781px) {
	.ok-hero__media::before { animation-range: 0 50vh; }
}

/* ---------------------------------------------------------------------------
 * Photo grade: the design's warm grade plus an 18% amber soft-light wash.
 * Filters and blend modes aren't in theme.json.
 * ------------------------------------------------------------------------- */
.ok-photo { position: relative; overflow: hidden; }
.ok-photo img { filter: var(--wp--custom--photo-grade); }
.ok-photo::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--wp--preset--color--amber-500);
	mix-blend-mode: soft-light;
	opacity: .18;
	pointer-events: none;
	border-radius: inherit;
}

/* Guide cards: image wash on the wrapper (starter upstream), title link tidy. */
.ok-card-grid .wp-block-post-featured-image { border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.ok-card-grid .wp-block-post-featured-image img { transition: transform .5s var(--wp--custom--ease); }
.ok-card-grid .wp-block-post:hover .wp-block-post-featured-image img { transform: scale(1.03); }
.ok-card-grid .wp-block-post-title a { text-decoration: none; }
.ok-card-grid .wp-block-post-title a:hover { text-decoration: underline; text-underline-offset: 3px; }

/*
 * Phones: article cards become rows (92px square photo, meta, title), like the
 * ready-made kit cards, so a section scans in a few screens. A post template's
 * inner layout can't switch from stacked to side-by-side in theme.json.
 */
@media (max-width: 600px) {
	.ok-card-grid .wp-block-post-template.is-layout-grid { gap: 10px; }
	.ok-card-grid .wp-block-post {
		display: grid;
		grid-template-columns: 92px minmax(0, 1fr);
		grid-template-rows: 1fr auto auto 1fr;
		column-gap: 14px;
		min-height: 92px;
		padding-right: 14px;
		background: var(--wp--preset--color--surface);
		border: 1px solid var(--wp--preset--color--sand-200);
		border-radius: 12px;
		overflow: hidden;
	}
	.ok-card-grid .wp-block-post > * { margin: 0; }
	.ok-card-grid .wp-block-post-featured-image { grid-row: 1 / -1; border-radius: 0; margin: 0; }
	.ok-card-grid .wp-block-post-featured-image a { display: block; height: 100%; }
	.ok-card-grid .wp-block-post-featured-image img { width: 92px; height: 100%; min-height: 92px; }
	.ok-card-grid .ok-meta { grid-column: 2; grid-row: 2; margin: 0 0 2px; padding-top: 10px; }
	.ok-card-grid .wp-block-post-title { grid-column: 2; grid-row: 3; padding-bottom: 10px; }
	.ok-card-grid .wp-block-post-excerpt { display: none; }
}

/* Post meta line: "Guide · 6 min read". The separator dot can't be a block. */
.ok-meta > * + *::before { content: "·"; margin: 0 .5em; color: var(--wp--preset--color--ink-4); }
.ok-meta .wp-block-post-terms a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------------------
 * Article body: readable defaults for long guides.
 * ------------------------------------------------------------------------- */
.ok-article .wp-block-post-content > * + h2 { margin-top: 2.2em; }
.ok-article .wp-block-post-content > * + h3 { margin-top: 1.6em; }
.ok-article .wp-block-post-content > p,
.ok-article .wp-block-post-content > .wp-block-list > li,
.ok-article .wp-block-post-content > .wp-block-group > p { font-size: var(--wp--preset--font-size--body-l); line-height: 1.65; }
.ok-article .wp-block-post-content > .wp-block-list > li + li { margin-top: .35em; }
.ok-article .wp-block-table table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
/* Columns size to their content, so "28 gal (106 L)" stays on one line where it can, and
   numbers never split mid-figure (core sets word-break: break-word on fixed-layout cells). */
.ok-article .wp-block-table .has-fixed-layout { table-layout: auto; }
.ok-article .wp-block-table .has-fixed-layout td,
.ok-article .wp-block-table .has-fixed-layout th { word-break: normal; overflow-wrap: normal; }
.ok-article .wp-block-table th,
.ok-article .wp-block-table td { border: 0; border-bottom: 1px solid var(--wp--preset--color--sand-200); padding: 12px 16px 12px 0; text-align: left; font-size: 1.0625rem; color: var(--wp--preset--color--ink); }
.ok-article .wp-block-table th { font-size: .9375rem; font-weight: 700; border-bottom: 2px solid var(--wp--preset--color--ink); }
.ok-article .wp-block-table td:first-child { font-weight: 700; }
@media (max-width: 600px) {
	.ok-article .wp-block-table th,
	.ok-article .wp-block-table td { font-size: .9375rem; padding: 10px 10px 10px 0; }
}

/* Lead: the article's answer-first opening, bigger and darker with an amber rule. */
.ok-article .wp-block-post-content > p.is-style-ok-lead {
	font-size: var(--wp--preset--font-size--heading-m);
	line-height: 1.5;
	font-weight: 500;
	color: var(--wp--preset--color--ink);
	border-left: 4px solid var(--wp--preset--color--amber-500);
	padding-left: 20px;
}

/* Sources fold away under one line (a core Details block). */
.ok-sources { margin-top: 2.2em; padding-top: 18px; border-top: 1px solid var(--wp--preset--color--sand-200); }
.ok-sources summary { cursor: pointer; font-size: 1.0625rem; font-weight: 700; color: var(--wp--preset--color--ink); }
.ok-article .wp-block-post-content h2[id] { scroll-margin-top: 24px; }
.ok-sources .wp-block-list { margin-top: 12px; }
.ok-sources li { font-size: var(--wp--preset--font-size--small); }
.ok-sources li + li { margin-top: 6px; }

/*
 * Side panel beside the article (On this page + Build my kit). It needs about
 * 260px, so it only shows on wide screens; elsewhere the end-of-article panel
 * does its job.
 */
.ok-article__aside { min-width: 16rem; }
.ok-toc__title { margin: 0 0 10px; font-size: var(--wp--preset--font-size--small); font-weight: 700; color: var(--wp--preset--color--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.ok-toc__list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--wp--preset--color--sand-200); }
.ok-toc__list li { margin: 0; }
.ok-toc__list a { display: block; padding: 6px 0 6px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--wp--preset--color--ink-2); text-decoration: none; font-size: .9375rem; line-height: 1.35; }
.ok-toc__list a:hover { color: var(--wp--preset--color--teal-700); border-left-color: var(--wp--preset--color--teal-700); }
@media (max-width: 1023px) {
	.ok-article__aside { display: none; }
}

/* Power-O list marker for short "what's included" lists. */
.is-style-ok-power-list { list-style: none; padding-left: 0 !important; }
.is-style-ok-power-list li { position: relative; padding-left: 1.7em; }
.is-style-ok-power-list li::before {
	content: "";
	position: absolute;
	left: 0;
	top: .28em;
	width: 1.05em;
	height: 1.05em;
	background: url("assets/logo/outage-kits-o.svg") center / contain no-repeat;
}

/* Callouts (caution / danger / tip): coloured groups with a title line. */
.is-style-ok-caution,
.is-style-ok-danger,
.is-style-ok-tip { border-radius: 10px; border: 1px solid; }
.is-style-ok-caution { background: var(--wp--preset--color--caution-bg); border-color: #EED6AC; }
.is-style-ok-caution > :first-child { color: var(--wp--preset--color--caution-ink); }
.is-style-ok-danger { background: var(--wp--preset--color--danger-bg); border-color: #EFCFC6; }
.is-style-ok-danger > :first-child { color: var(--wp--preset--color--danger-ink); }
.is-style-ok-tip { background: #F2EBDD; border-color: transparent; }

/* Dark kit / CTA panel: one faint cropped power O, never behind text. */
.ok-dark-panel { position: relative; overflow: hidden; }
.ok-dark-panel::before {
	content: "";
	position: absolute;
	width: 320px;
	height: 320px;
	right: -90px;
	top: -110px;
	background: url("assets/logo/outage-kits-o-reverse.svg") center / contain no-repeat;
	opacity: .14;
	pointer-events: none;
}
.ok-dark-panel > * { position: relative; }

/* Footer link lists: plain links without underlines until hover. */
.ok-footer a { color: var(--wp--preset--color--on-teal); text-decoration: none; }
.ok-footer a:hover { color: var(--wp--preset--color--white); text-decoration: underline; }
.ok-footer .ok-footer__links { list-style: none; padding: 0; margin: 14px 0 0; }
.ok-footer .ok-footer__links li + li { margin-top: 8px; }
.ok-footer .ok-footer__credit a { text-decoration: underline; text-underline-offset: 3px; }
.ok-footer .ok-footer__note { flex-basis: 100%; }
@media (max-width: 781px) {
	/* Build and Learn side by side, About under Build; the credit comes last. */
	.ok-footer .wp-block-columns.alignwide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 20px; }
	.ok-footer .wp-block-columns.alignwide > .wp-block-column:first-child { grid-column: 1 / -1; }
	.ok-footer .ok-footer__credit { order: 3; }
}

/* Skip link focus and generic focus ring (only Button and Navigation have theme.json states). */
:where(a, button, input, select, summary):focus-visible {
	outline: 3px solid var(--wp--preset--color--amber-500);
	outline-offset: 2px;
	border-radius: 4px;
}

/*
 * Checklist list style: square tick boxes instead of bullets (numbers sit in the
 * box on ordered lists). The plugin's site.js adds a real button per item, ticks
 * it on tap and remembers it on this device; without it the box is drawn here.
 */
.is-style-ok-checklist { list-style: none; padding-left: 0 !important; counter-reset: ok-check; }
.is-style-ok-checklist > li { position: relative; padding-left: 2.4rem; counter-increment: ok-check; }
.ok-article .wp-block-post-content > .is-style-ok-checklist > li + li { margin-top: .55em; }
.is-style-ok-checklist > li::before,
.is-style-ok-checklist .ok-tick {
	content: "";
	position: absolute;
	left: 0;
	top: .2em;
	width: 1.45rem;
	height: 1.45rem;
	box-sizing: border-box;
	border: 2px solid var(--wp--preset--color--teal-700);
	border-radius: 5px;
	background: var(--wp--preset--color--surface);
	padding: 0;
	cursor: pointer;
	display: grid;
	place-items: center;
	font: 700 .8rem/1 var(--wp--preset--font-family--body);
	color: var(--wp--preset--color--teal-700);
}
ol.is-style-ok-checklist > li::before,
ol.is-style-ok-checklist .ok-tick::before { content: counter(ok-check); }
.is-style-ok-checklist > li.has-tick { cursor: pointer; }
.is-style-ok-checklist > li.has-tick::before { content: none; }
.is-style-ok-checklist > li.is-ticked { color: var(--wp--preset--color--ink-3); }
.is-style-ok-checklist > li.is-ticked .ok-tick { background: var(--wp--preset--color--teal-700); }
.is-style-ok-checklist > li.is-ticked .ok-tick::before {
	content: "";
	width: .7rem;
	height: .38rem;
	border: solid #fff;
	border-width: 0 0 3px 3px;
	transform: translateY(-.08rem) rotate(-45deg);
}

/* Print: just the article and its lists (checklists print with their boxes). */
@media print {
	.ok-header, .ok-footer { display: none; }
	.ok-article__aside,
	.ok-article .wp-block-post-featured-image,
	.ok-article .ok-dark-panel,
	.ok-sources,
	.ok-article ~ *,
	.ok-check-tools { display: none !important; }
	body { background: #fff; }
	.ok-article { padding: 0 !important; }
	.ok-article .wp-block-post-title { font-size: 24pt !important; }
	.ok-article__body { margin-top: 14pt !important; }
	.ok-article .wp-block-post-content > p,
	.ok-article .wp-block-post-content > .wp-block-group > p,
	.ok-article .wp-block-post-content li { font-size: 11pt !important; line-height: 1.4; }
	.ok-article .wp-block-post-content h2 { font-size: 15pt; margin-top: 16pt; break-after: avoid; }
	.ok-article li { break-inside: avoid; }
	.ok-article a { color: inherit; text-decoration: none; }
	.is-style-ok-checklist .ok-tick,
	.is-style-ok-checklist > li::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Template parts sit flush: the root blockGap (theme.json) is for content flow, not the page frame. */
.wp-site-blocks > * + * { margin-block-start: 0; }

.ok-nowrap { white-space: nowrap; }

/* Mobile hero: media first and a full-width primary button, as in the design. */
@media (max-width: 781px) {
	.ok-hero .wp-block-column:last-child { order: -1; }
	.ok-hero .wp-block-buttons > .wp-block-button { flex: 1 1 100%; }
	.ok-hero .wp-block-buttons > .wp-block-button .wp-block-button__link { width: 100%; }
}

/* Phones: the homepage guide cards become a swipeable strip (design: 240 px cards, scroll-snap). */
@media (max-width: 600px) {
	.ok-strip .wp-block-post-template {
		display: flex !important;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		gap: 16px;
		margin-inline: calc(-1 * var(--wp--style--root--padding-left));
		padding-inline: var(--wp--style--root--padding-left);
		scrollbar-width: none;
	}
	.ok-strip .wp-block-post-template > li { flex: 0 0 240px; scroll-snap-align: start; }
}
