/*
 * HOME.CSS
 * The home page: tabs at the top, room for the Filter pill. (The wall of covers itself, .jm-grid--covers, is in card.css.)
 */

.jm-page--home {
	padding-top: var(--jm-space-2);
	padding-bottom: calc(var(--jm-space-6) * 2); /* keeps the last row clear of the Filter pill */
}

/* Phones: a slimmer side margin, so the covers get a little bigger. */
@media (max-width: 699px) {
	.jm-page--home {
		padding-left: var(--jm-space-2);
		padding-right: var(--jm-space-2);
	}
}

/* ============================================================
 * THE FILTER (Stage 6.4): the pill's count, and the sheet that opens from it
 * The sheet is a small pop-up (modal.css section 5). Changes apply at once (discover.js).
 * ============================================================ */

.jm-grid--covers > [hidden] { display: none; }   /* a filtered-out cover */

.jm-filter__badge {
	display: inline-grid;
	place-items: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: var(--jm-radius-button);
	background: var(--jm-colour-action);
	color: var(--jm-colour-action-text);
	font-size: var(--jm-text-xxs);
	font-weight: 700;
}

.jm-filter__badge[hidden] { display: none; }

.jm-filter {
	display: flex;
	flex-direction: column;
	gap: var(--jm-space-4);
}

.jm-filter__title {
	margin: 0;
	font-size: var(--jm-text-m);
}

/* Search: the same pill shape and height as the comment box. */
.jm-filter__search {
	min-height: var(--jm-control-size);
	padding: 0 var(--jm-space-4);
	border: 1px solid var(--jm-colour-line);
	border-radius: min(var(--jm-radius-button), calc(var(--jm-control-size) / 2));
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: var(--jm-text-s);
}

/* Two- or three-way toggles in one pill: Live competitions | Everything, and Unrated | All | Liked. */
.jm-filter__switch {
	display: grid;
	grid-auto-columns: 1fr;                  /* two or three equal parts */
	grid-auto-flow: column;
	border: 1px solid var(--jm-colour-line);
	border-radius: var(--jm-radius-button);
	overflow: hidden;
}

.jm-filter__switch label {
	position: relative;
	display: grid;
	place-items: center;
	min-height: 40px;
	font-size: var(--jm-text-s);
	cursor: pointer;
}

.jm-filter__switch input { position: absolute; opacity: 0; pointer-events: none; }

.jm-filter__switch label:has(input:checked) {
	background: var(--jm-colour-action);
	color: var(--jm-colour-action-text);
}

.jm-filter__group {
	margin: 0;
	padding: 0;
	border: 0;
}

.jm-filter__group legend {
	margin-bottom: var(--jm-space-2);
	font-size: var(--jm-text-xs);
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.jm-filter__hint {
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
	opacity: 0.7;
}

.jm-filter__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.jm-filter__chips .jm-chip {
	min-height: 32px;
	padding: 0 var(--jm-space-3);
	font-size: var(--jm-text-xs);
}

/* Ticked filter chips use the action colour (the wizard keeps its own flavour colour). */
.jm-filter .jm-chip:has(input:checked) {
	border-color: var(--jm-colour-action);
	background: var(--jm-colour-action);
	color: var(--jm-colour-action-text);
}

.jm-filter__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0;
}

/* Phones: the sheet fills the screen; it starts at the top (it can be taller than the screen). */
@media (max-width: 700px) {
	.jm-modal__card:has(.jm-filter) { justify-content: flex-start; }
}

/* While searching: a note in the sheet, and a divider on the wall before the mixes outside your filters. */
.jm-filter__note {
	margin: calc(var(--jm-space-3) * -1) 0 0;
	font-size: var(--jm-text-xs);
	opacity: 0.7;
}

.jm-grid__divider {
	grid-column: 1 / -1;
	margin: var(--jm-space-3) 0 0;
	padding-top: var(--jm-space-3);
	border-top: 1px solid var(--jm-colour-line);
	font-size: var(--jm-text-xs);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.7;
}


/* ============================================================
 * THE FILTER SUMMARY (above the wall): what's showing, and one tap to undo it
 * ============================================================ */

.jm-filter__summary {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--jm-space-1) var(--jm-space-3);
	margin: 0 0 var(--jm-space-3);
	font-size: var(--jm-text-xs);
}

.jm-filter__summary[hidden] { display: none; }

.jm-filter__words {
	padding: 0;
	border: 0;
	background: none;
	color: var(--jm-colour-text-soft);
	font: inherit;
	letter-spacing: 0.06em;
	text-align: left;
	text-transform: uppercase;
	cursor: pointer;
}

[data-jm-filter-action][hidden] { display: none; }

/* The floating Filter pill belongs to Discover: it slides down out of sight on the Mix Shelf tab and pops back up on
   Discover (Nick, 24 Oct). site.js sets body[data-jm-tab]. */
