/*
 * The cookie ticket: a kitchen ticket that slides up with a freshly baked,
 * orange-glazed cookie stuck to its corner. Yes takes a bite and stamps it
 * SERVED; no stamps it 86'd and the cookie rolls off. Colours and fonts come
 * from the theme's presets, with plain fallbacks for any other theme.
 */

.slop-cookie {
	--c-ink: var(--wp--preset--color--ink, #16140f);
	--c-paper: var(--wp--preset--color--paper, #f4f0e6);
	--c-card: var(--wp--preset--color--card, #fbf9f4);
	--c-orange: var(--wp--preset--color--orange, #ee5b2b);
	--c-grape: var(--wp--preset--color--grape, #8b72f2);
	--c-oat: var(--wp--preset--color--oat, #eae4d6);
	--c-sans: var(--wp--preset--font-family--archivo, Archivo, "Helvetica Neue", Arial, sans-serif);
	--c-display: var(--wp--preset--font-family--archivo-condensed, "Archivo Condensed", "Arial Narrow", Impact, sans-serif);
	--c-mono: var(--wp--preset--font-family--plex-mono, "IBM Plex Mono", ui-monospace, monospace);
	--c-ease: cubic-bezier(0.2, 0.9, 0.3, 1.2);
	--c-sticker: 7.25rem;
	--c-edge: clamp(1rem, 3vw, 2.5rem);
	position: fixed;
	right: var(--c-edge);
	bottom: calc(var(--c-edge) + env(safe-area-inset-bottom, 0px));
	z-index: 9997;
	width: min(23.5rem, calc(100vw - 2rem));
	color: var(--c-ink);
	animation: slop-cookie-in 0.75s var(--c-ease) both;
}
.slop-cookie[hidden] { display: none; }
.slop-cookie.is-leaving { animation: slop-cookie-out 0.45s cubic-bezier(0.5, 0, 0.9, 0.4) both; }

/* ----- The ticket: card paper, a torn bottom edge and a hard ink shadow ----- */

.slop-cookie__ticket {
	position: relative;
	padding: 1.2rem 1.35rem 2.1rem;
	font-family: var(--c-mono);
	font-size: 0.75rem;
	font-weight: 500;
	letter-spacing: 0.05em;
	line-height: 1.45;
	text-transform: uppercase;
	transform: rotate(-1.4deg);
	/* The shadow follows the torn edge, so it is a filter, not a box-shadow. */
	filter: drop-shadow(7px 7px 0 var(--c-ink));
	isolation: isolate;
	overflow: clip;
}
.slop-cookie__ticket::before,
.slop-cookie__ticket::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	z-index: -1;
}
.slop-cookie__ticket::before {
	top: 0;
	bottom: 9px;
	background: var(--c-card);
	border-radius: 6px 6px 0 0;
}
.slop-cookie__ticket::after {
	bottom: 0;
	height: 10px;
	background: var(--c-card);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 364 10' preserveAspectRatio='none'%3E%3Cpath d='M0 0 L7 10 L14 0 L21 10 L28 0 L35 10 L42 0 L49 10 L56 0 L63 10 L70 0 L77 10 L84 0 L91 10 L98 0 L105 10 L112 0 L119 10 L126 0 L133 10 L140 0 L147 10 L154 0 L161 10 L168 0 L175 10 L182 0 L189 10 L196 0 L203 10 L210 0 L217 10 L224 0 L231 10 L238 0 L245 10 L252 0 L259 10 L266 0 L273 10 L280 0 L287 10 L294 0 L301 10 L308 0 L315 10 L322 0 L329 10 L336 0 L343 10 L350 0 L357 10 L364 0 Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 364 10' preserveAspectRatio='none'%3E%3Cpath d='M0 0 L7 10 L14 0 L21 10 L28 0 L35 10 L42 0 L49 10 L56 0 L63 10 L70 0 L77 10 L84 0 L91 10 L98 0 L105 10 L112 0 L119 10 L126 0 L133 10 L140 0 L147 10 L154 0 L161 10 L168 0 L175 10 L182 0 L189 10 L196 0 L203 10 L210 0 L217 10 L224 0 L231 10 L238 0 L245 10 L252 0 L259 10 L266 0 L273 10 L280 0 L287 10 L294 0 L301 10 L308 0 L315 10 L322 0 L329 10 L336 0 L343 10 L350 0 L357 10 L364 0 Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}

/* On a short screen (a phone on its side, a small laptop with the ingredients
   open) the contents scroll inside the paper, clear of the sticker above. */
.slop-cookie__body {
	--c-room: calc(var(--c-edge) + env(safe-area-inset-bottom, 0px) + var(--c-sticker) * 0.5 + 4.5rem);
	max-height: calc(100vh - var(--c-room));
	max-height: calc(100dvh - var(--c-room));
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}

/* The sticker sits on the top-left corner, so the first two rows start after it. */
.slop-cookie__head,
.slop-cookie__meta {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin: 0;
	padding-left: calc(var(--c-sticker) * 0.58);
}
.slop-cookie__head {
	padding-bottom: 0.55rem;
	border-bottom: 2px solid var(--c-ink);
	font-weight: 700;
}
.slop-cookie__meta {
	padding-top: 0.45rem;
	padding-bottom: 0.45rem;
	border-bottom: 1px dashed color-mix(in oklab, var(--c-ink) 28%, transparent);
	color: color-mix(in oklab, var(--c-ink) 60%, transparent);
}
.slop-cookie__last { color: var(--c-ink); font-weight: 700; }

.slop-cookie__title {
	margin: 1rem 0 0.6rem;
	font-family: var(--c-display);
	font-size: clamp(2.3rem, 9vw, 2.9rem);
	font-weight: 900;
	letter-spacing: -0.005em;
	line-height: 0.86;
	text-transform: uppercase;
	color: var(--c-ink);
}
.slop-cookie__title em {
	display: block;
	font-style: normal;
	color: var(--c-orange);
}
.slop-cookie__lead {
	margin: 0 0 0.85rem;
	font-family: var(--c-sans);
	font-size: 0.95rem;
	font-weight: 400;
	letter-spacing: 0;
	line-height: 1.45;
	text-transform: none;
}

/* ----- Ingredients: exactly what the cookie is made of ----- */

.slop-cookie__ingredients {
	margin: 0 0 1rem;
	border-top: 1px dashed color-mix(in oklab, var(--c-ink) 28%, transparent);
	border-bottom: 1px dashed color-mix(in oklab, var(--c-ink) 28%, transparent);
}
.slop-cookie__ingredients summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.5rem 0;
	font-weight: 700;
	cursor: pointer;
	list-style: none;
}
.slop-cookie__ingredients summary::-webkit-details-marker { display: none; }
.slop-cookie__ingredients summary::after {
	content: "+";
	font-size: 1.1rem;
	line-height: 1;
	transition: rotate 0.25s var(--c-ease);
}
.slop-cookie__ingredients[open] summary::after { rotate: 45deg; }
.slop-cookie__ingredients summary:hover,
.slop-cookie__ingredients summary:focus-visible { color: var(--c-orange); }
.slop-cookie__ingredients dl { margin: 0 0 0.5rem; }
.slop-cookie__ingredients dl > div {
	display: grid;
	grid-template-columns: minmax(6.5em, auto) minmax(0, 1fr);
	gap: 0.75em;
	padding: 0.35rem 0;
	border-top: 1px dashed color-mix(in oklab, var(--c-ink) 18%, transparent);
}
.slop-cookie__ingredients dt { font-weight: 700; text-transform: none; overflow-wrap: anywhere; }
.slop-cookie__ingredients dd,
.slop-cookie__ingredients p {
	margin: 0;
	font-family: var(--c-sans);
	font-size: 0.82rem;
	letter-spacing: 0;
	line-height: 1.4;
	text-transform: none;
}
.slop-cookie__ingredients p { margin-bottom: 0.55rem; }
.slop-cookie__ingredients a { color: inherit; font-weight: 700; text-underline-offset: 0.15em; }
.slop-cookie__ingredients a:hover { color: var(--c-orange); }

/* ----- Answers: yes and no weigh the same ----- */

.slop-cookie__actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.6rem;
}
.slop-cookie__button {
	padding: 0.8rem 0.75rem;
	border: 1.5px solid var(--c-ink);
	border-radius: 999px;
	font-family: var(--c-sans);
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.1;
	text-transform: none;
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}
.slop-cookie__button[hidden] { display: none; }
.slop-cookie__button.is-yes { background: var(--c-orange); color: var(--c-ink); }
.slop-cookie__button.is-no { background: var(--c-ink); color: var(--c-paper); }
.slop-cookie__button.is-keep { background: transparent; color: var(--c-ink); }
.slop-cookie__button:hover,
.slop-cookie__button:focus-visible {
	transform: translate(-3px, -3px);
	box-shadow: 3px 3px 0 var(--c-ink);
	outline: none;
}
.slop-cookie__button.is-no:hover,
.slop-cookie__button.is-no:focus-visible { color: var(--c-orange); box-shadow: 3px 3px 0 var(--c-orange); }
.slop-cookie__button:focus-visible { outline: 2px solid var(--c-grape); outline-offset: 3px; }
.slop-cookie__button:active { transform: none; box-shadow: none; }

/* ----- Stamps ----- */

.slop-cookie__stamp {
	position: absolute;
	top: 46%;
	left: 50%;
	padding: 0.15em 0.45em 0.05em;
	border: 4px solid currentColor;
	border-radius: 10px;
	background: color-mix(in oklab, var(--c-card) 70%, transparent);
	font-family: var(--c-display);
	font-size: 3.4rem;
	font-weight: 900;
	letter-spacing: 0.02em;
	line-height: 1;
	text-transform: uppercase;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	translate: -50% -50%;
	rotate: -13deg;
}
.slop-cookie__stamp.is-served { color: var(--c-orange); }
.slop-cookie__stamp.is-86 { color: var(--c-grape); rotate: 9deg; }
.slop-cookie.is-served .slop-cookie__stamp.is-served,
.slop-cookie.is-86 .slop-cookie__stamp.is-86 { animation: slop-cookie-slam 0.45s var(--c-ease) both; }

/* ----- The cookie sticker ----- */

.slop-cookie__sticker {
	position: absolute;
	left: calc(var(--c-sticker) * -0.36);
	top: calc(var(--c-sticker) * -0.46);
	z-index: 2;
	width: var(--c-sticker);
	height: var(--c-sticker);
	rotate: -8deg;
	animation: slop-cookie-slap 0.5s var(--c-ease) 0.35s both;
}
.slop-cookie__ring {
	display: block;
	width: 100%;
	height: 100%;
	animation: slop-cookie-spin 28s linear infinite;
}
.slop-cookie__disc { fill: var(--c-paper); stroke: var(--c-ink); stroke-width: 1.5; }
.slop-cookie__ring-text {
	fill: var(--c-ink);
	font-family: var(--c-mono);
	font-size: 11.5px;
	font-weight: 500;
	text-transform: uppercase;
}
.slop-cookie__cookie {
	position: absolute;
	inset: 12%;
	overflow: visible;
}
.slop-cookie__dough { fill: var(--c-oat); stroke: var(--c-ink); stroke-width: 3; stroke-linejoin: round; }
.slop-cookie__glaze { fill: var(--c-orange); stroke: var(--c-ink); stroke-width: 3; stroke-linejoin: round; }
.slop-cookie__shine { fill: none; stroke: var(--c-paper); stroke-width: 4; stroke-linecap: round; opacity: 0.85; }
.slop-cookie__chip { fill: var(--c-ink); }
.slop-cookie__bite {
	transform: scale(0);
	transform-box: fill-box;
	transform-origin: center;
}
/* Yes: three bites, one after another. */
.slop-cookie.is-served .slop-cookie__bite { animation: slop-cookie-bite 0.2s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.slop-cookie.is-served .slop-cookie__bite:nth-of-type(2) { animation-delay: 0.22s; }
.slop-cookie.is-served .slop-cookie__bite:nth-of-type(3) { animation-delay: 0.44s; }
/* No: the cookie rolls off the ticket. */
.slop-cookie.is-86 .slop-cookie__sticker { animation: slop-cookie-roll 0.95s cubic-bezier(0.45, 0, 0.8, 0.5) both; }

/* ----- Phones: the ticket spans the screen; the sticker shrinks ----- */

@media (max-width: 600px) {
	.slop-cookie {
		--c-sticker: 5.5rem;
		--c-edge: 1rem;
		left: 1rem;
		right: 1rem;
		width: auto;
	}
	.slop-cookie__sticker { left: -0.4rem; top: calc(var(--c-sticker) * -0.52); }
	.slop-cookie__head,
	.slop-cookie__meta { padding-left: calc(var(--c-sticker) * 0.8); }
	.slop-cookie__ticket { padding: 1rem 1.1rem 1.9rem; }
	.slop-cookie__lead { font-size: 0.9rem; }
}

/* The footer's "Cookie settings" link sits inside the box of the giant
   wordmark below it, which would otherwise take its clicks. */
.slop-cookie-settings { position: relative; z-index: 1; }

/* A cookie ticket has no business on paper. */
@media print {
	.slop-cookie { display: none !important; }
}

/* Heard by screen readers only: what the stamp says. */
.slop-cookie__said {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ----- Motion ----- */

@keyframes slop-cookie-in {
	0% { opacity: 0; transform: translateY(calc(100% + 4rem)) rotate(5deg); }
	100% { opacity: 1; transform: none; }
}
@keyframes slop-cookie-out {
	0% { transform: none; }
	25% { transform: translateY(-10px) rotate(-1deg); }
	100% { opacity: 0; transform: translateY(calc(100% + 5rem)) rotate(-4deg); }
}
@keyframes slop-cookie-slap {
	0% { opacity: 0; scale: 2.3; }
	60% { opacity: 1; scale: 0.92; }
	100% { opacity: 1; scale: 1; }
}
@keyframes slop-cookie-slam {
	0% { opacity: 0; scale: 2.6; }
	60% { opacity: 1; scale: 0.92; }
	100% { opacity: 1; scale: 1; }
}
@keyframes slop-cookie-bite {
	to { transform: scale(1); }
}
@keyframes slop-cookie-roll {
	0% { translate: 0 0; rotate: -8deg; }
	100% { translate: 160vw 3rem; rotate: 540deg; }
}
@keyframes slop-cookie-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	.slop-cookie,
	.slop-cookie *,
	.slop-cookie.is-leaving { animation: none !important; transition: none !important; }
	.slop-cookie.is-served .slop-cookie__bite { transform: scale(1); }
	.slop-cookie.is-served .slop-cookie__stamp.is-served,
	.slop-cookie.is-86 .slop-cookie__stamp.is-86 { opacity: 1; }
}
