/* Japanese stationery / riso print: graph paper, ink outlines with hard
   offset shadows, washi tape, a few Memphis shapes. */

:root {
	--paper: #fbf6ea;
	--grid: rgba(0, 120, 191, .09);
	--ink: #23202e;
	--muted: #5d5868;
	--white: #fffdf8;
	--pink: #ff6fa8;
	--yellow: #ffd23f;
	--blue: #3d8fd6;
	--mint: #45c495;
	--wonky: 14px 5px 12px 6px / 6px 12px 5px 14px; /* slightly uneven, hand-cut corners */
	--display: 'Mochiy Pop One', 'Hiragino Maru Gothic ProN', ui-rounded, system-ui, sans-serif;
	--text: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
	font-family: var(--text);
	font-weight: 500;
	color: var(--ink);
	background-color: var(--paper);
	background-image:
		linear-gradient(var(--grid) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid) 1px, transparent 1px);
	background-size: 26px 26px;
	min-height: 100vh;
	min-height: 100dvh;
	-webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.visually-hidden {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap;
}

.screen {
	max-width: 720px;
	margin: 0 auto;
	padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

/* ---------- washi tape (set --tape for the colour) ---------- */

.steps li::before, .example::before, .polaroid::before, .polaroid::after {
	content: '';
	position: absolute;
	height: 22px;
	opacity: .85;
	background: repeating-linear-gradient(45deg, var(--tape) 0 6px, color-mix(in srgb, var(--tape) 55%, white) 6px 12px);
	clip-path: polygon(3% 0, 97% 4%, 100% 50%, 96% 100%, 2% 96%, 0 50%);
	pointer-events: none;
}

/* ---------- bunny ---------- */

.bunny {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
}
.logo, .hopper {
	display: block;
	line-height: 1;
	animation: hop 1.6s ease-in-out infinite;
	transform-origin: 50% 100%;
}
.logo { font-size: 72px; }
.hopper { font-size: 96px; animation-duration: .7s; }
.hop-shadow {
	width: 54px;
	height: 9px;
	margin-top: 4px;
	border-radius: 50%;
	background: rgba(35, 32, 46, .18);
	animation: shadow 1.6s ease-in-out infinite;
}
.hop-shadow.fast { width: 70px; animation-duration: .7s; }

/* ---------- home ---------- */

.hero {
	position: relative;
	text-align: center;
	margin: 8px 0 28px;
	padding-top: 8px;
}
/* Memphis bits: squiggle + triangle on the left, ring + dots on the right */
.hero::before, .hero::after {
	content: '';
	position: absolute;
	top: 10px;
	width: 120px;
	height: 120px;
	pointer-events: none;
	background-repeat: no-repeat;
	background-size: contain;
}
.hero::before {
	left: 4%;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cpath d='M8 30 q10 -18 20 0 t20 0 t20 0 t20 0' fill='none' stroke='%233d8fd6' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M30 70 l22 38 l-44 0 z' fill='%23ffd23f' stroke='%2323202e' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.hero::after {
	right: 4%;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Ccircle cx='78' cy='34' r='18' fill='none' stroke='%23ff6fa8' stroke-width='6'/%3E%3Cg fill='%2345c495'%3E%3Ccircle cx='24' cy='84' r='5'/%3E%3Ccircle cx='44' cy='84' r='5'/%3E%3Ccircle cx='64' cy='84' r='5'/%3E%3Ccircle cx='34' cy='102' r='5'/%3E%3Ccircle cx='54' cy='102' r='5'/%3E%3C/g%3E%3C/svg%3E");
}

h1 {
	font-family: var(--display);
	font-weight: 400;
	font-size: clamp(40px, 10vw, 66px);
	margin: 10px 0 6px;
	letter-spacing: .5px;
	color: var(--ink);
	text-shadow: 4px 3px 0 var(--pink); /* second riso colour, slightly off register */
}

.tagline { font-size: 21px; color: var(--muted); margin: 0; line-height: 1.5; }
.tagline em {
	font-style: normal;
	font-weight: 700;
	color: var(--ink);
	background: linear-gradient(transparent 55%, var(--yellow) 55%, var(--yellow) 90%, transparent 90%);
	padding: 0 2px;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	justify-content: center;
	margin: 22px 0;
}

.btn {
	font-family: var(--display);
	font-weight: 400;
	font-size: 19px;
	color: var(--ink);
	border: 3px solid var(--ink);
	border-radius: var(--wonky);
	padding: 14px 26px;
	min-height: 60px;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	box-shadow: 4px 4px 0 var(--ink);
	transition: transform .08s ease, box-shadow .08s ease;
	user-select: none;
}
.btn:nth-child(odd) { transform: rotate(-1deg); }
.btn:nth-child(even) { transform: rotate(1deg); }
.btn:hover { transform: rotate(0) translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px dashed var(--blue); outline-offset: 5px; }
.btn-icon { font-size: 24px; }

.btn-primary { background: var(--pink); }
.btn-secondary { background: var(--yellow); }
.btn-plain { background: var(--white); }

.steps {
	list-style: none;
	padding: 0;
	margin: 40px 0 32px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 22px 16px;
}
.steps li {
	position: relative;
	background: var(--white);
	border: 2.5px solid var(--ink);
	border-radius: var(--wonky);
	padding: 22px 16px 16px;
	text-align: center;
	font-size: 17px;
	line-height: 1.4;
	color: var(--muted);
}
.steps li:nth-child(1) { transform: rotate(-1.5deg); --tape: var(--pink); }
.steps li:nth-child(2) { transform: rotate(1deg); --tape: var(--blue); }
.steps li:nth-child(3) { transform: rotate(-.5deg); --tape: var(--mint); }
.steps li::before { top: -12px; left: 50%; width: 70px; transform: translateX(-50%) rotate(-3deg); }
.steps span { display: block; font-size: 32px; margin-bottom: 6px; }

.examples h2 {
	font-family: var(--display);
	font-weight: 400;
	font-size: 20px;
	text-align: center;
	margin: 40px 0 22px;
}

.example-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(190px, 40vw), 1fr));
	gap: 26px 18px;
}

