:root {
	--yellow: #ffc500;
	--yellow-dark: #e0a800;
	--ink: #1a1a17;
	--paper: #f6f4ec;
	--screen: #b1aea7;
	--lcd-bg: #f3f1ea;
	--lcd-ink: #312f28;
	--radius: 14px;
	color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
	margin: 0;
	font: 17px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--ink);
	background: var(--paper);
}

a { color: inherit; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: .5rem 1rem; z-index: 10; }

.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

h1, h2 { line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 .75rem; }
p, li, figcaption { text-wrap: pretty; }

kbd {
	font: 600 .8em ui-monospace, SFMono-Regular, Menlo, monospace;
	border: 1.5px solid currentColor; border-bottom-width: 3px;
	border-radius: 5px; padding: 0 .35em; margin: 0 .1em;
}

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
pre {
	background: var(--ink); color: var(--paper);
	padding: 1rem 1.25rem; border-radius: var(--radius); overflow-x: auto;
}
:not(pre) > code { background: rgb(0 0 0 / .07); padding: .1em .35em; border-radius: 4px; }

/* hero */
.hero {
	background: var(--yellow);
	padding: clamp(2.5rem, 8vw, 5rem) 1.25rem clamp(2.5rem, 6vw, 4rem);
	text-align: center;
	border-bottom: 3px solid var(--ink);
}
.hero .card {
	width: min(700px, 100%); height: auto;
	background: #fff; border-radius: 18px;
	box-shadow: 0 6px 0 var(--ink);
}
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); margin: 1.75rem auto .5rem; max-width: 18ch; }
.lede { max-width: 38rem; margin: 0 auto 1.75rem; font-size: 1.15rem; }
.cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

.btn {
	display: inline-block; text-decoration: none; font-weight: 700;
	padding: .8rem 1.4rem; border-radius: 999px;
	border: 2.5px solid var(--ink); background: #fff;
	box-shadow: 0 4px 0 var(--ink);
	transition: transform .12s ease-out, box-shadow .12s ease-out;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--ink); color: var(--yellow); }

main { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
main > section { padding: clamp(2.5rem, 7vw, 4.5rem) 0; border-bottom: 2px dashed rgb(0 0 0 / .18); }
main > section:last-child { border-bottom: 0; }
main p { max-width: 44rem; }

/* demo device: a Playdate drawn to scale in millimetres (76 x 74 mm body) */
.demo { text-align: center; }
.demo .hint { margin: 0 auto 2rem; }
.demo .hint.small { margin: 1.25rem auto 0; font-size: .95rem; }

.pd {
	/* 58.7 mm of screen = 600 px, a clean 1.5x of the 400 px LCD */
	--mm: min(10.221px, calc((100vw - 2.5rem) / 96));
	--body: #ffc500;
	--body-shade: #e8ab00;
	--black: #1d1c1a;
	position: relative; display: inline-block;
	width: calc(76 * var(--mm)); height: calc(74 * var(--mm));
	margin-right: calc(18 * var(--mm));
	text-align: left; user-select: none; -webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
}
.pd button { font: inherit; border: 0; padding: 0; cursor: pointer; }
.pd button:focus-visible { outline: 3px solid var(--black); outline-offset: 3px; }

.pd-body {
	position: absolute; inset: 0;
	background: var(--body);
	border-radius: calc(7.5 * var(--mm));
	box-shadow:
		inset 0 calc(-.8 * var(--mm)) 0 var(--body-shade),
		inset calc(-.6 * var(--mm)) 0 0 var(--body-shade),
		inset 0 calc(.4 * var(--mm)) 0 #ffd84a,
		0 calc(1.6 * var(--mm)) calc(4 * var(--mm)) rgb(0 0 0 / .22);
}

.pd-lock {
	position: absolute; top: calc(-.9 * var(--mm)); left: calc(53 * var(--mm));
	width: calc(9 * var(--mm)); height: calc(1.4 * var(--mm));
	background: var(--body-shade); border-radius: calc(.6 * var(--mm)) calc(.6 * var(--mm)) 0 0;
}

.pd-bezel {
	position: absolute; left: calc(5.65 * var(--mm)); top: calc(5 * var(--mm));
	width: calc(64.7 * var(--mm)); height: calc(41.2 * var(--mm));
	background: var(--black); border-radius: calc(1.6 * var(--mm));
	display: grid; place-items: center;
	box-shadow: inset 0 0 0 calc(.25 * var(--mm)) #33312d;
}
.pd-screen {
	display: block;
	width: calc(58.7 * var(--mm)); height: calc(35.2 * var(--mm));
	background: #b1aea7;
	touch-action: none;
}

.pd-menu {
	position: absolute; left: calc(70.9 * var(--mm)); top: calc(5.7 * var(--mm));
	width: calc(3.6 * var(--mm)); height: calc(3.6 * var(--mm));
	border-radius: 50%; background: var(--body) !important;
	box-shadow: inset 0 0 0 calc(.35 * var(--mm)) var(--body-shade), 0 calc(.3 * var(--mm)) 0 var(--body-shade);
}
.pd-menu.is-down, .pd-menu:active { box-shadow: inset 0 0 0 calc(.35 * var(--mm)) var(--body-shade), inset 0 calc(.4 * var(--mm)) calc(.6 * var(--mm)) rgb(0 0 0 / .25); }

.pd-logo {
	position: absolute; left: calc(5.65 * var(--mm)); top: calc(47.6 * var(--mm));
	font: 700 calc(2.7 * var(--mm)) / 1 ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
	letter-spacing: -.02em; color: var(--black); opacity: .9;
}

.pd-dpad {
	position: absolute; left: calc(7 * var(--mm)); top: calc(51 * var(--mm));
	width: calc(19 * var(--mm)); height: calc(19 * var(--mm));
	--arm: calc(6.4 * var(--mm));
}
.pd-dpad button, .pd-dpad .hub {
	position: absolute; background: var(--black);
	box-shadow: 0 calc(.5 * var(--mm)) 0 #000;
}
.pd-dpad .hub { left: var(--arm); top: var(--arm); width: var(--arm); height: var(--arm); box-shadow: none; pointer-events: none; }
.pd-dpad .up, .pd-dpad .down { left: var(--arm); width: var(--arm); height: calc(var(--arm) + 1px); }
.pd-dpad .left, .pd-dpad .right { top: var(--arm); height: var(--arm); width: calc(var(--arm) + 1px); }
.pd-dpad .up { top: 0; border-radius: calc(1 * var(--mm)) calc(1 * var(--mm)) 0 0; }
.pd-dpad .down { bottom: 0; border-radius: 0 0 calc(1 * var(--mm)) calc(1 * var(--mm)); }
.pd-dpad .left { left: 0; border-radius: calc(1 * var(--mm)) 0 0 calc(1 * var(--mm)); }
.pd-dpad .right { right: 0; border-radius: 0 calc(1 * var(--mm)) calc(1 * var(--mm)) 0; }
.pd-dpad button::after {
	content: ""; position: absolute; left: 50%; top: 50%;
	border: calc(1.1 * var(--mm)) solid transparent; translate: -50% -50%; opacity: .35;
}
.pd-dpad .up::after { border-bottom-color: var(--body); border-top-width: 0; }
.pd-dpad .down::after { border-top-color: var(--body); border-bottom-width: 0; }
.pd-dpad .left::after { border-right-color: var(--body); border-left-width: 0; }
.pd-dpad .right::after { border-left-color: var(--body); border-right-width: 0; }

.pd-ab {
	position: absolute; width: calc(10 * var(--mm)); height: calc(10 * var(--mm));
	border-radius: 50%; background: var(--black) !important;
	color: var(--body) !important; font-weight: 700 !important; font-size: calc(2.8 * var(--mm)) !important;
	box-shadow: 0 calc(.6 * var(--mm)) 0 #000;
}
.pd-b, .pd-a { top: calc(55.5 * var(--mm)); }
.pd-b { left: calc(46 * var(--mm)); }
.pd-a { left: calc(60 * var(--mm)); }
.pd button:not(.pd-menu).is-down, .pd button:not(.pd-menu):active { translate: 0 calc(.5 * var(--mm)); box-shadow: 0 calc(.1 * var(--mm)) 0 #000; }

.pd-speaker {
	position: absolute; right: calc(5 * var(--mm)); bottom: calc(4 * var(--mm));
	width: calc(5.6 * var(--mm)); height: calc(1.4 * var(--mm));
	background: radial-gradient(circle, var(--black) 40%, transparent 45%) 0 0 / calc(1.4 * var(--mm)) calc(1.4 * var(--mm));
	opacity: .55;
}

/* The crank is seen edge-on from the front: the arm swings up and down from
   the hub on the right side, and the knob sticks out sideways. */
.pd-crank {
	position: absolute; left: calc(75.4 * var(--mm)); top: calc(10 * var(--mm));
	width: calc(17 * var(--mm)); height: calc(40 * var(--mm));
	cursor: grab; touch-action: none; border-radius: calc(3 * var(--mm));
	--sin: 1; --cos: 0;
}
.pd-crank.is-turning { cursor: grabbing; }
.pd-crank:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.pd-crank-hub {
	position: absolute; left: 0; top: calc(50% - 4 * var(--mm));
	width: calc(1.8 * var(--mm)); height: calc(8 * var(--mm));
	background: var(--body-shade); border-radius: 0 calc(1 * var(--mm)) calc(1 * var(--mm)) 0;
}
.pd-crank { --len: calc(13 * var(--mm)); }
.pd-crank-arm {
	position: absolute; left: calc(1.2 * var(--mm)); width: calc(2.6 * var(--mm));
	top: calc(50% + min(0px, var(--sin) * var(--len)) - 1.3 * var(--mm));
	height: calc(abs(var(--sin)) * var(--len) + 2.6 * var(--mm));
	background: var(--body); border-radius: calc(1.3 * var(--mm));
	box-shadow: inset calc(-.5 * var(--mm)) 0 0 var(--body-shade);
}
.pd-crank-knob {
	position: absolute; left: calc(2 * var(--mm));
	top: calc(50% + var(--sin) * var(--len) - 2.5 * var(--mm));
	width: calc(12 * var(--mm)); height: calc(5 * var(--mm));
	background: linear-gradient(#fbfaf5, #dedbd0);
	border-radius: calc(2.5 * var(--mm));
	box-shadow: inset 0 calc(-.6 * var(--mm)) 0 #c4c0b2, 0 calc(.4 * var(--mm)) calc(.8 * var(--mm)) rgb(0 0 0 / .25);
}

.sim-tools { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }
.chip {
	font: 600 .9rem/1 ui-sans-serif, system-ui, sans-serif; color: var(--ink);
	padding: .55rem 1rem; border-radius: 999px; cursor: pointer;
	border: 2px solid var(--ink); background: #fff; box-shadow: 0 3px 0 var(--ink);
}
.chip:active { translate: 0 2px; box-shadow: 0 1px 0 var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }


/* gallery */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 2rem 1.75rem; }
figure { margin: 0; }
figure img {
	width: 100%; height: auto; display: block;
	border: 10px solid #2b2a26; border-radius: 10px; background: #fff;
}
figcaption { margin-top: .7rem; font-size: .95rem; }

/* pause */
.pause-row { display: flex; gap: 1.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.pause {
	display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 440px); aspect-ratio: 400 / 240;
	border: 10px solid #2b2a26; border-radius: 10px; background: #fff; overflow: hidden;
}
.pause img { width: 100%; height: 100%; display: block; }
.sysmenu {
	list-style: none; margin: 0; padding: 4% 6%;
	background: #fff; font: 600 clamp(14px, 2.6vw, 21px)/1.25 ui-sans-serif, system-ui, sans-serif; color: #000;
}
.sysmenu .sep { border-top: 2px solid #000; margin-top: .3em; padding-top: .2em; }

ol li { margin-bottom: .4rem; }

footer { background: var(--ink); color: #d8d5ca; padding: 2rem 1.25rem; text-align: center; font-size: .9rem; }
footer p { max-width: 44rem; margin: 0 auto; }

/* manual (docs.html) */
.topbar {
	display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
	background: var(--yellow); border-bottom: 3px solid var(--ink);
	padding: .6rem 1.25rem;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; text-decoration: none; }
.brand img { border-radius: 6px; }
.topbar nav { display: flex; gap: 1.25rem; font-weight: 600; }
.topbar nav a { text-decoration: none; }
.topbar nav a:hover, .topbar nav a[aria-current] { text-decoration: underline; }

.docs {
	display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2.5rem;
	max-width: 1180px; margin: 0 auto; padding: 0 1.25rem;
}
.toc { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 2rem 0; }
.toc-title { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; margin: 0 0 .5rem; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
	display: block; padding: .3rem .6rem; border-radius: 8px; text-decoration: none; font-size: .95rem;
}
.toc a::before { content: counter(toc) ". "; opacity: .55; font-variant-numeric: tabular-nums; }
.toc a:hover { background: rgb(0 0 0 / .07); }

.manual { max-width: none; margin: 0; padding: 0 0 3rem; }
.manual h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 2rem 0 .5rem; }
.manual .lede { margin: 0 0 1rem; max-width: 44rem; }
.manual > section { padding: 2.25rem 0; scroll-margin-top: 1rem; }
.manual h3 { font-size: 1.15rem; margin: 1.5rem 0 .4rem; }
.manual ol, .manual ul { max-width: 42rem; padding-left: 1.4rem; }
.manual li + li { margin-top: .3rem; }

.shot { margin: 1rem 0 1.25rem; }
.shot img {
	display: block; width: min(400px, 100%); height: auto;
	border: 3px solid var(--ink); border-radius: 6px; background: #fff;
}
.shot figcaption { font-size: .9rem; margin-top: .35rem; opacity: .75; }
.shot.float { float: right; margin: .25rem 0 1rem 1.75rem; }
.manual > section::after { content: ""; display: block; clear: both; }
.shots { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.shots .shot { margin: 0; }

.parts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; max-width: 46rem; }
.parts dt { font-weight: 700; }
.parts dd { margin: 0; }

.table-wrap { overflow-x: auto; margin: 1rem 0; max-width: 46rem; }
.manual table { border-collapse: collapse; width: 100%; background: #fff; border: 2.5px solid var(--ink); border-radius: 10px; }
.manual th, .manual td { text-align: left; vertical-align: top; padding: .55rem .8rem; border-bottom: 1px solid rgb(0 0 0 / .14); }
.manual th { background: var(--ink); color: var(--paper); font-size: .9rem; }
.manual tr:last-child td { border-bottom: 0; }
.manual td:first-child { white-space: nowrap; font-weight: 600; }
.btn.small { padding: .55rem 1.1rem; font-size: .95rem; }

@media (max-width: 1000px) {
	.shot.float { float: none; margin: 1rem 0; }
}
@media (max-width: 760px) {
	.docs { grid-template-columns: minmax(0, 1fr); gap: 0; }
	.toc { position: static; max-height: none; padding: 1.25rem 0 0; }
	.toc ol { columns: 2; column-gap: 1rem; }
	.parts { grid-template-columns: 1fr; }
	.parts dd { margin-bottom: .5rem; }
	.manual td:first-child { white-space: normal; }
}

/* Visually hidden but read by screen readers */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}
