/*
 * Layout "hanukkiah" (Chanukah, design 104): a dark page; the eight latest posts are the eight candles, the date tile is the shamash.
 * Markup contract: docs/design/holiday-layouts.md section 2.5. Every selector is scoped under body.yomi-layout-hanukkiah.
 * Candle titles: vertical text at 15px or more from 600px up; horizontal rows below 600px. Flames are decoration only.
 */

:root:has(body.yomi-layout-hanukkiah) {
	color-scheme: dark;
}

body.yomi-layout-hanukkiah {
	color-scheme: dark;
	font-synthesis: none;
	--hk-gold: var(--wp--preset--color--accent-text);
	--hk-line: var(--wp--preset--color--line);
	--hk-sham-w: 168px;
}

/* ---------- header / footer ---------- */

body.yomi-layout-hanukkiah .yomi-header {
	border-block-end: 1px solid var(--hk-line);
}

body.yomi-layout-hanukkiah .yomi-brand__name {
	color: var(--hk-gold);
}

body.yomi-layout-hanukkiah .yomi-footer {
	border-block-start: 1px solid var(--hk-line);
}

/* ---------- the date tile (the shamash) on a dark page ---------- */

body.yomi-layout-hanukkiah .yomi-leaf {
	background: var(--wp--preset--color--soft);
	border-color: var(--wp--preset--color--accent);
	box-shadow: none;
}

body.yomi-layout-hanukkiah .yomi-leaf__band {
	border-block-end-color: var(--wp--preset--color--on-accent);
}

/* ---------- home hero ---------- */

body.yomi-layout-hanukkiah .yomi-hero {
	border-block-end: 1px solid var(--hk-line);
	text-align: center;
}

body.yomi-layout-hanukkiah .yomi-hero__row {
	flex-direction: column;
	flex-wrap: nowrap;
	align-items: stretch;
	gap: 0;
}

body.yomi-layout-hanukkiah .yomi-hero__text {
	flex: 0 1 auto;
	text-align: center;
}

body.yomi-layout-hanukkiah .yomi-home-title {
	font-size: clamp(56px, 14vw, 120px);
	line-height: 1;
	letter-spacing: var(--wp--custom--tracking--title);
	color: var(--hk-gold);
}

body.yomi-layout-hanukkiah .yomi-tagline {
	color: var(--wp--preset--color--body);
	font-size: clamp(20px, 3vw, 28px);
}

body.yomi-layout-hanukkiah .yomi-accent {
	color: var(--hk-gold);
}

body.yomi-layout-hanukkiah .yomi-stats {
	border-block-start-color: var(--hk-line);
	text-align: center;
}

/* ---------- the hanukkiah ---------- */

body.yomi-layout-hanukkiah .yomi-slot--home-hero {
	inline-size: 100%;
	min-inline-size: 0;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	max-inline-size: 840px;
	margin-inline: auto;
	padding-block-start: 26px;
}

