/* Budget Math */

.budget-app {
	--bill: #d8fbeb;
	--over: var(--coral);
	--item-w: 128px;
}

/* Buttons and other display-setting components still hide with [hidden]. */
.budget-app [hidden] {
	display: none !important;
}

.poster-missing {
	display: grid;
	place-items: center;
	padding: 10px;
	background: repeating-linear-gradient(-45deg, var(--bg) 0 8px, var(--surface) 8px 16px);
	font-weight: 800;
	font-size: 15px;
	line-height: 1.2;
	text-align: center;
}

/* ---------- Logo: a banknote ---------- */

.bm-logo {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 26px;
	margin-bottom: 32px;
	font-size: clamp(54px, 11vw, 112px);
	line-height: 1;
}

.bm-logo .banknote {
	font-size: 0.86em;
	transform: rotate(-3deg);
	animation: note-in 0.8s var(--ease-spring) both;
}

@keyframes note-in {
	from {
		opacity: 0;
		transform: translateY(-50px) rotate(-16deg) scale(0.9);
	}
}

.bm-word {
	animation: screen-in 0.6s 0.35s var(--ease-out) both;
}

/* ---------- The equation ---------- */

.stage {
	padding: 26px 26px 20px;
}

.budget-app[data-state="loading"] .stage {
	min-height: 380px;
}

.budget-app[data-state="loading"] .stage > * {
	visibility: hidden;
}

.eq {
	display: grid;
	grid-template-columns: 200px auto minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}

.slot {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	border: var(--border);
	border-radius: 12px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	cursor: pointer;
	transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-spring), outline-color 0.15s;
}

.slot:hover {
	transform: translate(-2px, -2px);
}

/* The slot the next picked movie goes into */
.slot.is-target {
	outline: 3px dashed var(--ink);
	outline-offset: 5px;
}

.slot.is-over {
	outline: 3px solid var(--ink);
	outline-offset: 5px;
	transform: scale(1.04);
}

.is-dragging .slot:not(.is-over) {
	outline: 3px dashed var(--muted);
	outline-offset: 5px;
}

/* Main movie: the money to spend */
.main-slot {
	aspect-ratio: 2 / 3;
	box-shadow: var(--shadow-lg);
}

.main-slot:hover {
	box-shadow: 8px 8px 0 var(--ink);
}

.main-poster,
.item-poster {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 10px;
}

.main-text {
	margin-top: 16px;
}

.main-title {
	font-weight: 800;
	font-size: 24px;
	line-height: 1.1;
	letter-spacing: -0.015em;
	font-stretch: 90%;
	text-wrap: balance;
}

.main-year,
.main-then {
	color: var(--muted);
	font-weight: 600;
	font-size: 15px;
}

.main-year {
	margin-top: 2px;
}

/* Empty: the slot asks for a movie, with a way to see an example */
.main-slot.is-empty {
	display: grid;
	place-content: center;
	gap: 6px;
	border-style: dashed;
	background: var(--bill);
	box-shadow: none;
	text-align: center;
}

.empty-big {
	font-weight: 800;
	font-size: 64px;
	line-height: 1;
}

.empty-text {
	padding: 0 14px;
	font-weight: 700;
	line-height: 1.2;
}

.budget-app[data-state="empty"] .eq {
	grid-template-columns: 1fr;
}

.budget-app[data-state="empty"] .eq-main {
	display: grid;
	grid-template-columns: 170px minmax(0, 46ch);
	grid-template-rows: auto 1fr;
	gap: 14px 28px;
	align-items: start;
}

.budget-app[data-state="empty"] .main-slot {
	grid-row: span 2;
}

.budget-app[data-state="empty"] .eq-main .btn {
	justify-self: start;
}

