/* 12 Days of Spinmas – [spinlife_spinmas] */

/* How far the corner of a box is peeled back. Registered as a length so it can
   be transitioned and animated. */
@property --smc-peel {
	syntax: "<length>";
	inherits: true;
	initial-value: 0px;
}

.smc {
	--smc-red: #e0202a;
	--smc-red-dark: #8a0505;
	--smc-mint: #63f5d6;
	--smc-ink: #2b2f36;
	--smc-radius: 14px;

	position: relative;
	max-width: 1080px;
	margin: 0 auto;
	padding: 58px 0 60px;
	font-family: Kanit, sans-serif;
	color: var(--smc-ink);
}

.smc *,
.smc *::before,
.smc *::after {
	box-sizing: border-box;
}

.smc [hidden] {
	display: none !important;
}

.smc-stage {
	position: relative;
}

/* The calendar has its own heading – hide the theme's page title */
body.smc-page .entry-header {
	display: none;
}

/* ---------- Heading ---------- */

.smc .smc-title {
	position: relative;
	z-index: 1;
	margin: 0 0 54px;
	line-height: 1;
	text-align: center;
}

/* The "12 Days of Spinmas" logo */
.smc .smc-title__logo {
	display: block;
	width: min(368px, 88vw);
	height: auto;
	margin: 0 auto;
	filter: drop-shadow(0 6px 7px rgba(0, 0, 0, .26));
}

.smc-preview {
	position: relative;
	z-index: 1;
	margin: -10px 0 18px;
	font-size: 13px;
	text-align: center;
	color: #8a8f98;
}

/* ---------- Santa and the present beside the calendar ---------- */

.smc-deco {
	position: absolute;
	z-index: 0;
	pointer-events: none;
	user-select: none;
}

/* Santa stands to the left of the logo, whatever the width */
.smc-deco--santa { top: -20px; left: calc(50% - 400px); width: 200px; }
/* The present sits clear of the last box, and shrinks before it would reach
   the edge of the window */
.smc-deco--present { left: calc(50% + 385px); bottom: 60px; width: min(210px, calc(50vw - 395px)); transform: rotate(8deg); }

/* Logged out, Santa is in the login prompt instead */
.smc--guest .smc-deco--santa {
	display: none;
}

/* ---------- Board ---------- */

.smc-board {
	position: relative;
	z-index: 1;
	max-width: 760px;
	margin: 0 auto;
}

/* The candy cane behind the boxes – laid out by the script. Wider than the
   board (--smc-cane-pad on each side, which the script reads) so its loops fit. */
.smc-cane {
	--smc-cane-pad: 130px;

	position: absolute;
	top: 0;
	left: calc(var(--smc-cane-pad) * -1);
	width: calc(100% + var(--smc-cane-pad) * 2);
	height: 100%;
	overflow: visible;
	pointer-events: none;
	filter: drop-shadow(0 2px 2px rgba(60, 0, 0, .28));
}

/* The stretches that show in the gaps between the boxes – fainter than the
   turns at the row ends */
.smc-cane__straight {
	opacity: .35;
}

