/*
 * Zoey Made — the flashcard page as a parent sees it on screen (LRN-006).
 *
 * This is the **preview**: the page where a parent chooses a set, reads what to do with the scissors,
 * checks the printer settings and looks at the sheets before using paper. The sheets themselves are
 * drawn here at the proportions of US Letter so that what is on screen is the shape of what comes
 * out, and the rules that make them actual inches live in `learn-flashcards-print.css`.
 *
 * Nothing here is loaded anywhere but the flashcard route and the component showcase, because it
 * arrives with the `zoey-made/learn-flashcards` block.
 *
 * The cards' own geometry — the 2×5 lattice, the four strips, the halves, the fold — is written once,
 * below, in units that work in both media: fractions of the sheet rather than pixels. The print
 * stylesheet changes the sheet's size and its colours, and inherits the lattice unchanged. One
 * description of the layout, two media; a preview that was laid out separately would be a preview
 * that could disagree with the paper.
 */

/*
 * `[hidden]` is a user-agent rule, and **any class rule that sets `display` beats it**. Two Learn
 * stories have been bitten by exactly that — a spent control and a one-slot swap, both visible when
 * they were meant to be concealed — so every box on this page whose visibility a directive binds is
 * named here, before it is given a layout.
 */
.zoey-learn-flashcards__print-button[hidden],
.zoey-learn-flashcards__print-manual[hidden] {
	display: none;
}

/*
 * **The column is the shared template's now (SPL-001).**
 *
 * This file used to pin the page title and the feature block to 48rem itself, because
 * `page.html` sets its content size to `var(--wp--custom--measure)` — `56ch`, which resolves
 * against each element's own font size and so constrained the title to 1478px and the prose to
 * 470px. Three Learn stylesheets and two Make ones each corrected that for themselves.
 *
 * `templates/page-standard.html` carries `var(--wp--custom--layout--content)` instead, so core
 * generates the width rule for the title and for every default child of the content, and the two
 * share an edge without either of them asking. The correction is gone rather than kept beside its
 * replacement, because two owners of one width is how they drift apart.
 *
 * It is gone **only because these routes adopted that template**. A Learn block placed on a page
 * still using `page.html` would be back to the 56ch title, which is the thing to check first if
 * one ever looks wrong. `docs/COMPONENT-INVENTORY.md` records which pages have adopted.
 */

.zoey-learn-flashcards {
	display: grid;
	gap: var(--wp--preset--spacing--50, 1.5rem);
	justify-items: stretch;
}

.zoey-learn-flashcards__intro {
	margin-block-end: 0;
}

/* --- Choosing, and knowing what you chose ------------------------------------------------- */

.zoey-learn-flashcards__choices {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30, 0.75rem);
	align-items: center;
}

/*
 * The set that is showing is not a link to where you already are. It still reads as part of the row,
 * so the two choices look like two choices — one of them simply made.
 */
.zoey-learn-flashcards__chosen {
	display: inline-flex;
	align-items: center;
	min-block-size: 44px;
	padding: 0.5rem 1.1rem;
	border: 2px solid var(--wp--preset--color--ink);
	border-radius: 25px;
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--surface);
	font-weight: 800;
}

.zoey-learn-flashcards__summary {
	margin: 0;
	color: var(--wp--preset--color--ink-soft);
	font-weight: 700;
}

.zoey-learn-flashcards__instructions,
.zoey-learn-flashcards__changed {
	margin: 0;
}

.zoey-learn-flashcards__changed {
	display: grid;
	gap: var(--wp--preset--spacing--30, 0.75rem);
	justify-items: start;
}

.zoey-learn-flashcards__changed-action {
	margin: 0;
}

.zoey-learn-flashcards__print {
	margin: 0;
}

.zoey-learn-flashcards__print-manual {
	margin: 0;
	color: var(--wp--preset--color--ink-soft);
}

/* --- The sheets ---------------------------------------------------------------------------- */