.main-lede {
	align-self: end;
	font-weight: 700;
	font-size: clamp(22px, 2.6vw, 30px);
	line-height: 1.2;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.budget-app[data-state="empty"] .eq-sign,
.budget-app[data-state="empty"] .eq-items,
.budget-app[data-state="empty"] .meter-wrap,
.budget-app[data-state="empty"] [data-share],
.budget-app[data-state="empty"] [data-autofill],
.budget-app[data-state="empty"] [data-clear] {
	display: none;
}

.eq-sign {
	/* Level with the middle of the main poster */
	padding-top: 108px;
	font-weight: 800;
	font-size: 84px;
	line-height: 0.6;
	transition: color 0.2s;
}

.is-over .eq-sign {
	color: var(--over);
	-webkit-text-stroke: 2px var(--ink);
}

/* The movies it pays for */
.eq-items {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 18px 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.eq-plus {
	padding-top: calc(var(--item-w) * 0.75 - 16px);
	font-weight: 800;
	font-size: 34px;
	line-height: 1;
}

.item,
.eq-add {
	position: relative;
	width: var(--item-w);
}

.item-slot {
	aspect-ratio: 2 / 3;
	box-shadow: var(--shadow);
}

.item-count {
	position: absolute;
	right: -10px;
	bottom: 10px;
	padding: 1px 10px 3px;
	border: var(--border);
	border-radius: 50px;
	background: var(--c);
	font-weight: 800;
	font-size: 20px;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
	transform: rotate(-4deg);
}

.item-title {
	margin-top: 12px;
	font-weight: 700;
	font-size: 15px;
	line-height: 1.2;
	overflow-wrap: break-word;
}

.item-each {
	color: var(--muted);
	font-weight: 600;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
}

.stepper {
	display: flex;
	gap: 4px;
	margin-top: 8px;
}

.step {
	flex: none;
	min-width: 30px;
	height: 30px;
	padding: 0 8px;
	border: var(--border);
	border-radius: var(--radius-control);
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-weight: 800;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s, transform 0.12s var(--ease-out);
}

.step:hover:not(:disabled) {
	background: var(--btn-hover);
}

.step:active:not(:disabled) {
	transform: scale(0.9);
}

.step:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.step-fill {
	flex: 1;
	background: var(--c);
	font-size: 14px;
}

.step-fill:hover:not(:disabled) {
	background: var(--c);
	box-shadow: 2px 2px 0 var(--ink);
}

.item-remove {
	position: absolute;
	top: -10px;
	left: -10px;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	padding: 0 0 2px;
	border: var(--border);
	border-radius: 50%;
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-weight: 800;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s, background-color 0.15s;
}

.item:hover .item-remove,
.item-remove:focus-visible {
	opacity: 1;
}

.item-remove:hover {
	background: var(--over);
}

@media (hover: none) {
	.item-remove {
		opacity: 1;
	}
}

.add-slot {
	display: grid;
	place-content: center;
	gap: 4px;
	aspect-ratio: 2 / 3;
	border-style: dashed;
	background: transparent;
	text-align: center;
}

.add-slot:hover,
.add-slot.is-target {
	background: var(--surface);
}

/* Already dashed, so being the target fills it in instead */
.add-slot.is-target,
.main-slot.is-empty.is-target {
	outline: 0;
	background: var(--bill);
}

.add-icon {
	font-weight: 800;
	font-size: 48px;
	line-height: 1;
}

.add-text {
	padding: 0 8px;
	font-weight: 700;
	font-size: 15px;
	line-height: 1.2;
}

/* ---------- Price tags ---------- */

/* A paper tag, string hole and all */
.price-tag {
	position: absolute;
	top: 10px;
	left: -8px;
	z-index: 1;
	padding: 2px 9px 3px 20px;
	border: var(--border);
	border-radius: 4px 9px 9px 4px;
	background: var(--surface);
	box-shadow: 2px 2px 0 var(--ink);
	font-weight: 800;
	font-size: 15px;
	line-height: 1.25;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	transform: rotate(-6deg);
	pointer-events: none;
}

.price-tag::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 6px;
	width: 7px;
	height: 7px;
	margin-top: -3.5px;
	border: 2px solid var(--ink);
	border-radius: 50%;
	background: var(--bg);
}

.price-tag:empty {
	display: none;
}

.price-tag.big {
	top: 14px;
	left: -14px;
	padding: 3px 14px 5px 26px;
	background: var(--mint);
	box-shadow: 3px 3px 0 var(--ink);
	font-size: 26px;
	letter-spacing: -0.02em;
}

.price-tag.big::before {
	left: 8px;
	width: 9px;
	height: 9px;
	margin-top: -4.5px;
}

/* ---------- The meter: the budget as a strip of money ---------- */

.meter-wrap {
	margin-top: 30px;
}

.meter {
	position: relative;
	display: flex;
	height: 48px;
	border: var(--border);
	border-radius: 10px;
	background: var(--bill);
	overflow: hidden;
}

.meter-seg {
	flex: none;
	width: var(--w);
	border-right: 2px solid var(--ink);
	/* A notch per copy */
	background:
		linear-gradient(90deg, transparent calc(100% - 1.5px), #0000004d 0) 0 0 / calc(100% / var(--n)) 100%,
		var(--c);
	transition: width 0.5s var(--ease-out);
}

.meter-left {
	flex: none;
	width: var(--w);
	background: repeating-linear-gradient(-45deg, transparent 0 7px, #00b89426 7px 14px);
	transition: width 0.5s var(--ease-out);
}

/* Past the budget: everything right of the line is more than the main movie cost */
.meter-line {
	position: absolute;
	inset: 0 0 0 var(--at);
	border-left: 3px solid var(--ink);
	background: repeating-linear-gradient(-45deg, #ff7a59cc 0 7px, #ff7a5966 7px 14px);
	transition: left 0.5s var(--ease-out);
}

.meter-ends {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 16px;
	margin-top: 10px;
}

.meter-ends > span {
	color: var(--muted);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.meter-rest {
	padding: 0 12px 2px;
	border: var(--border);
	border-radius: 50px;
	background: var(--mint);
	font-weight: 800;
	font-size: 24px;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
	transition: background-color 0.2s;
}

.is-over .meter-rest {
	background: var(--over);
}

/* ---------- Under the equation ---------- */

.stage-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 14px 24px;
	margin-top: 18px;
	padding-top: 16px;
	border-top: 2px dashed #0000002e;
}

.stage-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 14px;
}

.budget-app[data-state="empty"] .stage-foot {
	border-top: 0;
	padding-top: 0;
}

.inflation {
	--check-color: var(--mint);
	padding: 6px 14px 6px 10px;
	border: var(--border);
	border-radius: 12px;
	background: var(--surface);
	transition: background-color 0.15s;
}

.inflation:has(input:checked) {
	background: var(--bill);
}

.inflation:has(input:disabled) {
	opacity: 0.6;
	cursor: not-allowed;
}

.inflation-text {
	font-weight: 700;
}

/* ---------- Mini meter, pinned while the equation is scrolled away ---------- */

.mini {
	position: fixed;
	top: 10px;
	left: 50%;
	z-index: 30;
	display: flex;
	align-items: center;
	gap: 12px;
	width: min(760px, calc(100% - 24px));
	padding: 7px 8px 7px 16px;
	border: var(--border);
	border-radius: 50px;
	background: var(--surface);
	box-shadow: var(--shadow);
	color: var(--ink);
	font: inherit;
	cursor: pointer;
	transform: translate(-50%, calc(-100% - 20px));
	visibility: hidden;
	transition: transform 0.35s var(--ease-spring), visibility 0s 0.35s;
}

.show-mini[data-state="ready"] .mini {
	transform: translate(-50%, 0);
	visibility: visible;
	transition: transform 0.35s var(--ease-spring);
}

.mini-title {
	flex: 0 1 auto;
	max-width: 30%;
	overflow: hidden;
	font-weight: 800;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.meter-small {
	flex: 1;
	height: 24px;
	border-radius: 50px;
}

.mini-rest {
	flex: none;
	padding: 0 10px 1px;
	border: var(--border);
	border-radius: 50px;
	background: var(--mint);
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.is-over .mini-rest {
	background: var(--over);
}

/* ---------- Shelf ---------- */

.shelf {
	margin-top: 44px;
}

.shelf-head {
	display: grid;
	gap: 14px;
}

.search {
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: 560px;
	height: 54px;
	padding: 0 18px;
	border: var(--border);
	border-radius: 50px;
	background: var(--surface);
	box-shadow: var(--shadow);
	cursor: text;
}

.search:focus-within {
	outline: 3px solid var(--mint-strong);
	outline-offset: 3px;
}

.search svg {
	flex: none;
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
}

.search input {
	flex: 1;
	min-width: 0;
	height: 100%;
	border: 0;
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-weight: 600;
	font-size: 18px;
	outline: none;
}

.search input::placeholder {
	color: var(--muted);
	font-weight: 500;
}

/* Lists: little ticket stubs, like Movie Quiz's */
.list-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.list-chip {
	display: inline-flex;
	align-items: stretch;
	border: var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-weight: 600;
	font-size: 15px;
	text-align: left;
	cursor: pointer;
	transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-spring), background-color 0.15s;
}

.list-chip:hover {
	transform: translate(-2px, -2px);
	box-shadow: 3px 3px 0 var(--ink);
}

.list-chip:active {
	transform: translate(1px, 1px);
	box-shadow: none;
}

.list-name {
	padding: 6px 12px;
}

.list-count {
	display: grid;
	place-items: center;
	padding: 6px 10px;
	border-left: 2px dashed var(--ink);
	font-variant-numeric: tabular-nums;
	font-weight: 700;
}

.list-chip[aria-pressed="true"] {
	background: var(--mint);
	transform: translate(-2px, -2px) rotate(-1deg);
	box-shadow: 3px 3px 0 var(--ink);
}

.list-chip[aria-pressed="true"] .list-count {
	background: var(--ink);
	color: #fff;
	border-radius: 0 7px 7px 0;
}

.shelf-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 20px;
	margin: 26px 0 22px;
}

/* What clicking a movie will do */
.hint {
	font-weight: 700;
	font-size: 17px;
	line-height: 1.3;
}

.fits-filter {
	--check-color: var(--mint);
	margin-left: auto;
	font-weight: 600;
	font-size: 16px;
}

.hint + .fits-filter[hidden] + .sort {
	margin-left: auto;
}

.sort {
	margin: 0;
	padding: 0;
	border: 0;
}

.shelf-status {
	margin-bottom: 18px;
	color: var(--muted);
	font-weight: 600;
}

.shelf-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 26px 20px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.film {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: var(--ink);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.film-poster {
	display: block;
	aspect-ratio: 2 / 3;
	border: var(--border);
	border-radius: 10px;
	background: var(--surface);
	box-shadow: var(--shadow);
	overflow: hidden;
	transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-spring);
}

.film-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.film:hover:not(:disabled) .film-poster {
	transform: translate(-3px, -3px) rotate(-1.5deg);
	box-shadow: var(--shadow-lg);
}

.film:active:not(:disabled) .film-poster {
	transform: translate(2px, 2px);
	box-shadow: 0 0 0 var(--ink);
}

.film:focus-visible {
	outline: none;
}

.film:focus-visible .film-poster {
	outline: 3px solid var(--mint-strong);
	outline-offset: 3px;
}

.film-title {
	margin-top: 10px;
	font-weight: 700;
	font-size: 16px;
	line-height: 1.2;
}

.film-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px 8px;
	margin-top: 3px;
	color: var(--muted);
	font-weight: 600;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
}

/* How many of this one the main movie's budget would buy */
.film-fits.is-fit {
	padding: 0 7px;
	border: 1.5px solid var(--ink);
	border-radius: 50px;
	background: var(--bill);
	color: var(--ink);
	font-weight: 700;
	font-size: 13px;
}

.film-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	padding: 1px 9px 2px;
	border-radius: 50px;
	background: var(--ink);
	color: #fff;
	font-weight: 700;
	font-size: 13px;
}

.film-badge:empty {
	display: none;
}

.film:disabled {
	cursor: not-allowed;
}

.film:disabled .film-poster {
	opacity: 0.5;
	box-shadow: none;
}

.film:disabled .price-tag {
	border-style: dashed;
	box-shadow: none;
	color: var(--muted);
}

.film.is-loading .film-poster {
	background: linear-gradient(100deg, var(--surface) 30%, var(--bg) 50%, var(--surface) 70%) 0 0 / 300% 100%;
	box-shadow: none;
	animation: shimmer 1.2s linear infinite;
}

.film.is-loading .film-title {
	width: 70%;
	height: 14px;
	border-radius: 4px;
	background: var(--bg-dot);
}

@keyframes shimmer {
	to {
		background-position: -150% 0;
	}
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
	.eq {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.eq-main {
		display: grid;
		grid-template-columns: 130px minmax(0, 1fr);
		gap: 18px;
		align-items: end;
	}

	.main-text {
		margin: 0 0 6px;
	}

	.main-title {
		font-size: 26px;
	}

	.price-tag.big {
		font-size: 20px;
		padding: 2px 10px 4px 22px;
	}

	.eq-sign {
		padding: 0;
		font-size: 56px;
		line-height: 0.7;
	}
}

@media (max-width: 520px) {
	main:has(.budget-app) {
		padding-top: 18px;
	}

	.budget-app {
		--item-w: calc((100% - 2 * 10px - 2 * 24px) / 3);
	}

	.bm-logo {
		margin-bottom: 20px;
	}

	.stage {
		padding: 18px 16px 16px;
	}

	.eq-main {
		grid-template-columns: 104px minmax(0, 1fr);
	}

	.budget-app[data-state="empty"] .eq-main {
		grid-template-columns: 110px minmax(0, 1fr);
		gap: 10px 16px;
	}

	.main-lede {
		font-size: 19px;
	}

	.main-title {
		font-size: 22px;
	}

	.eq-items {
		gap: 16px 0;
	}

	.eq-plus {
		width: 24px;
		padding-top: 19vw;
		font-size: 24px;
		text-align: center;
	}

	.item-count {
		right: -6px;
		padding: 0 7px 2px;
		font-size: 16px;
	}

	.item-title {
		font-size: 14px;
	}

	.stepper {
		flex-wrap: wrap;
	}

	.step {
		min-width: 0;
		flex: 1;
		height: 28px;
		padding: 0 4px;
	}

	.step-fill {
		flex-basis: 100%;
	}

	.meter {
		height: 38px;
	}

	.meter-rest {
		font-size: 20px;
	}

	.stage-tools {
		width: 100%;
	}

	.inflation {
		flex: 1 1 100%;
	}

	.search {
		height: 50px;
	}

	.shelf-grid {
		grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
		gap: 22px 16px;
	}

	.mini-title {
		display: none;
	}
}