.example {
	position: relative;
	font: inherit;
	font-weight: 700;
	font-size: 15px;
	color: var(--ink);
	border: 2.5px solid var(--ink);
	border-radius: 4px;
	padding: 8px 8px 10px;
	background: var(--white);
	box-shadow: 3px 3px 0 var(--ink);
	cursor: pointer;
	transition: transform .12s ease, box-shadow .12s ease;
}
.example:nth-child(3n+1) { transform: rotate(-2deg); --tape: var(--yellow); }
.example:nth-child(3n+2) { transform: rotate(1.5deg); --tape: var(--blue); }
.example:nth-child(3n) { transform: rotate(-.5deg); --tape: var(--pink); }
.example::before { top: -10px; right: -14px; width: 58px; height: 20px; transform: rotate(32deg); }
.example:hover, .example:focus-visible {
	transform: rotate(0) translate(-2px, -2px);
	box-shadow: 5px 5px 0 var(--ink);
	outline: none;
}
.example:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.example img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	display: block;
	margin-bottom: 8px;
	background: #efe9dc;
	border: 1.5px solid var(--ink);
}

.footer { text-align: center; color: var(--muted); font-size: 15px; margin: 44px 0 8px; }
.footer a { color: var(--ink); text-decoration-color: var(--pink); text-decoration-thickness: 3px; }

/* ---------- camera ---------- */

.camera {
	position: fixed;
	inset: 0;
	max-width: none;
	padding: 0;
	background: var(--ink);
	overflow: hidden;
}
.camera video, .camera canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}
.camera video { object-fit: cover; }
.camera.mirror video, .camera.mirror canvas { transform: scaleX(-1); }