.zoey-learn-flashcards__paper {
	display: grid;
	gap: var(--wp--preset--spacing--50, 1.5rem);
	justify-items: start;
	/* A grid item's automatic minimum is its content's; without this the sheet sets the page width. */
	min-inline-size: 0;
}

/*
 * A sheet on screen: white paper at Letter proportions, with a hairline and a soft shadow so it reads
 * as a sheet rather than as a region of the page. **No grain and no tape** — the contract is explicit
 * that printed content carries neither, and a preview that showed them would be previewing something
 * else.
 *
 * `aspect-ratio` rather than a height, so the preview is the right *shape* at any width. The padding
 * is a percentage of the width — 0.5in of 8.5in — so the safe print area scales with it.
 */
.zoey-learn-flashcards__sheet {
	/*
	 * The sheet spans the column rather than sitting in part of it. The whole page is a preview of a
	 * piece of paper, and a sheet that lines up with the words above it reads as the subject; one
	 * floating in a wider column reads as an illustration beside them.
	 */
	inline-size: 100%;
	min-inline-size: 0;
	aspect-ratio: 8.5 / 11;
	padding: 5.88%;
	display: flex;
	flex-direction: column;
	background: #fff;
	color: #1a1a1a;
	border: 1px solid var(--wp--preset--color--border-soft);
	box-shadow: 0 6px 20px rgba(52, 47, 64, 0.06);
}

.zoey-learn-flashcards__sheet-head {
	margin-block-end: 0.9rem;
}

.zoey-learn-flashcards__sheet-title {
	margin: 0;
	font-size: 0.95rem;
	font-weight: 800;
}

.zoey-learn-flashcards__sheet-meta {
	margin: 0.15rem 0 0;
	font-size: 0.7rem;
	color: #444;
}

.zoey-learn-flashcards__sheet-foot {
	margin-block-start: 0.9rem;
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	font-size: 0.62rem;
	color: #444;
}

/*
 * The lattice.
 *
 * **Every card draws its own four sides, and pulls itself a hair up and left** so each line it shares
 * with a neighbour is drawn once rather than twice. The obvious alternative — the container drawing
 * the top and left lines and each cell the bottom and right — was built first and is wrong on exactly
 * the sheet this story has to get right: the row template is fixed, so on a partial sheet the
 * container still fills the page, and its left line ran the whole height past the last card. A cut
 * line to nowhere is worse than a doubled one.
 */
.zoey-learn-flashcards__cards {
	flex: 1;
	display: grid;
	min-block-size: 0;
}

/*
 * **The preview's cards are the printed cards' shape**, not a share of whatever height is left.
 *
 * A spelling card is 3.75 × 1.85 inches on paper and a vocabulary strip is 7.5 × 2.3125; those ratios
 * are stated here as `aspect-ratio`, so the preview is the paper scaled rather than the paper
 * approximated. It also makes the partial sheet right on screen for the same reason it is right on
 * paper: a lone strip is the size of a strip, and the rest of the sheet is blank. Rows sized `1fr`
 * would have stretched it down the whole page — a dummy card by another means.
 */
.zoey-learn-flashcards__cards {
	align-content: start;
}

/*
 * `minmax(0, 1fr)`, not `1fr`. A grid track's automatic minimum is its content's minimum, so a long
 * word in a narrow column pushes the track — and the sheet — wider than the page rather than
 * wrapping inside it. The two columns of a spelling sheet and the two halves of a strip all need it.
 */