.smc .smc-grid {
	position: relative;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.smc .smc-day {
	position: relative;
	margin: 0;
	padding: 0;
	aspect-ratio: 7 / 5;
	container-type: inline-size;
	filter: drop-shadow(0 3px 3px rgba(40, 0, 0, .3));
	transition: --smc-peel .25s ease-out;
}

/* ---------- Closed box ---------- */

.smc-cover {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border-radius: var(--smc-radius);
	background: #b00a0a url("../images/spinmas/cover-red.jpg") center / cover no-repeat;
	box-shadow: inset 0 -5px 0 rgba(70, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .18);
	color: #fff;
	text-align: center;
	user-select: none;
}

/* Snowflakes – every box shows its own part of the same snowfall */
.smc-cover::before {
	content: "";
	position: absolute;
	inset: 0;
	background: url("../images/spinmas/snow.png") 12% 8% / 230% auto;
	opacity: .8;
}

.smc-day:nth-child(4n + 2) .smc-cover::before { background-position: 78% 30%; }
.smc-day:nth-child(4n + 3) .smc-cover::before { background-position: 34% 62%; }
.smc-day:nth-child(4n) .smc-cover::before { background-position: 92% 88%; }
.smc-day:nth-child(n + 5) .smc-cover::before { background-size: 260% auto; }
.smc-day:nth-child(n + 9) .smc-cover::before { background-size: 210% auto; transform: scaleX(-1); }

.smc-cover__num {
	position: relative;
	display: flex;
	align-items: baseline;
	font-family: Montserrat, Kanit, sans-serif;
	font-size: 68px;
	font-size: 46cqw;
	font-weight: 900;
	line-height: .86;
	letter-spacing: -.04em;
	text-shadow: 0 0 .3em rgba(255, 255, 255, .75), 0 .04em 0 rgba(110, 0, 0, .45);
}

.smc-cover__num span {
	margin-left: .14em;
	font-size: .26em;
	letter-spacing: 0;
	text-transform: uppercase;
}

.smc-cover__label {
	position: relative;
	margin-top: .35em;
	font-size: 10px;
	font-size: 6.2cqw;
	font-weight: 400;
	line-height: 1;
	letter-spacing: .03em;
	text-transform: uppercase;
}

/* "1D 2H 21M" until the box opens */
.smc-cover__label--countdown {
	font-size: 12px;
	font-size: 7.5cqw;
	font-variant-numeric: tabular-nums;
	letter-spacing: .06em;
	white-space: nowrap;
}

/* ---------- Locked box ---------- */

/* Darker than a box that's ready to peel – the number and the snow stay bright */
.smc-day--locked .smc-cover,
.smc-day--next .smc-cover {
	background-image:
		radial-gradient(ellipse at 50% 45%, rgba(45, 0, 0, .3) 0%, rgba(30, 0, 0, .68) 100%),
		url("../images/spinmas/cover-red.jpg");
	background-size: cover;
	background-position: center;
}

.smc-cover__lock {
	position: absolute;
	top: 5%;
	left: 4%;
	/* Small enough to stay clear of a two-digit number */
	width: 18px;
	width: 11cqw;
	height: auto;
	color: #fff;
	filter: drop-shadow(0 0 .25em rgba(255, 255, 255, .55)) drop-shadow(0 1px 1px rgba(60, 0, 0, .6));
}

/* "Xmas Special" – overlaps the bottom edge of the number */
.smc-cover__badge {
	position: relative;
	margin-top: -.1em;
	font-family: "Luckiest Guy", Kanit, sans-serif;
	font-size: 16px;
	font-size: 10.5cqw;
	line-height: 1;
	background: linear-gradient(180deg, #fff7b8 0%, #ffd84a 45%, #e39a00 60%, #ffdf6b 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: #ffd84a;
	filter: drop-shadow(0 1px 0 #5c1408) drop-shadow(0 2px 2px rgba(0, 0, 0, .5));
	padding-top: .15em;
}

/* ---------- Peel ---------- */

.smc-day--ready {
	--smc-peel: 30px;
	animation: smc-tease 3.2s ease-in-out infinite;
}

.smc-day--ready .smc-cover {
	/* The corner past the fold is cut away, showing the gift underneath */
	clip-path: polygon(0 0, calc(100% - var(--smc-peel)) 0, 100% var(--smc-peel), 100% 100%, 0 100%);
	cursor: pointer;
}

.smc-day--ready:hover,
.smc-day--ready:focus-within {
	--smc-peel: 48px;
	animation: none;
}

.smc-day--ready .smc-cover:focus-visible {
	outline: none;
}

.smc-day--ready:has(.smc-cover:focus-visible) {
	outline: 2px solid var(--smc-red);
	outline-offset: 3px;
	border-radius: var(--smc-radius);
}

/* The script drives --smc-peel while the box is peeled open */
.smc-day.is-peeling {
	z-index: 3;
	animation: none;
	transition: none;
}

@keyframes smc-tease {
	0%, 62%, 100% { --smc-peel: 30px; }
	78% { --smc-peel: 42px; }
}

/* The folded-back corner: a square in the top right, as big as the peel, whose
   lower-left triangle is the back of the paper. */
.smc-flap {
	position: absolute;
	top: 0;
	right: 0;
	width: var(--smc-peel);
	height: var(--smc-peel);
	pointer-events: none;
	filter: drop-shadow(-2px 3px 3px rgba(30, 0, 0, .5));
}

/* The back of the paper can't be bigger than the box itself (mirrored, so the
   box's height limits its width) – matters once the peel passes an edge. */
.smc-flap__limit {
	position: absolute;
	bottom: 0;
	left: 0;
	width: min(100%, var(--smc-h, 100%));
	height: min(100%, var(--smc-w, 100%));
	overflow: hidden;
	border-bottom-left-radius: 10px;
}

.smc-flap__paper {
	position: absolute;
	bottom: 0;
	left: 0;
	width: var(--smc-peel);
	height: var(--smc-peel);
	clip-path: polygon(0 0, 100% 100%, 0 100%);
	/* From the tip (bottom left) up to the fold (the diagonal, at 50%) */
	background: linear-gradient(45deg, #6d0303 0%, #a80c0c 22%, #e45a55 38%, #b51212 46%, #7c0404 50%);
}

/* ---------- Open box ---------- */

.smc-gift {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	overflow: hidden;
	padding: 5% 2.5% 6%;
	border: 2px solid var(--smc-mint);
	border-radius: var(--smc-radius);
	background:
		/* Darker towards the bottom, behind the text */
		linear-gradient(180deg, rgba(3, 60, 52, 0) 30%, rgba(3, 60, 52, .6) 100%),
		#0c6a5d url("../images/spinmas/gift-green.jpg") var(--smc-gift-pos, 50% 22%) / 150% auto no-repeat;
	box-shadow: 0 0 8px rgba(99, 245, 214, .55);
	color: #fff;
	text-align: center;
}

/* Every box shows its own part of the lights */
.smc-day:nth-child(5n + 2) { --smc-gift-pos: 100% 12%; }
.smc-day:nth-child(5n + 3) { --smc-gift-pos: 0% 30%; }
.smc-day:nth-child(5n + 4) { --smc-gift-pos: 70% 40%; }
.smc-day:nth-child(5n) { --smc-gift-pos: 25% 8%; }

.smc-gift--info {
	cursor: pointer;
}

/* Under the cover: no glow leaking out around it */
.smc-day--ready .smc-gift {
	box-shadow: none;
	pointer-events: none;
}

.smc-gift--info:focus-visible {
	outline: 2px solid var(--smc-ink);
	outline-offset: 3px;
}

.smc-day--open .smc-gift--info {
	transition: transform .15s;
}

.smc-day--open .smc-gift--info:hover {
	transform: translateY(-2px);
}

.smc-gift__icon {
	position: absolute;
	top: 6%;
	left: 4.5%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	width: 11cqw;
	aspect-ratio: 1;
	border-radius: 50%;
	background: #14171c;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 12px;
	font-size: 8cqw;
	font-weight: 700;
	line-height: 1;
	color: #fff;
}

.smc .smc-gift__img {
	flex: 1 1 0;
	/* A long title and text can't squeeze the image away */
	min-height: 34%;
	max-width: 62%;
	margin: 0 0 2%;
	object-fit: contain;
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}

.smc-gift__title {
	max-width: 100%;
	font-size: 15px;
	font-size: 9.2cqw;
	font-weight: 700;
	line-height: 1.05;
	letter-spacing: .01em;
	text-transform: uppercase;
	text-shadow: 0 1px 0 rgba(0, 40, 34, .9), 0 0 4px rgba(0, 40, 34, .7);
}

.smc-gift__sub {
	max-width: 100%;
	margin-top: 1%;
	font-size: 8px;
	font-size: 5.2cqw;
	font-style: italic;
	line-height: 1.15;
	text-transform: uppercase;
	text-shadow: 0 1px 2px rgba(0, 40, 34, .9);
}

/* Just peeled */
.smc-day.is-revealed .smc-gift {
	animation: smc-glow .9s ease-out;
}

@keyframes smc-glow {
	0% { box-shadow: 0 0 26px 6px rgba(99, 245, 214, .9); }
}

/* ---------- How do the gifts work ---------- */

.smc-how {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 14px;
	max-width: 440px;
	margin: 30px auto 0;
	padding: 8px 26px 8px 8px;
	background: linear-gradient(90deg, rgba(228, 230, 235, 0) 0%, #e4e6eb 12%, #e4e6eb 70%, rgba(228, 230, 235, 0) 100%);
}

.smc .smc-how__logo {
	flex: none;
	width: 64px;
	height: auto;
	padding-right: 12px;
	border-right: 2px solid #c9ccd3;
	box-sizing: content-box;
}

.smc-how__title {
	display: block;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	text-transform: uppercase;
	color: var(--smc-red);
}

.smc .smc-how p {
	margin: 2px 0 0;
	font-size: 10px;
	line-height: 1.35;
	color: var(--smc-ink);
}

.smc .smc-how a {
	color: inherit;
	text-decoration: underline;
}

.smc .smc-how a:hover {
	color: var(--smc-red);
}

/* ---------- Not logged in ---------- */

.smc--guest .smc-stage {
	filter: blur(9px) brightness(.82) saturate(.9);
	pointer-events: none;
	user-select: none;
}

.smc .smc-login {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding-bottom: 6%;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	color: #fff;
}

.smc .smc-login__santa {
	width: min(250px, 60vw);
	height: auto;
	margin-bottom: 4px;
	animation: smc-bob 3.6s ease-in-out infinite;
}

@keyframes smc-bob {
	50% { transform: translateY(-8px); }
}

.smc-login__top {
	font-size: 17px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: .03em;
	text-shadow: 0 0 2px #14171c, 0 0 2px #14171c, 0 1px 3px #14171c, 0 0 8px rgba(20, 23, 28, .6);
}

.smc-login__main {
	font-family: Montserrat, Kanit, sans-serif;
	font-size: 23px;
	font-weight: 900;
	line-height: 1.15;
	letter-spacing: .02em;
	color: #ff1414;
	text-shadow: 0 0 2px #2b0000, 0 0 2px #2b0000, 0 2px 0 #5c0000, 0 0 10px rgba(20, 23, 28, .45);
	transition: color .15s;
}

.smc .smc-login:hover .smc-login__main,
.smc .smc-login:focus-visible .smc-login__main {
	color: #ff4a4a;
}

.smc .smc-login:focus-visible {
	outline: none;
}

.smc .smc-login:focus-visible .smc-login__main {
	text-decoration: underline;
}

/* ---------- Gift info popup ---------- */

body.smc-modal-open {
	overflow: hidden;
}

.smc-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(18, 20, 26, .78);
	animation: smc-fade .2s ease-out;
}

@keyframes smc-fade {
	from { opacity: 0; }
}

@keyframes smc-pop {
	from { opacity: 0; transform: scale(.85); }
}

.smc-modal__box {
	position: relative;
	width: min(420px, 100%);
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: 26px 28px 28px;
	border: 2px solid var(--smc-mint);
	border-radius: 16px;
	background:
		linear-gradient(180deg, rgba(3, 60, 52, .1) 0%, rgba(3, 60, 52, .72) 55%, rgba(3, 60, 52, .86) 100%),
		#0c6a5d url("../images/spinmas/gift-green.jpg") center top / cover no-repeat;
	box-shadow: 0 0 18px rgba(99, 245, 214, .45);
	color: #fff;
	text-align: center;
	animation: smc-pop .25s ease-out;
}

.smc-modal__box:focus {
	outline: none;
}

.smc .smc-modal__close {
	position: absolute;
	top: 8px;
	right: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	font-size: 28px;
	line-height: 1;
	text-decoration: none;
	color: rgba(255, 255, 255, .8);
}

.smc .smc-modal__close:hover,
.smc .smc-modal__close:focus-visible {
	background: rgba(0, 0, 0, .25);
	color: #fff;
	outline: none;
}

.smc .smc-info__img {
	display: block;
	width: auto;
	max-width: 70%;
	max-height: 170px;
	margin: 0 auto 6px;
	filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .4));
}

.smc-info__day {
	display: block;
	font-size: 12px;
	font-style: italic;
	text-transform: uppercase;
	color: var(--smc-mint);
}

.smc .smc-info__title {
	margin: 2px 0 0;
	font-family: Kanit, sans-serif;
	font-size: 28px;
	font-weight: 700;
	line-height: 1.1;
	text-transform: uppercase;
	color: #fff;
}

.smc .smc-info__sub {
	margin: 4px 0 0;
	font-size: 15px;
	font-style: italic;
	line-height: 1.3;
	text-transform: uppercase;
	color: #fff;
}

.smc-info__text {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px solid rgba(255, 255, 255, .22);
	font-size: 14px;
	line-height: 1.5;
	text-align: left;
}

.smc .smc-info__text p {
	margin: 0 0 10px;
	color: #fff;
}

.smc .smc-info__text > :last-child {
	margin-bottom: 0;
}

.smc .smc-info__text a {
	color: var(--smc-mint);
	text-decoration: underline;
}

.smc .smc-btn,
.smc .smc-btn:hover,
.smc .smc-btn:focus {
	display: inline-block;
	margin-top: 18px;
	padding: 6px 22px 5px;
	border-radius: 8px;
	background: linear-gradient(180deg, #ff4a4a 0%, #e0202a 55%, #c2101a 100%);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 3px 0 #7a0202, 0 5px 6px rgba(0, 0, 0, .25);
	font-size: 18px;
	font-style: italic;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	text-transform: uppercase;
	color: #fff;
	transition: filter .15s, transform .15s;
}

.smc .smc-btn:hover,
.smc .smc-btn:focus-visible {
	filter: brightness(1.1);
	transform: translateY(-1px);
}

.smc .smc-btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* ---------- Responsive ---------- */

/* No room for the candy cane's loops or the present */
@media (max-width: 1000px) {
	.smc-cane,
	.smc-deco--present {
		display: none;
	}
}

/* No room for Santa */
@media (max-width: 860px) {
	.smc-deco {
		display: none;
	}

	.smc {
		padding-top: 16px;
	}
}

@media (max-width: 640px) {
	.smc .smc-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 10px;
	}

	.smc-day--ready { --smc-peel: 22px; }

	.smc-how {
		padding-right: 12px;
		background: #e4e6eb;
		border-radius: 8px;
	}

	/* The calendar is taller than the screen – keep the prompt near the top */
	.smc .smc-login {
		justify-content: flex-start;
		padding: 70px 0 0;
	}
}

@media (max-width: 420px) {
	.smc .smc-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (prefers-reduced-motion: reduce) {
	.smc-day,
	.smc-day--ready,
	.smc .smc-login__santa,
	.smc-modal,
	.smc-modal__box,
	.smc-day.is-revealed .smc-gift {
		animation: none;
		transition: none;
	}
}