.close {
	position: absolute;
	top: max(16px, env(safe-area-inset-top));
	right: 16px;
	width: 54px; height: 54px;
	font-family: var(--display);
	font-size: 22px;
	color: var(--ink);
	background: var(--white);
	border: 3px solid var(--ink);
	border-radius: var(--wonky);
	box-shadow: 3px 3px 0 var(--ink);
	cursor: pointer;
}
.close:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.hint {
	position: absolute;
	left: 50%;
	bottom: max(28px, env(safe-area-inset-bottom));
	transform: translateX(-50%) rotate(-1deg);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 22px 10px 12px;
	background: var(--white);
	border: 3px solid var(--ink);
	border-radius: var(--wonky);
	box-shadow: 4px 4px 0 var(--ink);
	font-family: var(--display);
	font-size: 18px;
	white-space: nowrap;
}
.ring { width: 38px; height: 38px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring-bg { stroke: #ece6d8; }
.ring-fg {
	stroke: var(--mint);
	stroke-dasharray: 94.25;
	stroke-dashoffset: 94.25;
	transition: stroke-dashoffset .15s linear;
}

.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .4s ease-out; }

/* ---------- busy / oops ---------- */

.busy, .oops {
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
}
.busy p { font-family: var(--display); font-size: 24px; margin-top: 18px; }

.oops-face { font-size: 84px; }
.oops h2 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 14px 0; }
.tips {
	text-align: left;
	font-size: 18px;
	color: var(--muted);
	line-height: 1.7;
	padding: 16px 20px 16px 2.2em;
	max-width: 30em;
	background: var(--white);
	border: 2.5px solid var(--ink);
	border-radius: var(--wonky);
}

/* ---------- result ---------- */

.result {
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.polaroid {
	position: relative;
	display: inline-block;
	background: var(--white);
	padding: 12px 12px 34px;
	border: 3px solid var(--ink);
	border-radius: 4px;
	box-shadow: 6px 6px 0 var(--ink);
	transform: rotate(-1.5deg);
	margin-top: 22px;
	max-width: 100%;
	animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.polaroid::before { top: -12px; left: -18px; width: 74px; transform: rotate(-28deg); --tape: var(--yellow); }
.polaroid::after { top: -12px; right: -18px; width: 74px; transform: rotate(28deg); --tape: var(--blue); }
.polaroid img {
	display: block;
	max-width: 100%;
	max-height: 60vh;
	max-height: 60dvh;
	border: 1.5px solid var(--ink);
}

.speed {
	display: inline-flex;
	gap: 4px;
	margin-top: 28px;
	padding: 5px;
	background: var(--white);
	border: 3px solid var(--ink);
	border-radius: var(--wonky);
	box-shadow: 3px 3px 0 var(--ink);
}
.speed button {
	font-size: 26px;
	width: 60px; height: 50px;
	border: 2.5px solid transparent;
	border-radius: var(--wonky);
	background: transparent;
	cursor: pointer;
}
.speed button[aria-checked="true"] { background: var(--yellow); border-color: var(--ink); }

.debug { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); }

/* ---------- motion ---------- */

@keyframes hop {
	0%, 100% { transform: translateY(0) scale(1, 1); }
	15% { transform: translateY(0) scale(1.1, .9); }
	45% { transform: translateY(-22px) scale(.95, 1.05); }
	75% { transform: translateY(0) scale(1.05, .95); }
}
@keyframes shadow {
	0%, 100% { transform: scaleX(1); opacity: 1; }
	15% { transform: scaleX(1.15); }
	45% { transform: scaleX(.6); opacity: .5; }
	75% { transform: scaleX(1.05); }
}
@keyframes pop { from { transform: scale(.6) rotate(-6deg); opacity: 0; } }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }

@media (max-width: 520px) {
	.steps { grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 32px 0 24px; }
	.steps li { padding: 18px 6px 10px; font-size: 13px; }
	.steps li::before { width: 46px; height: 16px; top: -9px; }
	.steps span { font-size: 26px; }
	.hero::before, .hero::after { width: 76px; height: 76px; }
	.hero::before { left: -6px; }
	.hero::after { right: -6px; }
}

@media (prefers-reduced-motion: reduce) {
	.logo, .hopper, .hop-shadow, .polaroid { animation: none; }
}