.zoey-learn-flashcards__cards--spelling {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zoey-learn-flashcards__cards--vocabulary {
	grid-template-columns: minmax(0, 1fr);
}

.zoey-learn-flashcards__card {
	aspect-ratio: 3.75 / 1.85;
}

.zoey-learn-flashcards__strip {
	aspect-ratio: 7.5 / 2.3125;
}

.zoey-learn-flashcards__card,
.zoey-learn-flashcards__strip {
	border: 1px solid #8a8a8a;
	margin-block-start: -1px;
	margin-inline-start: -1px;
	min-block-size: 0;
	min-inline-size: 0;
}

.zoey-learn-flashcards__card {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.9rem;
	text-align: center;
}

/* The two halves of a strip are equal, which is what lets it fold straight. */
.zoey-learn-flashcards__strip {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zoey-learn-flashcards__half {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.1rem 0.9rem 0.6rem;
	text-align: center;
	min-inline-size: 0;
}

/* The fold. Dashed, down the middle, and the only dashed line on the sheet. */
.zoey-learn-flashcards__half--clue {
	border-inline-end: 1px dashed #777;
}

.zoey-learn-flashcards__number {
	position: absolute;
	inset-block-start: 0.3rem;
	inset-inline-start: 0.45rem;
	font-size: 0.56rem;
	font-weight: 400;
	color: #666;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

/*
 * The word is the biggest thing on a card, and it has to stay readable rather than shrink: the
 * contract asks to *"preserve text at readable size; paginate/reflow rather than crop or shrink until
 * illegible"*. So the size is fixed in `em` of the sheet's own scale and a long word wraps inside its
 * card — a twelve-letter word, which is D4's maximum, is the case this was measured against.
 */
.zoey-learn-flashcards__word {
	margin: 0;
	font-size: 1.6rem;
	font-weight: 800;
	line-height: 1.15;
	overflow-wrap: anywhere;
	hyphens: none;
}

.zoey-learn-flashcards__definition {
	margin: 0;
	font-size: 0.85rem;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

/*
 * Narrow screens. The sheet keeps its proportions — a preview of a Letter page that is not Letter
 * shaped is not a preview — so everything on it gets smaller together, and the type steps down so a
 * ten-word sheet is still legible on a phone.
 */
@media (max-width: 34rem) {
	.zoey-learn-flashcards__sheet-title {
		font-size: 0.78rem;
	}

	.zoey-learn-flashcards__sheet-meta,
	.zoey-learn-flashcards__sheet-foot {
		font-size: 0.56rem;
	}

	.zoey-learn-flashcards__word {
		font-size: 1.05rem;
	}

	.zoey-learn-flashcards__definition {
		font-size: 0.6rem;
	}

	.zoey-learn-flashcards__half {
		padding: 0.8rem 0.45rem 0.4rem;
	}

	.zoey-learn-flashcards__card {
		padding: 0.5rem;
	}
}

.zoey-learn-flashcards__legend {
	margin: 0;
	color: var(--wp--preset--color--ink-soft);
	font-size: 0.9rem;
}

.zoey-learn-flashcards__legend-title {
	margin: 0 0 0.35rem;
	font-size: var(--wp--preset--font-size--section-small, 1.05rem);
	color: var(--wp--preset--color--ink);
}

.zoey-learn-flashcards__legend ul {
	margin: 0;
	padding-inline-start: 1.1rem;
	display: grid;
	gap: 0.2rem;
}

.zoey-learn-flashcards__back {
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30, 0.75rem);
}

/*
 * Forced colours. The sheet is drawn with literal black on literal white because it is paper, and in
 * a forced-colours mode those two literals are the two things the user has asked to be replaced — so
 * the sheet hands its colours back to the system and keeps only its structure.
 */
@media (forced-colors: active) {
	.zoey-learn-flashcards__sheet {
		background: Canvas;
		color: CanvasText;
		border-color: CanvasText;
	}

	.zoey-learn-flashcards__cards,
	.zoey-learn-flashcards__card,
	.zoey-learn-flashcards__strip,
	.zoey-learn-flashcards__half--clue {
		border-color: CanvasText;
	}

	.zoey-learn-flashcards__sheet-meta,
	.zoey-learn-flashcards__sheet-foot,
	.zoey-learn-flashcards__number {
		color: CanvasText;
	}

	.zoey-learn-flashcards__chosen {
		background: Highlight;
		color: HighlightText;
		border-color: Highlight;
	}
}