/* The shamash stands in the empty middle column of the candle grid (same grid area). */
body.yomi-layout-hanukkiah .yomi-hanukkiah__shamash {
	grid-area: 1 / 1;
	justify-self: center;
	align-self: end;
	z-index: 1;
	inline-size: var(--hk-sham-w);
	display: flex;
	justify-content: center;
	position: relative;
	/* The shamash stands on a stem, clearly above the eight candles. */
	padding-block: 28px 112px;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__shamash::before {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: calc(50% - 6px);
	inline-size: 12px;
	block-size: 20px;
	border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
	background: radial-gradient(circle at 50% 72%, #FFF6C9, #F4C95D 45%, #FF8A1F 82%);
	box-shadow: 0 0 14px 2px rgba(255, 138, 31, 0.55);
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__shamash::after {
	content: "";
	position: absolute;
	inset-block-end: 0;
	inset-inline-start: calc(50% - 8px);
	inline-size: 16px;
	block-size: 112px;
	background: linear-gradient(90deg, #8E9BBE, #C9D1E6 50%, #8E9BBE);
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__candles {
	grid-area: 1 / 1;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr)) var(--hk-sham-w) repeat(4, minmax(0, 1fr));
	align-items: end;
	column-gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Skip the middle column: the 5th candle starts in column 6. */
body.yomi-layout-hanukkiah .yomi-hanukkiah__candle:nth-child(5) {
	grid-column-start: 6;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__candle {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-inline-size: 0;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__flame {
	display: block;
	flex: none;
	inline-size: 12px;
	block-size: 20px;
	border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
	background: radial-gradient(circle at 50% 72%, #FFF6C9, #F4C95D 45%, #FF8A1F 82%);
	box-shadow: 0 0 14px 2px rgba(255, 138, 31, 0.55);
	transform-origin: 50% 100%;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__candle:not(.is-lit) .yomi-hanukkiah__flame {
	visibility: hidden;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__title {
	margin: 0;
	inline-size: 100%;
	display: flex;
	justify-content: center;
}

/* The candle: cream stick, vertical title. The link carries the box so its focus ring is never clipped. */
body.yomi-layout-hanukkiah .yomi-hanukkiah__title a {
	display: block;
	box-sizing: border-box;
	writing-mode: vertical-rl;
	/* vertical-rl: inline-size is the candle HEIGHT, block-size its WIDTH. */
	inline-size: 224px;
	block-size: 100%;
	max-block-size: 56px;
	padding: 10px 4px;
	overflow: hidden;
	border-radius: 4px 4px 0 0;
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--paper);
	font-family: var(--wp--custom--font--display);
	font-weight: var(--wp--custom--font--weight--black);
	font-size: 15px;
	line-height: 1.2;
	text-decoration: none;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__title a:hover {
	background: var(--wp--preset--color--accent-text);
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__title a:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent-text);
	outline-offset: 3px;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__date {
	display: block;
	max-inline-size: 100%;
	font-size: 13px;
	line-height: 1.2;
	text-align: center;
	color: var(--wp--preset--color--grey-text);
}

/* Base, stem and foot of the stand: text-free decoration. */
body.yomi-layout-hanukkiah .yomi-hanukkiah__stand {
	grid-area: 2 / 1;
	block-size: 50px;
	background:
		linear-gradient(#C9D1E6, #8E9BBE) 0 0 / 100% 14px no-repeat,
		linear-gradient(90deg, #8E9BBE, #C9D1E6, #8E9BBE) 50% 14px / 30px 26px no-repeat,
		linear-gradient(#8E9BBE, #8E9BBE) 50% 100% / 150px 10px no-repeat;
	border-radius: 0 0 8px 8px;
}

/* ---------- list below ---------- */

body.yomi-layout-hanukkiah .yomi-years__heading {
	margin: 0;
	padding-block: 32px 4px;
	font-family: var(--wp--custom--font--display);
	font-size: 20px;
	font-weight: var(--wp--custom--font--weight--black);
	color: var(--hk-gold);
}

body.yomi-layout-hanukkiah .yomi-ledger,
body.yomi-layout-hanukkiah .yomi-ledger__item {
	border-color: var(--hk-line);
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
	@keyframes yomi-hk-flicker {
		0% { scale: 1 1; rotate: -2deg; }
		50% { scale: 0.92 1.08; }
		100% { scale: 1.04 0.95; rotate: 2deg; }
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__candle.is-lit .yomi-hanukkiah__flame {
		animation: yomi-hk-flicker 1.6s ease-in-out infinite alternate;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__candle:nth-child(2n) .yomi-hanukkiah__flame {
		animation-duration: 1.2s;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__candle:nth-child(3n) .yomi-hanukkiah__flame {
		animation-delay: -0.6s;
	}
}

/* Long titles step down so they fit the candle instead of being clipped; ellipsis only as a last resort. */
body.yomi-layout-hanukkiah .yomi-hanukkiah__candle--long .yomi-hanukkiah__title a {
	font-size: 13px;
}

body.yomi-layout-hanukkiah .yomi-hanukkiah__candle--xlong .yomi-hanukkiah__title a {
	font-size: 12px;
	line-height: 1.15;
	text-overflow: ellipsis;
}

/* ---------- small screens: candles become rows (no vertical text) ---------- */

@media (max-width: 599px) {
	body.yomi-layout-hanukkiah .yomi-hanukkiah__shamash {
		inline-size: auto;
		padding-block: 0 20px;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__shamash::before,
	body.yomi-layout-hanukkiah .yomi-hanukkiah__shamash::after {
		display: none;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__candles {
		grid-area: 2 / 1;
		grid-template-columns: minmax(0, 1fr);
		align-items: stretch;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__candle:nth-child(5) {
		grid-column-start: auto;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__candle {
		display: grid;
		grid-template-columns: 24px minmax(0, 1fr) auto;
		align-items: center;
		gap: 4px 12px;
		min-block-size: 48px;
		padding-block: 4px;
		border-block-end: 1px solid var(--hk-line);
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__flame {
		justify-self: center;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__title {
		display: block;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__title a {
		writing-mode: horizontal-tb;
		inline-size: auto;
		max-block-size: none;
		block-size: auto;
		padding: 10px 0;
		overflow: visible;
		border-radius: 0;
		background: transparent;
		color: var(--wp--preset--color--ink);
		font-size: 17px !important;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__title a:hover {
		background: transparent;
		text-decoration: underline;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__date {
		text-align: end;
		white-space: nowrap;
	}

	body.yomi-layout-hanukkiah .yomi-hanukkiah__stand {
		display: none;
	}
}

/* Legibility: yod + gershayim in the display face reads as resh, so the day numerals use the body face. */
body.yomi-layout-hanukkiah .yomi-leaf__day,
body.yomi-layout-hanukkiah .yomi-mark__day {
	font-family: var(--wp--custom--font--body);
	font-weight: var(--wp--custom--font--weight--black);
	letter-spacing: 0;
}
