/* A room you operate. One picture, and two sets of controls on tabs beside
   it: our keypad first, then the builder's wall dimmers. The picture is on the left and the controls are on the
   right. On a phone held upright the picture runs the full width and the
   controls float over its lower right corner, as a picture in picture. */

/* The page's hero: one heading, and one subheading directly under it. */
.rooms-lead {
	margin-bottom: clamp(48px, 6vw, 80px);
}
.rooms-lead .sub + .sub {
	margin-top: 12px;
}

.room + .room {
	margin-top: clamp(72px, 9vw, 128px);
}

.room {
	display: grid;
	grid-template-columns: minmax(0, 58fr) minmax(0, 42fr);
	column-gap: 12px;
	row-gap: 20px;
	align-items: start;
}
.room-head {
	grid-column: 1 / -1;
}
.room-head .sub {
	margin-top: 12px;
}

/* ---- Tabs: a two-part switch, so it reads as something to press -------- */
.room-tabs {
	display: flex;
	width: fit-content;
	padding: 4px;
	border-radius: 10px;
	background: rgb(10 10 10 / 7%);
}
.room-tabs button {
	min-height: 40px;
	padding: 0 18px;
	border: 0;
	border-radius: 7px;
	background: none;
	font: inherit;
	font-size: 15px;
	color: var(--ink-dim);
	white-space: nowrap;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.room-tabs button:hover {
	color: var(--ink);
}
.room-tabs button[aria-selected="true"] {
	background: #ffffff;
	color: var(--ink);
	font-weight: 600;
	box-shadow:
		0 1px 2px rgb(10 10 10 / 16%),
		0 2px 6px rgb(10 10 10 / 8%);
}
.room-tabs button:focus-visible {
	outline: 2px solid var(--poppy);
	outline-offset: 2px;
}

/* ---- The picture ------------------------------------------------------- */
.room-picture {
	position: relative;
}
.room-view img,
.room-view canvas {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 960 / 691;
}
.room-view canvas {
	position: absolute;
	inset: 0 0 auto;
	visibility: hidden;
}
.room[data-drawn] .room-view canvas {
	visibility: visible;
}
/* Nothing is written under the picture: the owner wants people to look at it, not read.
   Each scene's line is still in the page for screen readers, which hear it when the scene
   changes. */

/* ---- Controls ---------------------------------------------------------- */
.room-controls {
	display: grid;
	gap: 12px;
}
.room:not([data-ready]) .wall {
	pointer-events: none;
}

/* The wall and the plates are drawn as on the controls slide of the Pendyala
   home office deck: a pale wall, a matte white plate, fine grey outlines.
   Every size comes from the width of one device, in the proportions of a
   real plate (2.75 x 4.5 in, with a 1.31 x 2.63 in opening for each device).
   The device's width comes from the width of the wall, so the controls fit
   the column they are in. */
.wall {
	container-type: inline-size;
	--line: #aeada7;
	background: linear-gradient(#f2f4ef, #e3e5e0);
}
.wall button {
	border: 0;
	background: none;
	font: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.wall button:focus-visible {
	outline: 2px solid var(--poppy);
	outline-offset: 2px;
}

.mount {
	--device-w: min(107px, 24cqw);
	display: grid;
	gap: 12px;
	justify-items: center;
	padding: 10cqw 0;
}
.plate {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: calc(var(--device-w) * 0.5);
	height: calc(var(--device-w) / 0.268);
	border-radius: 6px;
	background: linear-gradient(#f9f9f7, #f3f3ef);
	box-shadow:
		0 1px 2px rgb(10 10 10 / 6%),
		0 14px 34px rgb(10 10 10 / 12%);
}
.plate-one {
	width: calc(var(--device-w) * 2.343);
}
.plate-two {
	width: calc(var(--device-w) * 3.843);
}

/* The builder's dimmers, drawn after a Maestro: a tap paddle, a column of
   seven level dots at its left edge, and a small raise and lower rocker at
   its right edge. */
.device {
	position: relative;
	width: var(--device-w);
	height: calc(var(--device-w) * 2.21);
	border: 1.5px solid var(--line);
	background: #f7f7f4;
}
.paddle {
	position: absolute;
	inset: 0;
	width: 100%;
}
.leds {
	position: absolute;
	left: 8%;
	top: 50%;
	z-index: 1;
	display: grid;
	gap: calc(var(--device-w) * 0.062);
	transform: translateY(-50%);
	pointer-events: none;
}
.leds i {
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: rgb(174 173 167 / 55%);
}
.leds i[data-lit] {
	background: #2f8f4e;
	box-shadow: 0 0 4px rgb(47 143 78 / 70%);
}
.rocker {
	position: absolute;
	right: 7%;
	top: 50%;
	z-index: 1;
	display: grid;
	width: 15%;
	min-width: 9px;
	height: 34%;
	transform: translateY(-50%);
	border: 1.5px solid var(--line);
	border-radius: 2px;
	background: #fbfbf9;
}
.rocker button {
	position: relative;
}
.rocker button + button {
	border-top: 1px solid rgb(174 173 167 / 60%);
}
.rocker button::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	margin: -2px 0 0 -3px;
	border-inline: 3px solid transparent;
}
.rocker [data-raise]::before {
	border-bottom: 4px solid #8f8e88;
}
.rocker [data-lower]::before {
	border-top: 4px solid #8f8e88;
}
.rocker button::after {
	/* A wider place to tap than the rocker itself. */
	content: "";
	position: absolute;
	inset: 0 -14px 0 -12px;
}
.rocker [data-raise]::after {
	top: -18px;
}
.rocker [data-lower]::after {
	bottom: -18px;
}
.paddle:active,
.rocker button:active,
.keypad button:active {
	background-color: rgb(10 10 10 / 5%);
}

.plate-labels {
	display: flex;
	justify-content: center;
	gap: calc(var(--device-w) * 0.5);
}
.plate-labels span {
	width: var(--device-w);
	font-size: clamp(10px, 4.6cqw, 13px);
	line-height: 18px;
	text-align: center;
	white-space: nowrap;
	color: var(--ink-dim);
}

/* Our keypad: four buttons, matte white, the legend at the top left of each.
   The legend of the scene that is on is lit. */
.keypad {
	display: grid;
	grid-auto-rows: 1fr;
	width: var(--device-w);
	height: calc(var(--device-w) * 2.21);
	border: 1.5px solid var(--line);
	background: #f7f7f4;
}
.keypad button {
	display: flex;
	align-items: flex-start;
	padding: calc(var(--device-w) * 0.07) calc(var(--device-w) * 0.09);
	font-size: calc(var(--device-w) * 0.127);
	line-height: 1.2;
	text-align: left;
	color: #a3a29c;
	transition:
		color 0.25s,
		text-shadow 0.25s;
}
.keypad button + button {
	border-top: 1.5px solid var(--line);
}
.keypad button[aria-pressed="true"] {
	color: #3a3936;
	text-shadow:
		0 0 6px rgb(255 196 120 / 95%),
		0 0 14px rgb(255 196 120 / 55%);
}

/* In a narrow column, as on a phone held upright, a whole plate would make
   the controls too small to press. The wall shows the devices alone, as
   large as the column allows. */
@container (max-width: 300px) {
	.mount {
		padding: 7cqw 0;
	}
	.plate {
		width: auto;
		height: auto;
		gap: 9cqw;
		background: none;
		box-shadow: none;
	}
	.plate-two {
		--device-w: 40cqw;
	}
	.plate-one {
		--device-w: 80cqw;
	}
	.plate-labels {
		gap: 9cqw;
		--device-w: 40cqw;
	}
	.device,
	.keypad {
		background: linear-gradient(#f9f9f7, #f3f3ef);
		box-shadow: 0 6px 16px rgb(10 10 10 / 10%);
	}
}

/* A caption in the brand's ladder: 12/16, dim ink. */
.room-foot {
	font-size: 12px;
	line-height: 16px;
	color: var(--ink-dim);
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---- A phone held upright: the controls float over the picture --------- */
@media (max-width: 699px) {
	.room {
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: 12px;
		row-gap: 0;
	}
	/* The picture comes first. The headline is under it on the left, beside the
	   controls. */
	.room-head {
		grid-column: 1;
		grid-row: 2 / span 2;
		align-self: start;
		margin-top: 16px;
	}
	/* The figure, the controls and the open panel give their children to the
     room's grid, so the wall can sit beside the headline and over the picture. */
	.room-view,
	.room-controls,
	.room-controls [role="tabpanel"]:not([hidden]) {
		display: contents;
	}

	.room-picture {
		grid-column: 1 / -1;
		grid-row: 1;
		margin-inline: calc(-1 * var(--inset));
	}
	/* The switch and the controls are one card at the right, under the picture.
	   Only the top half of the switch sits over the picture's bottom edge, so
	   the card belongs to the picture and covers almost none of it. */
	.room-tabs {
		grid-column: 2;
		grid-row: 2;
		z-index: 2;
		width: 160px;
		margin-top: -22px;
		padding: 5px;
		border: 1px solid rgb(255 255 255 / 70%);
		border-bottom: 0;
		border-radius: 12px 12px 0 0;
		background: #dfe1dc;
		box-shadow:
			0 2px 6px rgb(0 0 0 / 18%),
			0 12px 28px rgb(0 0 0 / 30%);
	}
	/* Each side is as wide as its label needs, with room either side of it. */
	.room-tabs button {
		flex: 1 1 auto;
		height: 32px;
		min-height: 0;
		padding: 0 8px;
		font-size: 11px;
	}
	.wall {
		grid-column: 2;
		grid-row: 3;
		align-self: start;
		z-index: 2;
		width: 160px;
		border: 1px solid rgb(255 255 255 / 70%);
		border-top: 0;
		border-radius: 0 0 12px 12px;
		box-shadow:
			0 2px 6px rgb(0 0 0 / 18%),
			0 12px 28px rgb(0 0 0 / 30%);
	}
	.wall .plate-one {
		--device-w: 96px;
	}
	.wall .plate-two,
	.wall .plate-labels {
		--device-w: 58px;
	}
	.wall .device,
	.wall .keypad {
		box-shadow: none;
	}
}

/* ---- Wide screens ------------------------------------------------------ */
@media (min-width: 900px) {
	.room {
		grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
		column-gap: 48px;
		row-gap: 28px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.keypad button {
		transition: none;
	}
}