.jm-btn--float[data-jm-filter-open] {
	transition: transform var(--jm-motion-time) var(--jm-ease-out), opacity var(--jm-motion-time) var(--jm-ease-out);
}

body[data-jm-tab="shelf"] .jm-btn--float[data-jm-filter-open] {
	opacity: 0;
	transform: translate(-50%, calc(100% + var(--jm-space-5)));
	pointer-events: none;
}


/* ============================================================
 * THE SHELF TAB (Nick, 24 Oct): the bar (+ New box · pills · Surprise me), the boxes that are on, then Loose.
 * parts/shelf.php, shelf.js. Pills: the shared .jm-chip, equal widths, centred; on phones rows of 3 with the last
 * row stretched to fill. Boxes: square blocks like the Members page, side by side in twos, one alone full width.
 * ============================================================ */

.jm-shelf__bar {
	display: grid;
	grid-template-columns: auto 1fr auto;
	grid-template-areas: "new pills surprise";
	align-items: center;
	gap: var(--jm-space-3);
	margin: 0 0 var(--jm-space-4);
	font-size: var(--jm-text-s);
}

.jm-shelf__new { grid-area: new; }
.jm-shelf__surprise { grid-area: surprise; }
.jm-shelf__bar button:disabled { opacity: 0.4; cursor: default; }

.jm-shelf__pills {
	grid-area: pills;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--jm-space-2);
}

.jm-shelf__pill {
	display: block;           /* (not the chip's flex) so a long name ends in "…" */
	flex: 0 1 150px;          /* equal widths; a 16-letter name fits */
	min-width: 0;
	padding: 0 var(--jm-space-2);
	line-height: 34px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

@media (max-width: 699px) {
	.jm-shelf__bar {
		grid-template-columns: 1fr 1fr;
		grid-template-areas: "new surprise" "pills pills";
	}
	.jm-shelf__surprise { justify-self: end; }
	.jm-shelf__new { justify-self: start; }

	/* Rows of 3 on a six-column grid; the last row stretches: 2 left = half each, 1 left = full width. */
	.jm-shelf__pills {
		display: grid;
		grid-template-columns: repeat(6, minmax(0, 1fr));
	}
	.jm-shelf__pill { grid-column: span 2; font-size: var(--jm-text-xs); }
	.jm-shelf__pills[data-count="1"] > .jm-shelf__pill,
	.jm-shelf__pills[data-count="4"] > .jm-shelf__pill:last-child { grid-column: span 6; }
	.jm-shelf__pills[data-count="2"] > .jm-shelf__pill,
	.jm-shelf__pills[data-count="5"] > .jm-shelf__pill:nth-last-child(-n+2) { grid-column: span 3; }
}

/* The boxes that are on: two side by side; one alone in its row takes the full width (shelf.js adds .is-wide). */
.jm-shelf__boxes {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--jm-space-4);
}

.jm-shelf__boxes:has(.jm-box:not([hidden])) { margin-bottom: var(--jm-space-5); }

@media (min-width: 700px) {
	.jm-shelf__boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.jm-box.is-wide { grid-column: 1 / -1; }
}

.jm-box[hidden],
.jm-shelf__loose[hidden] { display: none; }

/* A box: the same square block as a member on the Members page. */
.jm-box {
	min-width: 0;
	padding: var(--jm-space-3);
	border-radius: var(--jm-radius-block);
	background: var(--jm-colour-header);
	box-shadow: var(--jm-shadow-2);
}

.jm-box__head {
	display: flex;
	align-items: center;
	gap: var(--jm-space-2);
	margin: 0 0 var(--jm-space-3);
}

.jm-box__name {
	padding: 0;
	border: 0;
	background: none;
	color: var(--jm-colour-heading);
	font: inherit;
	font-size: var(--jm-text-s);
	font-weight: 600;
	letter-spacing: 0.08em;
	text-align: left;
	text-transform: uppercase;
	cursor: pointer;
}

.jm-box__pencil {
	margin-left: var(--jm-space-1);
	color: var(--jm-colour-text-soft);
	font-weight: 400;
}

.jm-box__count {
	color: var(--jm-colour-text-soft);
	font-size: var(--jm-text-s);
}

.jm-box__menu {
	width: var(--jm-control-size);
	height: var(--jm-control-size);
	margin-left: auto;
	padding: 0;
	border: 0;
	background: none;
	color: var(--jm-colour-text-soft);
	font-size: 20px;
	cursor: pointer;
}

.jm-box__empty {
	margin: 0;
	color: var(--jm-colour-text-soft);
	font-size: var(--jm-text-xs);
}

/* The covers in a box and in Loose: smaller than Discover's, like the Members page. */
.jm-grid--shelf {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: var(--jm-space-2);
}

@media (min-width: 900px) {
	.jm-grid--shelf { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--jm-space-3); }
}
